mirror of
https://github.com/storytold/irsa-manager.git
synced 2026-10-30 09:08:02 +00:00
irsa webhook
This commit is contained in:
@@ -59,4 +59,3 @@ func (s *S3IdPDiscovery) Upload(ctx context.Context, o selfhosted.OIDCIdPDiscove
|
|||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1 +1,59 @@
|
|||||||
package webhook
|
package webhook
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
|
||||||
|
"k8s.io/apimachinery/pkg/runtime/serializer/yaml"
|
||||||
|
)
|
||||||
|
|
||||||
|
type WebhookManifests struct {
|
||||||
|
Manifests []*unstructured.Unstructured
|
||||||
|
}
|
||||||
|
|
||||||
|
func Read() ([]*unstructured.Unstructured, error) {
|
||||||
|
files := []string{
|
||||||
|
"auth.yaml",
|
||||||
|
"deployment.yaml",
|
||||||
|
"mutatingwebhook-ca-bundle.yaml",
|
||||||
|
"mutatingwebhook.yaml",
|
||||||
|
"service.yaml",
|
||||||
|
}
|
||||||
|
objs := []*unstructured.Unstructured{}
|
||||||
|
for _, f := range files {
|
||||||
|
tmp, err := ReadFile(f)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
objs = append(objs, tmp...)
|
||||||
|
}
|
||||||
|
return objs, nil
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func ReadFile(filePath string) ([]*unstructured.Unstructured, error) {
|
||||||
|
yamlContent, err := os.ReadFile(filePath)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// YAMLデコーダの準備
|
||||||
|
decUnstructured := yaml.NewDecodingSerializer(unstructured.UnstructuredJSONScheme)
|
||||||
|
// マニフェストを分割
|
||||||
|
documents := strings.Split(string(yamlContent), "---")
|
||||||
|
objs := make([]*unstructured.Unstructured, len(documents))
|
||||||
|
for i, doc := range documents {
|
||||||
|
if strings.TrimSpace(doc) == "" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
// 各マニフェストを解析
|
||||||
|
obj := &unstructured.Unstructured{}
|
||||||
|
_, _, err := decUnstructured.Decode([]byte(doc), nil, obj)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
objs[i] = obj
|
||||||
|
}
|
||||||
|
return objs, nil
|
||||||
|
}
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
package webhook
|
||||||
Reference in New Issue
Block a user