Browse Source

eat: add status printcolumn to ES CRD (#318)
Formatting changes

Elsa Chelala 4 years ago
parent
commit
db5b4c5044

+ 1 - 2
Dockerfile

@@ -1,8 +1,7 @@
 FROM alpine:3.14.1
 ARG TARGETOS
 ARG TARGETARCH
-COPY bin/external-secrets-${TARGETOS}-amd64 /bin/external-secrets 
-#Change back to Targetarch
+COPY bin/external-secrets-${TARGETOS}-${TARGETARCH} /bin/external-secrets
 
 # Run as UID for nobody
 USER 65534

+ 16 - 2
apis/externalsecrets/v1alpha1/secretstore_alibaba_types.go

@@ -1,3 +1,17 @@
+/*
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
 package v1alpha1
 
 import (
@@ -9,7 +23,7 @@ type AlibabaAuth struct {
 	SecretRef AlibabaAuthSecretRef `json:"secretRef"`
 }
 
-// AlibabaAuthSecretRef holds secret references for Alibaba credentials
+// AlibabaAuthSecretRef holds secret references for Alibaba credentials.
 type AlibabaAuthSecretRef struct {
 	// The AccessKeyID is used for authentication
 	AccessKeyID esmeta.SecretKeySelector `json:"accessKeyIDSecretRef"`
@@ -17,7 +31,7 @@ type AlibabaAuthSecretRef struct {
 	AccessKeySecret esmeta.SecretKeySelector `json:"accessKeySecretSecretRef"`
 }
 
-//AlibabaProvider configures a store to sync secrets using the Alibaba Secret Manager provider.
+// AlibabaProvider configures a store to sync secrets using the Alibaba Secret Manager provider.
 type AlibabaProvider struct {
 	Auth *AlibabaAuth `json:"auth"`
 	// +optional

+ 0 - 2
apis/externalsecrets/v1alpha1/zz_generated.deepcopy.go

@@ -745,7 +745,6 @@ func (in *SecretStoreProvider) DeepCopyInto(out *SecretStoreProvider) {
 		*out = new(IBMProvider)
 		(*in).DeepCopyInto(*out)
 	}
-
 	if in.YandexLockbox != nil {
 		in, out := &in.YandexLockbox, &out.YandexLockbox
 		*out = new(YandexLockboxProvider)
@@ -756,7 +755,6 @@ func (in *SecretStoreProvider) DeepCopyInto(out *SecretStoreProvider) {
 		*out = new(GitlabProvider)
 		(*in).DeepCopyInto(*out)
 	}
-
 	if in.Alibaba != nil {
 		in, out := &in.Alibaba, &out.Alibaba
 		*out = new(AlibabaProvider)

+ 1 - 5
deploy/crds/external-secrets.io_clustersecretstores.yaml

@@ -63,7 +63,7 @@ spec:
                         properties:
                           secretRef:
                             description: AlibabaAuthSecretRef holds secret references
-                              for Alibaba credentials
+                              for Alibaba credentials.
                             properties:
                               accessKeyIDSecretRef:
                                 description: The AccessKeyID is used for authentication
@@ -84,8 +84,6 @@ spec:
                                       cluster-scoped defaults to the namespace of
                                       the referent.
                                     type: string
-                                required:
-                                - name
                                 type: object
                               accessKeySecretSecretRef:
                                 description: The AccessKeySecret is used for authentication
@@ -106,8 +104,6 @@ spec:
                                       cluster-scoped defaults to the namespace of
                                       the referent.
                                     type: string
-                                required:
-                                - name
                                 type: object
                             required:
                             - accessKeyIDSecretRef

+ 1 - 5
deploy/crds/external-secrets.io_secretstores.yaml

@@ -63,7 +63,7 @@ spec:
                         properties:
                           secretRef:
                             description: AlibabaAuthSecretRef holds secret references
-                              for Alibaba credentials
+                              for Alibaba credentials.
                             properties:
                               accessKeyIDSecretRef:
                                 description: The AccessKeyID is used for authentication
@@ -84,8 +84,6 @@ spec:
                                       cluster-scoped defaults to the namespace of
                                       the referent.
                                     type: string
-                                required:
-                                - name
                                 type: object
                               accessKeySecretSecretRef:
                                 description: The AccessKeySecret is used for authentication
@@ -106,8 +104,6 @@ spec:
                                       cluster-scoped defaults to the namespace of
                                       the referent.
                                     type: string
-                                required:
-                                - name
                                 type: object
                             required:
                             - accessKeyIDSecretRef

+ 15 - 0
e2e/suite/alibaba/alibaba.go

@@ -1,7 +1,22 @@
+/*
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
 package alibaba
 
 import (
 	"os"
+
 	// nolint
 	. "github.com/onsi/ginkgo"
 	// nolint

+ 35 - 18
e2e/suite/alibaba/provider.go

@@ -1,8 +1,24 @@
+/*
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
 package alibaba
 
 import (
 	"context"
 
+	"github.com/aliyun/alibaba-cloud-sdk-go/services/kms"
+
 	//nolint
 	. "github.com/onsi/ginkgo"
 
@@ -11,8 +27,6 @@ import (
 	v1 "k8s.io/api/core/v1"
 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 
-	"github.com/aliyun/alibaba-cloud-sdk-go/services/kms"
-
 	esv1alpha1 "github.com/external-secrets/external-secrets/apis/externalsecrets/v1alpha1"
 	esmeta "github.com/external-secrets/external-secrets/apis/meta/v1"
 	"github.com/external-secrets/external-secrets/e2e/framework"
@@ -22,10 +36,13 @@ type alibabaProvider struct {
 	accessKeyID     string
 	accessKeySecret string
 	regionID        string
-	client          *kms.Client
 	framework       *framework.Framework
 }
 
+const (
+	secretName = "secretName"
+)
+
 func newAlibabaProvider(f *framework.Framework, accessKeyID, accessKeySecret, regionID string) *alibabaProvider {
 	prov := &alibabaProvider{
 		accessKeyID:     accessKeyID,
@@ -39,39 +56,39 @@ func newAlibabaProvider(f *framework.Framework, accessKeyID, accessKeySecret, re
 
 // CreateSecret creates a secret in both kv v1 and v2 provider.
 func (s *alibabaProvider) CreateSecret(key, val string) {
-	client, err := kms.NewClient()
+	client, err := kms.NewClientWithAccessKey(s.regionID, s.accessKeyID, s.accessKeySecret)
+	Expect(err).ToNot(HaveOccurred())
+	kmssecretrequest := kms.CreateCreateSecretRequest()
+	kmssecretrequest.SecretName = secretName
+	kmssecretrequest.SecretData = "value"
+	_, err = client.CreateSecret(kmssecretrequest)
 	Expect(err).ToNot(HaveOccurred())
-	kmssecretrequest := kms.CreateSecretRequest{
-		SecretName: "test-example",
-		SecretData: "value",
-	}
-	client.CreateSecret(&kmssecretrequest)
 }
 
 func (s *alibabaProvider) DeleteSecret(key string) {
-	client, err := kms.NewClient()
+	client, err := kms.NewClientWithAccessKey(s.regionID, s.accessKeyID, s.accessKeySecret)
+	Expect(err).ToNot(HaveOccurred())
+	kmssecretrequest := kms.CreateDeleteSecretRequest()
+	kmssecretrequest.SecretName = secretName
+	_, err = client.DeleteSecret(kmssecretrequest)
 	Expect(err).ToNot(HaveOccurred())
-	kmssecretrequest := kms.DeleteSecretRequest{
-		SecretName: "test-example",
-	}
-	client.DeleteSecret(&kmssecretrequest)
 }
 
 func (s *alibabaProvider) BeforeEach() {
-	//Creating an Alibaba secret
+	// Creating an Alibaba secret
 	alibabaCreds := &v1.Secret{
 		ObjectMeta: metav1.ObjectMeta{
-			Name:      "test-example",
+			Name:      secretName,
 			Namespace: s.framework.Namespace.Name,
 		},
 		StringData: map[string]string{
-			//secret
+			secretName: "value",
 		},
 	}
 	err := s.framework.CRClient.Create(context.Background(), alibabaCreds)
 	Expect(err).ToNot(HaveOccurred())
 
-	//Creating Alibaba secret store
+	// Creating Alibaba secret store
 	secretStore := &esv1alpha1.SecretStore{
 		ObjectMeta: metav1.ObjectMeta{
 			Name:      s.framework.Namespace.Name,

+ 0 - 1
go.mod

@@ -43,7 +43,6 @@ require (
 	github.com/aliyun/alibaba-cloud-sdk-go v1.61.1192
 	github.com/aws/aws-sdk-go v1.38.6
 	github.com/crossplane/crossplane-runtime v0.13.0
-	github.com/daixiang0/gci v0.2.9 // indirect
 	github.com/fatih/color v1.10.0 // indirect
 	github.com/frankban/quicktest v1.10.0 // indirect
 	github.com/go-logr/logr v0.4.0

+ 0 - 4
go.sum

@@ -131,8 +131,6 @@ github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ3
 github.com/creack/pty v1.1.11/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
 github.com/crossplane/crossplane-runtime v0.13.0 h1:TFeItxtW32/fETB9be0AsEha/ur0bbrtQRocC+Jd6RI=
 github.com/crossplane/crossplane-runtime v0.13.0/go.mod h1:Bc54/KBvV9ld/tvervcnhcSzk13FYguTqmYt72Mybps=
-github.com/daixiang0/gci v0.2.9 h1:iwJvwQpBZmMg31w+QQ6jsyZ54KEATn6/nfARbBNW294=
-github.com/daixiang0/gci v0.2.9/go.mod h1:+4dZ7TISfSmqfAGv59ePaHfNzgGtIkHAhhdKggP1JAc=
 github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
 github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
 github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
@@ -212,7 +210,6 @@ github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+
 github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
 github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk=
 github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
-github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 h1:p104kn46Q8WdvHunIJ9dAyjPVtrBPhSr3KT2yUst43I=
 github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE=
 github.com/go-test/deep v1.0.2-0.20181118220953-042da051cf31/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA=
 github.com/go-test/deep v1.0.2 h1:onZX1rnHT3Wv6cqNgYyFOOlgVKJrksuCMCRvJStbMYw=
@@ -965,7 +962,6 @@ golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc
 golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
 golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
 golang.org/x/tools v0.0.0-20200918232735-d647fc253266/go.mod h1:z6u4i615ZeAfBE4XtMziQW1fSVJXACjjbWkB/mvPzlU=
-golang.org/x/tools v0.0.0-20201118003311-bd56c0adb394/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
 golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
 golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
 golang.org/x/tools v0.0.0-20210114065538-d78b04bdf963/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=

+ 14 - 0
pkg/provider/alibaba/fake/fake.go

@@ -1,3 +1,17 @@
+/*
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
 package fake
 
 import (

+ 7 - 6
pkg/provider/alibaba/kms.go

@@ -20,15 +20,16 @@ import (
 	"fmt"
 
 	kmssdk "github.com/aliyun/alibaba-cloud-sdk-go/services/kms"
+	"github.com/tidwall/gjson"
+	corev1 "k8s.io/api/core/v1"
+	"k8s.io/apimachinery/pkg/types"
+	kclient "sigs.k8s.io/controller-runtime/pkg/client"
+
 	esv1alpha1 "github.com/external-secrets/external-secrets/apis/externalsecrets/v1alpha1"
 	"github.com/external-secrets/external-secrets/pkg/provider"
 	"github.com/external-secrets/external-secrets/pkg/provider/aws/util"
 	"github.com/external-secrets/external-secrets/pkg/provider/schema"
 	"github.com/external-secrets/external-secrets/pkg/utils"
-	"github.com/tidwall/gjson"
-	corev1 "k8s.io/api/core/v1"
-	"k8s.io/apimachinery/pkg/types"
-	kclient "sigs.k8s.io/controller-runtime/pkg/client"
 )
 
 const (
@@ -60,7 +61,7 @@ type SMInterface interface {
 	GetSecretValue(request *kmssdk.GetSecretValueRequest) (response *kmssdk.GetSecretValueResponse, err error)
 }
 
-//setAuth creates a new Alibaba session based on a store
+// setAuth creates a new Alibaba session based on a store.
 func (c *Client) setAuth(ctx context.Context) error {
 	credentialsSecret := &corev1.Secret{}
 	credentialsSecretName := c.store.Auth.SecretRef.AccessKeyID.Name
@@ -157,7 +158,7 @@ func (kms *KeyManagementService) GetSecretMap(ctx context.Context, ref esv1alpha
 	return secretData, nil
 }
 
-//NewClient constructs a new secrets client based on the provided store.
+// NewClient constructs a new secrets client based on the provided store.
 func (kms *KeyManagementService) NewClient(ctx context.Context, store esv1alpha1.GenericStore, kube kclient.Client, namespace string) (provider.SecretsClient, error) {
 	storeSpec := store.GetSpec()
 	alibabaSpec := storeSpec.Provider.Alibaba

+ 16 - 1
pkg/provider/alibaba/kms_test.go

@@ -1,3 +1,17 @@
+/*
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
 package alibaba
 
 import (
@@ -9,6 +23,7 @@ import (
 
 	"github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses"
 	kmssdk "github.com/aliyun/alibaba-cloud-sdk-go/services/kms"
+
 	esv1alpha1 "github.com/external-secrets/external-secrets/apis/externalsecrets/v1alpha1"
 	fakesm "github.com/external-secrets/external-secrets/pkg/provider/alibaba/fake"
 )
@@ -64,7 +79,7 @@ func makeValidAPIOutput() *kmssdk.GetSecretValueResponse {
 		SecretName:        secretName,
 		VersionId:         "",
 		CreateTime:        "",
-		SecretData:        "",
+		SecretData:        secretValue,
 		SecretDataType:    "",
 		AutomaticRotation: "",
 		RotationInterval:  "",