Skip to content

Commit

Permalink
add validations to kpt alpha rpkg init command (#3650)
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristopherFry committed Nov 4, 2022
1 parent 45b33ce commit 04f18c7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
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

0 comments on commit 04f18c7

Please sign in to comment.