diff --git a/docs/cmd/kn_source_apiserver_create.md b/docs/cmd/kn_source_apiserver_create.md index fda6dcc546..39511d5489 100644 --- a/docs/cmd/kn_source_apiserver_create.md +++ b/docs/cmd/kn_source_apiserver_create.md @@ -26,8 +26,8 @@ kn source apiserver create NAME --resource RESOURCE --service-account ACCOUNTNAM "Reference" sends only the reference to the resource, "Resource" send the full resource. (default "Reference") -n, --namespace string Specify the namespace to operate in. - --resource stringArray Specification for which events to listen, in the format Kind:APIVersion:isController, e.g. "Event:v1:true". - "isController" can be omitted and is "false" by default, e.g. "Event:v1". + --resource stringArray Specification for which events to listen, in the format Kind:APIVersion:LabelSelector, e.g. "Event:v1:key=value". + "LabelSelector" is a list of comma separated key value pairs. "LabelSelector" can be omitted, e.g. "Event:v1". --service-account string Name of the service account to use to run this source -s, --sink string Addressable sink for events ``` diff --git a/docs/cmd/kn_source_apiserver_update.md b/docs/cmd/kn_source_apiserver_update.md index 82fac73ac0..8d4acebc5a 100644 --- a/docs/cmd/kn_source_apiserver_update.md +++ b/docs/cmd/kn_source_apiserver_update.md @@ -26,8 +26,8 @@ kn source apiserver update NAME --resource RESOURCE --service-account ACCOUNTNAM "Reference" sends only the reference to the resource, "Resource" send the full resource. (default "Reference") -n, --namespace string Specify the namespace to operate in. - --resource stringArray Specification for which events to listen, in the format Kind:APIVersion:isController, e.g. "Event:v1:true". - "isController" can be omitted and is "false" by default, e.g. "Event:v1". + --resource stringArray Specification for which events to listen, in the format Kind:APIVersion:LabelSelector, e.g. "Event:v1:key=value". + "LabelSelector" is a list of comma separated key value pairs. "LabelSelector" can be omitted, e.g. "Event:v1". --service-account string Name of the service account to use to run this source -s, --sink string Addressable sink for events ``` diff --git a/pkg/kn/commands/source/apiserver/apiserver_test.go b/pkg/kn/commands/source/apiserver/apiserver_test.go index c3444ea438..8e9d247823 100644 --- a/pkg/kn/commands/source/apiserver/apiserver_test.go +++ b/pkg/kn/commands/source/apiserver/apiserver_test.go @@ -83,7 +83,7 @@ func cleanupAPIServerMockClient() { apiServerSourceClientFactory = nil } -func createAPIServerSource(name, resourceKind, resourceVersion, serviceAccount, mode, service string, isController bool) *v1alpha2.ApiServerSource { +func createAPIServerSource(name, resourceKind, resourceVersion, serviceAccount, mode, service string) *v1alpha2.ApiServerSource { resources := []v1alpha2.APIVersionKindSelector{{ APIVersion: resourceVersion, Kind: resourceKind, diff --git a/pkg/kn/commands/source/apiserver/create_test.go b/pkg/kn/commands/source/apiserver/create_test.go index 06b58cb707..619cd1cf5c 100644 --- a/pkg/kn/commands/source/apiserver/create_test.go +++ b/pkg/kn/commands/source/apiserver/create_test.go @@ -35,7 +35,7 @@ func TestCreateApiServerSource(t *testing.T) { apiServerClient := v1alpha2.NewMockKnAPIServerSourceClient(t) apiServerRecorder := apiServerClient.Recorder() - apiServerRecorder.CreateAPIServerSource(createAPIServerSource("testsource", "Event", "v1", "testsa", "Reference", "testsvc", false), nil) + apiServerRecorder.CreateAPIServerSource(createAPIServerSource("testsource", "Event", "v1", "testsa", "Reference", "testsvc"), nil) out, err := executeAPIServerSourceCommand(apiServerClient, dynamicClient, "create", "testsource", "--resource", "Event:v1", "--service-account", "testsa", "--sink", "svc:testsvc", "--mode", "Reference") assert.NilError(t, err, "ApiServer source should be created") diff --git a/pkg/kn/commands/source/apiserver/describe_test.go b/pkg/kn/commands/source/apiserver/describe_test.go index 25abdc740a..ffa7ae6e5f 100644 --- a/pkg/kn/commands/source/apiserver/describe_test.go +++ b/pkg/kn/commands/source/apiserver/describe_test.go @@ -28,7 +28,7 @@ func TestSimpleDescribe(t *testing.T) { apiServerClient := v1alpha2.NewMockKnAPIServerSourceClient(t, "mynamespace") apiServerRecorder := apiServerClient.Recorder() - sampleSource := createAPIServerSource("testsource", "Event", "v1", "testsa", "Reference", "testsvc", false) + sampleSource := createAPIServerSource("testsource", "Event", "v1", "testsa", "Reference", "testsvc") apiServerRecorder.GetAPIServerSource("testsource", sampleSource, nil) out, err := executeAPIServerSourceCommand(apiServerClient, nil, "describe", "testsource") diff --git a/pkg/kn/commands/source/apiserver/flags.go b/pkg/kn/commands/source/apiserver/flags.go index 446a334371..b576753ad2 100644 --- a/pkg/kn/commands/source/apiserver/flags.go +++ b/pkg/kn/commands/source/apiserver/flags.go @@ -159,8 +159,8 @@ func (f *APIServerSourceUpdateFlags) Add(cmd *cobra.Command) { cmd.Flags().StringArrayVar(&f.Resources, "resource", []string{}, - `Specification for which events to listen, in the format Kind:APIVersion:isController, e.g. "Event:v1:true". -"isController" can be omitted and is "false" by default, e.g. "Event:v1".`) + `Specification for which events to listen, in the format Kind:APIVersion:LabelSelector, e.g. "Event:v1:key=value". +"LabelSelector" is a list of comma separated key value pairs. "LabelSelector" can be omitted, e.g. "Event:v1".`) } // APIServerSourceListHandlers handles printing human readable table for `kn source apiserver list` command's output diff --git a/pkg/kn/commands/source/apiserver/flags_test.go b/pkg/kn/commands/source/apiserver/flags_test.go index 7f4b7d00ac..0ba56a221b 100644 --- a/pkg/kn/commands/source/apiserver/flags_test.go +++ b/pkg/kn/commands/source/apiserver/flags_test.go @@ -39,7 +39,7 @@ func TestGetAPIServerResourceArray(t *testing.T) { assert.DeepEqual(t, wanted, created) }) - t.Run("get single apiserver resource when isController is default", func(t *testing.T) { + t.Run("get single apiserver resource without label selector", func(t *testing.T) { createFlag := APIServerSourceUpdateFlags{ ServiceAccountName: "test-sa", Mode: "Reference", @@ -142,7 +142,6 @@ func TestGetUpdateAPIServerResourceArray(t *testing.T) { assert.DeepEqual(t, added, addwanted) assert.DeepEqual(t, removed, removewanted) - // default api version and isController createFlag = APIServerSourceUpdateFlags{ ServiceAccountName: "test-sa", Mode: "Resource", diff --git a/pkg/kn/commands/source/apiserver/list_test.go b/pkg/kn/commands/source/apiserver/list_test.go index b5419226b0..8aae3cf29e 100644 --- a/pkg/kn/commands/source/apiserver/list_test.go +++ b/pkg/kn/commands/source/apiserver/list_test.go @@ -29,7 +29,7 @@ func TestListAPIServerSource(t *testing.T) { apiServerClient := v1alpha22.NewMockKnAPIServerSourceClient(t) apiServerRecorder := apiServerClient.Recorder() - sampleSource := createAPIServerSource("testsource", "Event", "v1", "testsa", "Reference", "testsvc", false) + sampleSource := createAPIServerSource("testsource", "Event", "v1", "testsa", "Reference", "testsvc") sampleSourceList := v1alpha2.ApiServerSourceList{} sampleSourceList.Items = []v1alpha2.ApiServerSource{*sampleSource} diff --git a/pkg/kn/commands/source/apiserver/update_test.go b/pkg/kn/commands/source/apiserver/update_test.go index 2b0d9ee49c..932704a34e 100644 --- a/pkg/kn/commands/source/apiserver/update_test.go +++ b/pkg/kn/commands/source/apiserver/update_test.go @@ -37,10 +37,10 @@ func TestApiServerSourceUpdate(t *testing.T) { apiServerRecorder := apiServerClient.Recorder() - present := createAPIServerSource("testsource", "Event", "v1", "testsa1", "Reference", "svc1", false) + present := createAPIServerSource("testsource", "Event", "v1", "testsa1", "Reference", "svc1") apiServerRecorder.GetAPIServerSource("testsource", present, nil) - updated := createAPIServerSource("testsource", "Event", "v1", "testsa2", "Reference", "svc2", false) + updated := createAPIServerSource("testsource", "Event", "v1", "testsa2", "Reference", "svc2") apiServerRecorder.UpdateAPIServerSource(updated, nil) output, err := executeAPIServerSourceCommand(apiServerClient, dynamicClient, "update", "testsource", "--service-account", "testsa2", "--sink", "svc:svc2") @@ -54,7 +54,7 @@ func TestApiServerSourceUpdateDeletionTimestampNotNil(t *testing.T) { apiServerClient := v1alpha2.NewMockKnAPIServerSourceClient(t) apiServerRecorder := apiServerClient.Recorder() - present := createAPIServerSource("testsource", "Event", "v1", "testsa1", "Ref", "svc1", false) + present := createAPIServerSource("testsource", "Event", "v1", "testsa1", "Ref", "svc1") present.DeletionTimestamp = &metav1.Time{Time: time.Now()} apiServerRecorder.GetAPIServerSource("testsource", present, nil)