diff --git a/cmd/harbor/root/project/create.go b/cmd/harbor/root/project/create.go index 4a126a99..5371ed53 100644 --- a/cmd/harbor/root/project/create.go +++ b/cmd/harbor/root/project/create.go @@ -14,7 +14,6 @@ func CreateProjectCommand() *cobra.Command { cmd := &cobra.Command{ Use: "create", Short: "create project", - Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { var err error createView := &create.CreateView{ @@ -24,8 +23,10 @@ func CreateProjectCommand() *cobra.Command { StorageLimit: opts.StorageLimit, ProxyCache: false, } - - if opts.ProjectName != "" && opts.RegistryID != "" && opts.StorageLimit != "" { + if len(args) > 0 { + opts.ProjectName = args[0] + err = api.CreateProject(opts) + } else if opts.ProjectName != "" && opts.RegistryID != "" && opts.StorageLimit != "" { err = api.CreateProject(opts) } else { err = createProjectView(createView) @@ -40,7 +41,7 @@ func CreateProjectCommand() *cobra.Command { flags := cmd.Flags() flags.StringVarP(&opts.ProjectName, "name", "", "", "Name of the project") - flags.BoolVarP(&opts.Public, "public", "", true, "Project is public or private") + flags.BoolVarP(&opts.Public, "public", "", false, "Project is public or private. Private by default") flags.StringVarP(&opts.RegistryID, "registry-id", "", "", "ID of referenced registry when creating the proxy cache project") flags.StringVarP(&opts.StorageLimit, "storage-limit", "", "-1", "Storage quota of the project") flags.BoolVarP(&opts.ProxyCache, "proxy-cache", "", false, "Whether the project is a proxy cache project") @@ -52,7 +53,7 @@ func createProjectView(createView *create.CreateView) error { if createView == nil { createView = &create.CreateView{ ProjectName: "", - Public: true, + Public: false, RegistryID: "", StorageLimit: "-1", } diff --git a/pkg/views/project/list/view.go b/pkg/views/project/list/view.go index fd8a69a8..5f979844 100644 --- a/pkg/views/project/list/view.go +++ b/pkg/views/project/list/view.go @@ -13,7 +13,7 @@ import ( ) var columns = []table.Column{ - {Title: "ID", Width: 6}, + {Title: "ID", Width: 6}, {Title: "Project Name", Width: 12}, {Title: "Access Level", Width: 12}, {Title: "Type", Width: 12}, @@ -36,7 +36,7 @@ func ListProjects(projects []*models.Project) { } createdTime, _ := utils.FormatCreatedTime(project.CreationTime.String()) rows = append(rows, table.Row{ - strconv.FormatInt(int64(project.ProjectID), 10), // ProjectID + strconv.FormatInt(int64(project.ProjectID), 10), // ProjectID project.Name, // Project Name accessLevel, // Access Level projectType, // Type