MCPcopy Create free account
hub / github.com/OctopusDeploy/cli / viewRun

Function viewRun

pkg/cmd/projectgroup/view/view.go:83–135  ·  view source on GitHub ↗
(opts *ViewOptions)

Source from the content-addressed store, hash-verified

81}
82
83func viewRun(opts *ViewOptions) error {
84 projectGroup, err := opts.Client.ProjectGroups.GetByIDOrName(opts.idOrName)
85 if err != nil {
86 return err
87 }
88
89 projects, err := opts.Client.ProjectGroups.GetProjects(projectGroup)
90 if err != nil {
91 return err
92 }
93
94 return output.PrintResource(projectGroup, opts.Command, output.Mappers[*projectgroups.ProjectGroup]{
95 Json: func(pg *projectgroups.ProjectGroup) any {
96 projectList := make([]ProjectInfo, 0, len(projects))
97 for _, project := range projects {
98 projectList = append(projectList, ProjectInfo{
99 Id: project.GetID(),
100 Name: project.GetName(),
101 Slug: project.Slug,
102 })
103 }
104
105 return ProjectGroupAsJson{
106 Id: pg.GetID(),
107 Name: pg.GetName(),
108 Description: pg.Description,
109 Projects: projectList,
110 WebUrl: util.GenerateWebURL(opts.Host, pg.SpaceID, fmt.Sprintf("projects?projectGroupId=%s", pg.GetID())),
111 }
112 },
113 Table: output.TableDefinition[*projectgroups.ProjectGroup]{
114 Header: []string{"NAME", "DESCRIPTION", "PROJECTS COUNT", "WEB URL"},
115 Row: func(pg *projectgroups.ProjectGroup) []string {
116 description := pg.Description
117 if description == "" {
118 description = constants.NoDescription
119 }
120
121 url := util.GenerateWebURL(opts.Host, pg.SpaceID, fmt.Sprintf("projects?projectGroupId=%s", pg.GetID()))
122
123 return []string{
124 output.Bold(pg.GetName()),
125 description,
126 fmt.Sprintf("%d", len(projects)),
127 output.Blue(url),
128 }
129 },
130 },
131 Basic: func(pg *projectgroups.ProjectGroup) string {
132 return formatProjectGroupForBasic(opts, pg, projects)
133 },
134 })
135}
136
137type ProjectInfo struct {
138 Id string `json:"Id"`

Callers 1

NewCmdViewFunction · 0.70

Calls 6

PrintResourceFunction · 0.92
GenerateWebURLFunction · 0.92
BoldFunction · 0.92
BlueFunction · 0.92
GetNameMethod · 0.65

Tested by

no test coverage detected