diff --git a/internal/config/config.go b/internal/config/config.go index 335ecdc..a815db9 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -77,8 +77,8 @@ type DockerRegistryAuth struct { Username Value `json:"username"` Password Value `json:"password"` - // encoded auth string - Auth string `json:"auth"` + // encoded auth + Auth Value `json:"auth"` // future auths like aws ecr auth } diff --git a/internal/runconfig/runconfig.go b/internal/runconfig/runconfig.go index 442e7c4..4856baf 100644 --- a/internal/runconfig/runconfig.go +++ b/internal/runconfig/runconfig.go @@ -237,7 +237,7 @@ func GenRunConfigTasks(uuid util.UUIDGenerator, c *config.Config, runName string Type: rstypes.DockerRegistryAuthType(auth.Type), Username: genValue(auth.Username, variables), Password: genValue(auth.Password, variables), - Auth: auth.Auth, + Auth: genValue(auth.Auth, variables), } } } @@ -249,7 +249,7 @@ func GenRunConfigTasks(uuid util.UUIDGenerator, c *config.Config, runName string Type: rstypes.DockerRegistryAuthType(auth.Type), Username: genValue(auth.Username, variables), Password: genValue(auth.Password, variables), - Auth: auth.Auth, + Auth: genValue(auth.Auth, variables), } } } @@ -261,7 +261,7 @@ func GenRunConfigTasks(uuid util.UUIDGenerator, c *config.Config, runName string Type: rstypes.DockerRegistryAuthType(auth.Type), Username: genValue(auth.Username, variables), Password: genValue(auth.Password, variables), - Auth: auth.Auth, + Auth: genValue(auth.Auth, variables), } } } diff --git a/internal/runconfig/runconfig_test.go b/internal/runconfig/runconfig_test.go index d49e2dd..4cde8ce 100644 --- a/internal/runconfig/runconfig_test.go +++ b/internal/runconfig/runconfig_test.go @@ -1099,7 +1099,7 @@ func TestGenRunConfig(t *testing.T) { DockerRegistriesAuth: map[string]*config.DockerRegistryAuth{ "index.docker.io": { Type: config.DockerRegistryAuthTypeEncodedAuth, - Auth: "dXNlcm5hbWU6cGFzc3dvcmQ=", + Auth: config.Value{Type: config.ValueTypeString, Value: "dXNlcm5hbWU6cGFzc3dvcmQ="}, }, }, Runs: []*config.Run{ @@ -1159,7 +1159,7 @@ func TestGenRunConfig(t *testing.T) { DockerRegistriesAuth: map[string]*config.DockerRegistryAuth{ "index.docker.io": { Type: config.DockerRegistryAuthTypeEncodedAuth, - Auth: "dXNlcm5hbWU6cGFzc3dvcmQy", + Auth: config.Value{Type: config.ValueTypeString, Value: "dXNlcm5hbWU6cGFzc3dvcmQy"}, }, }, Runs: []*config.Run{ @@ -1168,7 +1168,7 @@ func TestGenRunConfig(t *testing.T) { DockerRegistriesAuth: map[string]*config.DockerRegistryAuth{ "index.docker.io": { Type: config.DockerRegistryAuthTypeEncodedAuth, - Auth: "dXNlcm5hbWUxOnBhc3N3b3JkMQ==", + Auth: config.Value{Type: config.ValueTypeString, Value: "dXNlcm5hbWUxOnBhc3N3b3JkMQ=="}, }, }, Tasks: []*config.Task{ @@ -1225,7 +1225,7 @@ func TestGenRunConfig(t *testing.T) { DockerRegistriesAuth: map[string]*config.DockerRegistryAuth{ "index.docker.io": { Type: config.DockerRegistryAuthTypeEncodedAuth, - Auth: "dXNlcm5hbWU6cGFzc3dvcmQy", + Auth: config.Value{Type: config.ValueTypeString, Value: "dXNlcm5hbWU6cGFzc3dvcmQy"}, }, }, Runs: []*config.Run{ @@ -1234,7 +1234,7 @@ func TestGenRunConfig(t *testing.T) { DockerRegistriesAuth: map[string]*config.DockerRegistryAuth{ "index.docker.io": { Type: config.DockerRegistryAuthTypeEncodedAuth, - Auth: "dXNlcm5hbWUxOnBhc3N3b3JkMQ==", + Auth: config.Value{Type: config.ValueTypeString, Value: "dXNlcm5hbWUxOnBhc3N3b3JkMQ=="}, }, }, Tasks: []*config.Task{ @@ -1243,7 +1243,7 @@ func TestGenRunConfig(t *testing.T) { DockerRegistriesAuth: map[string]*config.DockerRegistryAuth{ "index.docker.io": { Type: config.DockerRegistryAuthTypeEncodedAuth, - Auth: "dXNlcm5hbWUyOnBhc3N3b3JkMg==", + Auth: config.Value{Type: config.ValueTypeString, Value: "dXNlcm5hbWUyOnBhc3N3b3JkMg=="}, }, }, Runtime: &config.Runtime{ @@ -1291,6 +1291,73 @@ func TestGenRunConfig(t *testing.T) { }, }, }, + { + name: "test runconfig generation with encoded value type", + in: &config.Config{ + Runs: []*config.Run{ + &config.Run{ + Name: "run01", + DockerRegistriesAuth: map[string]*config.DockerRegistryAuth{ + "index.docker.io": { + Type: config.DockerRegistryAuthTypeEncodedAuth, + Auth: config.Value{Type: config.ValueTypeString, Value: "yourregistryusername:password2"}, + }, + }, + Tasks: []*config.Task{ + &config.Task{ + Name: "task01", + DockerRegistriesAuth: map[string]*config.DockerRegistryAuth{ + "index.docker.io": { + Type: config.DockerRegistryAuthTypeEncodedAuth, + Auth: config.Value{Type: config.ValueTypeFromVariable, Value: "auth"}, + }, + }, + Runtime: &config.Runtime{ + Type: "pod", + Containers: []*config.Container{ + &config.Container{ + Image: "image01", + User: "", + }, + }, + }, + Depends: []*config.Depend{}, + IgnoreFailure: false, + Approval: false, + }, + }, + }, + }, + }, + variables: map[string]string{ + "auth": "eW91cnJlZ2lzdHJ5dXNlcm5hbWU6cGFzc3dvcmQy", + }, + out: map[string]*rstypes.RunConfigTask{ + uuid.New("task01").String(): &rstypes.RunConfigTask{ + ID: uuid.New("task01").String(), + Name: "task01", Depends: map[string]*rstypes.RunConfigTaskDepend{}, + DockerRegistriesAuth: map[string]rstypes.DockerRegistryAuth{ + "index.docker.io": { + Type: rstypes.DockerRegistryAuthTypeEncodedAuth, + Auth: "eW91cnJlZ2lzdHJ5dXNlcm5hbWU6cGFzc3dvcmQy", + }, + }, + Runtime: &rstypes.Runtime{Type: rstypes.RuntimeType("pod"), + Containers: []*rstypes.Container{ + { + Image: "image01", + Environment: map[string]string{}, + Volumes: []rstypes.Volume{}, + }, + }, + }, + Shell: "/bin/sh -e", + Environment: map[string]string{}, + Steps: rstypes.Steps{}, + Skip: false, + }, + }, + }, } for _, tt := range tests {