Skip to content

Commit

Permalink
[EPMDEDP-12471]: chore: Add label for created secrets
Browse files Browse the repository at this point in the history
Put label for the secrets created by operator:
   "app.edp.epam.com/secret-type: sonar"

Related issue: #4

Signed-off-by: Sergiy Kulanov <[email protected]>
Change-Id: I2b7409f4af761d659434b2894b84c86c3ffc341a
  • Loading branch information
SergK committed Aug 17, 2023
1 parent 800b884 commit 87448fb
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
3 changes: 2 additions & 1 deletion pkg/helper/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ func GetExecutableFilePath() string {
// GenerateLabels returns map with labels for k8s objects.
func GenerateLabels(name string) map[string]string {
return map[string]string{
"app": name,
"app": name,
"app.edp.epam.com/secret-type": "sonar",
}
}

Expand Down
3 changes: 2 additions & 1 deletion pkg/service/platform/helper/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const (

func GenerateLabels(name string) map[string]string {
return map[string]string{
"app": name,
"app": name,
"app.edp.epam.com/secret-type": "sonar",
}
}
8 changes: 4 additions & 4 deletions pkg/service/platform/kubernetes/k8s_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func TestK8SService_CreateSecret_GetErr(t *testing.T) {
coreClient := kMock.K8SClusterClient{}
secrets := &kMock.SecretInterface{}
coreClient.On("Secrets", namespace).Return(secrets)
secrets.On("Get", context.Background(), secretName, metav1.GetOptions{}).Return(nil, errTest)
secrets.On("Get", context.TODO(), secretName, metav1.GetOptions{}).Return(nil, errTest)
service := K8SService{
k8sClusterClient: &coreClient,
}
Expand All @@ -141,7 +141,7 @@ func TestK8SService_CreateSecret_CreateErr(t *testing.T) {
coreClient := kMock.K8SClusterClient{}
secrets := &kMock.SecretInterface{}
coreClient.On("Secrets", namespace).Return(secrets)
secrets.On("Get", context.Background(), secretName, metav1.GetOptions{}).Return(nil, k8errors.NewNotFound(schema.GroupResource{}, name))
secrets.On("Get", context.TODO(), secretName, metav1.GetOptions{}).Return(nil, k8errors.NewNotFound(schema.GroupResource{}, name))
secrets.On("Create", context.Background(), secret, metav1.CreateOptions{}).Return(nil, errTest)
service := K8SService{
k8sClusterClient: &coreClient,
Expand All @@ -161,7 +161,7 @@ func TestK8SService_CreateSecret_AlreadyExist(t *testing.T) {
coreClient := kMock.K8SClusterClient{}
secrets := &kMock.SecretInterface{}
coreClient.On("Secrets", namespace).Return(secrets)
secrets.On("Get", context.Background(), secretName, metav1.GetOptions{}).Return(&existedSecret, nil)
secrets.On("Get", context.TODO(), secretName, metav1.GetOptions{}).Return(&existedSecret, nil)
service := K8SService{
k8sClusterClient: &coreClient,
}
Expand All @@ -178,7 +178,7 @@ func TestK8SService_CreateSecret(t *testing.T) {
coreClient := kMock.K8SClusterClient{}
secrets := &kMock.SecretInterface{}
coreClient.On("Secrets", namespace).Return(secrets)
secrets.On("Get", context.Background(), secretName, metav1.GetOptions{}).Return(nil, k8errors.NewNotFound(schema.GroupResource{}, name))
secrets.On("Get", context.TODO(), secretName, metav1.GetOptions{}).Return(nil, k8errors.NewNotFound(schema.GroupResource{}, name))
secrets.On("Create", context.Background(), secret, metav1.CreateOptions{}).Return(secret, nil)
service := K8SService{
k8sClusterClient: &coreClient,
Expand Down

0 comments on commit 87448fb

Please sign in to comment.