mirror of
https://github.com/storytold/irsa-manager.git
synced 2026-10-29 08:57:49 +00:00
irsa webhook
This commit is contained in:
@@ -57,7 +57,7 @@ func (r *IRSASetupReconciler) Reconcile(ctx context.Context, req ctrl.Request) (
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (r *IRSASetupReconciler) reconcile(ctx context.Context) error {
|
func (r *IRSASetupReconciler) reconcile(ctx context.Context) error {
|
||||||
err := reconcileSelfhosted(ctx)
|
err := reconcileSelfhosted(ctx)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,11 +70,11 @@ func reconcileSelfhosted(ctx context.Context) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
// get from CRs
|
// get from CRs
|
||||||
region := "ap-northeast-1"
|
region := "ap-northeast-1"
|
||||||
bucketName := "my-bucket-name"
|
bucketName := "my-bucket-name"
|
||||||
jwksFileName := "keys.json"
|
jwksFileName := "keys.json"
|
||||||
var factory selfhosted.OIDCIdPFactory
|
var factory selfhosted.OIDCIdPFactory
|
||||||
|
|
||||||
factory, err = oidc.NewAwsS3IdpFactory(
|
factory, err = oidc.NewAwsS3IdpFactory(
|
||||||
ctx,
|
ctx,
|
||||||
|
|||||||
@@ -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