From d8927f807ba60a9eab839328dd4883f6767c6f3c Mon Sep 17 00:00:00 2001 From: Jordan Liggitt Date: Wed, 1 Mar 2023 19:24:18 -0500 Subject: [PATCH 1/2] Run go-compatibility presubmits, still in optional mode --- .../jobs/kubernetes/sig-release/release-branch-jobs/1.23.yaml | 4 ++-- .../jobs/kubernetes/sig-release/release-branch-jobs/1.24.yaml | 4 ++-- .../jobs/kubernetes/sig-release/release-branch-jobs/1.25.yaml | 4 ++-- .../jobs/kubernetes/sig-release/release-branch-jobs/1.26.yaml | 4 ++-- config/jobs/kubernetes/sig-testing/integration.yaml | 4 ++-- config/jobs/kubernetes/sig-testing/make-test.yaml | 4 ++-- gubernator/config.yaml | 2 ++ 7 files changed, 14 insertions(+), 12 deletions(-) diff --git a/config/jobs/kubernetes/sig-release/release-branch-jobs/1.23.yaml b/config/jobs/kubernetes/sig-release/release-branch-jobs/1.23.yaml index 3f1be0ca0291..70d0377ced6e 100644 --- a/config/jobs/kubernetes/sig-release/release-branch-jobs/1.23.yaml +++ b/config/jobs/kubernetes/sig-release/release-branch-jobs/1.23.yaml @@ -1600,7 +1600,7 @@ presubmits: memory: 15Gi securityContext: privileged: true - - always_run: false + - always_run: true optional: true branches: - release-1.23 @@ -1782,7 +1782,7 @@ presubmits: memory: 36Gi securityContext: runAsUser: 2000 - - always_run: false + - always_run: true optional: true branches: - release-1.23 diff --git a/config/jobs/kubernetes/sig-release/release-branch-jobs/1.24.yaml b/config/jobs/kubernetes/sig-release/release-branch-jobs/1.24.yaml index 27687fd82ea9..b139107e6a61 100644 --- a/config/jobs/kubernetes/sig-release/release-branch-jobs/1.24.yaml +++ b/config/jobs/kubernetes/sig-release/release-branch-jobs/1.24.yaml @@ -1420,7 +1420,7 @@ presubmits: memory: 15Gi securityContext: privileged: true - - always_run: false + - always_run: true optional: true branches: - release-1.24 @@ -1602,7 +1602,7 @@ presubmits: memory: 36Gi securityContext: runAsUser: 2000 - - always_run: false + - always_run: true optional: true branches: - release-1.24 diff --git a/config/jobs/kubernetes/sig-release/release-branch-jobs/1.25.yaml b/config/jobs/kubernetes/sig-release/release-branch-jobs/1.25.yaml index 271093723b86..1faee2118219 100644 --- a/config/jobs/kubernetes/sig-release/release-branch-jobs/1.25.yaml +++ b/config/jobs/kubernetes/sig-release/release-branch-jobs/1.25.yaml @@ -1430,7 +1430,7 @@ presubmits: memory: 15Gi securityContext: privileged: true - - always_run: false + - always_run: true optional: true branches: - release-1.25 @@ -1612,7 +1612,7 @@ presubmits: memory: 36Gi securityContext: runAsUser: 2000 - - always_run: false + - always_run: true optional: true branches: - release-1.25 diff --git a/config/jobs/kubernetes/sig-release/release-branch-jobs/1.26.yaml b/config/jobs/kubernetes/sig-release/release-branch-jobs/1.26.yaml index c60bd135ab8f..dd58965189ab 100755 --- a/config/jobs/kubernetes/sig-release/release-branch-jobs/1.26.yaml +++ b/config/jobs/kubernetes/sig-release/release-branch-jobs/1.26.yaml @@ -1458,7 +1458,7 @@ presubmits: memory: 15Gi securityContext: privileged: true - - always_run: false + - always_run: true optional: true branches: - release-1.26 @@ -1638,7 +1638,7 @@ presubmits: requests: cpu: "4" memory: 36Gi - - always_run: false + - always_run: true optional: true branches: - release-1.26 diff --git a/config/jobs/kubernetes/sig-testing/integration.yaml b/config/jobs/kubernetes/sig-testing/integration.yaml index d3b41f3ce6d6..2099cffc8778 100644 --- a/config/jobs/kubernetes/sig-testing/integration.yaml +++ b/config/jobs/kubernetes/sig-testing/integration.yaml @@ -35,11 +35,11 @@ presubmits: memory: 15Gi - name: pull-kubernetes-integration-go-compatibility cluster: k8s-infra-prow-build - always_run: false + always_run: true optional: true decorate: true skip_branches: - - release-\d+.\d+ # per-release job + - .* # per-release job annotations: fork-per-release: "true" testgrid-dashboards: sig-testing-canaries diff --git a/config/jobs/kubernetes/sig-testing/make-test.yaml b/config/jobs/kubernetes/sig-testing/make-test.yaml index 413a1656f426..de7a5e0a921c 100644 --- a/config/jobs/kubernetes/sig-testing/make-test.yaml +++ b/config/jobs/kubernetes/sig-testing/make-test.yaml @@ -43,11 +43,11 @@ presubmits: decorate: true cluster: k8s-infra-prow-build skip_branches: - - release-\d+.\d+ # per-release job + - .* # per-release job labels: preset-service-account: "true" optional: true - always_run: false + always_run: true path_alias: k8s.io/kubernetes spec: # unit tests have no business requiring root or doing privileged operations diff --git a/gubernator/config.yaml b/gubernator/config.yaml index d567c4373c64..0004a86af7ee 100644 --- a/gubernator/config.yaml +++ b/gubernator/config.yaml @@ -32,9 +32,11 @@ jobs: - pull-kubernetes-e2e-kind - pull-kubernetes-e2e-kind-ipv6 - pull-kubernetes-integration + - pull-kubernetes-integration-go-compatibility - pull-kubernetes-node-e2e-containerd - pull-kubernetes-typecheck - pull-kubernetes-unit + - pull-kubernetes-unit-go-compatibility - pull-kubernetes-verify - pull-kubernetes-verify-govet-levee recursive_artifacts: false From 93499e1130d2241d6f5b4238b635dee338c6fb50 Mon Sep 17 00:00:00 2001 From: Jordan Liggitt Date: Thu, 2 Mar 2023 00:54:35 -0500 Subject: [PATCH 2/2] Add env-var replacement and go version to config-forker --- config/jobs/README.md | 5 +- .../kubernetes/sig-testing/integration.yaml | 1 + .../kubernetes/sig-testing/make-test.yaml | 1 + releng/config-forker/main.go | 122 ++++++++++++------ releng/config-forker/main_test.go | 27 ++-- 5 files changed, 103 insertions(+), 53 deletions(-) diff --git a/config/jobs/README.md b/config/jobs/README.md index 9bf7cd67451a..cdd2c67adde8 100644 --- a/config/jobs/README.md +++ b/config/jobs/README.md @@ -216,8 +216,9 @@ accomplish this, eg: # from test-infra root $ go run ./releng/config-forker \ --job-config $(pwd)/config/jobs \ - --version 1.15 \ - --output $(pwd)/config/jobs/kubernetes/sig-release/release-branch-jobs/1.15.yaml + --version 1.27 \ + --go-version 1.20.2 \ + --output $(pwd)/config/jobs/kubernetes/sig-release/release-branch-jobs/1.27.yaml ``` [prow.k8s.io]: https://prow.k8s.io diff --git a/config/jobs/kubernetes/sig-testing/integration.yaml b/config/jobs/kubernetes/sig-testing/integration.yaml index 2099cffc8778..da6b857af6d2 100644 --- a/config/jobs/kubernetes/sig-testing/integration.yaml +++ b/config/jobs/kubernetes/sig-testing/integration.yaml @@ -42,6 +42,7 @@ presubmits: - .* # per-release job annotations: fork-per-release: "true" + fork-per-release-replacements: "GO_VERSION= -> GO_VERSION={{.GoVersion}}" testgrid-dashboards: sig-testing-canaries description: run with GO_VERSION set to the original go version used for this branch path_alias: k8s.io/kubernetes diff --git a/config/jobs/kubernetes/sig-testing/make-test.yaml b/config/jobs/kubernetes/sig-testing/make-test.yaml index de7a5e0a921c..ef08d69ea63c 100644 --- a/config/jobs/kubernetes/sig-testing/make-test.yaml +++ b/config/jobs/kubernetes/sig-testing/make-test.yaml @@ -38,6 +38,7 @@ presubmits: - name: pull-kubernetes-unit-go-compatibility annotations: fork-per-release: "true" + fork-per-release-replacements: "GO_VERSION= -> GO_VERSION={{.GoVersion}}" testgrid-dashboards: sig-testing-canaries description: run with GO_VERSION set to the original go version used for this branch decorate: true diff --git a/releng/config-forker/main.go b/releng/config-forker/main.go index ecce007cbf09..4473cf11caa3 100644 --- a/releng/config-forker/main.go +++ b/releng/config-forker/main.go @@ -27,10 +27,11 @@ import ( "strings" "text/template" + "sigs.k8s.io/yaml" + v1 "k8s.io/api/core/v1" prowapi "k8s.io/test-infra/prow/apis/prowjobs/v1" "k8s.io/test-infra/prow/config" - "sigs.k8s.io/yaml" ) const ( @@ -45,7 +46,7 @@ const ( descriptionAnnotation = "description" ) -func generatePostsubmits(c config.JobConfig, version string) (map[string][]config.Postsubmit, error) { +func generatePostsubmits(c config.JobConfig, vars templateVars) (map[string][]config.Postsubmit, error) { newPostsubmits := map[string][]config.Postsubmit{} for repo, postsubmits := range c.PostsubmitsStatic { for _, postsubmit := range postsubmits { @@ -53,33 +54,39 @@ func generatePostsubmits(c config.JobConfig, version string) (map[string][]confi continue } p := postsubmit - p.Name = generateNameVariant(p.Name, version, postsubmit.Annotations[suffixAnnotation] == "true") + p.Name = generateNameVariant(p.Name, vars.Version, postsubmit.Annotations[suffixAnnotation] == "true") p.SkipBranches = nil - p.Branches = []string{"release-" + version} + p.Branches = []string{"release-" + vars.Version} if p.Spec != nil { for i := range p.Spec.Containers { c := &p.Spec.Containers[i] - c.Env = fixEnvVars(c.Env, version) - c.Image = fixImage(c.Image, version) + c.Env = fixEnvVars(c.Env, vars.Version) + c.Image = fixImage(c.Image, vars.Version) var err error - c.Command, err = performReplacement(c.Command, version, p.Annotations[replacementAnnotation]) + c.Command, err = performReplacement(c.Command, vars, p.Annotations[replacementAnnotation]) if err != nil { return nil, fmt.Errorf("%s: %w", postsubmit.Name, err) } - c.Args, err = performReplacement(c.Args, version, p.Annotations[replacementAnnotation]) + c.Args, err = performReplacement(c.Args, vars, p.Annotations[replacementAnnotation]) if err != nil { return nil, fmt.Errorf("%s: %w", postsubmit.Name, err) } + for i := range c.Env { + c.Env[i].Name, c.Env[i].Value, err = performEnvReplacement(c.Env[i].Name, c.Env[i].Value, vars, p.Annotations[replacementAnnotation]) + if err != nil { + return nil, fmt.Errorf("%s: %w", postsubmit.Name, err) + } + } } } - p.Annotations = cleanAnnotations(fixTestgridAnnotations(p.Annotations, version, false)) + p.Annotations = cleanAnnotations(fixTestgridAnnotations(p.Annotations, vars.Version, false)) newPostsubmits[repo] = append(newPostsubmits[repo], p) } } return newPostsubmits, nil } -func generatePresubmits(c config.JobConfig, version string) (map[string][]config.Presubmit, error) { +func generatePresubmits(c config.JobConfig, vars templateVars) (map[string][]config.Presubmit, error) { newPresubmits := map[string][]config.Presubmit{} for repo, presubmits := range c.PresubmitsStatic { for _, presubmit := range presubmits { @@ -88,25 +95,31 @@ func generatePresubmits(c config.JobConfig, version string) (map[string][]config } p := presubmit p.SkipBranches = nil - p.Branches = []string{"release-" + version} - p.Context = generatePresubmitContextVariant(p.Name, p.Context, version) + p.Branches = []string{"release-" + vars.Version} + p.Context = generatePresubmitContextVariant(p.Name, p.Context, vars.Version) if p.Spec != nil { for i := range p.Spec.Containers { c := &p.Spec.Containers[i] - c.Env = fixEnvVars(c.Env, version) - c.Image = fixImage(c.Image, version) + c.Env = fixEnvVars(c.Env, vars.Version) + c.Image = fixImage(c.Image, vars.Version) var err error - c.Command, err = performReplacement(c.Command, version, p.Annotations[replacementAnnotation]) + c.Command, err = performReplacement(c.Command, vars, p.Annotations[replacementAnnotation]) if err != nil { return nil, fmt.Errorf("%s: %w", presubmit.Name, err) } - c.Args, err = performReplacement(c.Args, version, p.Annotations[replacementAnnotation]) + c.Args, err = performReplacement(c.Args, vars, p.Annotations[replacementAnnotation]) if err != nil { return nil, fmt.Errorf("%s: %w", presubmit.Name, err) } + for i := range c.Env { + c.Env[i].Name, c.Env[i].Value, err = performEnvReplacement(c.Env[i].Name, c.Env[i].Value, vars, p.Annotations[replacementAnnotation]) + if err != nil { + return nil, fmt.Errorf("%s: %w", presubmit.Name, err) + } + } } } - p.Annotations = cleanAnnotations(fixTestgridAnnotations(p.Annotations, version, true)) + p.Annotations = cleanAnnotations(fixTestgridAnnotations(p.Annotations, vars.Version, true)) newPresubmits[repo] = append(newPresubmits[repo], p) } } @@ -120,36 +133,42 @@ func shouldDecorate(c *config.JobConfig, util config.UtilityConfig) bool { return c.DecorateAllJobs } -func generatePeriodics(conf config.JobConfig, version string) ([]config.Periodic, error) { +func generatePeriodics(conf config.JobConfig, vars templateVars) ([]config.Periodic, error) { var newPeriodics []config.Periodic for _, periodic := range conf.Periodics { if periodic.Annotations[forkAnnotation] != "true" { continue } p := periodic - p.Name = generateNameVariant(p.Name, version, periodic.Annotations[suffixAnnotation] == "true") + p.Name = generateNameVariant(p.Name, vars.Version, periodic.Annotations[suffixAnnotation] == "true") if p.Spec != nil { for i := range p.Spec.Containers { c := &p.Spec.Containers[i] - c.Image = fixImage(c.Image, version) - c.Env = fixEnvVars(c.Env, version) + c.Image = fixImage(c.Image, vars.Version) + c.Env = fixEnvVars(c.Env, vars.Version) if !shouldDecorate(&conf, p.JobBase.UtilityConfig) { - c.Command = fixBootstrapArgs(c.Command, version) - c.Args = fixBootstrapArgs(c.Args, version) + c.Command = fixBootstrapArgs(c.Command, vars.Version) + c.Args = fixBootstrapArgs(c.Args, vars.Version) } var err error - c.Command, err = performReplacement(c.Command, version, p.Annotations[replacementAnnotation]) + c.Command, err = performReplacement(c.Command, vars, p.Annotations[replacementAnnotation]) if err != nil { return nil, fmt.Errorf("%s: %w", periodic.Name, err) } - c.Args, err = performReplacement(c.Args, version, p.Annotations[replacementAnnotation]) + c.Args, err = performReplacement(c.Args, vars, p.Annotations[replacementAnnotation]) if err != nil { return nil, fmt.Errorf("%s: %w", periodic.Name, err) } + for i := range c.Env { + c.Env[i].Name, c.Env[i].Value, err = performEnvReplacement(c.Env[i].Name, c.Env[i].Value, vars, p.Annotations[replacementAnnotation]) + if err != nil { + return nil, fmt.Errorf("%s: %w", periodic.Name, err) + } + } } } if shouldDecorate(&conf, p.JobBase.UtilityConfig) { - p.ExtraRefs = fixExtraRefs(p.ExtraRefs, version) + p.ExtraRefs = fixExtraRefs(p.ExtraRefs, vars.Version) } if interval, ok := p.Annotations[periodicIntervalAnnotation]; ok { if _, ok := p.Annotations[cronAnnotation]; ok { @@ -171,12 +190,12 @@ func generatePeriodics(conf config.JobConfig, version string) ([]config.Periodic } } var err error - p.Tags, err = performReplacement(p.Tags, version, p.Annotations[replacementAnnotation]) + p.Tags, err = performReplacement(p.Tags, vars, p.Annotations[replacementAnnotation]) if err != nil { return nil, fmt.Errorf("%s: %w", periodic.Name, err) } p.Labels = performDeletion(p.Labels, p.Annotations[deletionAnnotation]) - p.Annotations = cleanAnnotations(fixTestgridAnnotations(p.Annotations, version, false)) + p.Annotations = cleanAnnotations(fixTestgridAnnotations(p.Annotations, vars.Version, false)) newPeriodics = append(newPeriodics, p) } return newPeriodics, nil @@ -212,7 +231,22 @@ func evaluateTemplate(s string, c interface{}) (string, error) { return wr.String(), nil } -func performReplacement(args []string, version, replacements string) ([]string, error) { +func performEnvReplacement(name, value string, vars templateVars, replacements string) (string, string, error) { + v, err := performReplacement([]string{name + "=" + value}, vars, replacements) + if err != nil { + return "", "", err + } + if len(v) != 1 { + return "", "", fmt.Errorf("expected a single string result replacing env var, got %d", len(v)) + } + parts := strings.SplitN(v[0], "=", 2) + if len(parts) != 2 { + return "", "", fmt.Errorf("expected NAME=VALUE format replacing env var, got %s", v[0]) + } + return parts[0], parts[1], nil +} + +func performReplacement(args []string, vars templateVars, replacements string) ([]string, error) { if args == nil { return nil, nil } @@ -227,7 +261,7 @@ func performReplacement(args []string, version, replacements string) ([]string, if len(s) != 2 { return nil, fmt.Errorf("failed to parse replacement %q", r) } - v, err := evaluateTemplate(s[1], struct{ Version string }{version}) + v, err := evaluateTemplate(s[1], vars) if err != nil { return nil, err } @@ -390,14 +424,20 @@ func generatePresubmitContextVariant(name, context, version string) string { type options struct { jobConfig string outputPath string - newVersion string + vars templateVars +} + +type templateVars struct { + Version string + GoVersion string } func parseFlags() options { o := options{} flag.StringVar(&o.jobConfig, "job-config", "", "Path to the job config") flag.StringVar(&o.outputPath, "output", "", "Path to the output yaml. if not specified, just validate.") - flag.StringVar(&o.newVersion, "version", "", "Version number to generate jobs for") + flag.StringVar(&o.vars.Version, "version", "", "Version number to generate jobs for") + flag.StringVar(&o.vars.GoVersion, "go-version", "", "Current go version in use; see http://git.k8s.io/kubernetes/.go-version") flag.Parse() return o } @@ -406,11 +446,17 @@ func validateOptions(o options) error { if o.jobConfig == "" { return errors.New("--job-config must be specified") } - if o.newVersion == "" { + if o.vars.Version == "" { return errors.New("--version must be specified") } - if match, err := regexp.MatchString(`^\d+\.\d+$`, o.newVersion); err != nil || !match { - return fmt.Errorf("%q doesn't look like a valid version number", o.newVersion) + if match, err := regexp.MatchString(`^\d+\.\d+$`, o.vars.Version); err != nil || !match { + return fmt.Errorf("%q doesn't look like a valid version number", o.vars.Version) + } + if o.vars.GoVersion == "" { + return errors.New("--go-version must be specified; http://git.k8s.io/kubernetes/.go-version contains the recommended value") + } + if match, err := regexp.MatchString(`^\d+\.\d+(\.\d+)?(rc\d)?$`, o.vars.GoVersion); err != nil || !match { + return fmt.Errorf("%q doesn't look like a valid go version; should match the format 1.20rc1, 1.20, or 1.20.2", o.vars.GoVersion) } return nil } @@ -425,15 +471,15 @@ func main() { log.Fatalf("Failed to load job config: %v\n", err) } - newPresubmits, err := generatePresubmits(c, o.newVersion) + newPresubmits, err := generatePresubmits(c, o.vars) if err != nil { log.Fatalf("Failed to generate presubmits: %v.\n", err) } - newPeriodics, err := generatePeriodics(c, o.newVersion) + newPeriodics, err := generatePeriodics(c, o.vars) if err != nil { log.Fatalf("Failed to generate periodics: %v.\n", err) } - newPostsubmits, err := generatePostsubmits(c, o.newVersion) + newPostsubmits, err := generatePostsubmits(c, o.vars) if err != nil { log.Fatalf("Failed to generate postsubmits: %v.\n", err) } diff --git a/releng/config-forker/main_test.go b/releng/config-forker/main_test.go index caee9282c5bc..0e1c4ebad55c 100644 --- a/releng/config-forker/main_test.go +++ b/releng/config-forker/main_test.go @@ -22,6 +22,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" + v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/util/diff" prowapi "k8s.io/test-infra/prow/apis/prowjobs/v1" @@ -165,7 +166,7 @@ func TestPerformArgReplacements(t *testing.T) { for _, tc := range tests { t.Run(tc.name, func(t *testing.T) { - result, err := performReplacement(tc.args, "1.15", tc.replacements) + result, err := performReplacement(tc.args, templateVars{Version: "1.15"}, tc.replacements) if err != nil { if !tc.expectErr { t.Fatalf("Unexpected error: %v", err) @@ -528,7 +529,7 @@ func TestGeneratePresubmits(t *testing.T) { Name: "pull-replace-some-things", Annotations: map[string]string{ forkAnnotation: "true", - replacementAnnotation: "foo -> {{.Version}}", + replacementAnnotation: "foo -> {{.Version}}, GO_VERSION= -> GO_VERSION={{.GoVersion}}", "testgrid-generate-test-group": "true", "some-annotation": "yup", }, @@ -538,7 +539,7 @@ func TestGeneratePresubmits(t *testing.T) { Image: "gcr.io/k8s-staging-test-infra/kubekins-e2e:blahblahblah-master", Command: []string{"--arg1=test", "--something=foo"}, Args: []string{"--repo=k8s.io/kubernetes", "--something=foo"}, - Env: []v1.EnvVar{{Name: "BRANCH", Value: "master"}}, + Env: []v1.EnvVar{{Name: "BRANCH", Value: "master"}, {Name: "GO_VERSION"}}, }, }, }, @@ -618,7 +619,7 @@ func TestGeneratePresubmits(t *testing.T) { Image: "gcr.io/k8s-staging-test-infra/kubekins-e2e:blahblahblah-1.15", Command: []string{"--arg1=test", "--something=1.15"}, Args: []string{"--repo=k8s.io/kubernetes", "--something=1.15"}, - Env: []v1.EnvVar{{Name: "BRANCH", Value: "release-1.15"}}, + Env: []v1.EnvVar{{Name: "BRANCH", Value: "release-1.15"}, {Name: "GO_VERSION", Value: "1.20.2"}}, }, }, }, @@ -633,7 +634,7 @@ func TestGeneratePresubmits(t *testing.T) { }, } - result, err := generatePresubmits(config.JobConfig{PresubmitsStatic: presubmits}, "1.15") + result, err := generatePresubmits(config.JobConfig{PresubmitsStatic: presubmits}, templateVars{Version: "1.15", GoVersion: "1.20.2"}) if err != nil { t.Fatalf("Unexpected error: %v", err) } @@ -682,7 +683,7 @@ func TestGeneratePeriodics(t *testing.T) { Annotations: map[string]string{ forkAnnotation: "true", periodicIntervalAnnotation: "6h 12h 24h 24h", - replacementAnnotation: "stable -> {{.Version}}", + replacementAnnotation: "stable -> {{.Version}}, GO_VERSION= -> GO_VERSION={{.GoVersion}}", }, Spec: &v1.PodSpec{ Containers: []v1.Container{ @@ -690,7 +691,7 @@ func TestGeneratePeriodics(t *testing.T) { Image: "gcr.io/k8s-testinfra/kubekins-e2e:blahblahblah-master", Command: []string{"--args1=test", "--version=stable"}, Args: []string{"--repo=k8s.io/kubernetes", "--version=stable"}, - Env: []v1.EnvVar{{Name: "BRANCH", Value: "master"}}, + Env: []v1.EnvVar{{Name: "BRANCH", Value: "master"}, {Name: "GO_VERSION"}}, }, }, }, @@ -756,7 +757,7 @@ func TestGeneratePeriodics(t *testing.T) { Image: "gcr.io/k8s-testinfra/kubekins-e2e:blahblahblah-1.15", Command: []string{"--args1=test", "--version=1.15"}, Args: []string{"--repo=k8s.io/kubernetes=release-1.15", "--version=1.15"}, - Env: []v1.EnvVar{{Name: "BRANCH", Value: "release-1.15"}}, + Env: []v1.EnvVar{{Name: "BRANCH", Value: "release-1.15"}, {Name: "GO_VERSION", Value: "1.20.2"}}, }, }, }, @@ -776,7 +777,7 @@ func TestGeneratePeriodics(t *testing.T) { }, } - result, err := generatePeriodics(config.JobConfig{Periodics: periodics}, "1.15") + result, err := generatePeriodics(config.JobConfig{Periodics: periodics}, templateVars{Version: "1.15", GoVersion: "1.20.2"}) if err != nil { t.Fatalf("Unexpected error: %v", err) } @@ -829,7 +830,7 @@ func TestGeneratePostsubmits(t *testing.T) { Name: "post-replace-some-things-master", Annotations: map[string]string{ forkAnnotation: "true", - replacementAnnotation: "foo -> {{.Version}}", + replacementAnnotation: "foo -> {{.Version}}, GO_VERSION= -> GO_VERSION={{.GoVersion}}", "some-annotation": "yup", }, Spec: &v1.PodSpec{ @@ -838,7 +839,7 @@ func TestGeneratePostsubmits(t *testing.T) { Image: "gcr.io/k8s-staging-test-infra/kubekins-e2e:blahblahblah-master", Command: []string{"--args1=test", "--something=foo"}, Args: []string{"--repo=k8s.io/kubernetes", "--something=foo"}, - Env: []v1.EnvVar{{Name: "BRANCH", Value: "master"}}, + Env: []v1.EnvVar{{Name: "BRANCH", Value: "master"}, {Name: "GO_VERSION"}}, }, }, }, @@ -904,7 +905,7 @@ func TestGeneratePostsubmits(t *testing.T) { Image: "gcr.io/k8s-staging-test-infra/kubekins-e2e:blahblahblah-1.15", Command: []string{"--args1=test", "--something=1.15"}, Args: []string{"--repo=k8s.io/kubernetes", "--something=1.15"}, - Env: []v1.EnvVar{{Name: "BRANCH", Value: "release-1.15"}}, + Env: []v1.EnvVar{{Name: "BRANCH", Value: "release-1.15"}, {Name: "GO_VERSION", Value: "1.20.2"}}, }, }, }, @@ -916,7 +917,7 @@ func TestGeneratePostsubmits(t *testing.T) { }, } - result, err := generatePostsubmits(config.JobConfig{PostsubmitsStatic: postsubmits}, "1.15") + result, err := generatePostsubmits(config.JobConfig{PostsubmitsStatic: postsubmits}, templateVars{Version: "1.15", GoVersion: "1.20.2"}) if err != nil { t.Fatalf("Unexpected error: %v", err) }