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

feat(version): Add JSON/YAML output formats for version command #709

Merged
merged 2 commits into from
Mar 9, 2020

Conversation

navidshaikh
Copy link
Collaborator

Fixes #513

Description:

Add -o flag to kn version command and support JSON/YAML formats.

Changes

Examples:

➜  client git:(pr/kn-version-json) kn version -ojson
{
	"Version": "v20200309-local-1cbb94e2-dirty",
	"BuildDate": "2020-03-09 13:35:39",
	"GitRevision": "1cbb94e2",
	"SupportedAPIs": {
		"eventing": [
			"sources.eventing.knative.dev/v1alpha1 (knative-eventing v0.13.1)",
			"sources.eventing.knative.dev/v1alpha2 (knative-eventing v0.13.1)",
			"eventing.knative.dev/v1alpha1 (knative-eventing v0.13.1)"
		],
		"serving": [
			"serving.knative.dev/v1 (knative-serving v0.13.0)"
		]
	}
}

and

➜  client git:(pr/kn-version-json) kn version -oyaml
BuildDate: "2020-03-09 13:35:39"
GitRevision: 1cbb94e2
SupportedAPIs:
  eventing:
  - sources.eventing.knative.dev/v1alpha1 (knative-eventing v0.13.1)
  - sources.eventing.knative.dev/v1alpha2 (knative-eventing v0.13.1)
  - eventing.knative.dev/v1alpha1 (knative-eventing v0.13.1)
  serving:
  - serving.knative.dev/v1 (knative-serving v0.13.0)
Version: v20200309-local-1cbb94e2-dirty

/lint

@googlebot googlebot added the cla: yes Indicates the PR's author has signed the CLA. label Mar 9, 2020
Copy link
Contributor

@knative-prow-robot knative-prow-robot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@navidshaikh: 1 warning.

In response to this:

Fixes #513

Description:

Add -o flag to kn version command and support JSON/YAML formats.

Changes

Examples:

➜  client git:(pr/kn-version-json) kn version -ojson
{
  "Version": "v20200309-local-1cbb94e2-dirty",
  "BuildDate": "2020-03-09 13:35:39",
  "GitRevision": "1cbb94e2",
  "SupportedAPIs": {
  	"eventing": [
  		"sources.eventing.knative.dev/v1alpha1 (knative-eventing v0.13.1)",
  		"sources.eventing.knative.dev/v1alpha2 (knative-eventing v0.13.1)",
  		"eventing.knative.dev/v1alpha1 (knative-eventing v0.13.1)"
  	],
  	"serving": [
  		"serving.knative.dev/v1 (knative-serving v0.13.0)"
  	]
  }
}

and

➜  client git:(pr/kn-version-json) kn version -oyaml
BuildDate: "2020-03-09 13:35:39"
GitRevision: 1cbb94e2
SupportedAPIs:
 eventing:
 - sources.eventing.knative.dev/v1alpha1 (knative-eventing v0.13.1)
 - sources.eventing.knative.dev/v1alpha2 (knative-eventing v0.13.1)
 - eventing.knative.dev/v1alpha1 (knative-eventing v0.13.1)
 serving:
 - serving.knative.dev/v1 (knative-serving v0.13.0)
Version: v20200309-local-1cbb94e2-dirty

/lint

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

pkg/kn/commands/version/version.go Show resolved Hide resolved
@knative-prow-robot knative-prow-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Mar 9, 2020
@knative-prow-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: navidshaikh

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@knative-prow-robot knative-prow-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 9, 2020
@navidshaikh
Copy link
Collaborator Author

/cc: @joshuawilson

@joshuawilson
Copy link

That looks good. What will be different when the version is a released version instead of a local build?

@navidshaikh
Copy link
Collaborator Author

@joshuawilson:
If its a local build, we get:

	"Version": "v20200309-local-1d4b497b",

while for released build:

	"Version": "v0.13.0",

rest of the fields should stay intact

@joshuawilson
Copy link

Thanks for fixing this.
Do you want me to mark/tag anything?

@navidshaikh
Copy link
Collaborator Author

@joshuawilson thanks for the review!

/assign @rhuss

Copy link
Contributor

@rhuss rhuss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me with some a minor improvement suggestion.

@navidshaikh do you want to address that now or ok to do it post 0.13.0 ?

@knative-metrics-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-knative-client-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/kn/commands/version/version.go 100.0% 93.5% -6.5

@rhuss
Copy link
Contributor

rhuss commented Mar 9, 2020

/lgtm

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Mar 9, 2020
@navidshaikh
Copy link
Collaborator Author

@rhuss: addressed the review comment.

@knative-prow-robot knative-prow-robot merged commit 14a5e83 into knative:master Mar 9, 2020
@navidshaikh navidshaikh deleted the pr/kn-version-json branch March 10, 2020 05:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cla: yes Indicates the PR's author has signed the CLA. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support machine-readable output for "kn version"
6 participants