Skip to content

Commit 04f18c7

Browse files
add validations to kpt alpha rpkg init command (#3650)
1 parent 45b33ce commit 04f18c7

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

commands/alpha/rpkg/clone/command.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ func (r *runner) preRunE(cmd *cobra.Command, args []string) error {
113113
}
114114

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

119119
source := args[0]

commands/alpha/rpkg/copy/command.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ func (r *runner) getPackageRevisionSpec() (*porchapi.PackageRevisionSpec, error)
124124
}
125125

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

130130
spec := &porchapi.PackageRevisionSpec{

commands/alpha/rpkg/init/command.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ func newRunner(ctx context.Context, rcg *genericclioptions.ConfigFlags) *runner
5656
c.Flags().StringVar(&r.Description, "description", "sample description", "short description of the package.")
5757
c.Flags().StringSliceVar(&r.Keywords, "keywords", []string{}, "list of keywords for the package.")
5858
c.Flags().StringVar(&r.Site, "site", "", "link to page with information about the package.")
59-
c.Flags().StringVar(&r.repository, "repository", "", "Repository to which package will be cloned (downstream repository).")
60-
c.Flags().StringVar(&r.workspace, "workspace", "", "Workspace name of the downstream package.")
59+
c.Flags().StringVar(&r.repository, "repository", "", "Repository to which package will be created.")
60+
c.Flags().StringVar(&r.workspace, "workspace", "", "Workspace name of the package.")
6161

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

93+
if r.repository == "" {
94+
return errors.E(op, fmt.Errorf("--repository is required to specify target repository"))
95+
}
96+
97+
if r.workspace == "" {
98+
return errors.E(op, fmt.Errorf("--workspace is required to specify workspace name"))
99+
}
100+
93101
r.name = args[0]
94102
pkgExists, err := util.PackageAlreadyExists(r.ctx, r.client, r.repository, r.name, *r.cfg.Namespace)
95103
if err != nil {

0 commit comments

Comments
 (0)