Adds a column in odo list output to indicate components created by odo (#4962)

* Adds a column in odo list output to indicate components created by odo

* Updates the changelog.md
This commit is contained in:
Mrinal Das
2021-08-05 14:10:57 +05:30
committed by GitHub
parent f12e036b5c
commit 6b03998f5b
5 changed files with 16 additions and 18 deletions

View File

@@ -4,6 +4,8 @@
### Feature/Enhancements
- Added a column in odo list output to indicate components created by odo ([#4962](https://github.com/openshift/odo/pull/4962))
### Bug Fixes
### Tests

View File

@@ -206,6 +206,10 @@ test-plugin-handler: ## Run odo plugin handler tests
test-cmd-devfile-catalog: ## Run odo catalog devfile command tests
$(RUN_GINKGO) $(GINKGO_FLAGS) -focus="odo devfile catalog command tests" tests/integration/devfile/
.PHONY: test-cmd-devfile-list
test-cmd-devfile-list: ## Run odo list devfile command tests
$(RUN_GINKGO) $(GINKGO_FLAGS) -focus="odo list with devfile" tests/integration/devfile/
.PHONY: test-cmd-devfile-create
test-cmd-devfile-create: ## Run odo create devfile command tests
$(RUN_GINKGO) $(GINKGO_FLAGS) -focus="odo devfile create command tests" tests/integration/devfile/

View File

@@ -297,12 +297,14 @@ func (lo *ListOptions) Run(cmd *cobra.Command) (err error) {
if !log.IsJSON() {
if len(devfileComponents) != 0 {
if len(devfileComponents) != 0 || len(otherComps) != 0 {
lo.hasDevfileComponents = true
fmt.Fprintln(w, "Devfile Components: ")
fmt.Fprintln(w, "APP", "\t", "NAME", "\t", "PROJECT", "\t", "TYPE", "\t", "STATE")
fmt.Fprintln(w, "APP", "\t", "NAME", "\t", "PROJECT", "\t", "TYPE", "\t", "STATE", "\t", "MANAGED BY ODO")
for _, comp := range devfileComponents {
fmt.Fprintln(w, comp.Spec.App, "\t", comp.Name, "\t", comp.Namespace, "\t", comp.Spec.Type, "\t", comp.Status.State)
fmt.Fprintln(w, comp.Spec.App, "\t", comp.Name, "\t", comp.Namespace, "\t", comp.Spec.Type, "\t", comp.Status.State, "\t", "Yes")
}
for _, comp := range otherComps {
fmt.Fprintln(w, comp.Spec.App, "\t", comp.Name, "\t", comp.Namespace, "\t", comp.Spec.Type, "\t", component.StateTypePushed, "\t", "No")
}
w.Flush()
@@ -321,15 +323,6 @@ func (lo *ListOptions) Run(cmd *cobra.Command) (err error) {
}
w.Flush()
}
if len(otherComps) != 0 {
w := tabwriter.NewWriter(os.Stdout, 5, 2, 3, ' ', tabwriter.TabIndent)
fmt.Fprintln(w, "Other Components running on the cluster(read-only): ")
fmt.Fprintln(w, "APP", "\t", "NAME", "\t", "PROJECT", "\t", "TYPE")
for _, comp := range otherComps {
fmt.Fprintln(w, comp.Spec.App, "\t", comp.Name, "\t", comp.Namespace, "\t", comp.Spec.Type)
}
w.Flush()
}
if !lo.hasDevfileComponents && !lo.hasS2IComponents && len(otherComps) == 0 {
log.Info("There are no components deployed.")

View File

@@ -645,7 +645,7 @@ func componentTests(args ...string) {
// check the status of devfile component
stdout := helper.Cmd("odo", "list", "--context", commonVar.Context).ShouldPass().Out()
helper.MatchAllInOutput(stdout, []string{cmpName, "Devfile Components", "Pushed"})
helper.MatchAllInOutput(stdout, []string{cmpName, "Pushed"})
// verify the url
stdout = helper.Cmd("odo", "url", "list", "--context", commonVar.Context).ShouldPass().Out()
@@ -688,7 +688,7 @@ func componentTests(args ...string) {
// verifyListOutput verifies if the components not managed by odo are listed
var verifyListOutput = func(output string, componentList []compStruct) {
Expect(output).To(ContainSubstring("Other Components running on the cluster(read-only)"))
helper.MatchAllInOutput(output, []string{"MANAGED BY ODO", "No"})
for _, comp := range componentList {
Expect(output).To(ContainSubstring(comp.Name))
Expect(output).To(ContainSubstring(comp.App))

View File

@@ -61,9 +61,8 @@ var _ = Describe("odo list with devfile", func() {
output = helper.Cmd("odo", "list", "--project", commonVar.Project).ShouldPass().Out()
// this test makes sure that a devfile component doesn't show up as an s2i component as well
Expect(helper.Suffocate(output)).To(Equal(helper.Suffocate(fmt.Sprintf(`
Devfile Components:
APP NAME PROJECT TYPE STATE
app %[1]s %[2]s nodejs Pushed
APP NAME PROJECT TYPE STATE MANAGED BY ODO
app %[1]s %[2]s nodejs Pushed Yes
`, cmpName, commonVar.Project))))
By("checking that it shows components in all applications")