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

Function viewRun

pkg/cmd/tenant/view/view.go:86–160  ·  view source on GitHub ↗
(opts *ViewOptions, cmd *cobra.Command)

Source from the content-addressed store, hash-verified

84}
85
86func viewRun(opts *ViewOptions, cmd *cobra.Command) error {
87 tenant, err := opts.Client.Tenants.GetByIdentifier(opts.idOrName)
88 if err != nil {
89 return err
90 }
91
92 environmentMap, err := shared.GetEnvironmentMapForTenants(opts.Client, []*tenants.Tenant{tenant})
93 if err != nil {
94 return err
95 }
96
97 projectMap, err := shared.GetProjectMap(opts.Client, []*tenants.Tenant{tenant})
98 if err != nil {
99 return err
100 }
101
102 return output.PrintResource(tenant, cmd, output.Mappers[*tenants.Tenant]{
103 Json: func(t *tenants.Tenant) any {
104
105 projectEnvironments := []shared.ProjectEnvironment{}
106
107 for p := range t.ProjectEnvironments {
108 projectEntity := output.IdAndName{Id: p, Name: projectMap[p]}
109 environments, err := shared.ResolveEntities(t.ProjectEnvironments[p], environmentMap)
110 if err != nil {
111 return err
112 }
113 projectEnvironments = append(projectEnvironments, shared.ProjectEnvironment{Project: projectEntity, Environments: environments})
114 }
115
116 t.Links = nil // ensure the links collection is not serialised
117 return shared.TenantAsJson{
118 Tenant: t,
119 ProjectEnvironments: projectEnvironments,
120 }
121 },
122 Table: output.TableDefinition[*tenants.Tenant]{
123 Header: []string{"NAME", "DESCRIPTION", "ID", "IS DISABLED", "TAGS"},
124 Row: func(t *tenants.Tenant) []string {
125 return []string{output.Bold(t.Name), t.Description, output.Dim(t.GetID()), strconv.FormatBool(t.IsDisabled), output.FormatAsList(t.TenantTags)}
126 },
127 },
128 Basic: func(item *tenants.Tenant) string {
129 var s strings.Builder
130
131 s.WriteString(fmt.Sprintf("%s %s\n", output.Bold(tenant.Name), output.Dimf("(%s)", tenant.ID)))
132
133 if len(tenant.TenantTags) > 0 {
134 s.WriteString(fmt.Sprintf("Tags: %s\n", output.FormatAsList(tenant.TenantTags)))
135 }
136
137 if tenant.Description == "" {
138 s.WriteString(fmt.Sprintln(output.Dim(constants.NoDescription)))
139 } else {
140 s.WriteString(fmt.Sprintln(output.Dim(tenant.Description)))
141 }
142
143 if tenant.IsDisabled {

Callers 1

NewCmdViewFunction · 0.70

Calls 10

GetProjectMapFunction · 0.92
PrintResourceFunction · 0.92
ResolveEntitiesFunction · 0.92
BoldFunction · 0.92
DimFunction · 0.92
FormatAsListFunction · 0.92
DimfFunction · 0.92
GenerateWebURLFunction · 0.92
BlueFunction · 0.92

Tested by

no test coverage detected