Skip to content

Commit

Permalink
Added --dump-values-path check
Browse files Browse the repository at this point in the history
  • Loading branch information
fra98 authored and adamjensenbot committed Sep 4, 2023
1 parent 7be4dfa commit 1df7796
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
5 changes: 3 additions & 2 deletions cmd/liqoctl/cmd/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,9 @@ func newInstallCommand(ctx context.Context, f *factory.Factory) *cobra.Command {

cmd.PersistentFlags().BoolVar(&options.OnlyOutputValues, "only-output-values", false,
"Generate the pre-configured values file for further customization, instead of installing Liqo (default false)")
cmd.PersistentFlags().StringVar(&options.ValuesPath, "dump-values-path", "./values.yaml",
"The path where the generated values file is saved (only in case --only-output-values is set)")
// the default value is set during the validation to check if the flag has been set or not
cmd.PersistentFlags().StringVar(&options.ValuesPath, "dump-values-path", "",
"The path where the generated values file is saved (only in case --only-output-values is set). Default: './values.yaml'")
cmd.PersistentFlags().BoolVar(&options.DryRun, "dry-run", false, "Simulate the installation process (default false)")

cmd.PersistentFlags().DurationVar(&options.Timeout, "timeout", 10*time.Minute,
Expand Down
3 changes: 3 additions & 0 deletions pkg/liqoctl/install/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,7 @@ const (

// LiqoReleaseName indicates the default release name when installing the Liqo chart.
LiqoReleaseName = "liqo"

// DefaultDumpValuesPath is the default path where the helm values file is written.
DefaultDumpValuesPath = "./values.yaml"
)
15 changes: 15 additions & 0 deletions pkg/liqoctl/install/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ func (o *Options) validate(ctx context.Context) error {
}
o.Printer.Verbosef("Service CIDR: %s\n", o.ServiceCIDR)

if err := o.validateOutputValues(); err != nil {
return fmt.Errorf("failed validating output values: %w", err)
}

return nil
}

Expand Down Expand Up @@ -194,6 +198,17 @@ func (o *Options) validateServiceCIDR(ctx context.Context) error {
return nil
}

// validateOutputValues validates the flags related to values.
func (o *Options) validateOutputValues() (err error) {
if o.ValuesPath != "" && !o.OnlyOutputValues {
return fmt.Errorf("--dump-values-path can only be used in conjunction with --only-output-values")
}
if o.ValuesPath == "" {
o.ValuesPath = DefaultDumpValuesPath
}
return nil
}

func getHostnamePort(urlString string) (hostname, port string, err error) {
if !strings.HasPrefix(urlString, "https://") {
urlString = fmt.Sprintf("https://%v", urlString)
Expand Down

0 comments on commit 1df7796

Please sign in to comment.