Просмотр исходного кода

Testing aws secretManager versioning function

Signed-off-by: Marcus Dantas <marcus.dantas@engineerbetter.com>
Co-authored-by: William Young <will.young@engineerbetter.com>
Marcus Dantas 3 лет назад
Родитель
Сommit
c044439d4d
1 измененных файлов с 11 добавлено и 2 удалено
  1. 11 2
      pkg/provider/aws/secretsmanager/secretsmanager.go

+ 11 - 2
pkg/provider/aws/secretsmanager/secretsmanager.go

@@ -115,19 +115,21 @@ type RequestFailure interface {
 
 func (sm *SecretsManager) SetSecret(ctx context.Context, value []byte, remoteRef esv1beta1.PushRemoteRef) error {
 	secretName := remoteRef.GetRemoteKey()
+	awsCurrent := "AWSCURRENT"
 	secretRequest := awssm.CreateSecretInput{
 		Name:         &secretName,
 		SecretBinary: value,
 	}
 
 	secretValue := awssm.GetSecretValueInput{
-		SecretId: &secretName,
+		SecretId:     &secretName,
+		VersionStage: &awsCurrent,
 	}
 
 	awsSecret, err := sm.client.GetSecretValueWithContext(ctx, &secretValue)
 	fmt.Println(awsSecret)
 
-	if awsSecret != nil &&  reflect.DeepEqual(awsSecret.SecretBinary, secretRequest.SecretBinary) {
+	if awsSecret != nil && reflect.DeepEqual(awsSecret.SecretBinary, secretRequest.SecretBinary) {
 		return nil
 	}
 
@@ -141,6 +143,13 @@ func (sm *SecretsManager) SetSecret(ctx context.Context, value []byte, remoteRef
 		return err
 	}
 
+	// Check for version here:
+	// Check for secret existing has been done
+	// Check key awssecret.key
+	// Add versioning logic
+
+	// if you're trying to push the same key, it should have logic to check the versioning
+
 CREATE:
 	_, err = sm.client.CreateSecretWithContext(ctx, &secretRequest)