Skip to content

Commit

Permalink
Make distro mandatory with warning
Browse files Browse the repository at this point in the history
  • Loading branch information
johannesfrey committed Apr 11, 2024
1 parent 2056fbb commit 33f151a
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions cmd/vclusterctl/cmd/migrate/values.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,17 @@ func migrateValues(globalFlags *flags.GlobalFlags) *cobra.Command {
Migrates values for a vcluster to the new format
Examples:
vcluster migrate values -f /my/k8s/values.yaml
vcluster migrate values --distro k3s -f /my/k3s/values.yaml
vcluster migrate values --distro k0s < /my/k0s/values.yaml
cat /my/k8s/values.yaml | vcluster migrate values --distro k8s
vcluster migrate values --distro k8s -f /my/k8s/values.yaml
vcluster migrate values --distro k3s < /my/k3s/values.yaml
cat /my/k0s/values.yaml | vcluster migrate values --distro k0s
#######################################################
`,
RunE: func(_ *cobra.Command, _ []string) error {
return c.Run()
}}

cobraCmd.Flags().StringVarP(&c.filePath, "file", "f", "", "Path to the input file")
cobraCmd.Flags().StringVar(&c.distro, "distro", "k8s", fmt.Sprintf("Kubernetes distro of the values. Allowed distros: %s", strings.Join([]string{"k8s", "k3s", "k0s", "eks"}, ", ")))
cobraCmd.Flags().StringVar(&c.distro, "distro", "", fmt.Sprintf("Kubernetes distro of the values. Allowed distros: %s", strings.Join([]string{"k8s", "k3s", "k0s", "eks"}, ", ")))
cobraCmd.Flags().StringVarP(&c.format, "output", "o", "yaml", "Prints the output in the specified format. Allowed values: yaml, json")

return cobraCmd
Expand All @@ -61,6 +60,10 @@ func (cmd *valuesCmd) Run() error {
err error
)

if cmd.distro == "" {
return fmt.Errorf("no distro given: please set \"--distro\" (IMPORTANT: distro must match the given values)")
}

if cmd.filePath != "" {
file, err := os.Open(cmd.filePath)
if err != nil {
Expand Down

0 comments on commit 33f151a

Please sign in to comment.