PR Feedback'

This commit is contained in:
mcmarkj
2021-06-07 21:51:44 +01:00
parent a428fe7462
commit fb1262f1bd

View File

@@ -23,23 +23,17 @@ const RestartDeploymentsAnnotation = OnepasswordPrefix + "/auto-restart"
var log = logf.Log var log = logf.Log
func CreateKubernetesSecretFromItem(kubeClient kubernetesClient.Client, secretName, namespace string, item *onepassword.Item, autoRestart string, labels map[string]string, annotations map[string]string) error { func CreateKubernetesSecretFromItem(kubeClient kubernetesClient.Client, secretName, namespace string, item *onepassword.Item, autoRestart string, labels map[string]string, secretAnnotations map[string]string) error {
itemVersion := fmt.Sprint(item.Version) itemVersion := fmt.Sprint(item.Version)
// Remove OP Annotations if they already exist // If secretAnnotations is nil we create an empty map so we can later assign values for the OP Annotations in the map
delete(annotations, VersionAnnotation) if secretAnnotations == nil {
delete(annotations, ItemPathAnnotation) secretAnnotations = map[string]string{}
secretAnnotations := map[string]string{
VersionAnnotation: itemVersion,
ItemPathAnnotation: fmt.Sprintf("vaults/%v/items/%v", item.Vault.ID, item.ID),
} }
// Merge the original annotations map, with our new secretAnnotations map secretAnnotations[VersionAnnotation] = itemVersion
for k, v := range annotations { secretAnnotations[ItemPathAnnotation] = fmt.Sprintf("vaults/%v/items/%v", item.Vault.ID, item.ID)
secretAnnotations[k] = v
}
if autoRestart != "" { if autoRestart != "" {
_, err := utils.StringToBool(autoRestart) _, err := utils.StringToBool(autoRestart)