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

make svcat describe and get broker now support namespaced resources #2564

Merged

Conversation

jberkhahn
Copy link
Contributor

@jberkhahn jberkhahn commented Feb 7, 2019

This PR is a

  • [x ] 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 broker named foo
  • look for clusterservicebrokers and servicebrokers in the current namespace named foo
    -if only 1 is found, return it
    if >1 are found, ask the user to specify scope

This also adds a typeline to the various places brokers are displayed to the user to inform them if its a clusterservicebroker or servicebroker

Which issue(s) this PR 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 cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Feb 7, 2019
@jberkhahn jberkhahn force-pushed the namespace_describe branch 8 times, most recently from 1449ee9 to 20267d3 Compare February 12, 2019 22:34
@jberkhahn
Copy link
Contributor Author

/retest

@jberkhahn
Copy link
Contributor Author

/cc @MHBauer could you take a look at this when you have some time?

@MHBauer
Copy link
Contributor

MHBauer commented Feb 15, 2019

pretty big, could take a while

@MHBauer
Copy link
Contributor

MHBauer commented Feb 19, 2019

cc needs to be on it's own line
/cc @MHBauer

@k8s-ci-robot k8s-ci-robot requested a review from MHBauer February 19, 2019 00:15
@MHBauer
Copy link
Contributor

MHBauer commented Feb 19, 2019

or it's just broke

@MHBauer
Copy link
Contributor

MHBauer commented Feb 19, 2019 via email

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.

sorry for taking so long. I see tiny nits and have questions.

Only one instance of "Why did you write it that way".

@@ -1,5 +1,5 @@
/*
Copyright 2018 The Kubernetes Authors.
Copy link
Contributor

Choose a reason for hiding this comment

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

mock changes, ignoring.

@@ -46,7 +46,7 @@ type SvcatClient interface {

Deregister(string, *ScopeOptions) error
RetrieveBrokers(opts ScopeOptions) ([]Broker, error)
RetrieveBroker(string) (*apiv1beta1.ClusterServiceBroker, error)
RetrieveBrokerByID(string, ScopeOptions) (Broker, error)
Copy link
Contributor

Choose a reason for hiding this comment

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

why change the method name?

Copy link
Contributor

Choose a reason for hiding this comment

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

missed the scope addition.

@@ -23,6 +23,13 @@ import (
"github.com/kubernetes-incubator/service-catalog/pkg/svcat/service-catalog"
)

func getBrokerScope(broker servicecatalog.Broker) string {
if broker.GetNamespace() != "" {
Copy link
Contributor

Choose a reason for hiding this comment

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

is empty string already resolved to "default" at this point?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note that this isn't an actual v1beta1 broker, it's our custom-spun interface that spans the two types for svcat to use - this always returns "" for CSB's: https://github.com/kubernetes-incubator/service-catalog/blob/master/pkg/apis/servicecatalog/v1beta1/broker.go#L30

Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@@ -126,6 +126,9 @@ tree:
use: binding NAME
Copy link
Contributor

Choose a reason for hiding this comment

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

ok

cmd/svcat/svcat_test.go Outdated Show resolved Hide resolved
@@ -14,89 +14,217 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
Copy link
Contributor

Choose a reason for hiding this comment

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

I trust the @jberkhahn tests.

cmd/svcat/broker/get_cmd_test.go Show resolved Hide resolved
cmd/svcat/output/broker.go Outdated Show resolved Hide resolved
cmd/svcat/broker/get_cmd.go Show resolved Hide resolved
cmd/svcat/broker/describe_cmd.go Show resolved Hide resolved
@jberkhahn
Copy link
Contributor Author

Thanks for the review @MHBauer. Gotta jet atm, but I will get this stuff looked at ASAP.

@jberkhahn jberkhahn force-pushed the namespace_describe branch from 66c50ea to b59db35 Compare March 6, 2019 23:29
@jberkhahn
Copy link
Contributor Author

/retest

1 similar comment
@jberkhahn
Copy link
Contributor Author

/retest

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.

I need more understanding of how opts matches works.

}
table = append(table, []string{"URL:", broker.GetURL()})
table = append(table, []string{"Status:", getBrokerStatusFull(broker.GetStatus())})
t.AppendBulk(table)
Copy link
Contributor

Choose a reason for hiding this comment

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

I like it.

}
}

if opts.Scope.Matches(NamespaceScope) {
Copy link
Contributor

Choose a reason for hiding this comment

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

else if?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it can't be an else if, its possible to match both

if err != nil && !apierrors.IsNotFound(err) {
return nil, fmt.Errorf("unable to search servicebrokers k8s by name (%s)", err)
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

return sb here ?

if err != nil && !apierrors.IsNotFound(err) {
return nil, fmt.Errorf("unable to search clusterservicebrokers by k8s name (%s)", err)
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

return csb here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

its possible we get both a sb and csb back, if they were created with the same name, which is possible as they're different types

@MHBauer
Copy link
Contributor

MHBauer commented Mar 7, 2019

strange case, makes sense now. gotta handle "all"
/lgtm

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

MHBauer commented Mar 7, 2019

/assign @jboyd01

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.

Sorry it took me so long to review. One nit and a simplification

@@ -29,6 +29,10 @@ import (
"k8s.io/apimachinery/pkg/util/wait"
)

// MultipleBrokersFoundError is the error returned when we find a clusterservicebroker
// and a servicebroker with the same name
const MultipleBrokersFoundError = "Too many brokers found"
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: what do you think about "more then one" vs "too many" ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sounds good.

sb = nil
}
if err != nil && !apierrors.IsNotFound(err) {
return nil, fmt.Errorf("unable to search servicebrokers k8s by name (%s)", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

should this be "unable to search servicebrokers by k8s name" ? (ie the placement of k8s). And should we not spell out kubernetes?

change 135 & 136 to } else { as we already know err != nil

Copy link
Contributor Author

Choose a reason for hiding this comment

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

will do.

@jberkhahn jberkhahn force-pushed the namespace_describe branch from b59db35 to 52de896 Compare March 8, 2019 19:35
@k8s-ci-robot k8s-ci-robot removed the lgtm Indicates that a PR is ready to be merged. label Mar 8, 2019
@jberkhahn
Copy link
Contributor Author

@jboyd01 @MHBauer changes are up

@jberkhahn jberkhahn force-pushed the namespace_describe branch from 52de896 to ac5837b Compare March 13, 2019 20:48
@jboyd01
Copy link
Contributor

jboyd01 commented Mar 13, 2019

/lgtm

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

MHBauer commented Mar 13, 2019

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: MHBauer

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 Mar 13, 2019
@jberkhahn
Copy link
Contributor Author

/test pull-service-catalog-xbuild

@k8s-ci-robot k8s-ci-robot merged commit f8870a5 into kubernetes-retired:master Mar 13, 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/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants