Skip to content

Commit a7c5d3d

Browse files
committed
chore: review feedback incorporated
1 parent 422f5af commit a7c5d3d

File tree

12 files changed

+227
-206
lines changed

12 files changed

+227
-206
lines changed

api/bean/ConfigMapAndSecret_ent.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ func (configSecret *ConfigSecretMap) AddDataToKey(keyName string, data []byte) (
2323
return configSecret, nil
2424
}
2525

26-
func (configSecret *ConfigSecretMap) GetBinaryDataMap() (map[string][]byte, error) {
27-
var dataMap map[string][]byte
28-
return dataMap, nil
26+
func (configSecret *ConfigSecretMap) GetBinaryDataMap() map[string][]byte {
27+
return nil
2928
}

go.mod

+2-2
Original file line numberDiff line numberDiff line change
@@ -307,8 +307,8 @@ require (
307307

308308
replace (
309309
github.com/argoproj/argo-workflows/v3 v3.5.13 => github.com/devtron-labs/argo-workflows/v3 v3.5.13
310-
github.com/devtron-labs/authenticator => github.com/devtron-labs/devtron-services/authenticator v0.0.0-20250424170212-5abc49b803f0
311-
github.com/devtron-labs/common-lib => github.com/devtron-labs/devtron-services/common-lib v0.0.0-20250424170212-5abc49b803f0
310+
github.com/devtron-labs/authenticator => github.com/devtron-labs/devtron-services/authenticator v0.0.0-20250425094825-c7c56d65b6e7
311+
github.com/devtron-labs/common-lib => github.com/devtron-labs/devtron-services/common-lib v0.0.0-20250425094825-c7c56d65b6e7
312312
github.com/go-check/check => github.com/go-check/check v0.0.0-20180628173108-788fd7840127
313313
github.com/googleapis/gnostic => github.com/googleapis/gnostic v0.5.5
314314
k8s.io/api => k8s.io/api v0.29.7

go.sum

+4-4
Original file line numberDiff line numberDiff line change
@@ -829,10 +829,10 @@ github.com/denisenkom/go-mssqldb v0.0.0-20200428022330-06a60b6afbbc h1:VRRKCwnzq
829829
github.com/denisenkom/go-mssqldb v0.0.0-20200428022330-06a60b6afbbc/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU=
830830
github.com/devtron-labs/argo-workflows/v3 v3.5.13 h1:3pINq0gXOSeTw2z/vYe+j80lRpSN5Rp/8mfQORh8SmU=
831831
github.com/devtron-labs/argo-workflows/v3 v3.5.13/go.mod h1:/vqxcovDPT4zqr4DjR5v7CF8ggpY1l3TSa2CIG3jmjA=
832-
github.com/devtron-labs/devtron-services/authenticator v0.0.0-20250424170212-5abc49b803f0 h1:RlOV9Tl5FSSVXYOD0aZv/ElNhkbt0NKU6nBUgAhhWZo=
833-
github.com/devtron-labs/devtron-services/authenticator v0.0.0-20250424170212-5abc49b803f0/go.mod h1:5lv4Wfj5ERhhvDGXe2IeES6qxjvUVCcohaRwKnWBMNo=
834-
github.com/devtron-labs/devtron-services/common-lib v0.0.0-20250424170212-5abc49b803f0 h1:76sFjY5H5F6vRI+Nypn/V0p3iRUXv/6Sg3/+dzRLk9w=
835-
github.com/devtron-labs/devtron-services/common-lib v0.0.0-20250424170212-5abc49b803f0/go.mod h1:ceFKgQ2qm40PR95g5Xp2EClq7nDBKFTcglJ0JdsgClA=
832+
github.com/devtron-labs/devtron-services/authenticator v0.0.0-20250425094825-c7c56d65b6e7 h1:hKzNdf9SALHO/+0TeFdejf3VXeBnS9rPYhqYthc2T2k=
833+
github.com/devtron-labs/devtron-services/authenticator v0.0.0-20250425094825-c7c56d65b6e7/go.mod h1:5lv4Wfj5ERhhvDGXe2IeES6qxjvUVCcohaRwKnWBMNo=
834+
github.com/devtron-labs/devtron-services/common-lib v0.0.0-20250425094825-c7c56d65b6e7 h1:Z9wLrk/uFOBgbycXG85/lzK4mGebcJqbZbnEb1NbEj4=
835+
github.com/devtron-labs/devtron-services/common-lib v0.0.0-20250425094825-c7c56d65b6e7/go.mod h1:ceFKgQ2qm40PR95g5Xp2EClq7nDBKFTcglJ0JdsgClA=
836836
github.com/devtron-labs/go-bitbucket v0.9.60-beta h1:VEx1jvDgdtDPS6A1uUFoaEi0l1/oLhbr+90xOwr6sDU=
837837
github.com/devtron-labs/go-bitbucket v0.9.60-beta/go.mod h1:GnuiCesvh8xyHeMCb+twm8lBR/kQzJYSKL28ZfObp1Y=
838838
github.com/devtron-labs/protos v0.0.3-0.20250323220609-ecf8a0f7305e h1:U6UdYbW8a7xn5IzFPd8cywjVVPfutGJCudjePAfL/Hs=

pkg/pipeline/ArgoWorkflowExecutor_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ func TestExecuteWorkflow(t *testing.T) {
7575
secretKeySecret := s3Artifact.SecretKeySecret
7676
assert.NotNil(t, accessKeySecret)
7777
assert.NotNil(t, secretKeySecret)
78-
assert.True(t, reflect.DeepEqual(accessKeySecret, executors.ACCESS_KEY_SELECTOR))
79-
assert.True(t, reflect.DeepEqual(secretKeySecret, executors.SECRET_KEY_SELECTOR))
78+
assert.True(t, reflect.DeepEqual(accessKeySecret, executors.AccessKeySelector))
79+
assert.True(t, reflect.DeepEqual(secretKeySecret, executors.SecretKeySelector))
8080
})
8181

8282
t.Run("validate s3 blob storage with endpoint", func(t *testing.T) {
@@ -105,7 +105,7 @@ func TestExecuteWorkflow(t *testing.T) {
105105
assert.Equal(t, gcpBlobStorage.LogBucketName, gcsArtifact.Bucket)
106106
secretKeySecret := gcsArtifact.ServiceAccountKeySecret
107107
assert.NotNil(t, secretKeySecret)
108-
assert.True(t, reflect.DeepEqual(secretKeySecret, executors.SECRET_KEY_SELECTOR))
108+
assert.True(t, reflect.DeepEqual(secretKeySecret, executors.SecretKeySelector))
109109
})
110110
t.Run("validate env specific cm and secret", func(t *testing.T) {
111111
workflowTemplate := getBaseWorkflowTemplate(cdConfig)

pkg/pipeline/executors/adapter/adapter.go

+60-11
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,36 @@
1717
package adapter
1818

1919
import (
20+
"encoding/json"
21+
"github.com/devtron-labs/common-lib/utils/k8s/commonBean"
2022
"github.com/devtron-labs/devtron/api/bean"
2123
"github.com/devtron-labs/devtron/pkg/pipeline/types"
22-
v12 "k8s.io/api/core/v1"
23-
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
24+
k8sApiV1 "k8s.io/api/core/v1"
25+
k8sMetaV1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2426
)
2527

26-
func GetConfigMapSecretDto(configSecretMap bean.ConfigSecretMap, ownerRef v1.OwnerReference, isSecret bool) (types.ConfigMapSecretDto, error) {
28+
func GetConfigMapJson(configMapSecretDto types.ConfigMapSecretDto) (string, error) {
29+
configMapBody := GetConfigMapBody(configMapSecretDto)
30+
configMapJson, err := json.Marshal(configMapBody)
31+
if err != nil {
32+
return "", err
33+
}
34+
return string(configMapJson), err
35+
}
36+
37+
func GetSecretJson(configMapSecretDto types.ConfigMapSecretDto) (string, error) {
38+
secretBody, err := GetSecretBody(configMapSecretDto)
39+
if err != nil {
40+
return "", err
41+
}
42+
secretJson, err := json.Marshal(secretBody)
43+
if err != nil {
44+
return "", err
45+
}
46+
return string(secretJson), err
47+
}
48+
49+
func GetConfigMapSecretDto(configSecretMap bean.ConfigSecretMap, ownerRef k8sMetaV1.OwnerReference, isSecret bool) (types.ConfigMapSecretDto, error) {
2750
configDataMap, err := configSecretMap.GetDataMap()
2851
if err != nil {
2952
return types.ConfigMapSecretDto{}, err
@@ -33,20 +56,46 @@ func GetConfigMapSecretDto(configSecretMap bean.ConfigSecretMap, ownerRef v1.Own
3356
Data: configDataMap,
3457
OwnerRef: ownerRef,
3558
}
36-
return updateBinaryDataInConfigMapSecretDto(configSecretMap, configMapSecretDto, isSecret)
59+
return updateBinaryDataInConfigMapSecretDto(configSecretMap, configMapSecretDto, isSecret), nil
3760
}
3861

39-
func GetConfigMapBody(configMapSecretDto types.ConfigMapSecretDto) v12.ConfigMap {
40-
configMap := v12.ConfigMap{
41-
TypeMeta: v1.TypeMeta{
42-
Kind: "ConfigMap",
43-
APIVersion: "v1",
62+
func GetConfigMapBody(configMapSecretDto types.ConfigMapSecretDto) k8sApiV1.ConfigMap {
63+
configMap := k8sApiV1.ConfigMap{
64+
TypeMeta: k8sMetaV1.TypeMeta{
65+
Kind: commonBean.ConfigMapKind,
66+
APIVersion: commonBean.V1VERSION,
4467
},
45-
ObjectMeta: v1.ObjectMeta{
68+
ObjectMeta: k8sMetaV1.ObjectMeta{
4669
Name: configMapSecretDto.Name,
47-
OwnerReferences: []v1.OwnerReference{configMapSecretDto.OwnerRef},
70+
OwnerReferences: []k8sMetaV1.OwnerReference{configMapSecretDto.OwnerRef},
4871
},
4972
Data: configMapSecretDto.Data,
5073
}
5174
return getConfigMapBodyEnt(configMapSecretDto, configMap)
5275
}
76+
77+
func GetSecretBody(configMapSecretDto types.ConfigMapSecretDto) (k8sApiV1.Secret, error) {
78+
secretDataMap := make(map[string][]byte)
79+
// adding handling to get base64 decoded value in map value
80+
cmsDataMarshaled, err := json.Marshal(configMapSecretDto.Data)
81+
if err != nil {
82+
return k8sApiV1.Secret{}, err
83+
}
84+
err = json.Unmarshal(cmsDataMarshaled, &secretDataMap)
85+
if err != nil {
86+
return k8sApiV1.Secret{}, err
87+
}
88+
secret := k8sApiV1.Secret{
89+
TypeMeta: k8sMetaV1.TypeMeta{
90+
Kind: commonBean.SecretKind,
91+
APIVersion: commonBean.V1VERSION,
92+
},
93+
ObjectMeta: k8sMetaV1.ObjectMeta{
94+
Name: configMapSecretDto.Name,
95+
OwnerReferences: []k8sMetaV1.OwnerReference{configMapSecretDto.OwnerRef},
96+
},
97+
Data: secretDataMap,
98+
Type: k8sApiV1.SecretTypeOpaque,
99+
}
100+
return secret, nil
101+
}

pkg/pipeline/executors/adapter/adapter_ent.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ package adapter
1919
import (
2020
"github.com/devtron-labs/devtron/api/bean"
2121
"github.com/devtron-labs/devtron/pkg/pipeline/types"
22-
v12 "k8s.io/api/core/v1"
22+
k8sApiV1 "k8s.io/api/core/v1"
2323
)
2424

25-
func updateBinaryDataInConfigMapSecretDto(configSecretMap bean.ConfigSecretMap, configMapSecretDto types.ConfigMapSecretDto, isSecret bool) (types.ConfigMapSecretDto, error) {
26-
return configMapSecretDto, nil
25+
func updateBinaryDataInConfigMapSecretDto(configSecretMap bean.ConfigSecretMap, configMapSecretDto types.ConfigMapSecretDto, isSecret bool) types.ConfigMapSecretDto {
26+
return configMapSecretDto
2727
}
2828

29-
func getConfigMapBodyEnt(configMapSecretDto types.ConfigMapSecretDto, configMap v12.ConfigMap) v12.ConfigMap {
29+
func getConfigMapBodyEnt(configMapSecretDto types.ConfigMapSecretDto, configMap k8sApiV1.ConfigMap) k8sApiV1.ConfigMap {
3030
return configMap
3131
}

0 commit comments

Comments
 (0)