Skip to content

Commit 25e37f3

Browse files
committed
print lifecycle state
Signed-off-by: Lukas Hoehl <lukas.hoehl@stackit.cloud>
1 parent f06e1ca commit 25e37f3

File tree

2 files changed

+27
-14
lines changed

2 files changed

+27
-14
lines changed

internal/cmd/project/list/list.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,8 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel,
156156
type project struct {
157157
Name string
158158
ID string
159+
Labels map[string]string
160+
State resourcemanager.LifecycleState
159161
Organization string
160162
Folder []string
161163
}
@@ -181,6 +183,8 @@ func getProjects(ctx context.Context, parent *node, org string, projChan chan<-
181183
}
182184
projChan <- project{
183185
Name: child.name,
186+
State: child.lifecycleState,
187+
Labels: child.labels,
184188
ID: child.resourceID,
185189
Organization: org,
186190
Folder: folderName,
@@ -236,14 +240,15 @@ func fetchProjects(ctx context.Context, model *inputModel, resourceClient *resou
236240
func outputResult(p *print.Printer, outputFormat string, projects []project) error {
237241
return p.OutputResult(outputFormat, projects, func() error {
238242
table := tables.NewTable()
239-
table.SetHeader("ORGANIZATION", "FOLDER", "NAME", "ID")
243+
table.SetHeader("ORGANIZATION", "FOLDER", "NAME", "ID", "STATE")
240244
for i := range projects {
241245
p := projects[i]
242246
table.AddRow(
243247
p.Organization,
244248
p.FolderPath(),
245249
p.Name,
246250
p.ID,
251+
p.State,
247252
)
248253
}
249254

internal/cmd/project/list/tree.go

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@ import (
1414
)
1515

1616
type node struct {
17-
resourceID string
18-
name string
17+
resourceID string
18+
name string
19+
lifecycleState resourcemanager.LifecycleState
20+
labels map[string]string
1921

2022
typ resourceType
2123
parent *node
@@ -73,9 +75,11 @@ func (r *resourceTree) Fill(ctx context.Context) error {
7375
return err
7476
}
7577
orgNode := &node{
76-
resourceID: org.GetOrganizationId(),
77-
name: org.GetName(),
78-
typ: resourceTypeOrg,
78+
resourceID: org.GetOrganizationId(),
79+
name: org.GetName(),
80+
typ: resourceTypeOrg,
81+
lifecycleState: org.GetLifecycleState(),
82+
labels: org.GetLabels(),
7983
}
8084
r.mu.Lock()
8185
r.roots[orgNode.resourceID] = orgNode
@@ -109,10 +113,12 @@ func (r *resourceTree) fillNode(ctx context.Context, parent *node) error {
109113
for _, folder := range resp.GetItems() {
110114
g.Go(func() error {
111115
newFolderNode := &node{
112-
resourceID: folder.GetFolderId(),
113-
parent: parent,
114-
typ: resourceTypeFolder,
115-
name: folder.GetName(),
116+
resourceID: folder.GetFolderId(),
117+
parent: parent,
118+
typ: resourceTypeFolder,
119+
name: folder.GetName(),
120+
lifecycleState: resourcemanager.LIFECYCLESTATE_ACTIVE,
121+
labels: folder.GetLabels(),
116122
}
117123
parent.children = append(parent.children, newFolderNode)
118124
return r.fillNode(ctx, newFolderNode)
@@ -136,10 +142,12 @@ func (r *resourceTree) getNodeProjects(ctx context.Context, parent *node) error
136142
}
137143
for _, proj := range resp.GetItems() {
138144
projNode := &node{
139-
resourceID: proj.GetProjectId(),
140-
typ: resourceTypeProject,
141-
name: proj.GetName(),
142-
parent: parent,
145+
resourceID: proj.GetProjectId(),
146+
typ: resourceTypeProject,
147+
name: proj.GetName(),
148+
labels: proj.GetLabels(),
149+
lifecycleState: proj.GetLifecycleState(),
150+
parent: parent,
143151
}
144152
parent.children = append(parent.children, projNode)
145153
}

0 commit comments

Comments
 (0)