completed remove isController from apiserver source command group (#817)

This commit is contained in:
Ying Chun Guo 2020-04-21 23:43:08 +08:00 committed by GitHub
parent f936c93698
commit a730e98802
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 14 additions and 15 deletions

View File

@ -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
```

View File

@ -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
```

View File

@ -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,

View File

@ -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")

View File

@ -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")

View File

@ -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

View File

@ -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",

View File

@ -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}

View File

@ -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)