Skip to content

Commit

Permalink
Remove deprecated --inject-broker flag from trigger cmds
Browse files Browse the repository at this point in the history
  • Loading branch information
xiangpingjiang committed Aug 18, 2023
1 parent 9676e46 commit 0cf971a
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 113 deletions.
9 changes: 0 additions & 9 deletions pkg/kn/commands/trigger/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,6 @@ func NewTriggerCreateCommand(p *commands.KnParams) *cobra.Command {
Ref: objectRef.Ref,
URI: objectRef.URI,
})
// add inject annotation only if flag broker name is `default`
if triggerUpdateFlags.InjectBroker {
if triggerUpdateFlags.Broker == "default" {
triggerBuilder.InjectBroker(true)
} else {
return fmt.Errorf("cannot create trigger '%s' in namespace '%s' "+
"because broker name must be 'default' if '--inject-broker' flag is used", name, namespace)
}
}

err = eventingClient.CreateTrigger(cmd.Context(), triggerBuilder.Build())
if err != nil {
Expand Down
30 changes: 0 additions & 30 deletions pkg/kn/commands/trigger/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,36 +49,6 @@ func TestTriggerCreate(t *testing.T) {
eventingRecorder.Validate()
}

func TestTriggerWithInjectCreate(t *testing.T) {
eventingClient := clienteventingv1.NewMockKnEventingClient(t)
dynamicClient := dynamicfake.CreateFakeKnDynamicClient("default", &servingv1.Service{
TypeMeta: metav1.TypeMeta{Kind: "Service", APIVersion: "serving.knative.dev/v1"},
ObjectMeta: metav1.ObjectMeta{Name: "mysvc", Namespace: "default"},
})

eventingRecorder := eventingClient.Recorder()
eventingRecorder.CreateTrigger(createTriggerWithInject("default", triggerName, map[string]string{"type": "dev.knative.foo"}, "default", "mysvc"), nil)

out, err := executeTriggerCommand(eventingClient, dynamicClient, "create", triggerName, "--broker", "default", "--inject-broker",
"--filter", "type=dev.knative.foo", "--sink", "ksvc:mysvc")
assert.NilError(t, err, "Trigger should be created")
assert.Assert(t, util.ContainsAll(out, "Trigger", triggerName, "created", "namespace", "default"))

eventingRecorder.Validate()
}

func TestTriggerWithInjectError(t *testing.T) {
eventingClient := clienteventingv1.NewMockKnEventingClient(t)
dynamicClient := dynamicfake.CreateFakeKnDynamicClient("default", &servingv1.Service{
TypeMeta: metav1.TypeMeta{Kind: "Service", APIVersion: "serving.knative.dev/v1"},
ObjectMeta: metav1.ObjectMeta{Name: "mysvc", Namespace: "default"},
})

_, err := executeTriggerCommand(eventingClient, dynamicClient, "create", triggerName, "--broker", "mybroker", "--inject-broker",
"--filter", "type=dev.knative.foo", "--sink", "ksvc:mysvc")
assert.ErrorContains(t, err, "broker", "name", "'default'", "--inject-broker", "flag")
}

func TestSinkNotFoundError(t *testing.T) {
eventingClient := clienteventingv1.NewMockKnEventingClient(t)
dynamicClient := dynamicfake.CreateFakeKnDynamicClient("default")
Expand Down
8 changes: 1 addition & 7 deletions pkg/kn/commands/trigger/update_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,6 @@ func (f *TriggerUpdateFlags) Add(cmd *cobra.Command) {
// Spec.Broker is immutable field
cmd.Flags().StringVar(&f.Broker, "broker", "default", "Name of the Broker which the trigger associates with.")
}
// The Sugar controller was integrated into main Eventing controller. With that the default behavior was changed as well.
// Users need to configure 'Automatic Broker Creation' per linked docs.
// Deprecated in 1.4, remove in 1.6.
cmd.Flags().BoolVar(&f.InjectBroker, "inject-broker", false, "Create new broker with name default through common annotation")
cmd.Flags().MarkDeprecated("inject-broker", "effective since 1.4 and will be removed in 1.6 release. \n"+
"Please refer to 'Automatic Broker Creation' section for configuration options, "+
"https://knative.dev/docs/eventing/sugar/#automatic-broker-creation.")

cmd.Flags().StringSliceVar(&f.Filters, "filter", nil, "Key-value pair for exact CloudEvent attribute matching against incoming events, e.g type=dev.knative.foo")
}
67 changes: 0 additions & 67 deletions test/e2e/trigger_inject_broker_test.go

This file was deleted.

0 comments on commit 0cf971a

Please sign in to comment.