-
Notifications
You must be signed in to change notification settings - Fork 385
Add basic Register broker command to Svcat #2162
Conversation
Use: "register NAME --url URL", | ||
Short: "Registers a new broker with service catalog", | ||
Example: command.NormalizeExamples(` | ||
svcat register mysqlbroker --url http://mysqlbroker.com |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
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. |
There was a problem hiding this 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
Fixed the new test suit. make test-update-goldenfiles
works
pkg/svcat/svcat.go
Outdated
*servicecatalog.SDK | ||
|
||
//*servicecatalog.SDK | ||
SDK servicecatalog.SvcatAPI |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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) | ||
} |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SGTM.
a1aac87
to
1757979
Compare
} | ||
|
||
// 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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
returns true
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
c69ae0f
to
f2ab8b6
Compare
f2ab8b6
to
162b67e
Compare
There was a problem hiding this 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.
There was a problem hiding this 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.
pkg/svcat/service-catalog/sdk.go
Outdated
"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 |
There was a problem hiding this comment.
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")) |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
pkg/svcat/service-catalog/sdk.go
Outdated
"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 { |
There was a problem hiding this comment.
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.
There was a problem hiding this 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.
162b67e
to
1183b97
Compare
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. | ||
|
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this 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
There was a problem hiding this 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.
pkg/svcat/svcat.go
Outdated
"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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SvcatClient
instead of SvcatAPI
There was a problem hiding this comment.
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
1183b97
to
1e2b815
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this 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
[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 |
#1807
This command will allow users to add a broker to service catalog