-
Notifications
You must be signed in to change notification settings - Fork 108
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
Add option --allow-change-package-name in the package installed update operation #1671
base: develop
Are you sure you want to change the base?
Conversation
…operation this option allows user to change the package name for the packageinstalled CR Signed-off-by: luwang <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the PR,
Have the changes in the PR been tested?
// If o.PackageName is provided by the user (via --package flag), verify that the package name in PackageInstall matches it. | ||
// This will prevent the users from accidentally overwriting an installed package with another package content due to choosing a pre-existing name for the package isntall. | ||
// Otherwise if o.PackageName is not provided, fill it from the installed package spec | ||
if o.packageName != "" && updatedPkgInstall.Spec.PackageRef.RefName != o.packageName { | ||
return nil, fmt.Errorf("Installed package '%s' is already associated with package '%s'", o.Name, updatedPkgInstall.Spec.PackageRef.RefName) | ||
if !o.rename { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit:
could you please reverse the if condition?
if o.rename {
updatedPkgInstall.Spec.PackageRef.RefName = o.packageName
} else {
if o.packageName != "" && updatedPkgInstall.Spec.PackageRef.RefName != o.packageName {
return nil, fmt.Errorf("Installed package '%s' is already associated with package '%s'", o.Name, updatedPkgInstall.Spec.PackageRef.RefName)
}
o.packageName = updatedPkgInstall.Spec.PackageRef.RefName
}
@@ -195,6 +197,7 @@ func NewUpdateCmd(o *CreateOrUpdateOptions, flagsFactory cmdcore.FlagsFactory) * | |||
cmd.Flags().StringVarP(&o.version, "version", "v", "", "Set package version") | |||
cmd.Flags().StringVar(&o.valuesFile, "values-file", "", "The path to the configuration values file, optional") | |||
cmd.Flags().BoolVar(&o.values, "values", true, "Add or keep values supplied to package install, optional") | |||
cmd.Flags().BoolVar(&o.rename, "allow-change-package-name", false, "Allow to use different package name, optional") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please change the flag name to allow-package-name-change
or rename-package
?
Add option allow-change-package-name in the package installed update operation
this option allows user to change the package name for the packageinstalled CR
What this PR does / why we need it:
We need to change the package name for the installed package. However the current code blocks it .
Which issue(s) this PR fixes:
Fixes #1651
Does this PR introduce a user-facing change?
Additional Notes for your reviewer:
Review Checklist:
a link to that PR
change
Additional documentation e.g., Proposal, usage docs, etc.: