globallogicuki / provider-harbor

Crossplane provider for Harbor based on terraform-provider-harbor
Apache License 2.0
2 stars 1 forks source link

External Secret Stores not working #6

Closed tschlaepfer closed 4 months ago

tschlaepfer commented 4 months ago

Hi @lornest

I found that the Harbor provider does not support external secret stores. When I set the external-secrets-stores flag in the provider config the provider pod is failing with an nil pointer exception.

apiVersion: pkg.crossplane.io/v1alpha1
kind: ControllerConfig
metadata:
  name: debug-provider-config
spec:
  args:
    - --debug
    - --enable-external-secret-stores
---
apiVersion: pkg.crossplane.io/v1
kind: Provider
metadata:
  name: provider-harbor
spec:
  package: xpkg.upbound.io/globallogicuki/provider-harbor:v0.1.0
  controllerConfigRef:
    name: debug-provider-config

Here the logs from the provider pod

kubectl logs -n crossplane-system provider-harbor-baf1f067b15f-6d4bd4d98-75jtj   
2024-07-25T08:34:21Z    DEBUG   provider-harbor Starting    {"sync-period": "1h0m0s", "poll-interval": "10m0s", "max-reconcile-rate": 10}
2024-07-25T08:34:21Z    INFO    provider-harbor Alpha feature enabled   {"flag": "EnableAlphaExternalSecretStores"}
2024-07-25T08:34:21Z    INFO    provider-harbor Beta feature enabled    {"flag": "EnableBetaManagementPolicies"}
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x1987253]

goroutine 1 [running]:
github.com/globallogicuki/provider-harbor/internal/controller/config/configauth.Setup({0x21536f8, 0xc000397a00}, {{{0x2145950, 0xc000123080}, {0x21452f0, 0xc0000136e8}, 0x8bb2c97000, 0xa, 0xc0003e9300, 0x0}, ...})
    github.com/globallogicuki/provider-harbor/internal/controller/config/configauth/zz_controller.go:36 +0x2f3
github.com/globallogicuki/provider-harbor/internal/controller.Setup({0x21536f8, 0xc000397a00}, {{{0x2145950, 0xc000123080}, {0x21452f0, 0xc0000136e8}, 0x8bb2c97000, 0xa, 0xc0003e9300, 0x0}, ...})
    github.com/globallogicuki/provider-harbor/internal/controller/zz_setup.go:61 +0x216
main.main()
    github.com/globallogicuki/provider-harbor/cmd/provider/main.go:122 +0x2188

I had a look at the features.go file and found that the issue is most likely due to writing "xpfeature.Flag" instead of "feature.Flag", here an example where from the vault-provider

I will supply another pull request to address this issue.