Skip to content

Commit 6bcfca5

Browse files
authored
[release-0.18] Backport of #1117 (#1132)
* 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 knative/eventing#4514) workaround for #1100 this changeset should be reverted when eventing#4514 is resolved * Add CHANGELOG * Update changelog for v0.18.3
1 parent 47f59f0 commit 6bcfca5

File tree

7 files changed

+23
-10
lines changed

7 files changed

+23
-10
lines changed

CHANGELOG.adoc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,18 @@
1212
| https://github.com/knative/client/pull/[#]
1313
////
1414

15+
## v0.18.3 (2020-11-24)
16+
17+
[cols="1,10,3", options="header", width="100%"]
18+
|===
19+
| | Description | PR
20+
21+
| 🐛
22+
| Embed the namespace in request body while creating channels
23+
| https://github.com/knative/client/pull/1117[#1117]
24+
25+
|===
26+
1527
## v0.18.2 (2020-11-10)
1628

1729
[cols="1,10,3", options="header", width="100%"]

pkg/kn/commands/channel/channel_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,6 @@ func cleanupChannelMockClient() {
7676
channelClientFactory = nil
7777
}
7878

79-
func createChannel(name string, gvk *schema.GroupVersionKind) *v1beta1.Channel {
80-
return clientv1beta1.NewChannelBuilder(name).Type(gvk).Build()
79+
func createChannel(name, namespace string, gvk *schema.GroupVersionKind) *v1beta1.Channel {
80+
return clientv1beta1.NewChannelBuilder(name, namespace).Type(gvk).Build()
8181
}

pkg/kn/commands/channel/create.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ func NewChannelCreateCommand(p *commands.KnParams) *cobra.Command {
6060
return err
6161
}
6262

63-
cb := knmessagingv1beta1.NewChannelBuilder(name)
63+
cb := knmessagingv1beta1.NewChannelBuilder(name, namespace)
6464

6565
if cmd.Flag("type").Changed {
6666
gvk, err := ctypeFlags.Parse()

pkg/kn/commands/channel/create_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func TestCreateChannelErrorCaseTypeFormat(t *testing.T) {
4343
func TestCreateChannelDefaultChannel(t *testing.T) {
4444
cClient := v1beta1.NewMockKnChannelsClient(t)
4545
cRecorder := cClient.Recorder()
46-
cRecorder.CreateChannel(createChannel("pipe", nil), nil)
46+
cRecorder.CreateChannel(createChannel("pipe", "default", nil), nil)
4747
out, err := executeChannelCommand(cClient, "create", "pipe")
4848
assert.NilError(t, err, "channel should be created")
4949
assert.Assert(t, util.ContainsAll(out, "created", "pipe", "default"))
@@ -53,7 +53,7 @@ func TestCreateChannelDefaultChannel(t *testing.T) {
5353
func TestCreateChannelWithTypeFlagInMemoryChannel(t *testing.T) {
5454
cClient := v1beta1.NewMockKnChannelsClient(t)
5555
cRecorder := cClient.Recorder()
56-
cRecorder.CreateChannel(createChannel("pipe", &schema.GroupVersionKind{Group: "messaging.knative.dev", Version: "v1beta1", Kind: "InMemoryChannel"}), nil)
56+
cRecorder.CreateChannel(createChannel("pipe", "default", &schema.GroupVersionKind{Group: "messaging.knative.dev", Version: "v1beta1", Kind: "InMemoryChannel"}), nil)
5757
out, err := executeChannelCommand(cClient, "create", "pipe", "--type", "imcv1beta1")
5858
assert.NilError(t, err, "channel should be created")
5959
assert.Assert(t, util.ContainsAll(out, "created", "pipe", "default"))

pkg/kn/commands/channel/describe_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func TestDescribeChannelErrorCaseNotFound(t *testing.T) {
4545
func TestDescribeChannel(t *testing.T) {
4646
cClient := v1beta1.NewMockKnChannelsClient(t)
4747
cRecorder := cClient.Recorder()
48-
cRecorder.GetChannel("pipe", createChannel("pipe", &schema.GroupVersionKind{Group: "messaging.knative.dev", Version: "v1beta1", Kind: "InMemoryChannel"}), nil)
48+
cRecorder.GetChannel("pipe", createChannel("pipe", "default", &schema.GroupVersionKind{Group: "messaging.knative.dev", Version: "v1beta1", Kind: "InMemoryChannel"}), nil)
4949
out, err := executeChannelCommand(cClient, "describe", "pipe")
5050
assert.NilError(t, err, "channel should be described")
5151
assert.Assert(t, util.ContainsAll(out, "messaging.knative.dev", "v1beta1", "InMemoryChannel", "pipe"))

pkg/kn/commands/channel/list_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ func TestChannelList(t *testing.T) {
4141
cRecorder := cClient.Recorder()
4242
clist := &messagingv1beta1.ChannelList{}
4343
clist.Items = []messagingv1beta1.Channel{
44-
*createChannel("c0", &schema.GroupVersionKind{Group: "messaging.knative.dev", Version: "v1beta1", Kind: "InMemoryChannel"}),
45-
*createChannel("c1", &schema.GroupVersionKind{Group: "messaging.knative.dev", Version: "v1beta1", Kind: "InMemoryChannel"}),
44+
*createChannel("c0", "default", &schema.GroupVersionKind{Group: "messaging.knative.dev", Version: "v1beta1", Kind: "InMemoryChannel"}),
45+
*createChannel("c1", "default", &schema.GroupVersionKind{Group: "messaging.knative.dev", Version: "v1beta1", Kind: "InMemoryChannel"}),
4646
}
4747
cRecorder.ListChannel(clist, nil)
4848
out, err := executeChannelCommand(cClient, "list")

pkg/messaging/v1beta1/channels_client.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,11 @@ type ChannelBuilder struct {
122122
}
123123

124124
// NewChannelBuilder for building Channel object
125-
func NewChannelBuilder(name string) *ChannelBuilder {
125+
func NewChannelBuilder(name, namespace string) *ChannelBuilder {
126126
return &ChannelBuilder{channel: &v1beta1.Channel{
127127
ObjectMeta: metav1.ObjectMeta{
128-
Name: name,
128+
Name: name,
129+
Namespace: namespace,
129130
},
130131
}}
131132
}

0 commit comments

Comments
 (0)