Skip to content

Commit

Permalink
completed remove isController from apiserver source command group (kn…
Browse files Browse the repository at this point in the history
  • Loading branch information
Ying Chun Guo authored Apr 21, 2020
1 parent f936c93 commit a730e98
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 15 deletions.
4 changes: 2 additions & 2 deletions docs/cmd/kn_source_apiserver_create.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
Expand Down
4 changes: 2 additions & 2 deletions docs/cmd/kn_source_apiserver_update.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
Expand Down
2 changes: 1 addition & 1 deletion pkg/kn/commands/source/apiserver/apiserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion pkg/kn/commands/source/apiserver/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion pkg/kn/commands/source/apiserver/describe_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
4 changes: 2 additions & 2 deletions pkg/kn/commands/source/apiserver/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions pkg/kn/commands/source/apiserver/flags_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion pkg/kn/commands/source/apiserver/list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}

Expand Down
6 changes: 3 additions & 3 deletions pkg/kn/commands/source/apiserver/update_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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)

Expand Down

0 comments on commit a730e98

Please sign in to comment.