Skip to content

Commit

Permalink
feat: add flag to specify display for project
Browse files Browse the repository at this point in the history
  • Loading branch information
ctrox committed Feb 6, 2024
1 parent 67ccdfb commit 71177cb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
9 changes: 6 additions & 3 deletions create/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (

type projectCmd struct {
Name string `arg:"" default:"" help:"Name of the project. A random name is generated if omitted."`
DisplayName string `default:"" help:"Display Name of the project."`
Wait bool `default:"true" help:"Wait until the project was fully created."`
WaitTimeout time.Duration `default:"10m" help:"Duration to wait for project getting ready. Only relevant if wait is set."`
}
Expand All @@ -27,7 +28,7 @@ func (proj *projectCmd) Run(ctx context.Context, client *api.Client) error {
return err
}

p := newProject(proj.Name, cfg.Organization)
p := newProject(proj.Name, cfg.Organization, proj.DisplayName)
fmt.Printf("Creating new project %s for organization %s\n", p.Name, cfg.Organization)
c := newCreator(client, p, strings.ToLower(management.ProjectKind))
ctx, cancel := context.WithTimeout(ctx, proj.WaitTimeout)
Expand All @@ -47,7 +48,7 @@ func (proj *projectCmd) Run(ctx context.Context, client *api.Client) error {
})
}

func newProject(name, project string) *management.Project {
func newProject(name, project, displayName string) *management.Project {
return &management.Project{
ObjectMeta: metav1.ObjectMeta{
Name: getName(name),
Expand All @@ -57,6 +58,8 @@ func newProject(name, project string) *management.Project {
Kind: management.ProjectKind,
APIVersion: management.SchemeGroupVersion.String(),
},
Spec: management.ProjectSpec{},
Spec: management.ProjectSpec{
DisplayName: displayName,
},
}
}
1 change: 1 addition & 0 deletions create/project_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ func TestProjects(t *testing.T) {

cmd := projectCmd{
Name: projectName,
DisplayName: "Some Display Name",
Wait: false,
WaitTimeout: time.Second,
}
Expand Down

0 comments on commit 71177cb

Please sign in to comment.