Skip to content

Commit

Permalink
Merge pull request #119 from Althaf66/Althaf66/issue117
Browse files Browse the repository at this point in the history
Enhanced the create project flow
  • Loading branch information
Vad1mo authored Jun 11, 2024
2 parents bb70d52 + d02894f commit aa12b5b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
11 changes: 6 additions & 5 deletions cmd/harbor/root/project/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -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)
Expand All @@ -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")
Expand All @@ -52,7 +53,7 @@ func createProjectView(createView *create.CreateView) error {
if createView == nil {
createView = &create.CreateView{
ProjectName: "",
Public: true,
Public: false,
RegistryID: "",
StorageLimit: "-1",
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/views/project/list/view.go
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand All @@ -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
Expand Down

0 comments on commit aa12b5b

Please sign in to comment.