diff --git a/k8-operator/controllers/infisicalsecret_helper.go b/k8-operator/controllers/infisicalsecret_helper.go index 042d19edf..cc9b5c68e 100644 --- a/k8-operator/controllers/infisicalsecret_helper.go +++ b/k8-operator/controllers/infisicalsecret_helper.go @@ -227,11 +227,6 @@ func (r *InfisicalSecretReconciler) GetInfisicalServiceAccountCredentialsFromKub return model.ServiceAccountDetails{AccessKey: string(accessKeyFromSecret), PrivateKey: string(privateKeyFromSecret), PublicKey: string(publicKeyFromSecret)}, nil } -type TemplateSecret struct { - Value string `json:"value"` - SecretPath string `json:"secretPath"` -} - func (r *InfisicalSecretReconciler) CreateInfisicalManagedKubeSecret(ctx context.Context, infisicalSecret v1alpha1.InfisicalSecret, secretsFromAPI []model.SingleEnvironmentVariable, ETag string) error { plainProcessedSecrets := make(map[string][]byte) secretType := infisicalSecret.Spec.ManagedSecretReference.SecretType @@ -244,26 +239,26 @@ func (r *InfisicalSecretReconciler) CreateInfisicalManagedKubeSecret(ctx context } if managedTemplateData != nil { - secretKeyValue := make(map[string]TemplateSecret) + secretKeyValue := make(map[string]model.SecretTemplateOptions) for _, secret := range secretsFromAPI { - secretKeyValue[secret.Key] = TemplateSecret{ + secretKeyValue[secret.Key] = model.SecretTemplateOptions{ Value: secret.Value, SecretPath: secret.SecretPath, } } - for tmplKey, userTmpl := range managedTemplateData.Data { - tmpl, err := template.New("secret-templates").Parse(userTmpl) + for templateKey, userTemplate := range managedTemplateData.Data { + tmpl, err := template.New("secret-templates").Parse(userTemplate) if err != nil { - return fmt.Errorf("Unable to compile template: %s", tmplKey, err) + return fmt.Errorf("Unable to compile template: %s", templateKey, err) } buf := bytes.NewBuffer(nil) err = tmpl.Execute(buf, secretKeyValue) if err != nil { - return fmt.Errorf("Unable to execute template: %s", tmplKey, err) + return fmt.Errorf("Unable to execute template: %s", templateKey, err) } - plainProcessedSecrets[tmplKey] = buf.Bytes() + plainProcessedSecrets[templateKey] = buf.Bytes() } } @@ -330,26 +325,26 @@ func (r *InfisicalSecretReconciler) UpdateInfisicalManagedKubeSecret(ctx context } if managedTemplateData != nil { - secretKeyValue := make(map[string]TemplateSecret) + secretKeyValue := make(map[string]model.SecretTemplateOptions) for _, secret := range secretsFromAPI { - secretKeyValue[secret.Key] = TemplateSecret{ + secretKeyValue[secret.Key] = model.SecretTemplateOptions{ Value: secret.Value, SecretPath: secret.SecretPath, } } - for tmplKey, userTmpl := range managedTemplateData.Data { - tmpl, err := template.New("secret-templates").Parse(userTmpl) + for templateKey, userTemplate := range managedTemplateData.Data { + tmpl, err := template.New("secret-templates").Parse(userTemplate) if err != nil { - return fmt.Errorf("Unable to compile template: %s", tmplKey, err) + return fmt.Errorf("Unable to compile template: %s", templateKey, err) } buf := bytes.NewBuffer(nil) err = tmpl.Execute(buf, secretKeyValue) if err != nil { - return fmt.Errorf("Unable to execute template: %s", tmplKey, err) + return fmt.Errorf("Unable to execute template: %s", templateKey, err) } - plainProcessedSecrets[tmplKey] = buf.Bytes() + plainProcessedSecrets[templateKey] = buf.Bytes() } } diff --git a/k8-operator/main.go b/k8-operator/main.go index d400545ff..50c0cda00 100644 --- a/k8-operator/main.go +++ b/k8-operator/main.go @@ -36,7 +36,7 @@ func main() { var metricsAddr string var enableLeaderElection bool var probeAddr string - flag.StringVar(&metricsAddr, "metrics-bind-address", ":8082", "The address the metric endpoint binds to.") + flag.StringVar(&metricsAddr, "metrics-bind-address", ":8080", "The address the metric endpoint binds to.") flag.StringVar(&probeAddr, "health-probe-bind-address", ":8081", "The address the probe endpoint binds to.") flag.BoolVar(&enableLeaderElection, "leader-elect", false, "Enable leader election for controller manager. "+ diff --git a/k8-operator/packages/model/model.go b/k8-operator/packages/model/model.go index aa68597f5..e3328061c 100644 --- a/k8-operator/packages/model/model.go +++ b/k8-operator/packages/model/model.go @@ -21,5 +21,10 @@ type SingleEnvironmentVariable struct { Value string `json:"value"` SecretPath string `json:"secretPath"` Type string `json:"type"` - ID string `json:"_id"` + ID string `json:"id"` +} + +type SecretTemplateOptions struct { + Value string `json:"value"` + SecretPath string `json:"secretPath"` }