Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unusable --broker flag from trigger update cmd #1847

Merged
merged 2 commits into from
Aug 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion docs/cmd/kn_trigger_update.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ kn trigger update NAME
### Options

```
--broker string Name of the Broker which the trigger associates with. (default "default")
--filter strings Key-value pair for exact CloudEvent attribute matching against incoming events, e.g type=dev.knative.foo
-h, --help help for update
-n, --namespace string Specify the namespace to operate in.
Expand Down
5 changes: 4 additions & 1 deletion pkg/kn/commands/trigger/update_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ func (f *TriggerUpdateFlags) GetUpdateFilters() (map[string]string, []string, er

// Add is to set parameters
func (f *TriggerUpdateFlags) Add(cmd *cobra.Command) {
cmd.Flags().StringVar(&f.Broker, "broker", "default", "Name of the Broker which the trigger associates with.")
if cmd.Name() != "update" {
// 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.
Expand Down
14 changes: 0 additions & 14 deletions pkg/kn/commands/trigger/update_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,20 +62,6 @@ func TestTriggerUpdateWithError(t *testing.T) {
eventingRecorder.Validate()
}

func TestTriggerUpdateInvalidBroker(t *testing.T) {
eventingClient := clienteventingv1.NewMockKnEventingClient(t)
eventingRecorder := eventingClient.Recorder()
present := createTrigger("default", triggerName, map[string]string{"type": "dev.knative.new"}, "mybroker", "newsvc")
eventingRecorder.GetTrigger(triggerName, present, nil)

out, err := executeTriggerCommand(eventingClient, nil, "update", triggerName,
"--broker", "newbroker")
assert.ErrorContains(t, err, "broker is immutable")
assert.Assert(t, util.ContainsAll(out, "Usage", triggerName))

eventingRecorder.Validate()
}

func TestTriggerUpdateDeletionTimestampNotNil(t *testing.T) {
eventingClient := clienteventingv1.NewMockKnEventingClient(t)

Expand Down
Loading