runconfig: fix missing generation of dockerregistryauth auth field

This commit is contained in:
alessandro.pinna 2022-02-01 14:50:14 +01:00
parent b234ce86a4
commit c5d240f0d0
2 changed files with 201 additions and 0 deletions

View File

@ -237,6 +237,7 @@ func GenRunConfigTasks(uuid util.UUIDGenerator, c *config.Config, runName string
Type: rstypes.DockerRegistryAuthType(auth.Type), Type: rstypes.DockerRegistryAuthType(auth.Type),
Username: genValue(auth.Username, variables), Username: genValue(auth.Username, variables),
Password: genValue(auth.Password, variables), Password: genValue(auth.Password, variables),
Auth: auth.Auth,
} }
} }
} }
@ -248,6 +249,7 @@ func GenRunConfigTasks(uuid util.UUIDGenerator, c *config.Config, runName string
Type: rstypes.DockerRegistryAuthType(auth.Type), Type: rstypes.DockerRegistryAuthType(auth.Type),
Username: genValue(auth.Username, variables), Username: genValue(auth.Username, variables),
Password: genValue(auth.Password, variables), Password: genValue(auth.Password, variables),
Auth: auth.Auth,
} }
} }
} }
@ -259,6 +261,7 @@ func GenRunConfigTasks(uuid util.UUIDGenerator, c *config.Config, runName string
Type: rstypes.DockerRegistryAuthType(auth.Type), Type: rstypes.DockerRegistryAuthType(auth.Type),
Username: genValue(auth.Username, variables), Username: genValue(auth.Username, variables),
Password: genValue(auth.Password, variables), Password: genValue(auth.Password, variables),
Auth: auth.Auth,
} }
} }
} }

View File

@ -1093,6 +1093,204 @@ func TestGenRunConfig(t *testing.T) {
}, },
}, },
}, },
{
name: "test runconfig generation encodedauth global",
in: &config.Config{
DockerRegistriesAuth: map[string]*config.DockerRegistryAuth{
"index.docker.io": {
Type: config.DockerRegistryAuthTypeEncodedAuth,
Auth: "dXNlcm5hbWU6cGFzc3dvcmQ=",
},
},
Runs: []*config.Run{
&config.Run{
Name: "run01",
Tasks: []*config.Task{
&config.Task{
Name: "task01",
Runtime: &config.Runtime{
Type: "pod",
Arch: "",
Containers: []*config.Container{
&config.Container{
Image: "image01",
},
},
},
Depends: []*config.Depend{},
WorkingDir: "",
Shell: "",
User: "",
},
},
},
},
},
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: "dXNlcm5hbWU6cGFzc3dvcmQ=",
},
},
Runtime: &rstypes.Runtime{Type: rstypes.RuntimeType("pod"),
Containers: []*rstypes.Container{
{
Image: "image01",
Volumes: []rstypes.Volume{},
Environment: map[string]string{},
},
},
},
Environment: map[string]string{},
Skip: false,
Steps: rstypes.Steps{},
Shell: "/bin/sh -e",
},
},
},
{
name: "test global encodedauth override by run auth",
in: &config.Config{
DockerRegistriesAuth: map[string]*config.DockerRegistryAuth{
"index.docker.io": {
Type: config.DockerRegistryAuthTypeEncodedAuth,
Auth: "dXNlcm5hbWU6cGFzc3dvcmQy",
},
},
Runs: []*config.Run{
&config.Run{
Name: "run01",
DockerRegistriesAuth: map[string]*config.DockerRegistryAuth{
"index.docker.io": {
Type: config.DockerRegistryAuthTypeEncodedAuth,
Auth: "dXNlcm5hbWUxOnBhc3N3b3JkMQ==",
},
},
Tasks: []*config.Task{
&config.Task{
Name: "task01",
Runtime: &config.Runtime{
Type: "pod",
Arch: "",
Containers: []*config.Container{
&config.Container{
Image: "image01",
},
},
},
Depends: []*config.Depend{},
WorkingDir: "",
Shell: "",
User: "",
},
},
},
},
},
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: "dXNlcm5hbWUxOnBhc3N3b3JkMQ==",
},
},
Runtime: &rstypes.Runtime{Type: rstypes.RuntimeType("pod"),
Containers: []*rstypes.Container{
{
Image: "image01",
Volumes: []rstypes.Volume{},
Environment: map[string]string{},
},
},
},
Environment: map[string]string{},
Skip: false,
Steps: rstypes.Steps{},
Shell: "/bin/sh -e",
},
},
},
{
name: "test global run encodedauth override by task auth",
in: &config.Config{
DockerRegistriesAuth: map[string]*config.DockerRegistryAuth{
"index.docker.io": {
Type: config.DockerRegistryAuthTypeEncodedAuth,
Auth: "dXNlcm5hbWU6cGFzc3dvcmQy",
},
},
Runs: []*config.Run{
&config.Run{
Name: "run01",
DockerRegistriesAuth: map[string]*config.DockerRegistryAuth{
"index.docker.io": {
Type: config.DockerRegistryAuthTypeEncodedAuth,
Auth: "dXNlcm5hbWUxOnBhc3N3b3JkMQ==",
},
},
Tasks: []*config.Task{
&config.Task{
Name: "task01",
DockerRegistriesAuth: map[string]*config.DockerRegistryAuth{
"index.docker.io": {
Type: config.DockerRegistryAuthTypeEncodedAuth,
Auth: "dXNlcm5hbWUyOnBhc3N3b3JkMg==",
},
},
Runtime: &config.Runtime{
Type: "pod",
Arch: "",
Containers: []*config.Container{
&config.Container{
Image: "image01",
},
},
},
Depends: []*config.Depend{},
WorkingDir: "",
Shell: "",
User: "",
},
},
},
},
},
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: "dXNlcm5hbWUyOnBhc3N3b3JkMg==",
},
},
Runtime: &rstypes.Runtime{Type: rstypes.RuntimeType("pod"),
Containers: []*rstypes.Container{
{
Image: "image01",
Volumes: []rstypes.Volume{},
Environment: map[string]string{},
},
},
},
Environment: map[string]string{},
Skip: false,
Steps: rstypes.Steps{},
Shell: "/bin/sh -e",
},
},
},
} }
for _, tt := range tests { for _, tt := range tests {