Skip to content

Commit 44be61b

Browse files
committed
add option to specify the relative base folder for migration definitions
1 parent cdbb147 commit 44be61b

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

cmd/helm-migrate-values/root.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,16 @@ func NewRootCmd(actionConfig *action.Configuration, settings *cli.EnvSettings, o
6060
var outputFile string
6161
flags.StringVarP(&outputFile, "output-file", "o", "",
6262
"The output file to which the result is saved. Standard output is used if this option is not set.")
63+
var migrationDir string
64+
flags.StringVar(&migrationDir, "migration-dir", "value-migrations", "Specifies the relative path to the directory containing migration definition files. The path should be relative to the Helm chart directory.")
6365

64-
runner := newRunner(actionConfig, flags, settings, out, &outputFile, log)
66+
runner := newRunner(actionConfig, flags, settings, out, &migrationDir, &outputFile, log)
6567
cmd.RunE = runner
6668

6769
return cmd, nil
6870
}
6971

70-
func newRunner(actionConfig *action.Configuration, flags *pflag.FlagSet, settings *cli.EnvSettings, out io.Writer, outputFile *string, log pkg.Logger) func(cmd *cobra.Command, args []string) error {
72+
func newRunner(actionConfig *action.Configuration, flags *pflag.FlagSet, settings *cli.EnvSettings, out io.Writer, migrationDir *string, outputFile *string, log pkg.Logger) func(cmd *cobra.Command, args []string) error {
7173
// We use the install action for locating the chart
7274
var installAction = action.NewInstall(actionConfig)
7375
var listAction = action.NewList(actionConfig)
@@ -128,7 +130,7 @@ func newRunner(actionConfig *action.Configuration, flags *pflag.FlagSet, setting
128130
return fmt.Errorf("failed to extract major version from chart version: %s", release.Chart.Metadata.Version)
129131
}
130132
relMajorVer, _ := strconv.Atoi(matches[1])
131-
migrationsPath := filepath.Join(*chartDir, release.Chart.Name(), "value-migrations")
133+
migrationsPath := filepath.Join(*chartDir, *migrationDir)
132134

133135
// vTo is always nil, because it really only makes sense to migrate to the current chart version.
134136
// The migrations library does support migrating to a specific version though.

0 commit comments

Comments
 (0)