Embed the namespace in request body while creating channels (#1117)

* Embed the namespace in request body while creating channels

 since on the eventing side, defaulting for channel isnt picking
 the namespace from the context (see https://github.com/knative/eventing/issues/4514)

 workaround for #1100
 this changeset should be reverted when eventing#4514 is resolved

* Add CHANGELOG
This commit is contained in:
Navid Shaikh 2020-11-13 02:14:59 +05:30 committed by GitHub
parent b93ca9b34d
commit 6508fedbac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 21 additions and 10 deletions

View File

@ -12,6 +12,16 @@
| https://github.com/knative/client/pull/[#] | https://github.com/knative/client/pull/[#]
//// ////
### Unreleased
[cols="1,10,3", options="header", width="100%"]
|===
| | Description | PR
| 🐛
| Embed the namespace in request body while creating channels
| https://github.com/knative/client/pull/1117[#1117]
|===
### v0.19.0 (2020-11-11) ### v0.19.0 (2020-11-11)
[cols="1,10,3", options="header", width="100%"] [cols="1,10,3", options="header", width="100%"]
|=== |===

View File

@ -76,6 +76,6 @@ func cleanupChannelMockClient() {
channelClientFactory = nil channelClientFactory = nil
} }
func createChannel(name string, gvk *schema.GroupVersionKind) *v1beta1.Channel { func createChannel(name, namespace string, gvk *schema.GroupVersionKind) *v1beta1.Channel {
return clientv1beta1.NewChannelBuilder(name).Type(gvk).Build() return clientv1beta1.NewChannelBuilder(name, namespace).Type(gvk).Build()
} }

View File

@ -60,7 +60,7 @@ func NewChannelCreateCommand(p *commands.KnParams) *cobra.Command {
return err return err
} }
cb := knmessagingv1beta1.NewChannelBuilder(name) cb := knmessagingv1beta1.NewChannelBuilder(name, namespace)
if cmd.Flag("type").Changed { if cmd.Flag("type").Changed {
gvk, err := ctypeFlags.Parse() gvk, err := ctypeFlags.Parse()

View File

@ -43,7 +43,7 @@ func TestCreateChannelErrorCaseTypeFormat(t *testing.T) {
func TestCreateChannelDefaultChannel(t *testing.T) { func TestCreateChannelDefaultChannel(t *testing.T) {
cClient := v1beta1.NewMockKnChannelsClient(t) cClient := v1beta1.NewMockKnChannelsClient(t)
cRecorder := cClient.Recorder() cRecorder := cClient.Recorder()
cRecorder.CreateChannel(createChannel("pipe", nil), nil) cRecorder.CreateChannel(createChannel("pipe", "default", nil), nil)
out, err := executeChannelCommand(cClient, "create", "pipe") out, err := executeChannelCommand(cClient, "create", "pipe")
assert.NilError(t, err, "channel should be created") assert.NilError(t, err, "channel should be created")
assert.Assert(t, util.ContainsAll(out, "created", "pipe", "default")) assert.Assert(t, util.ContainsAll(out, "created", "pipe", "default"))
@ -53,7 +53,7 @@ func TestCreateChannelDefaultChannel(t *testing.T) {
func TestCreateChannelWithTypeFlagInMemoryChannel(t *testing.T) { func TestCreateChannelWithTypeFlagInMemoryChannel(t *testing.T) {
cClient := v1beta1.NewMockKnChannelsClient(t) cClient := v1beta1.NewMockKnChannelsClient(t)
cRecorder := cClient.Recorder() cRecorder := cClient.Recorder()
cRecorder.CreateChannel(createChannel("pipe", &schema.GroupVersionKind{Group: "messaging.knative.dev", Version: "v1beta1", Kind: "InMemoryChannel"}), nil) cRecorder.CreateChannel(createChannel("pipe", "default", &schema.GroupVersionKind{Group: "messaging.knative.dev", Version: "v1beta1", Kind: "InMemoryChannel"}), nil)
out, err := executeChannelCommand(cClient, "create", "pipe", "--type", "imcv1beta1") out, err := executeChannelCommand(cClient, "create", "pipe", "--type", "imcv1beta1")
assert.NilError(t, err, "channel should be created") assert.NilError(t, err, "channel should be created")
assert.Assert(t, util.ContainsAll(out, "created", "pipe", "default")) assert.Assert(t, util.ContainsAll(out, "created", "pipe", "default"))

View File

@ -45,7 +45,7 @@ func TestDescribeChannelErrorCaseNotFound(t *testing.T) {
func TestDescribeChannel(t *testing.T) { func TestDescribeChannel(t *testing.T) {
cClient := v1beta1.NewMockKnChannelsClient(t) cClient := v1beta1.NewMockKnChannelsClient(t)
cRecorder := cClient.Recorder() cRecorder := cClient.Recorder()
cRecorder.GetChannel("pipe", createChannel("pipe", &schema.GroupVersionKind{Group: "messaging.knative.dev", Version: "v1beta1", Kind: "InMemoryChannel"}), nil) cRecorder.GetChannel("pipe", createChannel("pipe", "default", &schema.GroupVersionKind{Group: "messaging.knative.dev", Version: "v1beta1", Kind: "InMemoryChannel"}), nil)
out, err := executeChannelCommand(cClient, "describe", "pipe") out, err := executeChannelCommand(cClient, "describe", "pipe")
assert.NilError(t, err, "channel should be described") assert.NilError(t, err, "channel should be described")
assert.Assert(t, util.ContainsAll(out, "messaging.knative.dev", "v1beta1", "InMemoryChannel", "pipe")) assert.Assert(t, util.ContainsAll(out, "messaging.knative.dev", "v1beta1", "InMemoryChannel", "pipe"))

View File

@ -41,8 +41,8 @@ func TestChannelList(t *testing.T) {
cRecorder := cClient.Recorder() cRecorder := cClient.Recorder()
clist := &messagingv1beta1.ChannelList{} clist := &messagingv1beta1.ChannelList{}
clist.Items = []messagingv1beta1.Channel{ clist.Items = []messagingv1beta1.Channel{
*createChannel("c0", &schema.GroupVersionKind{Group: "messaging.knative.dev", Version: "v1beta1", Kind: "InMemoryChannel"}), *createChannel("c0", "default", &schema.GroupVersionKind{Group: "messaging.knative.dev", Version: "v1beta1", Kind: "InMemoryChannel"}),
*createChannel("c1", &schema.GroupVersionKind{Group: "messaging.knative.dev", Version: "v1beta1", Kind: "InMemoryChannel"}), *createChannel("c1", "default", &schema.GroupVersionKind{Group: "messaging.knative.dev", Version: "v1beta1", Kind: "InMemoryChannel"}),
} }
cRecorder.ListChannel(clist, nil) cRecorder.ListChannel(clist, nil)
out, err := executeChannelCommand(cClient, "list") out, err := executeChannelCommand(cClient, "list")

View File

@ -122,10 +122,11 @@ type ChannelBuilder struct {
} }
// NewChannelBuilder for building Channel object // NewChannelBuilder for building Channel object
func NewChannelBuilder(name string) *ChannelBuilder { func NewChannelBuilder(name, namespace string) *ChannelBuilder {
return &ChannelBuilder{channel: &v1beta1.Channel{ return &ChannelBuilder{channel: &v1beta1.Channel{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: name, Name: name,
Namespace: namespace,
}, },
}} }}
} }