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

Add basic Register broker command to Svcat #2162

Merged
merged 1 commit into from
Jul 16, 2018

Conversation

jberkhahn
Copy link
Contributor

@jberkhahn jberkhahn commented Jun 27, 2018

#1807

This command will allow users to add a broker to service catalog

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. 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 Jun 27, 2018
Use: "register NAME --url URL",
Short: "Registers a new broker with service catalog",
Example: command.NormalizeExamples(`
svcat register mysqlbroker --url http://mysqlbroker.com
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe this needs to be svcat register broker mysqlbroker ..., so it's aligned with svcat sync broker mysqlbroker

Copy link
Contributor Author

@jberkhahn jberkhahn Jun 29, 2018

Choose a reason for hiding this comment

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

I'm not sure about that. I would think register would be like provision and bind, neither of which require you to specify the object types they create. @carolynvs thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm with Jonathan on that, for our domain specific verbs that only apply to a single resource type (in this case a broker), I would prefer that we are consistent and not require the redundant noun.

@k8s-ci-robot k8s-ci-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jul 4, 2018
@jberkhahn jberkhahn removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 5, 2018
@jberkhahn
Copy link
Contributor Author

Ok, this should be ready to be merged now.

Most of the size is from junk I had to rewrite to turn pkg/svcat/service-catalog into an interface. Everything it does is still the same, it's just specified in an interface so it can be faked out in cmd/svcat for the unit tests.

Copy link
Contributor

@staebler staebler left a comment

Choose a reason for hiding this comment

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

make test-update-goldenfiles fails

@jberkhahn jberkhahn dismissed staebler’s stale review July 5, 2018 22:00

Fixed the new test suit. make test-update-goldenfiles works

@jberkhahn jberkhahn changed the title WIP: Issue 1807 Add Register broker command to Svcat Add basic Register broker command to Svcat Jul 5, 2018
*servicecatalog.SDK

//*servicecatalog.SDK
SDK servicecatalog.SvcatAPI
Copy link
Contributor

Choose a reason for hiding this comment

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

why not keep this as an embed and avoid the App.SDK.fn calls change above?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Other than my dislike of inlining in general? Not really I suppose. I'll revert that bit.

RetrieveSecretByBinding(*apiv1beta1.ServiceBinding) (*apicorev1.Secret, error)

ServerVersion() (*version.Info, error)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Not being sure how this interface is going to be used, I wonder if it best split up into multiple sub interfaces, approximately how it is split by newlines.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

And then what? Have the Svcat app type inline multiple interfaces? Seems like it would be more of a mess to fake, esp. considering you would have to update them individually with Counterfeiter.

Having one bighuge interface does seem kind of messy, but I don't think splitting it up is actually a better alternative.

Copy link
Contributor

Choose a reason for hiding this comment

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

Exactly so. If this isn't intended to be used as a nicer version of a client in any way, then we can leave it, otherwise I think it would be nice to have a binder and a provisioner, or a broker client and a plan client, etc.
I'm fine with it as is. Like I said, I haven't thought about how the interface is to be used.

Copy link
Contributor

Choose a reason for hiding this comment

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

I am fine with a mega interface for now. If there's a need to break it down further, let's tackle that then.

Copy link
Contributor

Choose a reason for hiding this comment

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

SGTM.

@jberkhahn jberkhahn force-pushed the svcat_register branch 7 times, most recently from a1aac87 to 1757979 Compare July 6, 2018 19:01
}

// IsBindingFailed returns if the instance is in the Failed status.
func (sdk *SDK) IsBindingFailed(binding *v1beta1.ServiceBinding) bool {
return sdk.BindingHasStatus(binding, v1beta1.ServiceBindingConditionFailed)
return sdk.bindingHasStatus(binding, v1beta1.ServiceBindingConditionFailed)
}

// BindingHasStatus returns if the instance is in the specified status.
Copy link
Contributor

Choose a reason for hiding this comment

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

returns true

Copy link
Contributor Author

@jberkhahn jberkhahn Jul 6, 2018

Choose a reason for hiding this comment

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

i didn't write that as part of this PR, but thanks

},
},
}
result, err := sdk.ServiceCatalog().ClusterServiceBrokers().Create(request)
Copy link
Contributor

Choose a reason for hiding this comment

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

is auth and stuff handled inside of here or is it future work?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Authenticated brokers is not covered as part of this PR

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.

LGTM from me about the parts I understand.
/lgtm
I'll let @carolynvs do the approval.

@k8s-ci-robot k8s-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Jul 11, 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.

I'm not done yet will finish tonight after dinner.

"k8s.io/client-go/kubernetes"
corev1 "k8s.io/client-go/kubernetes/typed/core/v1"
)

// SvcatAPI is an interface containing the variuos actions in the svcat pkg lib
// This interface is then faked with Counterfeiter for the cmd/svcat unit tests
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add a blurb to docs/devguide.md explaining how to install and use Counterfeiter to perform this task.

Expect(*cmd).NotTo(BeNil())
Expect(cmd.Use).To(Equal("register NAME --url URL"))
Expect(cmd.Short).To(Equal("Registers a new broker with service catalog"))
Expect(cmd.Example).To(Equal(" svcat register mysqlbroker --url http://mysqlbroker.com"))
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we switch from Equals to Contains so that we aren't so whitespace sensitive?

}

// BindingHasStatus returns if the instance is in the specified status.
func (sdk *SDK) BindingHasStatus(binding *v1beta1.ServiceBinding, status v1beta1.ServiceBindingConditionType) bool {
func (sdk *SDK) bindingHasStatus(binding *v1beta1.ServiceBinding, status v1beta1.ServiceBindingConditionType) bool {
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

"k8s.io/client-go/kubernetes"
corev1 "k8s.io/client-go/kubernetes/typed/core/v1"
)

// SvcatAPI is an interface containing the variuos actions in the svcat pkg lib
// This interface is then faked with Counterfeiter for the cmd/svcat unit tests
type SvcatAPI interface {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we come up with a different name for this that doesn't include "API"? The reason I went with SDK on the wrapper that I created was that it really wasn't a blind api client like the regenerated go client already is.

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.

Just some small nits and then this is good to go.

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

@MHBauer @carolynvs

Moved some things around a bit. Renamed the pkg/svcat interface to SvcatClient, because it's Svcat's wrapper around the generated client. Is that a better name?

Added a blurb about counterfeiter to docs/devguide.md as well.

docs/devguide.md Outdated
Counterfeiter by running `go get http://github.com/maxbrunsfeld/counterfeiter && go install http://github.com/maxbrunsfeld/countefeiter`.
Then regenerate the fake with `counterfeiter ./path/to/dir/with/interface InterfaceName`. You may have to manually paste the boilerplate
comment into the fakes.

Copy link
Contributor

Choose a reason for hiding this comment

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

is the version of counterfeiter relevant to mention? I know we had some issues to work through.

docs/devguide.md Outdated
Certain tests use fakes generated with [Counterfeiter](http://github.com/maxbrunsfeld/counterfeiter). If you add a method
to an interface (such as SvcatAPI in pkg/svcat/service-catalog) you may need to regenerate the fake. You can install
Counterfeiter by running `go get http://github.com/maxbrunsfeld/counterfeiter && go install http://github.com/maxbrunsfeld/countefeiter`.
Then regenerate the fake with `counterfeiter ./path/to/dir/with/interface InterfaceName`. You may have to manually paste the boilerplate
Copy link
Contributor

Choose a reason for hiding this comment

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

good mention of the boilerplate.

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'll wait for carolyn to get off the plane, but seems fine still. I like the added docs.
/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Jul 12, 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.

Just one small change (not all the renames made it in) and then this is ready to merge.

"github.com/kubernetes-incubator/service-catalog/pkg/svcat/service-catalog"
k8sclient "k8s.io/client-go/kubernetes"
)

// App is the underlying application behind the svcat cli.
type App struct {
*servicecatalog.SDK

// SvcatAPI is the interface for performing actions against the service-catalog apiserver
Copy link
Contributor

Choose a reason for hiding this comment

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

SvcatClient

docs/devguide.md Outdated
@@ -310,6 +310,13 @@ Keep in mind that golden files help catch errors when the output unexpectedly ch
It's up to you to judge when you should run the tests with -update,
and to diff the changes in the golden file to ensure that the new output is correct.

### Counterfeiter
Certain tests use fakes generated with [Counterfeiter](http://github.com/maxbrunsfeld/counterfeiter). If you add a method
to an interface (such as SvcatAPI in pkg/svcat/service-catalog) you may need to regenerate the fake. You can install
Copy link
Contributor

Choose a reason for hiding this comment

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

SvcatClient instead of SvcatAPI

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.

- refactor pkg/svcat to use an interface
- begin adding unit tests to cmd/svcat w/ faked out pkg interface
@k8s-ci-robot k8s-ci-robot removed the lgtm Indicates that a PR is ready to be merged. label Jul 16, 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

@k8s-ci-robot k8s-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Jul 16, 2018
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.

/LGTM
LGTM
/approve
go for merge

@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 Jul 16, 2018
@jberkhahn jberkhahn merged commit d4b2273 into kubernetes-retired:master Jul 16, 2018
@MHBauer MHBauer mentioned this pull request Jul 19, 2018
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. LGTM1 LGTM2 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.

6 participants