Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

oc projects -q outputs display-name #12267

Closed
jupierce opened this issue Dec 14, 2016 · 3 comments
Closed

oc projects -q outputs display-name #12267

jupierce opened this issue Dec 14, 2016 · 3 comments

Comments

@jupierce
Copy link
Contributor

oc projects -q sometimes includes project display-names and sometimes it does not.

Version

oc v1.5.0-alpha.0+cd418ff-255-dirty
kubernetes v1.4.0+776c994
features: Basic-Auth

Steps To Reproduce

When one project (which includes a display-name) exists (e.g. after a clean cluster up):
$ oc projects -q
My Project (myproject)
$ oc new-project temp
$ oc projects -q
myproject
temp

Current Result

Depending on the project metadata, the oc projects -q either includes or excludes the display-name of the project.

Expected Result

The -q flag is ideal for programmatic integration (e.g. iterating through projects from a shell script). The display-name being included in some output introduces unnecessary & somewhat unpredictable parsing requirements.

@chmouel
Copy link
Member

chmouel commented Dec 15, 2016

I believe this is a pretty easy to fix with this patch but waiting for confirmation before sending a pull-req

diff --git a/pkg/cmd/cli/cmd/projects.go b/pkg/cmd/cli/cmd/projects.go
index c43bd93..e1ff49d 100644
--- a/pkg/cmd/cli/cmd/projects.go
+++ b/pkg/cmd/cli/cmd/projects.go
@@ -144,7 +144,7 @@ func (o ProjectsOptions) RunProjects() error {
 			msg += "You are not a member of any projects. You can request a project to be created with the 'new-project' command."
 		case 1:
 			if o.DisplayShort {
-				msg += fmt.Sprintf("%s", api.DisplayNameAndNameForProject(&projects[0]))
+				msg += fmt.Sprintf("%s", &projects[0].Name)
 			} else {
 				msg += fmt.Sprintf("You have one project on this server: %q.", api.DisplayNameAndNameForProject(&projects[0]))
 			}

@fabianofranz
Copy link
Member

Seems reasonable to me, even the flag mentions it only displays the projects names, with no reference to the display names. I'll defer the decision to @juanvallejo.

@jupierce
Copy link
Contributor Author

Thanks @chmouel ! I would also expect no output in the case 0: when -q is used.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants