Skip to content

Commit cd27685

Browse files
committed
have osc status highlight disabled deployment configs
1 parent 546fda9 commit cd27685

File tree

2 files changed

+26
-6
lines changed

2 files changed

+26
-6
lines changed

pkg/cmd/cli/describe/projectstatus.go

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,12 @@ func (d *ProjectStatusDescriber) Describe(namespace, name string) (string, error
7676

7777
return tabbedString(func(out *tabwriter.Writer) error {
7878
indent := " "
79-
if len(project.Annotations[projectapi.ProjectDisplayName]) > 0 &&
80-
project.Annotations[projectapi.ProjectDisplayName] != namespace {
81-
fmt.Fprintf(out, "In project %s (%s)\n", project.Annotations[projectapi.ProjectDisplayName], namespace)
82-
} else {
83-
fmt.Fprintf(out, "In project %s\n", namespace)
79+
fmt.Fprintf(out, "In project %s\n", projectapi.DisplayNameAndNameForProject(project))
80+
81+
if disabledDCs := disabledDeploymentConfigs(dcs); len(disabledDCs) > 0 {
82+
fmt.Fprintln(out)
83+
fmt.Fprintln(out, "Some DeploymentConfigs do not have any automatic triggers. They can only be triggered by manually calling `osc deploy <name> --latest`.")
84+
printLines(out, indent, 1, describeDisabledDeploymentConfigs(disabledDCs)...)
8485
}
8586

8687
for _, group := range groups {
@@ -119,6 +120,25 @@ func (d *ProjectStatusDescriber) Describe(namespace, name string) (string, error
119120
})
120121
}
121122

123+
func disabledDeploymentConfigs(dcs *deployapi.DeploymentConfigList) []deployapi.DeploymentConfig {
124+
disabledDCs := []deployapi.DeploymentConfig{}
125+
for _, dc := range dcs.Items {
126+
if len(dc.Triggers) == 0 {
127+
disabledDCs = append(disabledDCs, dc)
128+
}
129+
}
130+
131+
return disabledDCs
132+
}
133+
func describeDisabledDeploymentConfigs(dcs []deployapi.DeploymentConfig) []string {
134+
lines := []string{}
135+
for _, dc := range dcs {
136+
lines = append(lines, fmt.Sprintf("%s - trigger a new Deployment by running `osc deploy %s --latest`", dc.Name, dc.Name))
137+
}
138+
139+
return lines
140+
}
141+
122142
func printLines(out io.Writer, indent string, depth int, lines ...string) {
123143
for i, s := range lines {
124144
fmt.Fprintf(out, strings.Repeat(indent, depth))

pkg/cmd/cli/describe/projectstatus_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func TestProjectStatus(t *testing.T) {
4040
Name: "example",
4141
Namespace: "",
4242
Annotations: map[string]string{
43-
"openshift.io/display-name": "Test",
43+
projectapi.ProjectDisplayName: "Test",
4444
},
4545
},
4646
},

0 commit comments

Comments
 (0)