Skip to content
This repository has been archived by the owner on May 6, 2022. It is now read-only.

add svcat version #1839

Merged
merged 12 commits into from
Mar 23, 2018
Merged

Conversation

n3wscott
Copy link
Contributor

This added the command svcat version with optional --server or --client flags to just return the client (svcat version) or the server (git label via apiserver call).

I am not seeing a good test for this, please let me know if you see a testable way to do this.

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Mar 15, 2018
@n3wscott n3wscott requested a review from carolynvs March 15, 2018 20:54
@n3wscott
Copy link
Contributor Author

Fixes #1752

@n3wscott
Copy link
Contributor Author

Local results:

⦿ ./bin/svcat/svcat version
client: v0.1.10-21-gb11513a-dirty
server: v1.9.3-gke.0

Copy link
Contributor

@carolynvs carolynvs left a comment

Choose a reason for hiding this comment

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

Close, I think we just need to tweak the flags used to make kubectl plugin mode happy.

false,
"Show only the client version",
)
cmd.Flags().BoolVarP(
Copy link
Contributor

Choose a reason for hiding this comment

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

This conflicts with a global kubectl flag, --server, which is why you don't see it output in the plugin manifest yaml file.

I recommend that we follow the kubectl convetion for the version command. Just use a single flag, -c, --client, and always output the client version (since it's always available):

$ kubectl version --help
Print the client and server version information for the current context

Examples:
  # Print the client and server versions for the current context
  kubectl version

Options:
  -c, --client=false: Client version only (no server required).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok no problem

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.


// ServerVersion asks the Service Catalog API Server for the version.Info object and returns it.
func (sdk *SDK) ServerVersion() (*version.Info, error) {
serverVersion, err := sdk.ServiceCatalogClient.Discovery().ServerVersion()
Copy link
Contributor

Choose a reason for hiding this comment

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

Sweet! I didn't know about this! 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nor did I until I dug in... I was looking at some way to add a new rest endpoint on the generic api server and oh my... that is some crazy code. Then I found the Discovery object and did a dance.

Copy link
Contributor

Choose a reason for hiding this comment

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

Well done

@n3wscott
Copy link
Contributor Author

PTAL

Copy link
Contributor

@carolynvs carolynvs left a comment

Choose a reason for hiding this comment

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

LGTM once the old --version flag is nuked.

return c.version()
}

func (c *versionCmd) version() error {
Copy link
Contributor

Choose a reason for hiding this comment

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

As a follow up we should move this into the pkg/svcat directory. The rule of thumb for cmd/svcat is that it should offload any non-cli logic to that package. But for version it's not a huge deal.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Left this task as a followup

@@ -105,6 +106,7 @@ func buildRootCommand() *cobra.Command {
cmd.AddCommand(newSyncCmd(cxt))
cmd.AddCommand(newInstallCmd(cxt))
cmd.AddCommand(newTouchCmd(cxt))
cmd.AddCommand(versions.NewVersionCmd(cxt))
Copy link
Contributor

Choose a reason for hiding this comment

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

We need to remove the existing handling for the --version flag. So line 114 (printVersion) and lines 81-84. Having it be it's own command is better IMO, so let's just remove the old way.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed --version and updated the install document.

Copy link
Contributor

@pmorie pmorie left a comment

Choose a reason for hiding this comment

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

LGTM


// ServerVersion asks the Service Catalog API Server for the version.Info object and returns it.
func (sdk *SDK) ServerVersion() (*version.Info, error) {
serverVersion, err := sdk.ServiceCatalogClient.Discovery().ServerVersion()
Copy link
Contributor

Choose a reason for hiding this comment

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

Well done

@pmorie pmorie added the LGTM1 label Mar 20, 2018
Copy link
Contributor

@carolynvs carolynvs left a comment

Choose a reason for hiding this comment

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

LGTM!

@carolynvs carolynvs merged commit fb136f1 into kubernetes-retired:master Mar 23, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. LGTM1 LGTM2 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.

None yet

4 participants