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

svcat describe and get classes now support namespaced resources #2582

Merged

Conversation

jberkhahn
Copy link
Contributor

This PR is a

  • Feature Implementation
  • Bug Fix
  • Documentation

What this PR does / why we need it:
per #2451 as part of the burndown on namespace resources, this changes the behavior of svcat get and describe to as follows:

user asks for some class named foo
look for clusterserviceclasses and serviceclasses in the current namespace named foo
-if only 1 is found, return it
if >1 are found, ask the user to specify scope

Which issue(s) this PR fixes
Fixes #2451

Please leave this checklist in the PR comment so that maintainers can ensure a good PR.

Merge Checklist:

  • New feature
    • Tests
    • Documentation
  • SVCat CLI flag
  • Server Flag for config
    • Chart changes
    • removing a flag by marking deprecated and hiding to avoid
      breaking the chart release and existing clients who provide a
      flag that will get an error when they try to update

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Mar 13, 2019
@k8s-ci-robot k8s-ci-robot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Mar 13, 2019
@jberkhahn jberkhahn force-pushed the namespace_describe_classes branch 8 times, most recently from 87f9279 to 72ab07b Compare March 14, 2019 22:27
@jberkhahn
Copy link
Contributor Author

/cc @jboyd01 @MHBauer

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 31, 2019
kubeName string
name string
// DescribeCmd contains the information needed to describe a specific class
type DescribeCmd struct {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this should have a public context or nothing should have a public context

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't remember what this means.

Expect(actions[1].Matches("get", "serviceclasses")).To(BeTrue())
Expect(actions[1].(testing.GetActionImpl).Name).To(Equal(classID))
})
It("doesn't short circuit on not-found errors", func() {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

add a test for the both-not-found case

Copy link
Contributor

@MHBauer MHBauer left a comment

Choose a reason for hiding this comment

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

looked at with jonathan. his comments are my comments

class, err := sdk.ServiceCatalog().ClusterServiceClasses().Get(kubeName, metav1.GetOptions{})
if err != nil {
return nil, fmt.Errorf("unable to get class (%s)", err)
func (sdk *SDK) RetrieveClassByID(kubeName string, opts ScopeOptions) (Class, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

same code as previously

class, err = c.App.RetrieveClassByName(c.name, servicecatalog.ScopeOptions{
Scope: servicecatalog.ClusterScope,
})
class, err = c.App.RetrieveClassByName(c.Name, scopeOpts)
Copy link
Contributor

Choose a reason for hiding this comment

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

names look funny when compared with previous PR

@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 2, 2019
@jberkhahn jberkhahn force-pushed the namespace_describe_classes branch 2 times, most recently from f5e570b to 2b71b96 Compare April 2, 2019 22:38
@jberkhahn
Copy link
Contributor Author

@MHBauer could you take another look at this? fixed your concerns. I'll have to submit another PR to change the naming stuff in the broker commands.

@MHBauer MHBauer self-requested a review April 3, 2019 00:34
Copy link
Contributor

@MHBauer MHBauer left a comment

Choose a reason for hiding this comment

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

/gtm

kubeName string
name string
// DescribeCmd contains the information needed to describe a specific class
type DescribeCmd struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't remember what this means.

@jberkhahn
Copy link
Contributor Author

@MHBauer looks like your LGTM didn't take, could you re /lgtm this?

@k8s-ci-robot k8s-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Apr 8, 2019
jboyd01
jboyd01 previously requested changes Apr 9, 2019
Copy link
Contributor

@jboyd01 jboyd01 left a comment

Choose a reason for hiding this comment

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

I'm kind of surprised the namespaced scoped describe class test works since the namespace scope doesn't work from the command line (flag not recognized) (see below)....

At md/svcat/class/describe_cmd.go:114

	opts := servicecatalog.ScopeOptions{Scope: servicecatalog.AllScope}
	plans, err := c.App.RetrievePlans(class.GetName(), opts)
	if err != nil {
		return err
	}

I think if the scope is namespace we should set namespace for the plan scope as well. Probably applies to more then just plans. IE all describe operations pull up instances/classes/plans right? we should apply the same scope to all describe commands. Maybe this is best done in a follow up, if you agree would you mind creating an issue? Or let me know and I can create.

)
describeCmd.AddScopedFlags(cmd.Flags(), true)

Copy link
Contributor

Choose a reason for hiding this comment

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

Missing describeCmd.AddNamespaceFlags(cmd.Flags(), false). Running svcat describe class --help doesn't show the -n or --namespace option and trying to use it I get errors about unknown flag

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, the reason the test passes is the actual bit that compiles the command and parses junk is inside the cobra framework, so I can't test it. I have to manually reach in and set the fields.

As for filtering the plans by namespace, that shouldn't be necessary because we're filtering by the exact k8s name of the parent class (filtered through the pkg/svcat interface so it doesn't matter if it's a ServiceClass or ClusterServiceClass).

Copy link
Contributor

Choose a reason for hiding this comment

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

As for filtering the plans by namespace, that shouldn't be necessary because we're filtering by the exact k8s name of the parent class (filtered through the pkg/svcat interface so it doesn't matter if it's a ServiceClass or ClusterServiceClass).

I was doing some poking a week ago with this review as a non-admin user and specified a single namespace on the describe class command. I got errors indicating I didn't have privs to get cluster scoped plans. So I think this is a real issue, but I'll have to wait 'til next time I have an environment up and time to reproduce. I'm fine if we address that in a separate issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh huh, that is interesting. Although I think that's a larger problem that the scope of this PR, because doesn't that mean you wouldn't be able to see cluster plans to know what they're called to even provision one?

@@ -112,10 +112,6 @@ func (c *getCmd) Validate(args []string) error {
}

func (c *getCmd) Run() error {
fmt.Println("KUBENAME: ", c.kubeName)
Copy link
Contributor

Choose a reason for hiding this comment

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

I saw this output in my last built svcat - glad you are removing this, I wasn't aware we had actually checked this in like this.

@k8s-ci-robot k8s-ci-robot removed the lgtm Indicates that a PR is ready to be merged. label Apr 15, 2019
@jberkhahn
Copy link
Contributor Author

@MHBauer need to review again
@jboyd01 addressed your things

@MHBauer
Copy link
Contributor

MHBauer commented Apr 16, 2019

test fails
/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Apr 16, 2019
@MHBauer
Copy link
Contributor

MHBauer commented Apr 16, 2019

real failure, need to update the goldens and the completions

@jboyd01
Copy link
Contributor

jboyd01 commented Apr 16, 2019

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jboyd01

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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 16, 2019
@k8s-ci-robot k8s-ci-robot removed the lgtm Indicates that a PR is ready to be merged. label Apr 16, 2019
@jberkhahn
Copy link
Contributor Author

updated the golden files

@MHBauer
Copy link
Contributor

MHBauer commented Apr 17, 2019

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Apr 17, 2019
@jberkhahn
Copy link
Contributor Author

/test pull-service-catalog-xbuild

@jberkhahn jberkhahn dismissed jboyd01’s stale review April 17, 2019 21:31

beyond the scope of this PR

@k8s-ci-robot k8s-ci-robot merged commit 7e3e171 into kubernetes-retired:master Apr 17, 2019
viviyww pushed a commit to viviyww/service-catalog that referenced this pull request May 10, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm Indicates that a PR is ready to be merged. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

svcat describe should support namespaced resources
4 participants