mirror of
https://github.com/external-secrets/external-secrets.git
synced 2024-12-15 17:51:01 +00:00
Implemented function for Akeyless provider
Signed-off-by: Idowu Emehinola <hydeenoble39@gmail.com>
This commit is contained in:
parent
922217d36e
commit
e86ffac960
2 changed files with 65 additions and 0 deletions
|
@ -71,6 +71,33 @@ func (p *Provider) NewClient(ctx context.Context, store esv1beta1.GenericStore,
|
|||
}
|
||||
|
||||
func (p *Provider) ValidateStore(store esv1beta1.GenericStore) error {
|
||||
storeSpec := store.GetSpec()
|
||||
akeylessSpec := storeSpec.Provider.Akeyless
|
||||
|
||||
akeylessGWApiURL := akeylessSpec.AkeylessGWApiURL
|
||||
|
||||
if akeylessGWApiURL == nil {
|
||||
return fmt.Errorf("Akeyless GW API URL is required ")
|
||||
}
|
||||
|
||||
accessId := akeylessSpec.Auth.SecretRef.AccessID
|
||||
err := utils.ValidateSecretSelector(store, accessId)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
accessType := akeylessSpec.Auth.SecretRef.AccessType
|
||||
err = utils.ValidateSecretSelector(store, accessType)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
accessTypeParam := akeylessSpec.Auth.SecretRef.AccessTypeParam
|
||||
err = utils.ValidateSecretSelector(store, accessTypeParam)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ import (
|
|||
|
||||
esv1beta1 "github.com/external-secrets/external-secrets/apis/externalsecrets/v1beta1"
|
||||
fakeakeyless "github.com/external-secrets/external-secrets/pkg/provider/akeyless/fake"
|
||||
esmeta "github.com/external-secrets/external-secrets/apis/meta/v1"
|
||||
)
|
||||
|
||||
type akeylessTestCase struct {
|
||||
|
@ -124,6 +125,43 @@ func TestAkeylessGetSecret(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestValidateStore(t *testing.T) {
|
||||
provider := Provider{}
|
||||
|
||||
akeylessGWApiURL := "gwapi.akeyless"
|
||||
|
||||
store := &esv1beta1.SecretStore{
|
||||
Spec: esv1beta1.SecretStoreSpec{
|
||||
Provider: &esv1beta1.SecretStoreProvider{
|
||||
Akeyless: &esv1beta1.AkeylessProvider{
|
||||
AkeylessGWApiURL: &akeylessGWApiURL,
|
||||
Auth: &esv1beta1.AkeylessAuth{
|
||||
SecretRef: esv1beta1.AkeylessAuthSecretRef{
|
||||
AccessID: esmeta.SecretKeySelector{
|
||||
Name: "accessId",
|
||||
Key: "key-1",
|
||||
},
|
||||
AccessType: esmeta.SecretKeySelector{
|
||||
Name: "accessId",
|
||||
Key: "key-1",
|
||||
},
|
||||
AccessTypeParam: esmeta.SecretKeySelector{
|
||||
Name: "accessId",
|
||||
Key: "key-1",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
err := provider.ValidateStore(store)
|
||||
if err != nil {
|
||||
t.Errorf(err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetSecretMap(t *testing.T) {
|
||||
// good case: default version & deserialization
|
||||
setDeserialization := func(smtc *akeylessTestCase) {
|
||||
|
|
Loading…
Reference in a new issue