diff --git a/pkg/apis/api.kusion.io/v1/types.go b/pkg/apis/api.kusion.io/v1/types.go index f33ac38d..9bb66f96 100644 --- a/pkg/apis/api.kusion.io/v1/types.go +++ b/pkg/apis/api.kusion.io/v1/types.go @@ -721,6 +721,9 @@ type ProviderSpec struct { // Fake configures a store with static key/value pairs Fake *FakeProvider `yaml:"fake,omitempty" json:"fake,omitempty"` + + // custom configures a store with custom define attributes + Custom *CustomSecretProvider `yaml:"custom,omitempty" json:"custom,omitempty"` } // AlicloudProvider configures a store to retrieve secrets from Alicloud Secrets Manager. @@ -798,6 +801,14 @@ type FakeProviderData struct { Version string `json:"version,omitempty"` } +// CustomSecretProvider configures a secret provider with custom define attributes +type CustomSecretProvider struct { + // platform name of the provider + Name string `json:"name"` + // attributes of the provider + Attributes map[string]string `json:"attributes,omitempty"` +} + type Type string const ( diff --git a/pkg/secrets/providers.go b/pkg/secrets/providers.go index 46bad127..a56c1b42 100644 --- a/pkg/secrets/providers.go +++ b/pkg/secrets/providers.go @@ -100,5 +100,9 @@ func getProviderName(spec *v1.ProviderSpec) (string, error) { return "", fmt.Errorf("secret stores must only have exactly one provider specified, found %d", len(specMap)) } + if maps.Keys(specMap)[0] == "custom" { + return specMap["custom"].(map[string]interface{})["name"].(string), nil + } + return maps.Keys(specMap)[0], nil } diff --git a/pkg/secrets/providers_test.go b/pkg/secrets/providers_test.go index 01506972..6d2f92ae 100644 --- a/pkg/secrets/providers_test.go +++ b/pkg/secrets/providers_test.go @@ -47,6 +47,17 @@ func TestRegister(t *testing.T) { AWS: &v1.AWSProvider{}, }, }, + { + name: "should register a valid provider", + providerName: "customplaform", + shouldPanic: false, + expExists: true, + spec: &v1.ProviderSpec{ + Custom: &v1.CustomSecretProvider{ + Name: "customplaform", + }, + }, + }, } fsp := &FakeSecretStoreProvider{}