Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Liqoctl: check --dump-values-path install flag #1975

Merged
merged 1 commit into from
Sep 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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",
fra98 marked this conversation as resolved.
Show resolved Hide resolved
"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