Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provider overwriting SecretV2 data #54

Open
ottramst opened this issue Jan 21, 2025 · 0 comments
Open

Provider overwriting SecretV2 data #54

ottramst opened this issue Jan 21, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@ottramst
Copy link

ottramst commented Jan 21, 2025

What happened?

When defining a SecretV2 with an empty JSON and defining the dataJsonSecretRef attribute under initProvider the secret contents still get overwritten.

This is buggy behaviour since, sometimes we need to just create a SecretV2 and then inject data into the secret externally.

It seems that the documentation on the resource itself for initProvider field, is false:

InitProvider holds the same fields as ForProvider, with the exception of Identifier and other resource reference fields. The fields that are in InitProvider are merged into ForProvider when the resource is created.

Seems that this merging is not happening or the required fields check is run before the merge operation.

How can we reproduce it?

Using these manifests

---
apiVersion: v1
kind: Secret
metadata:
  name: test-vault-kvv2
  namespace: crossplane
type: Opaque
stringData:
  data: |
    {}

---
apiVersion: kv.vault.upbound.io/v1alpha1
kind: SecretV2
metadata:
  name: test-vault-kvv2
  namespace: crossplane
spec:
  deletionPolicy: Delete
  forProvider:
    deleteAllVersions: true
    customMetadata:
      - maxVersions: 10
        data:
          environment: test
          test: test
    mount: common
    name: test
    dataJsonSecretRef:
      key: data
      name: test-vault-kvv2
      namespace: crossplane
  initProvider:
    dataJsonSecretRef:
      key: data
      name: test-vault-kvv2
      namespace: crossplane
  providerConfigRef:
    name: vault

For example, when changing/adding a custom metadata map object, the secret contents will be overwritten by an empty JSON, even though the dataJSONSecretRef is defined under initProvider

Furthermore, it isn't possible to omit forProvider.dataJsonSecretRef because it's a required field.

What environment did it happen in?

  • Vault provider: v2.0.1
@ottramst ottramst added the bug Something isn't working label Jan 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant