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

add validations to kpt alpha rpkg init command #3650

Merged
merged 1 commit into from
Nov 4, 2022
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
2 changes: 1 addition & 1 deletion commands/alpha/rpkg/clone/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func (r *runner) preRunE(cmd *cobra.Command, args []string) error {
}

if r.workspace == "" {
return errors.E(op, fmt.Errorf("--workspace is required to specify downstream workspaceName"))
return errors.E(op, fmt.Errorf("--workspace is required to specify downstream workspace name"))
}

source := args[0]
Expand Down
2 changes: 1 addition & 1 deletion commands/alpha/rpkg/copy/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func (r *runner) getPackageRevisionSpec() (*porchapi.PackageRevisionSpec, error)
}

if r.workspace == "" {
return nil, fmt.Errorf("--workspace is required to specify downstream workspaceName")
return nil, fmt.Errorf("--workspace is required to specify workspace name")
}

spec := &porchapi.PackageRevisionSpec{
Expand Down
12 changes: 10 additions & 2 deletions commands/alpha/rpkg/init/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ func newRunner(ctx context.Context, rcg *genericclioptions.ConfigFlags) *runner
c.Flags().StringVar(&r.Description, "description", "sample description", "short description of the package.")
c.Flags().StringSliceVar(&r.Keywords, "keywords", []string{}, "list of keywords for the package.")
c.Flags().StringVar(&r.Site, "site", "", "link to page with information about the package.")
c.Flags().StringVar(&r.repository, "repository", "", "Repository to which package will be cloned (downstream repository).")
c.Flags().StringVar(&r.workspace, "workspace", "", "Workspace name of the downstream package.")
c.Flags().StringVar(&r.repository, "repository", "", "Repository to which package will be created.")
c.Flags().StringVar(&r.workspace, "workspace", "", "Workspace name of the package.")

return r
}
Expand Down Expand Up @@ -90,6 +90,14 @@ func (r *runner) preRunE(cmd *cobra.Command, args []string) error {
return errors.E(op, "PACKAGE_NAME is a required positional argument")
}

if r.repository == "" {
return errors.E(op, fmt.Errorf("--repository is required to specify target repository"))
}

if r.workspace == "" {
return errors.E(op, fmt.Errorf("--workspace is required to specify workspace name"))
}

r.name = args[0]
pkgExists, err := util.PackageAlreadyExists(r.ctx, r.client, r.repository, r.name, *r.cfg.Namespace)
if err != nil {
Expand Down