mirror of https://github.com/knative/client.git
completed remove isController from apiserver source command group (#817)
This commit is contained in:
parent
f936c93698
commit
a730e98802
|
|
@ -26,8 +26,8 @@ kn source apiserver create NAME --resource RESOURCE --service-account ACCOUNTNAM
|
||||||
"Reference" sends only the reference to the resource,
|
"Reference" sends only the reference to the resource,
|
||||||
"Resource" send the full resource. (default "Reference")
|
"Resource" send the full resource. (default "Reference")
|
||||||
-n, --namespace string Specify the namespace to operate in.
|
-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".
|
--resource stringArray Specification for which events to listen, in the format Kind:APIVersion:LabelSelector, e.g. "Event:v1:key=value".
|
||||||
"isController" can be omitted and is "false" by default, e.g. "Event:v1".
|
"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
|
--service-account string Name of the service account to use to run this source
|
||||||
-s, --sink string Addressable sink for events
|
-s, --sink string Addressable sink for events
|
||||||
```
|
```
|
||||||
|
|
|
||||||
|
|
@ -26,8 +26,8 @@ kn source apiserver update NAME --resource RESOURCE --service-account ACCOUNTNAM
|
||||||
"Reference" sends only the reference to the resource,
|
"Reference" sends only the reference to the resource,
|
||||||
"Resource" send the full resource. (default "Reference")
|
"Resource" send the full resource. (default "Reference")
|
||||||
-n, --namespace string Specify the namespace to operate in.
|
-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".
|
--resource stringArray Specification for which events to listen, in the format Kind:APIVersion:LabelSelector, e.g. "Event:v1:key=value".
|
||||||
"isController" can be omitted and is "false" by default, e.g. "Event:v1".
|
"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
|
--service-account string Name of the service account to use to run this source
|
||||||
-s, --sink string Addressable sink for events
|
-s, --sink string Addressable sink for events
|
||||||
```
|
```
|
||||||
|
|
|
||||||
|
|
@ -83,7 +83,7 @@ func cleanupAPIServerMockClient() {
|
||||||
apiServerSourceClientFactory = nil
|
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{{
|
resources := []v1alpha2.APIVersionKindSelector{{
|
||||||
APIVersion: resourceVersion,
|
APIVersion: resourceVersion,
|
||||||
Kind: resourceKind,
|
Kind: resourceKind,
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ func TestCreateApiServerSource(t *testing.T) {
|
||||||
apiServerClient := v1alpha2.NewMockKnAPIServerSourceClient(t)
|
apiServerClient := v1alpha2.NewMockKnAPIServerSourceClient(t)
|
||||||
|
|
||||||
apiServerRecorder := apiServerClient.Recorder()
|
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")
|
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")
|
assert.NilError(t, err, "ApiServer source should be created")
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ func TestSimpleDescribe(t *testing.T) {
|
||||||
apiServerClient := v1alpha2.NewMockKnAPIServerSourceClient(t, "mynamespace")
|
apiServerClient := v1alpha2.NewMockKnAPIServerSourceClient(t, "mynamespace")
|
||||||
|
|
||||||
apiServerRecorder := apiServerClient.Recorder()
|
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)
|
apiServerRecorder.GetAPIServerSource("testsource", sampleSource, nil)
|
||||||
|
|
||||||
out, err := executeAPIServerSourceCommand(apiServerClient, nil, "describe", "testsource")
|
out, err := executeAPIServerSourceCommand(apiServerClient, nil, "describe", "testsource")
|
||||||
|
|
|
||||||
|
|
@ -159,8 +159,8 @@ func (f *APIServerSourceUpdateFlags) Add(cmd *cobra.Command) {
|
||||||
cmd.Flags().StringArrayVar(&f.Resources,
|
cmd.Flags().StringArrayVar(&f.Resources,
|
||||||
"resource",
|
"resource",
|
||||||
[]string{},
|
[]string{},
|
||||||
`Specification for which events to listen, in the format Kind:APIVersion:isController, e.g. "Event:v1:true".
|
`Specification for which events to listen, in the format Kind:APIVersion:LabelSelector, e.g. "Event:v1:key=value".
|
||||||
"isController" can be omitted and is "false" by default, e.g. "Event:v1".`)
|
"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
|
// APIServerSourceListHandlers handles printing human readable table for `kn source apiserver list` command's output
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ func TestGetAPIServerResourceArray(t *testing.T) {
|
||||||
assert.DeepEqual(t, wanted, created)
|
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{
|
createFlag := APIServerSourceUpdateFlags{
|
||||||
ServiceAccountName: "test-sa",
|
ServiceAccountName: "test-sa",
|
||||||
Mode: "Reference",
|
Mode: "Reference",
|
||||||
|
|
@ -142,7 +142,6 @@ func TestGetUpdateAPIServerResourceArray(t *testing.T) {
|
||||||
assert.DeepEqual(t, added, addwanted)
|
assert.DeepEqual(t, added, addwanted)
|
||||||
assert.DeepEqual(t, removed, removewanted)
|
assert.DeepEqual(t, removed, removewanted)
|
||||||
|
|
||||||
// default api version and isController
|
|
||||||
createFlag = APIServerSourceUpdateFlags{
|
createFlag = APIServerSourceUpdateFlags{
|
||||||
ServiceAccountName: "test-sa",
|
ServiceAccountName: "test-sa",
|
||||||
Mode: "Resource",
|
Mode: "Resource",
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ func TestListAPIServerSource(t *testing.T) {
|
||||||
apiServerClient := v1alpha22.NewMockKnAPIServerSourceClient(t)
|
apiServerClient := v1alpha22.NewMockKnAPIServerSourceClient(t)
|
||||||
|
|
||||||
apiServerRecorder := apiServerClient.Recorder()
|
apiServerRecorder := apiServerClient.Recorder()
|
||||||
sampleSource := createAPIServerSource("testsource", "Event", "v1", "testsa", "Reference", "testsvc", false)
|
sampleSource := createAPIServerSource("testsource", "Event", "v1", "testsa", "Reference", "testsvc")
|
||||||
sampleSourceList := v1alpha2.ApiServerSourceList{}
|
sampleSourceList := v1alpha2.ApiServerSourceList{}
|
||||||
sampleSourceList.Items = []v1alpha2.ApiServerSource{*sampleSource}
|
sampleSourceList.Items = []v1alpha2.ApiServerSource{*sampleSource}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,10 +37,10 @@ func TestApiServerSourceUpdate(t *testing.T) {
|
||||||
|
|
||||||
apiServerRecorder := apiServerClient.Recorder()
|
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)
|
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)
|
apiServerRecorder.UpdateAPIServerSource(updated, nil)
|
||||||
|
|
||||||
output, err := executeAPIServerSourceCommand(apiServerClient, dynamicClient, "update", "testsource", "--service-account", "testsa2", "--sink", "svc:svc2")
|
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)
|
apiServerClient := v1alpha2.NewMockKnAPIServerSourceClient(t)
|
||||||
apiServerRecorder := apiServerClient.Recorder()
|
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()}
|
present.DeletionTimestamp = &metav1.Time{Time: time.Now()}
|
||||||
apiServerRecorder.GetAPIServerSource("testsource", present, nil)
|
apiServerRecorder.GetAPIServerSource("testsource", present, nil)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue