Skip to content

Commit de90f57

Browse files
committed
updates
1 parent 35bb1b7 commit de90f57

2 files changed

Lines changed: 35 additions & 1 deletion

File tree

automation/render-tool-config/main.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ func (cfg renderConfig) validate(lane signoffLane) error {
180180
}
181181

182182
func renderToolConfig(cfg renderConfig, lane signoffLane) string {
183+
rancherDistro := rancherDistroForLane(cfg.RancherDistro, lane)
183184
return fmt.Sprintf(`rancher:
184185
mode: auto
185186
version: %s
@@ -211,7 +212,7 @@ tf_vars:
211212
aws_route53_fqdn: %s
212213
`,
213214
yamlQuote(strings.TrimPrefix(lane.InstallRancher, "v")),
214-
yamlQuote(cfg.RancherDistro),
215+
yamlQuote(rancherDistro),
215216
yamlQuote(cfg.BootstrapPassword),
216217
cfg.AutoApprove,
217218
cfg.PreloadImages,
@@ -232,6 +233,17 @@ tf_vars:
232233
)
233234
}
234235

236+
func rancherDistroForLane(configured string, lane signoffLane) string {
237+
configured = strings.TrimSpace(configured)
238+
if strings.EqualFold(configured, "auto") && strings.TrimSpace(lane.UpgradeToRancher) != "" {
239+
// Keep the upgrade on one distribution. Otherwise auto mode installs the
240+
// released baseline from Prime but resolves prerelease targets from the
241+
// community repos, carrying Prime's system registry into the RC webhook.
242+
return "community"
243+
}
244+
return configured
245+
}
246+
235247
func renderEnvOutput(plan signoffPlan, lane signoffLane) (string, error) {
236248
var b strings.Builder
237249
if err := writeGitHubEnvLine(&b, "TF_STATE_KEY", lane.TerraformStateKey); err != nil {

automation/render-tool-config/main_test.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,28 @@ func TestRenderToolConfigForFreshLane(t *testing.T) {
4545
assertContains(t, rendered, `total_has: 1`)
4646
}
4747

48+
func TestRenderToolConfigKeepsAutoUpgradeLaneOnCommunityDistro(t *testing.T) {
49+
cfg := renderConfig{
50+
RancherDistro: "auto",
51+
}
52+
lane := signoffLane{
53+
Name: "webhook-upgrade",
54+
InstallRancher: "v2.14.3",
55+
UpgradeToRancher: "v2.15.0-rc2",
56+
}
57+
58+
rendered := renderToolConfig(cfg, lane)
59+
assertContains(t, rendered, `version: "2.14.3"`)
60+
assertContains(t, rendered, `distro: "community"`)
61+
}
62+
63+
func TestRancherDistroForLanePreservesExplicitSelection(t *testing.T) {
64+
lane := signoffLane{UpgradeToRancher: "v2.15.0-rc2"}
65+
if got := rancherDistroForLane("prime", lane); got != "prime" {
66+
t.Fatalf("explicit distro changed to %q", got)
67+
}
68+
}
69+
4870
func TestRendererWritesConfigAndEnvOutput(t *testing.T) {
4971
tempDir := t.TempDir()
5072
planPath := filepath.Join(tempDir, "plan.json")

0 commit comments

Comments
 (0)