Skip to content

Commit 4dfb5c6

Browse files
committed
ci: Updates to support the migration on the CLI.
1 parent 85fc9cd commit 4dfb5c6

File tree

4 files changed

+71
-22
lines changed

4 files changed

+71
-22
lines changed

scripts/camunda-core/pkg/scenarios/scenarios.go

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ type DeploymentConfig struct {
3434
QA bool // Enable QA configuration (test users, etc.)
3535
ImageTags bool // Enable image tag overrides from env vars
3636
Upgrade bool // Enable upgrade flow configuration
37+
38+
// Migration support (for helm chart schema changes)
39+
ChartVersion string // Chart version (e.g., "13.0.0") - used to determine if migrator is needed
40+
Flow string // Deployment flow: install, upgrade-patch, upgrade-minor
3741
}
3842

3943
// Validate checks that required fields are set and feature constraints are satisfied.
@@ -75,7 +79,7 @@ func (c *DeploymentConfig) Validate() error {
7579
}
7680

7781
// ResolvePaths returns the ordered list of values files based on the configuration.
78-
// Files are returned in order: base -> base modifiers -> identity -> persistence -> platform -> features
82+
// Files are returned in order: base -> base modifiers -> identity -> persistence -> platform -> features -> migrator -> image-tags
7983
func (c *DeploymentConfig) ResolvePaths(scenariosDir string) ([]string, error) {
8084
valuesDir := filepath.Join(scenariosDir, ValuesDir)
8185

@@ -142,7 +146,18 @@ func (c *DeploymentConfig) ResolvePaths(scenariosDir string) ([]string, error) {
142146
}
143147
}
144148

145-
// Layer 7: Image tags (applied last, needs env var processing)
149+
// Layer 7: Migrator (for chart version 13.x minor upgrades)
150+
// The migrator handles schema migrations like global.security.initialization -> orchestration.security.initialization
151+
// Include when: chart version starts with "13" AND flow is not "upgrade-patch" (i.e., it's a minor upgrade or install)
152+
if c.needsMigrator() {
153+
// Migrator file is at chart-full-setup/values-enable-migrator.yaml (one level up from values/)
154+
migratorPath := filepath.Join(scenariosDir, "values-enable-migrator.yaml")
155+
if _, err := os.Stat(migratorPath); err == nil {
156+
files = append(files, migratorPath)
157+
}
158+
}
159+
160+
// Layer 8: Image tags (applied last, needs env var processing)
146161
// Note: ImageTags file path is returned but the caller is responsible
147162
// for processing environment variable substitution
148163
if c.ImageTags {
@@ -155,6 +170,23 @@ func (c *DeploymentConfig) ResolvePaths(scenariosDir string) ([]string, error) {
155170
return files, nil
156171
}
157172

173+
// needsMigrator returns true if the migrator values file should be included.
174+
// The migrator is needed for chart version 13.x when the flow is not a patch upgrade.
175+
func (c *DeploymentConfig) needsMigrator() bool {
176+
// Only needed for chart version 13.x
177+
if !strings.HasPrefix(c.ChartVersion, "13") {
178+
return false
179+
}
180+
181+
// Skip for patch upgrades (they don't need schema migration)
182+
if c.Flow == "upgrade-patch" {
183+
return false
184+
}
185+
186+
// Include for install, upgrade-minor, or any other flow on chart 13.x
187+
return true
188+
}
189+
158190
// MapScenarioToConfig converts a legacy scenario name to a DeploymentConfig.
159191
// This provides backward compatibility with the old --scenario flag.
160192
func MapScenarioToConfig(scenario string) *DeploymentConfig {

scripts/camunda-deployer/pkg/deployer/prepare.go

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"os"
66
"path/filepath"
77
"scripts/camunda-core/pkg/logging"
8+
"scripts/camunda-core/pkg/scenarios"
89
"sort"
910
"strings"
1011
)
@@ -26,11 +27,17 @@ var CommonValuesFiles = []string{
2627
// If commonFiles is provided (non-nil), those files are used directly as the common base layer.
2728
// If commonFiles is nil, the function will attempt to discover common files from ../common/ relative to scenarioDir.
2829
func BuildValuesList(scenarioDir string, scenarios []string, auth string, includeEnterprise, includeDigest bool, userValues []string, commonFiles []string) ([]string, error) {
30+
return BuildValuesListWithConfig(scenarioDir, scenarios, auth, includeEnterprise, includeDigest, userValues, commonFiles, nil)
31+
}
32+
33+
// BuildValuesListWithConfig is like BuildValuesList but accepts a DeploymentConfig
34+
// for layered values resolution. This allows passing ChartVersion and Flow for migrator detection.
35+
func BuildValuesListWithConfig(scenarioDir string, scenarioNames []string, auth string, includeEnterprise, includeDigest bool, userValues []string, commonFiles []string, config *scenarios.DeploymentConfig) ([]string, error) {
2936
var files []string
3037

3138
logging.Logger.Debug().
3239
Str("scenarioDir", scenarioDir).
33-
Strs("scenarios", scenarios).
40+
Strs("scenarios", scenarioNames).
3441
Str("auth", auth).
3542
Bool("includeEnterprise", includeEnterprise).
3643
Bool("includeDigest", includeDigest).
@@ -65,7 +72,7 @@ func BuildValuesList(scenarioDir string, scenarios []string, auth string, includ
6572
logging.Logger.Debug().
6673
Str("auth", auth).
6774
Msg("📋 [BuildValuesList] resolving auth scenario")
68-
authFiles, err := ResolveScenarioFiles(scenarioDir, []string{auth})
75+
authFiles, err := ResolveScenarioFilesWithConfig(scenarioDir, []string{auth}, config)
6976
if err != nil {
7077
logging.Logger.Debug().
7178
Err(err).
@@ -81,13 +88,13 @@ func BuildValuesList(scenarioDir string, scenarios []string, auth string, includ
8188

8289
// Add main scenario values
8390
logging.Logger.Debug().
84-
Strs("scenarios", scenarios).
91+
Strs("scenarios", scenarioNames).
8592
Msg("📋 [BuildValuesList] resolving main scenario(s)")
86-
scenarioFiles, err := ResolveScenarioFiles(scenarioDir, scenarios)
93+
scenarioFiles, err := ResolveScenarioFilesWithConfig(scenarioDir, scenarioNames, config)
8794
if err != nil {
8895
logging.Logger.Debug().
8996
Err(err).
90-
Strs("scenarios", scenarios).
97+
Strs("scenarios", scenarioNames).
9198
Msg("❌ [BuildValuesList] failed to resolve scenario files")
9299
return nil, err
93100
}
@@ -216,4 +223,4 @@ func overlayIfExists(scenarioDir, fileName string) string {
216223
return p
217224
}
218225
return ""
219-
}
226+
}

scripts/camunda-deployer/pkg/deployer/values.go

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,20 @@ type ScenarioMeta struct {
1717
// ResolveScenarioFiles resolves scenario names to their values file paths.
1818
// It supports both layered values (values/ directory) and legacy single-file approach.
1919
func ResolveScenarioFiles(scenarioDir string, scenarioNames []string) ([]string, error) {
20+
return ResolveScenarioFilesWithConfig(scenarioDir, scenarioNames, nil)
21+
}
22+
23+
// ResolveScenarioFilesWithConfig resolves scenario names to their values file paths,
24+
// using the provided deployment config for layered values resolution.
25+
// This allows passing ChartVersion and Flow for migrator detection.
26+
func ResolveScenarioFilesWithConfig(scenarioDir string, scenarioNames []string, config *scenarios.DeploymentConfig) ([]string, error) {
2027
if len(scenarioNames) == 0 {
2128
return nil, nil
2229
}
2330

2431
// Check if this scenario directory uses layered values
2532
if scenarios.HasLayeredValues(scenarioDir) {
26-
return resolveLayeredScenarioFiles(scenarioDir, scenarioNames)
33+
return resolveLayeredScenarioFiles(scenarioDir, scenarioNames, config)
2734
}
2835

2936
// Fall back to legacy single-file approach
@@ -32,7 +39,7 @@ func ResolveScenarioFiles(scenarioDir string, scenarioNames []string) ([]string,
3239

3340
// resolveLayeredScenarioFiles resolves scenarios using the layered values structure.
3441
// For layered values, we combine all layer files for each scenario.
35-
func resolveLayeredScenarioFiles(scenarioDir string, scenarioNames []string) ([]string, error) {
42+
func resolveLayeredScenarioFiles(scenarioDir string, scenarioNames []string, baseConfig *scenarios.DeploymentConfig) ([]string, error) {
3643
var allFiles []string
3744
var missing []string
3845

@@ -42,7 +49,14 @@ func resolveLayeredScenarioFiles(scenarioDir string, scenarioNames []string) ([]
4249
continue
4350
}
4451

45-
files, err := scenarios.ResolveLayeredPaths(scenarioDir, s, nil)
52+
// Start with the provided config or derive from scenario name
53+
var config *scenarios.DeploymentConfig
54+
if baseConfig != nil {
55+
// Use the provided config (which includes ChartVersion and Flow)
56+
config = baseConfig
57+
}
58+
59+
files, err := scenarios.ResolveLayeredPaths(scenarioDir, s, config)
4660
if err != nil {
4761
missing = append(missing, s)
4862
continue
@@ -91,14 +105,3 @@ func resolveLegacyScenarioFiles(scenarioDir string, scenarioNames []string) ([]s
91105

92106
return files, nil
93107
}
94-
95-
// ResolveScenarioFilesWithConfig resolves scenario files using an explicit layered config.
96-
// This allows callers to specify exactly which layers to use, bypassing auto-detection.
97-
func ResolveScenarioFilesWithConfig(scenarioDir string, config *scenarios.LayeredConfig) ([]string, error) {
98-
if config == nil {
99-
return nil, fmt.Errorf("layered config is required")
100-
}
101-
102-
// Use an empty scenario name since config is explicit
103-
return scenarios.ResolveLayeredPaths(scenarioDir, "", config)
104-
}

scripts/deploy-camunda/deploy/deploy.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,10 @@ func buildDeploymentConfigFromFlags(flags *config.RuntimeFlags, scenarioName str
433433
config.Upgrade = true
434434
}
435435

436+
// Set chart version and flow for migrator detection
437+
config.ChartVersion = flags.ChartVersion
438+
config.Flow = flags.Flow
439+
436440
return config
437441
}
438442

@@ -980,6 +984,9 @@ func prepareScenarioValues(scenarioCtx *ScenarioContext, flags *config.RuntimeFl
980984
}
981985
}
982986

987+
// Build deployment config for layered values resolution (includes ChartVersion and Flow for migrator)
988+
deployConfig := buildDeploymentConfigFromFlags(flags, scenarioCtx.ScenarioName)
989+
983990
// Build values files list
984991
logging.Logger.Debug().
985992
Str("scenario", scenarioCtx.ScenarioName).

0 commit comments

Comments
 (0)