mirror of https://github.com/knative/client.git
refactor(source): Update to Knative eventing 0.13.0 (#705)
* chore(e2e): Optimized tests Smoke Tests now run before the E2E tests, but in the same cluster * chore: Removed unneeded test * fix * fix * fix * fix * chore: Update to serving & eventing v0.13.0 * refactor(source): Update to Knative eventing 0.13.0 * Moved to "sources.knative.dev" API group * Replaced CronJobSource with PingSource (and removed unsupported options for service account, requests limits) * Move to versions: - SinkBinding v1alpha2 - PingSource v1alpha2 - ApiServerSource v1alpha1 * update to eventing 0.13.1 * go.sum fix * fixed test * test updates * try to enhance error output * fix test. * update tests infra to 0.13.1
This commit is contained in:
parent
50a36b4ba7
commit
46d5e60e42
|
|
@ -18,8 +18,12 @@
|
||||||
|===
|
|===
|
||||||
| | Description | PR
|
| | Description | PR
|
||||||
|
|
||||||
|
| 🐣
|
||||||
|
| Replaced `kn source cron` with `kn source ping`. `--schedule` is not mandatory anymore and defaults to "* * * * *" (every minute)
|
||||||
|
| https://github.com/knative/client/issues/564[#564]
|
||||||
|
|
||||||
| ✨
|
| ✨
|
||||||
| Add serviceaccount and resources config to cronjob source handling
|
| Update to Knative serving 0.13.0 and Knative eventing 0.13.1
|
||||||
| https://github.com/knative/client/issues/564[#564]
|
| https://github.com/knative/client/issues/564[#564]
|
||||||
|
|
||||||
| ✨
|
| ✨
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,6 @@ kn source [flags]
|
||||||
* [kn](kn.md) - Knative client
|
* [kn](kn.md) - Knative client
|
||||||
* [kn source apiserver](kn_source_apiserver.md) - Kubernetes API Server Event Source command group
|
* [kn source apiserver](kn_source_apiserver.md) - Kubernetes API Server Event Source command group
|
||||||
* [kn source binding](kn_source_binding.md) - Sink binding command group
|
* [kn source binding](kn_source_binding.md) - Sink binding command group
|
||||||
* [kn source cronjob](kn_source_cronjob.md) - CronJob source command group
|
|
||||||
* [kn source list-types](kn_source_list-types.md) - List available source types
|
* [kn source list-types](kn_source_list-types.md) - List available source types
|
||||||
|
* [kn source ping](kn_source_ping.md) - Ping source command group
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,35 +0,0 @@
|
||||||
## kn source cronjob
|
|
||||||
|
|
||||||
CronJob source command group
|
|
||||||
|
|
||||||
### Synopsis
|
|
||||||
|
|
||||||
CronJob source command group
|
|
||||||
|
|
||||||
```
|
|
||||||
kn source cronjob [flags]
|
|
||||||
```
|
|
||||||
|
|
||||||
### Options
|
|
||||||
|
|
||||||
```
|
|
||||||
-h, --help help for cronjob
|
|
||||||
```
|
|
||||||
|
|
||||||
### Options inherited from parent commands
|
|
||||||
|
|
||||||
```
|
|
||||||
--config string kn config file (default is ~/.config/kn/config.yaml)
|
|
||||||
--kubeconfig string kubectl config file (default is ~/.kube/config)
|
|
||||||
--log-http log http traffic
|
|
||||||
```
|
|
||||||
|
|
||||||
### SEE ALSO
|
|
||||||
|
|
||||||
* [kn source](kn_source.md) - Event source command group
|
|
||||||
* [kn source cronjob create](kn_source_cronjob_create.md) - Create a CronJob source.
|
|
||||||
* [kn source cronjob delete](kn_source_cronjob_delete.md) - Delete a CronJob source.
|
|
||||||
* [kn source cronjob describe](kn_source_cronjob_describe.md) - Show details of a CronJob source
|
|
||||||
* [kn source cronjob list](kn_source_cronjob_list.md) - List CronJob sources.
|
|
||||||
* [kn source cronjob update](kn_source_cronjob_update.md) - Update a CronJob source.
|
|
||||||
|
|
||||||
|
|
@ -1,53 +0,0 @@
|
||||||
## kn source cronjob create
|
|
||||||
|
|
||||||
Create a CronJob source.
|
|
||||||
|
|
||||||
### Synopsis
|
|
||||||
|
|
||||||
Create a CronJob source.
|
|
||||||
|
|
||||||
```
|
|
||||||
kn source cronjob create NAME --schedule SCHEDULE --sink SINK --data DATA [flags]
|
|
||||||
```
|
|
||||||
|
|
||||||
### Examples
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
# Create a crontab scheduler 'my-cron-trigger' which fires every minute and sends 'ping' to service 'mysvc' as a cloudevent
|
|
||||||
kn source cronjob create my-cron-trigger --schedule "* * * * */1" --data "ping" --sink svc:mysvc
|
|
||||||
|
|
||||||
# Create a crontab scheduler 'my-cron-trigger' with ServiceAccount name
|
|
||||||
kn source cronjob create my-cron-trigger1 --schedule "* * * * */1" --data "ping" --sink svc:event-display --service-account myaccount
|
|
||||||
|
|
||||||
# Create a crontab scheduler 'my-cron-trigger' with requested resources
|
|
||||||
kn source cronjob create my-cron-trigger1 --schedule "* * * * */1" --data "ping" --sink svc:event-display --requests-cpu 100m --requests-memory 128Mi
|
|
||||||
```
|
|
||||||
|
|
||||||
### Options
|
|
||||||
|
|
||||||
```
|
|
||||||
-d, --data string String data to send
|
|
||||||
-h, --help help for create
|
|
||||||
--limits-cpu string The limits on the requested CPU (e.g., 1000m).
|
|
||||||
--limits-memory string The limits on the requested memory (e.g., 1024Mi).
|
|
||||||
-n, --namespace string Specify the namespace to operate in.
|
|
||||||
--requests-cpu string The requested CPU (e.g., 250m).
|
|
||||||
--requests-memory string The requested memory (e.g., 64Mi).
|
|
||||||
--schedule string Schedule specification in crontab format (e.g. '* * * * */2' for every two minutes
|
|
||||||
--service-account string Name of the service account to use to run this source
|
|
||||||
-s, --sink string Addressable sink for events
|
|
||||||
```
|
|
||||||
|
|
||||||
### Options inherited from parent commands
|
|
||||||
|
|
||||||
```
|
|
||||||
--config string kn config file (default is ~/.config/kn/config.yaml)
|
|
||||||
--kubeconfig string kubectl config file (default is ~/.kube/config)
|
|
||||||
--log-http log http traffic
|
|
||||||
```
|
|
||||||
|
|
||||||
### SEE ALSO
|
|
||||||
|
|
||||||
* [kn source cronjob](kn_source_cronjob.md) - CronJob source command group
|
|
||||||
|
|
||||||
|
|
@ -1,47 +0,0 @@
|
||||||
## kn source cronjob update
|
|
||||||
|
|
||||||
Update a CronJob source.
|
|
||||||
|
|
||||||
### Synopsis
|
|
||||||
|
|
||||||
Update a CronJob source.
|
|
||||||
|
|
||||||
```
|
|
||||||
kn source cronjob update NAME --schedule SCHEDULE --sink SERVICE --data DATA [flags]
|
|
||||||
```
|
|
||||||
|
|
||||||
### Examples
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
# Update the schedule of a crontab source 'my-cron-trigger' to fire every minute
|
|
||||||
kn source cronjob update my-cron-trigger --schedule "* * * * */1"
|
|
||||||
```
|
|
||||||
|
|
||||||
### Options
|
|
||||||
|
|
||||||
```
|
|
||||||
-d, --data string String data to send
|
|
||||||
-h, --help help for update
|
|
||||||
--limits-cpu string The limits on the requested CPU (e.g., 1000m).
|
|
||||||
--limits-memory string The limits on the requested memory (e.g., 1024Mi).
|
|
||||||
-n, --namespace string Specify the namespace to operate in.
|
|
||||||
--requests-cpu string The requested CPU (e.g., 250m).
|
|
||||||
--requests-memory string The requested memory (e.g., 64Mi).
|
|
||||||
--schedule string Schedule specification in crontab format (e.g. '* * * * */2' for every two minutes
|
|
||||||
--service-account string Name of the service account to use to run this source
|
|
||||||
-s, --sink string Addressable sink for events
|
|
||||||
```
|
|
||||||
|
|
||||||
### Options inherited from parent commands
|
|
||||||
|
|
||||||
```
|
|
||||||
--config string kn config file (default is ~/.config/kn/config.yaml)
|
|
||||||
--kubeconfig string kubectl config file (default is ~/.kube/config)
|
|
||||||
--log-http log http traffic
|
|
||||||
```
|
|
||||||
|
|
||||||
### SEE ALSO
|
|
||||||
|
|
||||||
* [kn source cronjob](kn_source_cronjob.md) - CronJob source command group
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,35 @@
|
||||||
|
## kn source ping
|
||||||
|
|
||||||
|
Ping source command group
|
||||||
|
|
||||||
|
### Synopsis
|
||||||
|
|
||||||
|
Ping source command group
|
||||||
|
|
||||||
|
```
|
||||||
|
kn source ping [flags]
|
||||||
|
```
|
||||||
|
|
||||||
|
### Options
|
||||||
|
|
||||||
|
```
|
||||||
|
-h, --help help for ping
|
||||||
|
```
|
||||||
|
|
||||||
|
### Options inherited from parent commands
|
||||||
|
|
||||||
|
```
|
||||||
|
--config string kn config file (default is ~/.config/kn/config.yaml)
|
||||||
|
--kubeconfig string kubectl config file (default is ~/.kube/config)
|
||||||
|
--log-http log http traffic
|
||||||
|
```
|
||||||
|
|
||||||
|
### SEE ALSO
|
||||||
|
|
||||||
|
* [kn source](kn_source.md) - Event source command group
|
||||||
|
* [kn source ping create](kn_source_ping_create.md) - Create a Ping source.
|
||||||
|
* [kn source ping delete](kn_source_ping_delete.md) - Delete a Ping source.
|
||||||
|
* [kn source ping describe](kn_source_ping_describe.md) - Show details of a Ping source
|
||||||
|
* [kn source ping list](kn_source_ping_list.md) - List Ping sources.
|
||||||
|
* [kn source ping update](kn_source_ping_update.md) - Update a Ping source.
|
||||||
|
|
||||||
|
|
@ -0,0 +1,42 @@
|
||||||
|
## kn source ping create
|
||||||
|
|
||||||
|
Create a Ping source.
|
||||||
|
|
||||||
|
### Synopsis
|
||||||
|
|
||||||
|
Create a Ping source.
|
||||||
|
|
||||||
|
```
|
||||||
|
kn source ping create NAME --schedule SCHEDULE --sink SINK --data DATA [flags]
|
||||||
|
```
|
||||||
|
|
||||||
|
### Examples
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
# Create a Ping source 'my-ping' which fires every two minutes and sends '{ value: "hello" }' to service 'mysvc' as a cloudevent
|
||||||
|
kn source ping create my-ping --schedule "*/2 * * * *" --data '{ value: "hello" }' --sink svc:mysvc
|
||||||
|
```
|
||||||
|
|
||||||
|
### Options
|
||||||
|
|
||||||
|
```
|
||||||
|
-d, --data string Json data to send
|
||||||
|
-h, --help help for create
|
||||||
|
-n, --namespace string Specify the namespace to operate in.
|
||||||
|
--schedule string Optional schedule specification in crontab format (e.g. '*/2 * * * *' for every two minutes. By default fire every minute.
|
||||||
|
-s, --sink string Addressable sink for events
|
||||||
|
```
|
||||||
|
|
||||||
|
### Options inherited from parent commands
|
||||||
|
|
||||||
|
```
|
||||||
|
--config string kn config file (default is ~/.config/kn/config.yaml)
|
||||||
|
--kubeconfig string kubectl config file (default is ~/.kube/config)
|
||||||
|
--log-http log http traffic
|
||||||
|
```
|
||||||
|
|
||||||
|
### SEE ALSO
|
||||||
|
|
||||||
|
* [kn source ping](kn_source_ping.md) - Ping source command group
|
||||||
|
|
||||||
|
|
@ -1,21 +1,21 @@
|
||||||
## kn source cronjob delete
|
## kn source ping delete
|
||||||
|
|
||||||
Delete a CronJob source.
|
Delete a Ping source.
|
||||||
|
|
||||||
### Synopsis
|
### Synopsis
|
||||||
|
|
||||||
Delete a CronJob source.
|
Delete a Ping source.
|
||||||
|
|
||||||
```
|
```
|
||||||
kn source cronjob delete NAME [flags]
|
kn source ping delete NAME [flags]
|
||||||
```
|
```
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
# Delete a CronJob source 'my-cron-trigger'
|
# Delete a Ping source 'my-ping'
|
||||||
kn source cronjob delete my-cron-trigger
|
kn source ping delete my-ping
|
||||||
```
|
```
|
||||||
|
|
||||||
### Options
|
### Options
|
||||||
|
|
@ -35,5 +35,5 @@ kn source cronjob delete NAME [flags]
|
||||||
|
|
||||||
### SEE ALSO
|
### SEE ALSO
|
||||||
|
|
||||||
* [kn source cronjob](kn_source_cronjob.md) - CronJob source command group
|
* [kn source ping](kn_source_ping.md) - Ping source command group
|
||||||
|
|
||||||
|
|
@ -1,21 +1,21 @@
|
||||||
## kn source cronjob describe
|
## kn source ping describe
|
||||||
|
|
||||||
Show details of a CronJob source
|
Show details of a Ping source
|
||||||
|
|
||||||
### Synopsis
|
### Synopsis
|
||||||
|
|
||||||
Show details of a CronJob source
|
Show details of a Ping source
|
||||||
|
|
||||||
```
|
```
|
||||||
kn source cronjob describe NAME [flags]
|
kn source ping describe NAME [flags]
|
||||||
```
|
```
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
# Describe a cronjob source with name 'mycronjob'
|
# Describe a Ping source with name 'myping'
|
||||||
kn source cronjob describe mycronjob
|
kn source ping describe myping
|
||||||
```
|
```
|
||||||
|
|
||||||
### Options
|
### Options
|
||||||
|
|
@ -36,5 +36,5 @@ kn source cronjob describe NAME [flags]
|
||||||
|
|
||||||
### SEE ALSO
|
### SEE ALSO
|
||||||
|
|
||||||
* [kn source cronjob](kn_source_cronjob.md) - CronJob source command group
|
* [kn source ping](kn_source_ping.md) - Ping source command group
|
||||||
|
|
||||||
|
|
@ -1,24 +1,24 @@
|
||||||
## kn source cronjob list
|
## kn source ping list
|
||||||
|
|
||||||
List CronJob sources.
|
List Ping sources.
|
||||||
|
|
||||||
### Synopsis
|
### Synopsis
|
||||||
|
|
||||||
List CronJob sources.
|
List Ping sources.
|
||||||
|
|
||||||
```
|
```
|
||||||
kn source cronjob list [flags]
|
kn source ping list [flags]
|
||||||
```
|
```
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
# List all CronJob sources
|
# List all Ping sources
|
||||||
kn source cronjob list
|
kn source ping list
|
||||||
|
|
||||||
# List all CronJob sources in YAML format
|
# List all Ping sources in YAML format
|
||||||
kn source cronjob list -o yaml
|
kn source ping list -o yaml
|
||||||
```
|
```
|
||||||
|
|
||||||
### Options
|
### Options
|
||||||
|
|
@ -43,5 +43,5 @@ kn source cronjob list [flags]
|
||||||
|
|
||||||
### SEE ALSO
|
### SEE ALSO
|
||||||
|
|
||||||
* [kn source cronjob](kn_source_cronjob.md) - CronJob source command group
|
* [kn source ping](kn_source_ping.md) - Ping source command group
|
||||||
|
|
||||||
|
|
@ -0,0 +1,42 @@
|
||||||
|
## kn source ping update
|
||||||
|
|
||||||
|
Update a Ping source.
|
||||||
|
|
||||||
|
### Synopsis
|
||||||
|
|
||||||
|
Update a Ping source.
|
||||||
|
|
||||||
|
```
|
||||||
|
kn source ping update NAME --schedule SCHEDULE --sink SERVICE --data DATA [flags]
|
||||||
|
```
|
||||||
|
|
||||||
|
### Examples
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
# Update the schedule of a Ping source 'my-ping' to fire every minute
|
||||||
|
kn source ping update my-ping --schedule "* * * * *"
|
||||||
|
```
|
||||||
|
|
||||||
|
### Options
|
||||||
|
|
||||||
|
```
|
||||||
|
-d, --data string Json data to send
|
||||||
|
-h, --help help for update
|
||||||
|
-n, --namespace string Specify the namespace to operate in.
|
||||||
|
--schedule string Optional schedule specification in crontab format (e.g. '*/2 * * * *' for every two minutes. By default fire every minute.
|
||||||
|
-s, --sink string Addressable sink for events
|
||||||
|
```
|
||||||
|
|
||||||
|
### Options inherited from parent commands
|
||||||
|
|
||||||
|
```
|
||||||
|
--config string kn config file (default is ~/.config/kn/config.yaml)
|
||||||
|
--kubeconfig string kubectl config file (default is ~/.kube/config)
|
||||||
|
--log-http log http traffic
|
||||||
|
```
|
||||||
|
|
||||||
|
### SEE ALSO
|
||||||
|
|
||||||
|
* [kn source ping](kn_source_ping.md) - Ping source command group
|
||||||
|
|
||||||
10
go.mod
10
go.mod
|
|
@ -4,9 +4,8 @@ require (
|
||||||
contrib.go.opencensus.io/exporter/ocagent v0.6.0 // indirect
|
contrib.go.opencensus.io/exporter/ocagent v0.6.0 // indirect
|
||||||
contrib.go.opencensus.io/exporter/prometheus v0.1.0 // indirect
|
contrib.go.opencensus.io/exporter/prometheus v0.1.0 // indirect
|
||||||
contrib.go.opencensus.io/exporter/stackdriver v0.13.0 // indirect
|
contrib.go.opencensus.io/exporter/stackdriver v0.13.0 // indirect
|
||||||
github.com/google/go-containerregistry v0.0.0-20200212224832-c629a66d7231 // indirect
|
github.com/google/go-containerregistry v0.0.0-20200304201134-fcc8ea80e26f // indirect
|
||||||
github.com/magiconair/properties v1.8.0
|
github.com/magiconair/properties v1.8.0
|
||||||
github.com/mattbaird/jsonpatch v0.0.0-20171005235357-81af80346b1a // indirect
|
|
||||||
github.com/mitchellh/go-homedir v1.1.0
|
github.com/mitchellh/go-homedir v1.1.0
|
||||||
github.com/openzipkin/zipkin-go v0.2.2 // indirect
|
github.com/openzipkin/zipkin-go v0.2.2 // indirect
|
||||||
github.com/pkg/errors v0.8.1
|
github.com/pkg/errors v0.8.1
|
||||||
|
|
@ -15,14 +14,15 @@ require (
|
||||||
github.com/spf13/pflag v1.0.5
|
github.com/spf13/pflag v1.0.5
|
||||||
github.com/spf13/viper v1.4.0
|
github.com/spf13/viper v1.4.0
|
||||||
golang.org/x/crypto v0.0.0-20191206172530-e9b2fee46413
|
golang.org/x/crypto v0.0.0-20191206172530-e9b2fee46413
|
||||||
|
gomodules.xyz/jsonpatch/v2 v2.1.0 // indirect
|
||||||
gotest.tools v2.2.0+incompatible
|
gotest.tools v2.2.0+incompatible
|
||||||
k8s.io/api v0.17.0
|
k8s.io/api v0.17.0
|
||||||
k8s.io/apimachinery v0.17.0
|
k8s.io/apimachinery v0.17.0
|
||||||
k8s.io/cli-runtime v0.17.0
|
k8s.io/cli-runtime v0.17.0
|
||||||
k8s.io/client-go v0.17.0
|
k8s.io/client-go v0.17.0
|
||||||
knative.dev/eventing v0.12.1-0.20200206203632-b0a7d8a77cc7
|
knative.dev/eventing v0.13.1
|
||||||
knative.dev/pkg v0.0.0-20200206191432-9072f494c940
|
knative.dev/pkg v0.0.0-20200304185554-312b1be35ceb
|
||||||
knative.dev/serving v0.12.1-0.20200206201132-525b15d87dc1
|
knative.dev/serving v0.13.0
|
||||||
knative.dev/test-infra v0.0.0-20200229011351-4dac123b9a3d
|
knative.dev/test-infra v0.0.0-20200229011351-4dac123b9a3d
|
||||||
sigs.k8s.io/yaml v1.1.0
|
sigs.k8s.io/yaml v1.1.0
|
||||||
)
|
)
|
||||||
|
|
|
||||||
35
go.sum
35
go.sum
|
|
@ -107,6 +107,8 @@ github.com/emicklei/go-restful v2.9.5+incompatible/go.mod h1:otzb+WCGbkyDHkqmQmT
|
||||||
github.com/envoyproxy/go-control-plane v0.6.9/go.mod h1:SBwIajubJHhxtWwsL9s8ss4safvEdbitLhGGK48rN6g=
|
github.com/envoyproxy/go-control-plane v0.6.9/go.mod h1:SBwIajubJHhxtWwsL9s8ss4safvEdbitLhGGK48rN6g=
|
||||||
github.com/evanphx/json-patch v4.2.0+incompatible h1:fUDGZCv/7iAN7u0puUVhvKCcsR6vRfwrJatElLBEf0I=
|
github.com/evanphx/json-patch v4.2.0+incompatible h1:fUDGZCv/7iAN7u0puUVhvKCcsR6vRfwrJatElLBEf0I=
|
||||||
github.com/evanphx/json-patch v4.2.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk=
|
github.com/evanphx/json-patch v4.2.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk=
|
||||||
|
github.com/evanphx/json-patch v4.5.0+incompatible h1:ouOWdg56aJriqS0huScTkVXPC5IcNrDCXZ6OoTAWu7M=
|
||||||
|
github.com/evanphx/json-patch v4.5.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk=
|
||||||
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
|
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
|
||||||
github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
|
github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
|
||||||
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||||
|
|
@ -116,6 +118,7 @@ github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeME
|
||||||
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
||||||
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
|
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
|
||||||
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
|
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
|
||||||
|
github.com/go-logr/logr v0.1.0 h1:M1Tv3VzNlEHg6uyACnRdtrploV2P7wZqH8BoQMtz0cg=
|
||||||
github.com/go-logr/logr v0.1.0/go.mod h1:ixOQHD9gLJUVQQ2ZOR7zLEifBX6tGkNJF4QyIY7sIas=
|
github.com/go-logr/logr v0.1.0/go.mod h1:ixOQHD9gLJUVQQ2ZOR7zLEifBX6tGkNJF4QyIY7sIas=
|
||||||
github.com/go-openapi/jsonpointer v0.0.0-20160704185906-46af16f9f7b1/go.mod h1:+35s3my2LFTysnkMfxsJBAMHj/DoqoB9knIWoYG/Vk0=
|
github.com/go-openapi/jsonpointer v0.0.0-20160704185906-46af16f9f7b1/go.mod h1:+35s3my2LFTysnkMfxsJBAMHj/DoqoB9knIWoYG/Vk0=
|
||||||
github.com/go-openapi/jsonpointer v0.19.2/go.mod h1:3akKfEdA7DF1sugOqz1dVQHBcuDBPKZGEoHC/NkiQRg=
|
github.com/go-openapi/jsonpointer v0.19.2/go.mod h1:3akKfEdA7DF1sugOqz1dVQHBcuDBPKZGEoHC/NkiQRg=
|
||||||
|
|
@ -163,8 +166,8 @@ github.com/google/go-cmp v0.3.0 h1:crn/baboCvb5fXaQ0IJ1SGTsTVrWpDsCWC8EGETZijY=
|
||||||
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||||
github.com/google/go-cmp v0.3.1 h1:Xye71clBPdm5HgqGwUkwhbynsUJZhDbS20FvLhQ2izg=
|
github.com/google/go-cmp v0.3.1 h1:Xye71clBPdm5HgqGwUkwhbynsUJZhDbS20FvLhQ2izg=
|
||||||
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||||
github.com/google/go-containerregistry v0.0.0-20200212224832-c629a66d7231 h1:zoj6E1dzY9aeZw1CGJv1hffxgyunrLpjI0SZWK7ynzg=
|
github.com/google/go-containerregistry v0.0.0-20200304201134-fcc8ea80e26f h1:tc00QCOHwGF/IyStWQnJN7zmrPP9LBJTKyulXzApCfw=
|
||||||
github.com/google/go-containerregistry v0.0.0-20200212224832-c629a66d7231/go.mod h1:Wtl/v6YdQxv397EREtzwgd9+Ud7Q5D8XMbi3Zazgkrs=
|
github.com/google/go-containerregistry v0.0.0-20200304201134-fcc8ea80e26f/go.mod h1:m8YvHwSOuBCq25yrj1DaX/fIMrv6ec3CNg8jY8+5PEA=
|
||||||
github.com/google/gofuzz v0.0.0-20161122191042-44d81051d367/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI=
|
github.com/google/gofuzz v0.0.0-20161122191042-44d81051d367/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI=
|
||||||
github.com/google/gofuzz v1.0.0 h1:A8PeW59pxE9IoFRqBp37U+mSNaQoZ46F1f0f863XSXw=
|
github.com/google/gofuzz v1.0.0 h1:A8PeW59pxE9IoFRqBp37U+mSNaQoZ46F1f0f863XSXw=
|
||||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||||
|
|
@ -243,8 +246,6 @@ github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN
|
||||||
github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
|
github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
|
||||||
github.com/mailru/easyjson v0.7.0 h1:aizVhC/NAAcKWb+5QsU1iNOZb4Yws5UO2I+aIprQITM=
|
github.com/mailru/easyjson v0.7.0 h1:aizVhC/NAAcKWb+5QsU1iNOZb4Yws5UO2I+aIprQITM=
|
||||||
github.com/mailru/easyjson v0.7.0/go.mod h1:KAzv3t3aY1NaHWoQz1+4F1ccyAH66Jk7yos7ldAVICs=
|
github.com/mailru/easyjson v0.7.0/go.mod h1:KAzv3t3aY1NaHWoQz1+4F1ccyAH66Jk7yos7ldAVICs=
|
||||||
github.com/mattbaird/jsonpatch v0.0.0-20171005235357-81af80346b1a h1:+J2gw7Bw77w/fbK7wnNJJDKmw1IbWft2Ul5BzrG1Qm8=
|
|
||||||
github.com/mattbaird/jsonpatch v0.0.0-20171005235357-81af80346b1a/go.mod h1:M1qoD/MqPgTZIk0EWKB38wE28ACRfVcn+cU08jyArI0=
|
|
||||||
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
|
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
|
||||||
github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
|
github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
|
||||||
github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
|
github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
|
||||||
|
|
@ -400,9 +401,10 @@ golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvx
|
||||||
golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||||
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||||
golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||||
golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs=
|
golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
|
||||||
golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE=
|
golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE=
|
||||||
golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc=
|
golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc=
|
||||||
|
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee h1:WG0RUwxtNT4qqaXX3DPA8zHFNm/D9xaBpxzHt1WcA/E=
|
||||||
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
|
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
|
||||||
golang.org/x/net v0.0.0-20170114055629-f2499483f923/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
golang.org/x/net v0.0.0-20170114055629-f2499483f923/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
|
|
@ -490,11 +492,14 @@ golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgw
|
||||||
golang.org/x/tools v0.0.0-20190706070813-72ffa07ba3db/go.mod h1:jcCCGcm9btYwXyDqrUWc6MKQKKGJCWEQ3AfLSRIbEuI=
|
golang.org/x/tools v0.0.0-20190706070813-72ffa07ba3db/go.mod h1:jcCCGcm9btYwXyDqrUWc6MKQKKGJCWEQ3AfLSRIbEuI=
|
||||||
golang.org/x/tools v0.0.0-20190920225731-5eefd052ad72/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
golang.org/x/tools v0.0.0-20190920225731-5eefd052ad72/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||||
golang.org/x/tools v0.0.0-20191010075000-0337d82405ff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
golang.org/x/tools v0.0.0-20191010075000-0337d82405ff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||||
golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||||
golang.org/x/tools v0.0.0-20200115165105-de0b1760071a h1:bEJ3JL2YUH3tt9KX9dsy0WUF3WOrhjtNjK93o0svepY=
|
golang.org/x/tools v0.0.0-20200210192313-1ace956b0e17 h1:a/Fd23DJvg1CaeDH0dYHahE+hCI0v9rFgxSNIThoUcM=
|
||||||
golang.org/x/tools v0.0.0-20200115165105-de0b1760071a/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
golang.org/x/tools v0.0.0-20200210192313-1ace956b0e17/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
|
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898 h1:/atklqdjdhuosWIl6AIbOeHJjicWYPqR9bpxqxYG2pA=
|
||||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
|
gomodules.xyz/jsonpatch/v2 v2.1.0 h1:Phva6wqu+xR//Njw6iorylFFgn/z547tw5Ne3HZPQ+k=
|
||||||
|
gomodules.xyz/jsonpatch/v2 v2.1.0/go.mod h1:IhYNNY4jnS53ZnfE4PAmpKtDpTCj1JFXc+3mwe7XcUU=
|
||||||
gonum.org/v1/gonum v0.0.0-20190331200053-3d26580ed485/go.mod h1:2ltnJ7xHfj0zHS40VVPYEAAMTa3ZGguvHGBSJeRWqE0=
|
gonum.org/v1/gonum v0.0.0-20190331200053-3d26580ed485/go.mod h1:2ltnJ7xHfj0zHS40VVPYEAAMTa3ZGguvHGBSJeRWqE0=
|
||||||
gonum.org/v1/netlib v0.0.0-20190313105609-8cb42192e0e0/go.mod h1:wa6Ws7BG/ESfp6dHfk7C6KdzKA7wR7u/rKwOGE66zvw=
|
gonum.org/v1/netlib v0.0.0-20190313105609-8cb42192e0e0/go.mod h1:wa6Ws7BG/ESfp6dHfk7C6KdzKA7wR7u/rKwOGE66zvw=
|
||||||
gonum.org/v1/netlib v0.0.0-20190331212654-76723241ea4e/go.mod h1:kS+toOQn6AQKjmKJ7gzohV1XkqsFehRA2FbsbkopSuQ=
|
gonum.org/v1/netlib v0.0.0-20190331212654-76723241ea4e/go.mod h1:kS+toOQn6AQKjmKJ7gzohV1XkqsFehRA2FbsbkopSuQ=
|
||||||
|
|
@ -573,7 +578,7 @@ k8s.io/cli-runtime v0.17.0/go.mod h1:1E5iQpMODZq2lMWLUJELwRu2MLWIzwvMgDBpn3Y81Qo
|
||||||
k8s.io/client-go v0.17.0 h1:8QOGvUGdqDMFrm9sD6IUFl256BcffynGoe80sxgTEDg=
|
k8s.io/client-go v0.17.0 h1:8QOGvUGdqDMFrm9sD6IUFl256BcffynGoe80sxgTEDg=
|
||||||
k8s.io/client-go v0.17.0/go.mod h1:TYgR6EUHs6k45hb6KWjVD6jFZvJV4gHDikv/It0xz+k=
|
k8s.io/client-go v0.17.0/go.mod h1:TYgR6EUHs6k45hb6KWjVD6jFZvJV4gHDikv/It0xz+k=
|
||||||
k8s.io/cloud-provider v0.17.0/go.mod h1:Ze4c3w2C0bRsjkBUoHpFi+qWe3ob1wI2/7cUn+YQIDE=
|
k8s.io/cloud-provider v0.17.0/go.mod h1:Ze4c3w2C0bRsjkBUoHpFi+qWe3ob1wI2/7cUn+YQIDE=
|
||||||
k8s.io/code-generator v0.17.1/go.mod h1:DVmfPQgxQENqDIzVR2ddLXMH34qeszkKSdH/N+s+38s=
|
k8s.io/code-generator v0.17.2/go.mod h1:DVmfPQgxQENqDIzVR2ddLXMH34qeszkKSdH/N+s+38s=
|
||||||
k8s.io/component-base v0.17.0/go.mod h1:rKuRAokNMY2nn2A6LP/MiwpoaMRHpfRnrPaUJJj1Yoc=
|
k8s.io/component-base v0.17.0/go.mod h1:rKuRAokNMY2nn2A6LP/MiwpoaMRHpfRnrPaUJJj1Yoc=
|
||||||
k8s.io/csi-translation-lib v0.17.0/go.mod h1:HEF7MEz7pOLJCnxabi45IPkhSsE/KmxPQksuCrHKWls=
|
k8s.io/csi-translation-lib v0.17.0/go.mod h1:HEF7MEz7pOLJCnxabi45IPkhSsE/KmxPQksuCrHKWls=
|
||||||
k8s.io/gengo v0.0.0-20190128074634-0689ccc1d7d6/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0=
|
k8s.io/gengo v0.0.0-20190128074634-0689ccc1d7d6/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0=
|
||||||
|
|
@ -587,12 +592,12 @@ k8s.io/kube-openapi v0.0.0-20191107075043-30be4d16710a/go.mod h1:1TqjTSzOxsLGIKf
|
||||||
k8s.io/legacy-cloud-providers v0.17.0/go.mod h1:DdzaepJ3RtRy+e5YhNtrCYwlgyK87j/5+Yfp0L9Syp8=
|
k8s.io/legacy-cloud-providers v0.17.0/go.mod h1:DdzaepJ3RtRy+e5YhNtrCYwlgyK87j/5+Yfp0L9Syp8=
|
||||||
k8s.io/utils v0.0.0-20191114184206-e782cd3c129f h1:GiPwtSzdP43eI1hpPCbROQCCIgCuiMMNF8YUVLF3vJo=
|
k8s.io/utils v0.0.0-20191114184206-e782cd3c129f h1:GiPwtSzdP43eI1hpPCbROQCCIgCuiMMNF8YUVLF3vJo=
|
||||||
k8s.io/utils v0.0.0-20191114184206-e782cd3c129f/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew=
|
k8s.io/utils v0.0.0-20191114184206-e782cd3c129f/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew=
|
||||||
knative.dev/eventing v0.12.1-0.20200206203632-b0a7d8a77cc7 h1:U19nb8snRDKxIhyl0B/SVcTCkv8lF7cEPr1oesfxO7E=
|
knative.dev/eventing v0.13.1 h1:2jnxea7XtqFX8dMFu9cZ7ocMuQV5ZnXX+6tLF6AbYGo=
|
||||||
knative.dev/eventing v0.12.1-0.20200206203632-b0a7d8a77cc7/go.mod h1:UxweNv8yXhsdHJitcb9R6rmfNaUD2DFi9GWwNRyIs58=
|
knative.dev/eventing v0.13.1/go.mod h1:UxweNv8yXhsdHJitcb9R6rmfNaUD2DFi9GWwNRyIs58=
|
||||||
knative.dev/pkg v0.0.0-20200206191432-9072f494c940 h1:bbmIixxihewJeoxolF7jRgSzERXW1hR+XnNujVqjVpk=
|
knative.dev/pkg v0.0.0-20200304185554-312b1be35ceb h1:cgpFaVF0jb7z+zJGzq30HMfxMmWwX5WEnkMZ9EHli7I=
|
||||||
knative.dev/pkg v0.0.0-20200206191432-9072f494c940/go.mod h1:pgODObA1dTyhNoFxPZTTjNWfx6F0aKsKzn+vaT9XO/Q=
|
knative.dev/pkg v0.0.0-20200304185554-312b1be35ceb/go.mod h1:pgODObA1dTyhNoFxPZTTjNWfx6F0aKsKzn+vaT9XO/Q=
|
||||||
knative.dev/serving v0.12.1-0.20200206201132-525b15d87dc1 h1:fEj1JY8FwjyQ3bB7+nMGrKX/apOwIJOB7UVuLzIYkmA=
|
knative.dev/serving v0.13.0 h1:HkkTVBi6EWoFJcgjXgAVUFdKdxZRulb38dnfnkBYCrQ=
|
||||||
knative.dev/serving v0.12.1-0.20200206201132-525b15d87dc1/go.mod h1:x2n255JS2XBI39tmjZ8CwTxIf9EKNMCrkVuiOttLRm0=
|
knative.dev/serving v0.13.0/go.mod h1:x2n255JS2XBI39tmjZ8CwTxIf9EKNMCrkVuiOttLRm0=
|
||||||
knative.dev/test-infra v0.0.0-20200229011351-4dac123b9a3d h1:YlscBzPOL3Rfyl8844/wHhJNL5uiHDdyaRn6IEVvv64=
|
knative.dev/test-infra v0.0.0-20200229011351-4dac123b9a3d h1:YlscBzPOL3Rfyl8844/wHhJNL5uiHDdyaRn6IEVvv64=
|
||||||
knative.dev/test-infra v0.0.0-20200229011351-4dac123b9a3d/go.mod h1:xcdUkMJrLlBswIZqL5zCuBFOC22WIPMQoVX1L35i0vQ=
|
knative.dev/test-infra v0.0.0-20200229011351-4dac123b9a3d/go.mod h1:xcdUkMJrLlBswIZqL5zCuBFOC22WIPMQoVX1L35i0vQ=
|
||||||
modernc.org/cc v1.0.0/go.mod h1:1Sk4//wdnYJiUIxnW8ddKpaOJCF37yAdqYnkxUpaYxw=
|
modernc.org/cc v1.0.0/go.mod h1:1Sk4//wdnYJiUIxnW8ddKpaOJCF37yAdqYnkxUpaYxw=
|
||||||
|
|
|
||||||
|
|
@ -1,188 +0,0 @@
|
||||||
// Copyright © 2019 The Knative Authors
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
package v1alpha1
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
|
||||||
"knative.dev/eventing/pkg/apis/legacysources/v1alpha1"
|
|
||||||
|
|
||||||
"knative.dev/client/pkg/util"
|
|
||||||
"knative.dev/eventing/pkg/legacyclient/clientset/versioned/scheme"
|
|
||||||
client_v1alpha1 "knative.dev/eventing/pkg/legacyclient/clientset/versioned/typed/legacysources/v1alpha1"
|
|
||||||
duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Interface for interacting with a cronjob source
|
|
||||||
type KnCronJobSourcesClient interface {
|
|
||||||
|
|
||||||
// Get a single cronjob source by name
|
|
||||||
GetCronJobSource(name string) (*v1alpha1.CronJobSource, error)
|
|
||||||
|
|
||||||
// Create a cronjob source by providing the schedule, data and sink
|
|
||||||
CreateCronJobSource(cronjobSource *v1alpha1.CronJobSource) error
|
|
||||||
|
|
||||||
// Update a cronjob source by providing the schedule, data and sink
|
|
||||||
UpdateCronJobSource(cronjobSource *v1alpha1.CronJobSource) error
|
|
||||||
|
|
||||||
// Delete a cronjob source by name
|
|
||||||
DeleteCronJobSource(name string) error
|
|
||||||
|
|
||||||
// List CronJob sources
|
|
||||||
// TODO: Support list configs like in service list
|
|
||||||
ListCronJobSource() (*v1alpha1.CronJobSourceList, error)
|
|
||||||
|
|
||||||
// Get namespace for this source
|
|
||||||
Namespace() string
|
|
||||||
}
|
|
||||||
|
|
||||||
// knSourcesClient is a combination of Sources client interface and namespace
|
|
||||||
// Temporarily help to add sources dependencies
|
|
||||||
// May be changed when adding real sources features
|
|
||||||
type cronJobSourcesClient struct {
|
|
||||||
client client_v1alpha1.CronJobSourceInterface
|
|
||||||
namespace string
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewKnSourcesClient is to invoke Eventing Sources Client API to create object
|
|
||||||
func newKnCronJobSourcesClient(client client_v1alpha1.CronJobSourceInterface, namespace string) KnCronJobSourcesClient {
|
|
||||||
return &cronJobSourcesClient{
|
|
||||||
client: client,
|
|
||||||
namespace: namespace,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get the namespace for which this client has been created
|
|
||||||
func (c *cronJobSourcesClient) Namespace() string {
|
|
||||||
return c.namespace
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *cronJobSourcesClient) CreateCronJobSource(cronjobSource *v1alpha1.CronJobSource) error {
|
|
||||||
if cronjobSource.Spec.Sink == nil {
|
|
||||||
return fmt.Errorf("a sink is required for creating a source")
|
|
||||||
}
|
|
||||||
_, err := c.client.Create(cronjobSource)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *cronJobSourcesClient) UpdateCronJobSource(cronjobSource *v1alpha1.CronJobSource) error {
|
|
||||||
_, err := c.client.Update(cronjobSource)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *cronJobSourcesClient) DeleteCronJobSource(name string) error {
|
|
||||||
return c.client.Delete(name, &metav1.DeleteOptions{})
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *cronJobSourcesClient) GetCronJobSource(name string) (*v1alpha1.CronJobSource, error) {
|
|
||||||
return c.client.Get(name, metav1.GetOptions{})
|
|
||||||
}
|
|
||||||
|
|
||||||
// ListCronJobSource returns the available CronJob type sources
|
|
||||||
func (c *cronJobSourcesClient) ListCronJobSource() (*v1alpha1.CronJobSourceList, error) {
|
|
||||||
sourceList, err := c.client.List(metav1.ListOptions{})
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return updateCronJobSourceListGVK(sourceList)
|
|
||||||
}
|
|
||||||
|
|
||||||
func updateCronJobSourceListGVK(sourceList *v1alpha1.CronJobSourceList) (*v1alpha1.CronJobSourceList, error) {
|
|
||||||
sourceListNew := sourceList.DeepCopy()
|
|
||||||
err := updateSourceGVK(sourceListNew)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
sourceListNew.Items = make([]v1alpha1.CronJobSource, len(sourceList.Items))
|
|
||||||
for idx, source := range sourceList.Items {
|
|
||||||
sourceClone := source.DeepCopy()
|
|
||||||
err := updateSourceGVK(sourceClone)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
sourceListNew.Items[idx] = *sourceClone
|
|
||||||
}
|
|
||||||
return sourceListNew, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func updateSourceGVK(obj runtime.Object) error {
|
|
||||||
return util.UpdateGroupVersionKindWithScheme(obj, v1alpha1.SchemeGroupVersion, scheme.Scheme)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Builder for building up cronjob sources
|
|
||||||
|
|
||||||
type CronJobSourceBuilder struct {
|
|
||||||
cronjobSource *v1alpha1.CronJobSource
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewCronJobSourceBuilder(name string) *CronJobSourceBuilder {
|
|
||||||
return &CronJobSourceBuilder{cronjobSource: &v1alpha1.CronJobSource{
|
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
|
||||||
Name: name,
|
|
||||||
},
|
|
||||||
}}
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewCronJobSourceBuilderFromExisting(cronjobsource *v1alpha1.CronJobSource) *CronJobSourceBuilder {
|
|
||||||
return &CronJobSourceBuilder{cronjobSource: cronjobsource.DeepCopy()}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *CronJobSourceBuilder) Schedule(schedule string) *CronJobSourceBuilder {
|
|
||||||
b.cronjobSource.Spec.Schedule = schedule
|
|
||||||
return b
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *CronJobSourceBuilder) Data(data string) *CronJobSourceBuilder {
|
|
||||||
b.cronjobSource.Spec.Data = data
|
|
||||||
return b
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *CronJobSourceBuilder) Sink(sink *duckv1beta1.Destination) *CronJobSourceBuilder {
|
|
||||||
b.cronjobSource.Spec.Sink = sink
|
|
||||||
return b
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *CronJobSourceBuilder) ServiceAccount(sa string) *CronJobSourceBuilder {
|
|
||||||
b.cronjobSource.Spec.ServiceAccountName = sa
|
|
||||||
return b
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *CronJobSourceBuilder) ResourceRequestsCPU(cpu string) *CronJobSourceBuilder {
|
|
||||||
b.cronjobSource.Spec.Resources.Requests.ResourceCPU = cpu
|
|
||||||
return b
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *CronJobSourceBuilder) ResourceRequestsMemory(memory string) *CronJobSourceBuilder {
|
|
||||||
b.cronjobSource.Spec.Resources.Requests.ResourceMemory = memory
|
|
||||||
return b
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *CronJobSourceBuilder) ResourceLimitsCPU(cpu string) *CronJobSourceBuilder {
|
|
||||||
b.cronjobSource.Spec.Resources.Limits.ResourceCPU = cpu
|
|
||||||
return b
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *CronJobSourceBuilder) ResourceLimitsMemory(memory string) *CronJobSourceBuilder {
|
|
||||||
b.cronjobSource.Spec.Resources.Limits.ResourceMemory = memory
|
|
||||||
return b
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *CronJobSourceBuilder) Build() *v1alpha1.CronJobSource {
|
|
||||||
return b.cronjobSource
|
|
||||||
}
|
|
||||||
|
|
@ -1,119 +0,0 @@
|
||||||
// Copyright © 2019 The Knative Authors
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
package v1alpha1
|
|
||||||
|
|
||||||
import (
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"knative.dev/eventing/pkg/apis/legacysources/v1alpha1"
|
|
||||||
|
|
||||||
"knative.dev/client/pkg/util/mock"
|
|
||||||
)
|
|
||||||
|
|
||||||
type MockKnCronJobSourceClient struct {
|
|
||||||
t *testing.T
|
|
||||||
recorder *CronJobSourcesRecorder
|
|
||||||
namespace string
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewMockKnCronJobSourceClient returns a new mock instance which you need to record for
|
|
||||||
func NewMockKnCronJobSourceClient(t *testing.T, ns ...string) *MockKnCronJobSourceClient {
|
|
||||||
namespace := "default"
|
|
||||||
if len(ns) > 0 {
|
|
||||||
namespace = ns[0]
|
|
||||||
}
|
|
||||||
return &MockKnCronJobSourceClient{
|
|
||||||
t: t,
|
|
||||||
recorder: &CronJobSourcesRecorder{mock.NewRecorder(t, namespace)},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ensure that the interface is implemented
|
|
||||||
var _ KnCronJobSourcesClient = &MockKnCronJobSourceClient{}
|
|
||||||
|
|
||||||
// recorder for service
|
|
||||||
type CronJobSourcesRecorder struct {
|
|
||||||
r *mock.Recorder
|
|
||||||
}
|
|
||||||
|
|
||||||
// Recorder returns the recorder for registering API calls
|
|
||||||
func (c *MockKnCronJobSourceClient) Recorder() *CronJobSourcesRecorder {
|
|
||||||
return c.recorder
|
|
||||||
}
|
|
||||||
|
|
||||||
// Namespace of this client
|
|
||||||
func (c *MockKnCronJobSourceClient) Namespace() string {
|
|
||||||
return c.recorder.r.Namespace()
|
|
||||||
}
|
|
||||||
|
|
||||||
// CreateCronJobSource records a call for CreateCronJobSource with the expected error
|
|
||||||
func (sr *CronJobSourcesRecorder) CreateCronJobSource(cronjobSource interface{}, err error) {
|
|
||||||
sr.r.Add("CreateCronJobSource", []interface{}{cronjobSource}, []interface{}{err})
|
|
||||||
}
|
|
||||||
|
|
||||||
// CreateCronJobSource performs a previously recorded action, failing if non has been registered
|
|
||||||
func (c *MockKnCronJobSourceClient) CreateCronJobSource(cronjobSource *v1alpha1.CronJobSource) error {
|
|
||||||
call := c.recorder.r.VerifyCall("CreateCronJobSource", cronjobSource)
|
|
||||||
return mock.ErrorOrNil(call.Result[0])
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetCronJobSource records a call for GetCronJobSource with the expected object or error. Either cronjobsource or err should be nil
|
|
||||||
func (sr *CronJobSourcesRecorder) GetCronJobSource(name interface{}, cronjobSource *v1alpha1.CronJobSource, err error) {
|
|
||||||
sr.r.Add("GetCronJobSource", []interface{}{name}, []interface{}{cronjobSource, err})
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetCronJobSource performs a previously recorded action, failing if non has been registered
|
|
||||||
func (c *MockKnCronJobSourceClient) GetCronJobSource(name string) (*v1alpha1.CronJobSource, error) {
|
|
||||||
call := c.recorder.r.VerifyCall("GetCronJobSource", name)
|
|
||||||
return call.Result[0].(*v1alpha1.CronJobSource), mock.ErrorOrNil(call.Result[1])
|
|
||||||
}
|
|
||||||
|
|
||||||
// UpdateCronJobSource records a call for UpdateCronJobSource with the expected error (nil if none)
|
|
||||||
func (sr *CronJobSourcesRecorder) UpdateCronJobSource(cronjobSource interface{}, err error) {
|
|
||||||
sr.r.Add("UpdateCronJobSource", []interface{}{cronjobSource}, []interface{}{err})
|
|
||||||
}
|
|
||||||
|
|
||||||
// UpdateCronJobSource performs a previously recorded action, failing if non has been registered
|
|
||||||
func (c *MockKnCronJobSourceClient) UpdateCronJobSource(cronjobSource *v1alpha1.CronJobSource) error {
|
|
||||||
call := c.recorder.r.VerifyCall("UpdateCronJobSource", cronjobSource)
|
|
||||||
return mock.ErrorOrNil(call.Result[0])
|
|
||||||
}
|
|
||||||
|
|
||||||
// UpdateCronJobSource records a call for DeleteCronJobSource with the expected error (nil if none)
|
|
||||||
func (sr *CronJobSourcesRecorder) DeleteCronJobSource(name interface{}, err error) {
|
|
||||||
sr.r.Add("DeleteCronJobSource", []interface{}{name}, []interface{}{err})
|
|
||||||
}
|
|
||||||
|
|
||||||
// DeleteCronJobSource performs a previously recorded action, failing if non has been registered
|
|
||||||
func (c *MockKnCronJobSourceClient) DeleteCronJobSource(name string) error {
|
|
||||||
call := c.recorder.r.VerifyCall("DeleteCronJobSource", name)
|
|
||||||
return mock.ErrorOrNil(call.Result[0])
|
|
||||||
}
|
|
||||||
|
|
||||||
// ListCronJobSource records a call for ListCronJobSource with the expected error (nil if none)
|
|
||||||
func (sr *CronJobSourcesRecorder) ListCronJobSource(cronJobSourceList *v1alpha1.CronJobSourceList, err error) {
|
|
||||||
sr.r.Add("ListCronJobSource", []interface{}{}, []interface{}{cronJobSourceList, err})
|
|
||||||
}
|
|
||||||
|
|
||||||
// ListCronJobSource performs a previously recorded action, failing if non has been registered
|
|
||||||
func (c *MockKnCronJobSourceClient) ListCronJobSource() (*v1alpha1.CronJobSourceList, error) {
|
|
||||||
call := c.recorder.r.VerifyCall("ListCronJobSource")
|
|
||||||
return call.Result[0].(*v1alpha1.CronJobSourceList), mock.ErrorOrNil(call.Result[1])
|
|
||||||
}
|
|
||||||
|
|
||||||
// Validates validates whether every recorded action has been called
|
|
||||||
func (sr *CronJobSourcesRecorder) Validate() {
|
|
||||||
sr.r.CheckThatAllRecordedMethodsHaveBeenCalled()
|
|
||||||
}
|
|
||||||
|
|
@ -1,152 +0,0 @@
|
||||||
// Copyright © 2019 The Knative Authors
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
package v1alpha1
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"gotest.tools/assert"
|
|
||||||
v1 "k8s.io/api/core/v1"
|
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
|
||||||
client_testing "k8s.io/client-go/testing"
|
|
||||||
"knative.dev/eventing/pkg/apis/legacysources/v1alpha1"
|
|
||||||
"knative.dev/eventing/pkg/legacyclient/clientset/versioned/typed/legacysources/v1alpha1/fake"
|
|
||||||
"knative.dev/pkg/apis/duck/v1beta1"
|
|
||||||
)
|
|
||||||
|
|
||||||
func setupCronJobSourcesClient(t *testing.T) (sources fake.FakeSourcesV1alpha1, client KnCronJobSourcesClient) {
|
|
||||||
sources = fake.FakeSourcesV1alpha1{Fake: &client_testing.Fake{}}
|
|
||||||
client = NewKnSourcesClient(&sources, "test-ns").CronJobSourcesClient()
|
|
||||||
assert.Equal(t, client.Namespace(), "test-ns")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestCreateCronJobSource(t *testing.T) {
|
|
||||||
sourcesServer, client := setupCronJobSourcesClient(t)
|
|
||||||
|
|
||||||
sourcesServer.AddReactor("create", "cronjobsources",
|
|
||||||
func(a client_testing.Action) (bool, runtime.Object, error) {
|
|
||||||
newSource := a.(client_testing.CreateAction).GetObject()
|
|
||||||
name := newSource.(metav1.Object).GetName()
|
|
||||||
if name == "errorSource" {
|
|
||||||
return true, nil, fmt.Errorf("error while creating cronjobsource %s", name)
|
|
||||||
}
|
|
||||||
return true, newSource, nil
|
|
||||||
})
|
|
||||||
|
|
||||||
err := client.CreateCronJobSource(newCronJobSource("testsource", "mysvc"))
|
|
||||||
assert.NilError(t, err)
|
|
||||||
|
|
||||||
err = client.CreateCronJobSource(newCronJobSource("testsource", ""))
|
|
||||||
assert.ErrorContains(t, err, "sink")
|
|
||||||
assert.ErrorContains(t, err, "required")
|
|
||||||
|
|
||||||
err = client.CreateCronJobSource(newCronJobSource("errorSource", "mysvc"))
|
|
||||||
assert.ErrorContains(t, err, "errorSource")
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestUpdateCronJobSource(t *testing.T) {
|
|
||||||
sourcesServer, client := setupCronJobSourcesClient(t)
|
|
||||||
|
|
||||||
sourcesServer.AddReactor("update", "cronjobsources",
|
|
||||||
func(a client_testing.Action) (bool, runtime.Object, error) {
|
|
||||||
newSource := a.(client_testing.UpdateAction).GetObject()
|
|
||||||
name := newSource.(metav1.Object).GetName()
|
|
||||||
if name == "errorSource" {
|
|
||||||
return true, nil, fmt.Errorf("error while updating cronjobsource %s", name)
|
|
||||||
}
|
|
||||||
return true, NewCronJobSourceBuilderFromExisting(newSource.(*v1alpha1.CronJobSource)).Build(), nil
|
|
||||||
})
|
|
||||||
|
|
||||||
err := client.UpdateCronJobSource(newCronJobSource("testsource", ""))
|
|
||||||
assert.NilError(t, err)
|
|
||||||
|
|
||||||
err = client.UpdateCronJobSource(newCronJobSource("errorSource", ""))
|
|
||||||
assert.ErrorContains(t, err, "errorSource")
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestDeleteCronJobSource(t *testing.T) {
|
|
||||||
sourcesServer, client := setupCronJobSourcesClient(t)
|
|
||||||
|
|
||||||
sourcesServer.AddReactor("delete", "cronjobsources",
|
|
||||||
func(a client_testing.Action) (bool, runtime.Object, error) {
|
|
||||||
name := a.(client_testing.DeleteAction).GetName()
|
|
||||||
if name == "errorSource" {
|
|
||||||
return true, nil, fmt.Errorf("error while updating cronjobsource %s", name)
|
|
||||||
}
|
|
||||||
return true, nil, nil
|
|
||||||
})
|
|
||||||
|
|
||||||
err := client.DeleteCronJobSource("testsource")
|
|
||||||
assert.NilError(t, err)
|
|
||||||
|
|
||||||
err = client.DeleteCronJobSource("errorSource")
|
|
||||||
assert.ErrorContains(t, err, "errorSource")
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestGetCronJobSource(t *testing.T) {
|
|
||||||
sourcesServer, client := setupCronJobSourcesClient(t)
|
|
||||||
|
|
||||||
sourcesServer.AddReactor("get", "cronjobsources",
|
|
||||||
func(a client_testing.Action) (bool, runtime.Object, error) {
|
|
||||||
name := a.(client_testing.GetAction).GetName()
|
|
||||||
if name == "errorSource" {
|
|
||||||
return true, nil, fmt.Errorf("error while updating cronjobsource %s", name)
|
|
||||||
}
|
|
||||||
return true, newCronJobSource(name, "mysvc"), nil
|
|
||||||
})
|
|
||||||
|
|
||||||
source, err := client.GetCronJobSource("testsource")
|
|
||||||
assert.NilError(t, err)
|
|
||||||
assert.Equal(t, source.Name, "testsource")
|
|
||||||
assert.Equal(t, source.Spec.Sink.Ref.Name, "mysvc")
|
|
||||||
|
|
||||||
_, err = client.GetCronJobSource("errorSource")
|
|
||||||
assert.ErrorContains(t, err, "errorSource")
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestListCronJobSource(t *testing.T) {
|
|
||||||
sourcesServer, client := setupCronJobSourcesClient(t)
|
|
||||||
|
|
||||||
sourcesServer.AddReactor("list", "cronjobsources",
|
|
||||||
func(a client_testing.Action) (bool, runtime.Object, error) {
|
|
||||||
cJSource := newCronJobSource("testsource", "mysvc")
|
|
||||||
return true, &v1alpha1.CronJobSourceList{Items: []v1alpha1.CronJobSource{*cJSource}}, nil
|
|
||||||
})
|
|
||||||
|
|
||||||
sourceList, err := client.ListCronJobSource()
|
|
||||||
assert.NilError(t, err)
|
|
||||||
assert.Equal(t, len(sourceList.Items), 1)
|
|
||||||
}
|
|
||||||
|
|
||||||
func newCronJobSource(name string, sink string) *v1alpha1.CronJobSource {
|
|
||||||
b := NewCronJobSourceBuilder(name).
|
|
||||||
Schedule("* * * * *").
|
|
||||||
Data("mydata")
|
|
||||||
|
|
||||||
if sink != "" {
|
|
||||||
b.Sink(
|
|
||||||
&v1beta1.Destination{
|
|
||||||
Ref: &v1.ObjectReference{
|
|
||||||
Kind: "Service",
|
|
||||||
Name: sink,
|
|
||||||
Namespace: "default",
|
|
||||||
},
|
|
||||||
})
|
|
||||||
}
|
|
||||||
return b.Build()
|
|
||||||
}
|
|
||||||
|
|
@ -59,7 +59,7 @@ func (c *MockKnEventingClient) Namespace() string {
|
||||||
return c.recorder.r.Namespace()
|
return c.recorder.r.Namespace()
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateTrigger records a call for CreateCronJobSource with the expected error
|
// CreateTrigger records a call for CreatePingSource with the expected error
|
||||||
func (sr *EventingRecorder) CreateTrigger(trigger interface{}, err error) {
|
func (sr *EventingRecorder) CreateTrigger(trigger interface{}, err error) {
|
||||||
sr.r.Add("CreateTrigger", []interface{}{trigger}, []interface{}{err})
|
sr.r.Add("CreateTrigger", []interface{}{trigger}, []interface{}{err})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ package flags
|
||||||
import (
|
import (
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"k8s.io/cli-runtime/pkg/genericclioptions"
|
"k8s.io/cli-runtime/pkg/genericclioptions"
|
||||||
|
|
||||||
"knative.dev/client/pkg/kn/commands"
|
"knative.dev/client/pkg/kn/commands"
|
||||||
hprinters "knative.dev/client/pkg/printers"
|
hprinters "knative.dev/client/pkg/printers"
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -21,10 +21,10 @@ import (
|
||||||
v1 "knative.dev/pkg/apis/duck/v1"
|
v1 "knative.dev/pkg/apis/duck/v1"
|
||||||
"knative.dev/pkg/apis/duck/v1beta1"
|
"knative.dev/pkg/apis/duck/v1beta1"
|
||||||
|
|
||||||
sources_v1alpha1 "knative.dev/eventing/pkg/legacyclient/clientset/versioned/typed/legacysources/v1alpha1"
|
clientv1alpha1 "knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha1"
|
||||||
|
|
||||||
knsources_v1alpha1 "knative.dev/client/pkg/eventing/legacysources/v1alpha1"
|
|
||||||
"knative.dev/client/pkg/kn/commands"
|
"knative.dev/client/pkg/kn/commands"
|
||||||
|
v1alpha1 "knative.dev/client/pkg/sources/v1alpha1"
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewAPIServerCommand for managing ApiServer source
|
// NewAPIServerCommand for managing ApiServer source
|
||||||
|
|
@ -41,9 +41,9 @@ func NewAPIServerCommand(p *commands.KnParams) *cobra.Command {
|
||||||
return apiServerSourceCmd
|
return apiServerSourceCmd
|
||||||
}
|
}
|
||||||
|
|
||||||
var apiServerSourceClientFactory func(config clientcmd.ClientConfig, namespace string) (knsources_v1alpha1.KnAPIServerSourcesClient, error)
|
var apiServerSourceClientFactory func(config clientcmd.ClientConfig, namespace string) (v1alpha1.KnAPIServerSourcesClient, error)
|
||||||
|
|
||||||
func newAPIServerSourceClient(p *commands.KnParams, cmd *cobra.Command) (knsources_v1alpha1.KnAPIServerSourcesClient, error) {
|
func newAPIServerSourceClient(p *commands.KnParams, cmd *cobra.Command) (v1alpha1.KnAPIServerSourcesClient, error) {
|
||||||
namespace, err := p.GetNamespace(cmd)
|
namespace, err := p.GetNamespace(cmd)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
@ -62,12 +62,12 @@ func newAPIServerSourceClient(p *commands.KnParams, cmd *cobra.Command) (knsourc
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
client, err := sources_v1alpha1.NewForConfig(clientConfig)
|
client, err := clientv1alpha1.NewForConfig(clientConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return knsources_v1alpha1.NewKnSourcesClient(client, namespace).APIServerSourcesClient(), nil
|
return v1alpha1.NewKnSourcesClient(client, namespace).APIServerSourcesClient(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func toDuckV1Beta1(destination *v1.Destination) *v1beta1.Destination {
|
func toDuckV1Beta1(destination *v1.Destination) *v1beta1.Destination {
|
||||||
|
|
|
||||||
|
|
@ -19,12 +19,13 @@ import (
|
||||||
|
|
||||||
corev1 "k8s.io/api/core/v1"
|
corev1 "k8s.io/api/core/v1"
|
||||||
"k8s.io/client-go/tools/clientcmd"
|
"k8s.io/client-go/tools/clientcmd"
|
||||||
kn_dynamic "knative.dev/client/pkg/dynamic"
|
"knative.dev/eventing/pkg/apis/sources/v1alpha1"
|
||||||
"knative.dev/eventing/pkg/apis/legacysources/v1alpha1"
|
|
||||||
duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1"
|
duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1"
|
||||||
|
|
||||||
knsource_v1alpha1 "knative.dev/client/pkg/eventing/legacysources/v1alpha1"
|
kndynamic "knative.dev/client/pkg/dynamic"
|
||||||
|
|
||||||
"knative.dev/client/pkg/kn/commands"
|
"knative.dev/client/pkg/kn/commands"
|
||||||
|
clientv1alpha1 "knative.dev/client/pkg/sources/v1alpha1"
|
||||||
)
|
)
|
||||||
|
|
||||||
const testNamespace = "default"
|
const testNamespace = "default"
|
||||||
|
|
@ -55,13 +56,13 @@ current-context: x
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func executeAPIServerSourceCommand(apiServerSourceClient knsource_v1alpha1.KnAPIServerSourcesClient, dynamicClient kn_dynamic.KnDynamicClient, args ...string) (string, error) {
|
func executeAPIServerSourceCommand(apiServerSourceClient clientv1alpha1.KnAPIServerSourcesClient, dynamicClient kndynamic.KnDynamicClient, args ...string) (string, error) {
|
||||||
knParams := &commands.KnParams{}
|
knParams := &commands.KnParams{}
|
||||||
knParams.ClientConfig = blankConfig
|
knParams.ClientConfig = blankConfig
|
||||||
|
|
||||||
output := new(bytes.Buffer)
|
output := new(bytes.Buffer)
|
||||||
knParams.Output = output
|
knParams.Output = output
|
||||||
knParams.NewDynamicClient = func(namespace string) (kn_dynamic.KnDynamicClient, error) {
|
knParams.NewDynamicClient = func(namespace string) (kndynamic.KnDynamicClient, error) {
|
||||||
return dynamicClient, nil
|
return dynamicClient, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -69,7 +70,7 @@ func executeAPIServerSourceCommand(apiServerSourceClient knsource_v1alpha1.KnAPI
|
||||||
cmd.SetArgs(args)
|
cmd.SetArgs(args)
|
||||||
cmd.SetOutput(output)
|
cmd.SetOutput(output)
|
||||||
|
|
||||||
apiServerSourceClientFactory = func(config clientcmd.ClientConfig, namespace string) (knsource_v1alpha1.KnAPIServerSourcesClient, error) {
|
apiServerSourceClientFactory = func(config clientcmd.ClientConfig, namespace string) (clientv1alpha1.KnAPIServerSourcesClient, error) {
|
||||||
return apiServerSourceClient, nil
|
return apiServerSourceClient, nil
|
||||||
}
|
}
|
||||||
defer cleanupAPIServerMockClient()
|
defer cleanupAPIServerMockClient()
|
||||||
|
|
@ -98,7 +99,7 @@ func createAPIServerSource(name, resourceKind, resourceVersion, serviceAccount,
|
||||||
Namespace: "default",
|
Namespace: "default",
|
||||||
}}
|
}}
|
||||||
|
|
||||||
return knsource_v1alpha1.NewAPIServerSourceBuilder(name).
|
return clientv1alpha1.NewAPIServerSourceBuilder(name).
|
||||||
Resources(resources).
|
Resources(resources).
|
||||||
ServiceAccount(serviceAccount).
|
ServiceAccount(serviceAccount).
|
||||||
Mode(mode).
|
Mode(mode).
|
||||||
|
|
|
||||||
|
|
@ -20,9 +20,9 @@ import (
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
"knative.dev/client/pkg/eventing/legacysources/v1alpha1"
|
|
||||||
"knative.dev/client/pkg/kn/commands"
|
"knative.dev/client/pkg/kn/commands"
|
||||||
"knative.dev/client/pkg/kn/commands/flags"
|
"knative.dev/client/pkg/kn/commands/flags"
|
||||||
|
"knative.dev/client/pkg/sources/v1alpha1"
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewAPIServerCreateCommand for creating source
|
// NewAPIServerCreateCommand for creating source
|
||||||
|
|
|
||||||
|
|
@ -21,8 +21,8 @@ import (
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
servingv1 "knative.dev/serving/pkg/apis/serving/v1"
|
servingv1 "knative.dev/serving/pkg/apis/serving/v1"
|
||||||
|
|
||||||
clientdynamicfake "knative.dev/client/pkg/dynamic/fake"
|
dynamicfake "knative.dev/client/pkg/dynamic/fake"
|
||||||
sourcesv1alpha1 "knative.dev/client/pkg/eventing/legacysources/v1alpha1"
|
clientv1alpha1 "knative.dev/client/pkg/sources/v1alpha1"
|
||||||
"knative.dev/client/pkg/util"
|
"knative.dev/client/pkg/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -31,8 +31,8 @@ func TestCreateApiServerSource(t *testing.T) {
|
||||||
TypeMeta: metav1.TypeMeta{Kind: "Service", APIVersion: "serving.knative.dev/v1"},
|
TypeMeta: metav1.TypeMeta{Kind: "Service", APIVersion: "serving.knative.dev/v1"},
|
||||||
ObjectMeta: metav1.ObjectMeta{Name: "testsvc", Namespace: "default"},
|
ObjectMeta: metav1.ObjectMeta{Name: "testsvc", Namespace: "default"},
|
||||||
}
|
}
|
||||||
dynamicClient := clientdynamicfake.CreateFakeKnDynamicClient("default", testsvc)
|
dynamicClient := dynamicfake.CreateFakeKnDynamicClient("default", testsvc)
|
||||||
apiServerClient := sourcesv1alpha1.NewMockKnAPIServerSourceClient(t)
|
apiServerClient := clientv1alpha1.NewMockKnAPIServerSourceClient(t)
|
||||||
|
|
||||||
apiServerRecorder := apiServerClient.Recorder()
|
apiServerRecorder := apiServerClient.Recorder()
|
||||||
apiServerRecorder.CreateAPIServerSource(createAPIServerSource("testsource", "Event", "v1", "testsa", "Ref", "testsvc", false), nil)
|
apiServerRecorder.CreateAPIServerSource(createAPIServerSource("testsource", "Event", "v1", "testsa", "Ref", "testsvc", false), nil)
|
||||||
|
|
@ -45,8 +45,8 @@ func TestCreateApiServerSource(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSinkNotFoundError(t *testing.T) {
|
func TestSinkNotFoundError(t *testing.T) {
|
||||||
dynamicClient := clientdynamicfake.CreateFakeKnDynamicClient("default")
|
dynamicClient := dynamicfake.CreateFakeKnDynamicClient("default")
|
||||||
apiServerClient := sourcesv1alpha1.NewMockKnAPIServerSourceClient(t)
|
apiServerClient := clientv1alpha1.NewMockKnAPIServerSourceClient(t)
|
||||||
errorMsg := "cannot create ApiServerSource 'testsource' in namespace 'default' because: services.serving.knative.dev \"testsvc\" not found"
|
errorMsg := "cannot create ApiServerSource 'testsource' in namespace 'default' because: services.serving.knative.dev \"testsvc\" not found"
|
||||||
out, err := executeAPIServerSourceCommand(apiServerClient, dynamicClient, "create", "testsource", "--resource", "Event:v1:false", "--service-account", "testsa", "--sink", "svc:testsvc", "--mode", "Ref")
|
out, err := executeAPIServerSourceCommand(apiServerClient, dynamicClient, "create", "testsource", "--resource", "Event:v1:false", "--service-account", "testsa", "--sink", "svc:testsvc", "--mode", "Ref")
|
||||||
assert.Error(t, err, errorMsg)
|
assert.Error(t, err, errorMsg)
|
||||||
|
|
@ -54,7 +54,7 @@ func TestSinkNotFoundError(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestNoSinkError(t *testing.T) {
|
func TestNoSinkError(t *testing.T) {
|
||||||
apiServerClient := sourcesv1alpha1.NewMockKnAPIServerSourceClient(t)
|
apiServerClient := clientv1alpha1.NewMockKnAPIServerSourceClient(t)
|
||||||
_, err := executeAPIServerSourceCommand(apiServerClient, nil, "create", "testsource", "--resource", "Event:v1:false", "--service-account", "testsa", "--mode", "Ref")
|
_, err := executeAPIServerSourceCommand(apiServerClient, nil, "create", "testsource", "--resource", "Event:v1:false", "--service-account", "testsa", "--mode", "Ref")
|
||||||
assert.ErrorContains(t, err, "required flag(s)", "sink", "not set")
|
assert.ErrorContains(t, err, "required flag(s)", "sink", "not set")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
"knative.dev/client/pkg/kn/commands"
|
"knative.dev/client/pkg/kn/commands"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,13 +20,13 @@ import (
|
||||||
|
|
||||||
"gotest.tools/assert"
|
"gotest.tools/assert"
|
||||||
|
|
||||||
knsources_v1alpha1 "knative.dev/client/pkg/eventing/legacysources/v1alpha1"
|
clientv1alpha1 "knative.dev/client/pkg/sources/v1alpha1"
|
||||||
"knative.dev/client/pkg/util"
|
"knative.dev/client/pkg/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestApiServerSourceDelete(t *testing.T) {
|
func TestApiServerSourceDelete(t *testing.T) {
|
||||||
|
|
||||||
apiServerClient := knsources_v1alpha1.NewMockKnAPIServerSourceClient(t, "testns")
|
apiServerClient := clientv1alpha1.NewMockKnAPIServerSourceClient(t, "testns")
|
||||||
apiServerRecorder := apiServerClient.Recorder()
|
apiServerRecorder := apiServerClient.Recorder()
|
||||||
|
|
||||||
apiServerRecorder.DeleteAPIServerSource("testsource", nil)
|
apiServerRecorder.DeleteAPIServerSource("testsource", nil)
|
||||||
|
|
@ -40,7 +40,7 @@ func TestApiServerSourceDelete(t *testing.T) {
|
||||||
|
|
||||||
func TestDeleteWithError(t *testing.T) {
|
func TestDeleteWithError(t *testing.T) {
|
||||||
|
|
||||||
apiServerClient := knsources_v1alpha1.NewMockKnAPIServerSourceClient(t, "mynamespace")
|
apiServerClient := clientv1alpha1.NewMockKnAPIServerSourceClient(t, "mynamespace")
|
||||||
apiServerRecorder := apiServerClient.Recorder()
|
apiServerRecorder := apiServerClient.Recorder()
|
||||||
|
|
||||||
apiServerRecorder.DeleteAPIServerSource("testsource", errors.New("apiserver source testsource not found"))
|
apiServerRecorder.DeleteAPIServerSource("testsource", errors.New("apiserver source testsource not found"))
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"knative.dev/eventing/pkg/apis/legacysources/v1alpha1"
|
"knative.dev/eventing/pkg/apis/sources/v1alpha1"
|
||||||
duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1"
|
duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1"
|
||||||
|
|
||||||
"knative.dev/client/pkg/kn/commands"
|
"knative.dev/client/pkg/kn/commands"
|
||||||
|
|
|
||||||
|
|
@ -20,12 +20,12 @@ import (
|
||||||
|
|
||||||
"gotest.tools/assert"
|
"gotest.tools/assert"
|
||||||
|
|
||||||
knsource_v1alpha1 "knative.dev/client/pkg/eventing/legacysources/v1alpha1"
|
clientv1alpha1 "knative.dev/client/pkg/sources/v1alpha1"
|
||||||
"knative.dev/client/pkg/util"
|
"knative.dev/client/pkg/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestSimpleDescribe(t *testing.T) {
|
func TestSimpleDescribe(t *testing.T) {
|
||||||
apiServerClient := knsource_v1alpha1.NewMockKnAPIServerSourceClient(t, "mynamespace")
|
apiServerClient := clientv1alpha1.NewMockKnAPIServerSourceClient(t, "mynamespace")
|
||||||
|
|
||||||
apiServerRecorder := apiServerClient.Recorder()
|
apiServerRecorder := apiServerClient.Recorder()
|
||||||
sampleSource := createAPIServerSource("testsource", "Event", "v1", "testsa", "Ref", "testsvc", false)
|
sampleSource := createAPIServerSource("testsource", "Event", "v1", "testsa", "Ref", "testsvc", false)
|
||||||
|
|
@ -39,7 +39,7 @@ func TestSimpleDescribe(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDescribeError(t *testing.T) {
|
func TestDescribeError(t *testing.T) {
|
||||||
apiServerClient := knsource_v1alpha1.NewMockKnAPIServerSourceClient(t, "mynamespace")
|
apiServerClient := clientv1alpha1.NewMockKnAPIServerSourceClient(t, "mynamespace")
|
||||||
|
|
||||||
apiServerRecorder := apiServerClient.Recorder()
|
apiServerRecorder := apiServerClient.Recorder()
|
||||||
apiServerRecorder.GetAPIServerSource("testsource", nil, errors.New("no apiserver source testsource"))
|
apiServerRecorder.GetAPIServerSource("testsource", nil, errors.New("no apiserver source testsource"))
|
||||||
|
|
|
||||||
|
|
@ -23,10 +23,12 @@ import (
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
|
"knative.dev/eventing/pkg/apis/sources/v1alpha1"
|
||||||
|
|
||||||
"knative.dev/client/pkg/kn/commands"
|
"knative.dev/client/pkg/kn/commands"
|
||||||
"knative.dev/eventing/pkg/apis/legacysources/v1alpha1"
|
|
||||||
|
|
||||||
metav1beta1 "k8s.io/apimachinery/pkg/apis/meta/v1beta1"
|
metav1beta1 "k8s.io/apimachinery/pkg/apis/meta/v1beta1"
|
||||||
|
|
||||||
hprinters "knative.dev/client/pkg/printers"
|
hprinters "knative.dev/client/pkg/printers"
|
||||||
"knative.dev/client/pkg/util"
|
"knative.dev/client/pkg/util"
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"gotest.tools/assert"
|
"gotest.tools/assert"
|
||||||
"knative.dev/eventing/pkg/apis/legacysources/v1alpha1"
|
"knative.dev/eventing/pkg/apis/sources/v1alpha1"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestGetAPIServerResourceArray(t *testing.T) {
|
func TestGetAPIServerResourceArray(t *testing.T) {
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
"knative.dev/client/pkg/kn/commands"
|
"knative.dev/client/pkg/kn/commands"
|
||||||
"knative.dev/client/pkg/kn/commands/flags"
|
"knative.dev/client/pkg/kn/commands/flags"
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -19,13 +19,14 @@ import (
|
||||||
|
|
||||||
"gotest.tools/assert"
|
"gotest.tools/assert"
|
||||||
|
|
||||||
knsource_v1alpha1 "knative.dev/client/pkg/eventing/legacysources/v1alpha1"
|
"knative.dev/eventing/pkg/apis/sources/v1alpha1"
|
||||||
|
|
||||||
|
clientv1alpha1 "knative.dev/client/pkg/sources/v1alpha1"
|
||||||
"knative.dev/client/pkg/util"
|
"knative.dev/client/pkg/util"
|
||||||
"knative.dev/eventing/pkg/apis/legacysources/v1alpha1"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestListAPIServerSource(t *testing.T) {
|
func TestListAPIServerSource(t *testing.T) {
|
||||||
apiServerClient := knsource_v1alpha1.NewMockKnAPIServerSourceClient(t)
|
apiServerClient := clientv1alpha1.NewMockKnAPIServerSourceClient(t)
|
||||||
|
|
||||||
apiServerRecorder := apiServerClient.Recorder()
|
apiServerRecorder := apiServerClient.Recorder()
|
||||||
sampleSource := createAPIServerSource("testsource", "Event", "v1", "testsa", "Ref", "testsvc", false)
|
sampleSource := createAPIServerSource("testsource", "Event", "v1", "testsa", "Ref", "testsvc", false)
|
||||||
|
|
@ -43,7 +44,7 @@ func TestListAPIServerSource(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestListAPIServerSourceEmpty(t *testing.T) {
|
func TestListAPIServerSourceEmpty(t *testing.T) {
|
||||||
apiServerClient := knsource_v1alpha1.NewMockKnAPIServerSourceClient(t)
|
apiServerClient := clientv1alpha1.NewMockKnAPIServerSourceClient(t)
|
||||||
|
|
||||||
apiServerRecorder := apiServerClient.Recorder()
|
apiServerRecorder := apiServerClient.Recorder()
|
||||||
sampleSourceList := v1alpha1.ApiServerSourceList{}
|
sampleSourceList := v1alpha1.ApiServerSourceList{}
|
||||||
|
|
|
||||||
|
|
@ -20,9 +20,9 @@ import (
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
"knative.dev/client/pkg/eventing/legacysources/v1alpha1"
|
|
||||||
"knative.dev/client/pkg/kn/commands"
|
"knative.dev/client/pkg/kn/commands"
|
||||||
"knative.dev/client/pkg/kn/commands/flags"
|
"knative.dev/client/pkg/kn/commands/flags"
|
||||||
|
clientv1alpha1 "knative.dev/client/pkg/sources/v1alpha1"
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewAPIServerUpdateCommand for managing source update
|
// NewAPIServerUpdateCommand for managing source update
|
||||||
|
|
@ -64,7 +64,7 @@ func NewAPIServerUpdateCommand(p *commands.KnParams) *cobra.Command {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
b := v1alpha1.NewAPIServerSourceBuilderFromExisting(source)
|
b := clientv1alpha1.NewAPIServerSourceBuilderFromExisting(source)
|
||||||
if cmd.Flags().Changed("service-account") {
|
if cmd.Flags().Changed("service-account") {
|
||||||
b.ServiceAccount(apiServerUpdateFlags.ServiceAccountName)
|
b.ServiceAccount(apiServerUpdateFlags.ServiceAccountName)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ import (
|
||||||
servingv1 "knative.dev/serving/pkg/apis/serving/v1"
|
servingv1 "knative.dev/serving/pkg/apis/serving/v1"
|
||||||
|
|
||||||
dynamicfake "knative.dev/client/pkg/dynamic/fake"
|
dynamicfake "knative.dev/client/pkg/dynamic/fake"
|
||||||
clientsourcesv1alpha1 "knative.dev/client/pkg/eventing/legacysources/v1alpha1"
|
clientsourcesv1alpha1 "knative.dev/client/pkg/sources/v1alpha1"
|
||||||
"knative.dev/client/pkg/util"
|
"knative.dev/client/pkg/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,11 +22,11 @@ import (
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
"k8s.io/client-go/tools/clientcmd"
|
"k8s.io/client-go/tools/clientcmd"
|
||||||
"knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha1"
|
v1alpha2 "knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha2"
|
||||||
"knative.dev/pkg/tracker"
|
"knative.dev/pkg/tracker"
|
||||||
|
|
||||||
"knative.dev/client/pkg/kn/commands"
|
"knative.dev/client/pkg/kn/commands"
|
||||||
clientsourcesv1alpha1 "knative.dev/client/pkg/sources/v1alpha1"
|
clientsourcesv1alpha1 "knative.dev/client/pkg/sources/v1alpha2"
|
||||||
"knative.dev/client/pkg/util"
|
"knative.dev/client/pkg/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -67,7 +67,7 @@ func newSinkBindingClient(p *commands.KnParams, cmd *cobra.Command) (clientsourc
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
client, err := v1alpha1.NewForConfig(clientConfig)
|
client, err := v1alpha2.NewForConfig(clientConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,12 +19,12 @@ import (
|
||||||
|
|
||||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
"k8s.io/client-go/tools/clientcmd"
|
"k8s.io/client-go/tools/clientcmd"
|
||||||
"knative.dev/eventing/pkg/apis/sources/v1alpha1"
|
v1alpha2 "knative.dev/eventing/pkg/apis/sources/v1alpha2"
|
||||||
v1 "knative.dev/pkg/apis/duck/v1"
|
v1 "knative.dev/pkg/apis/duck/v1"
|
||||||
|
|
||||||
kn_dynamic "knative.dev/client/pkg/dynamic"
|
kndynamic "knative.dev/client/pkg/dynamic"
|
||||||
"knative.dev/client/pkg/kn/commands"
|
"knative.dev/client/pkg/kn/commands"
|
||||||
cl_sources_v1alpha1 "knative.dev/client/pkg/sources/v1alpha1"
|
clientv1alpha2 "knative.dev/client/pkg/sources/v1alpha2"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Helper methods
|
// Helper methods
|
||||||
|
|
@ -57,13 +57,13 @@ current-context: x
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func executeSinkBindingCommand(sinkBindingClient cl_sources_v1alpha1.KnSinkBindingClient, dynamicClient kn_dynamic.KnDynamicClient, args ...string) (string, error) {
|
func executeSinkBindingCommand(sinkBindingClient clientv1alpha2.KnSinkBindingClient, dynamicClient kndynamic.KnDynamicClient, args ...string) (string, error) {
|
||||||
knParams := &commands.KnParams{}
|
knParams := &commands.KnParams{}
|
||||||
knParams.ClientConfig = blankConfig
|
knParams.ClientConfig = blankConfig
|
||||||
|
|
||||||
output := new(bytes.Buffer)
|
output := new(bytes.Buffer)
|
||||||
knParams.Output = output
|
knParams.Output = output
|
||||||
knParams.NewDynamicClient = func(namespace string) (kn_dynamic.KnDynamicClient, error) {
|
knParams.NewDynamicClient = func(namespace string) (kndynamic.KnDynamicClient, error) {
|
||||||
return dynamicClient, nil
|
return dynamicClient, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -71,7 +71,7 @@ func executeSinkBindingCommand(sinkBindingClient cl_sources_v1alpha1.KnSinkBindi
|
||||||
cmd.SetArgs(args)
|
cmd.SetArgs(args)
|
||||||
cmd.SetOutput(output)
|
cmd.SetOutput(output)
|
||||||
|
|
||||||
sinkBindingClientFactory = func(config clientcmd.ClientConfig, namespace string) (cl_sources_v1alpha1.KnSinkBindingClient, error) {
|
sinkBindingClientFactory = func(config clientcmd.ClientConfig, namespace string) (clientv1alpha2.KnSinkBindingClient, error) {
|
||||||
return sinkBindingClient, nil
|
return sinkBindingClient, nil
|
||||||
}
|
}
|
||||||
defer cleanupSinkBindingClient()
|
defer cleanupSinkBindingClient()
|
||||||
|
|
@ -85,9 +85,9 @@ func cleanupSinkBindingClient() {
|
||||||
sinkBindingClientFactory = nil
|
sinkBindingClientFactory = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func createSinkBinding(name, service string, subjectGvk schema.GroupVersionKind, subjectName string, ceOverrides map[string]string) *v1alpha1.SinkBinding {
|
func createSinkBinding(name, service string, subjectGvk schema.GroupVersionKind, subjectName string, ceOverrides map[string]string) *v1alpha2.SinkBinding {
|
||||||
sink := createServiceSink(service)
|
sink := createServiceSink(service)
|
||||||
builder := cl_sources_v1alpha1.NewSinkBindingBuilder(name).
|
builder := clientv1alpha2.NewSinkBindingBuilder(name).
|
||||||
Namespace("default").
|
Namespace("default").
|
||||||
Sink(&sink).
|
Sink(&sink).
|
||||||
SubjectGVK(&subjectGvk).
|
SubjectGVK(&subjectGvk).
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ import (
|
||||||
|
|
||||||
"knative.dev/client/pkg/kn/commands"
|
"knative.dev/client/pkg/kn/commands"
|
||||||
"knative.dev/client/pkg/kn/commands/flags"
|
"knative.dev/client/pkg/kn/commands/flags"
|
||||||
v1alpha12 "knative.dev/client/pkg/sources/v1alpha1"
|
v1alpha12 "knative.dev/client/pkg/sources/v1alpha2"
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewBindingCreateCommand is for creating sink bindings
|
// NewBindingCreateCommand is for creating sink bindings
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ import (
|
||||||
"gotest.tools/assert"
|
"gotest.tools/assert"
|
||||||
|
|
||||||
dynamicfake "knative.dev/client/pkg/dynamic/fake"
|
dynamicfake "knative.dev/client/pkg/dynamic/fake"
|
||||||
"knative.dev/client/pkg/sources/v1alpha1"
|
"knative.dev/client/pkg/sources/v1alpha2"
|
||||||
|
|
||||||
"knative.dev/client/pkg/util"
|
"knative.dev/client/pkg/util"
|
||||||
)
|
)
|
||||||
|
|
@ -29,7 +29,7 @@ func TestSimpleCreateBinding(t *testing.T) {
|
||||||
mysvc := createService("mysvc")
|
mysvc := createService("mysvc")
|
||||||
dynamicClient := dynamicfake.CreateFakeKnDynamicClient("default", mysvc)
|
dynamicClient := dynamicfake.CreateFakeKnDynamicClient("default", mysvc)
|
||||||
|
|
||||||
bindingClient := v1alpha1.NewMockKnSinkBindingClient(t)
|
bindingClient := v1alpha2.NewMockKnSinkBindingClient(t)
|
||||||
bindingRecorder := bindingClient.Recorder()
|
bindingRecorder := bindingClient.Recorder()
|
||||||
bindingRecorder.CreateSinkBinding(createSinkBinding("testbinding", "mysvc", deploymentGvk, "mydeploy", map[string]string{"bla": "blub", "foo": "bar"}), nil)
|
bindingRecorder.CreateSinkBinding(createSinkBinding("testbinding", "mysvc", deploymentGvk, "mydeploy", map[string]string{"bla": "blub", "foo": "bar"}), nil)
|
||||||
|
|
||||||
|
|
@ -41,7 +41,7 @@ func TestSimpleCreateBinding(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestNoSinkError(t *testing.T) {
|
func TestNoSinkError(t *testing.T) {
|
||||||
bindingClient := v1alpha1.NewMockKnSinkBindingClient(t)
|
bindingClient := v1alpha2.NewMockKnSinkBindingClient(t)
|
||||||
dynamicClient := dynamicfake.CreateFakeKnDynamicClient("default")
|
dynamicClient := dynamicfake.CreateFakeKnDynamicClient("default")
|
||||||
|
|
||||||
_, err := executeSinkBindingCommand(bindingClient, dynamicClient, "create", "testbinding", "--sink", "svc:mysvc", "--subject", "deployment:apps/v1:app=myapp")
|
_, err := executeSinkBindingCommand(bindingClient, dynamicClient, "create", "testbinding", "--sink", "svc:mysvc", "--subject", "deployment:apps/v1:app=myapp")
|
||||||
|
|
|
||||||
|
|
@ -20,13 +20,13 @@ import (
|
||||||
|
|
||||||
"gotest.tools/assert"
|
"gotest.tools/assert"
|
||||||
|
|
||||||
"knative.dev/client/pkg/sources/v1alpha1"
|
"knative.dev/client/pkg/sources/v1alpha2"
|
||||||
"knative.dev/client/pkg/util"
|
"knative.dev/client/pkg/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestSimpleDelete(t *testing.T) {
|
func TestSimpleDelete(t *testing.T) {
|
||||||
|
|
||||||
bindingClient := v1alpha1.NewMockKnSinkBindingClient(t, "mynamespace")
|
bindingClient := v1alpha2.NewMockKnSinkBindingClient(t, "mynamespace")
|
||||||
|
|
||||||
bindingRecorder := bindingClient.Recorder()
|
bindingRecorder := bindingClient.Recorder()
|
||||||
bindingRecorder.DeleteSinkBinding("mybinding", nil)
|
bindingRecorder.DeleteSinkBinding("mybinding", nil)
|
||||||
|
|
@ -40,7 +40,7 @@ func TestSimpleDelete(t *testing.T) {
|
||||||
|
|
||||||
func TestDeleteWithError(t *testing.T) {
|
func TestDeleteWithError(t *testing.T) {
|
||||||
|
|
||||||
bindingClient := v1alpha1.NewMockKnSinkBindingClient(t, "mynamespace")
|
bindingClient := v1alpha2.NewMockKnSinkBindingClient(t, "mynamespace")
|
||||||
|
|
||||||
bindingRecorder := bindingClient.Recorder()
|
bindingRecorder := bindingClient.Recorder()
|
||||||
bindingRecorder.DeleteSinkBinding("mybinding", errors.New("no such sink binding mybinding"))
|
bindingRecorder.DeleteSinkBinding("mybinding", errors.New("no such sink binding mybinding"))
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ import (
|
||||||
"sort"
|
"sort"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
v1alpha12 "knative.dev/eventing/pkg/apis/sources/v1alpha1"
|
v1alpha2 "knative.dev/eventing/pkg/apis/sources/v1alpha2"
|
||||||
duckv1 "knative.dev/pkg/apis/duck/v1"
|
duckv1 "knative.dev/pkg/apis/duck/v1"
|
||||||
"knative.dev/pkg/tracker"
|
"knative.dev/pkg/tracker"
|
||||||
|
|
||||||
|
|
@ -82,7 +82,7 @@ func NewBindingDescribeCommand(p *commands.KnParams) *cobra.Command {
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
||||||
func writeSinkBinding(dw printers.PrefixWriter, binding *v1alpha12.SinkBinding, printDetails bool) {
|
func writeSinkBinding(dw printers.PrefixWriter, binding *v1alpha2.SinkBinding, printDetails bool) {
|
||||||
commands.WriteMetadata(dw, &binding.ObjectMeta, printDetails)
|
commands.WriteMetadata(dw, &binding.ObjectMeta, printDetails)
|
||||||
writeSubject(dw, binding.Namespace, &binding.Spec.Subject)
|
writeSubject(dw, binding.Namespace, &binding.Spec.Subject)
|
||||||
writeSink(dw, binding.Namespace, &binding.Spec.Sink)
|
writeSink(dw, binding.Namespace, &binding.Spec.Sink)
|
||||||
|
|
|
||||||
|
|
@ -21,17 +21,17 @@ import (
|
||||||
|
|
||||||
"gotest.tools/assert"
|
"gotest.tools/assert"
|
||||||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
v1alpha14 "knative.dev/eventing/pkg/apis/sources/v1alpha1"
|
v1alpha2 "knative.dev/eventing/pkg/apis/sources/v1alpha2"
|
||||||
duckv1 "knative.dev/pkg/apis/duck/v1"
|
duckv1 "knative.dev/pkg/apis/duck/v1"
|
||||||
"knative.dev/pkg/apis/duck/v1alpha1"
|
"knative.dev/pkg/apis/duck/v1alpha1"
|
||||||
"knative.dev/pkg/tracker"
|
"knative.dev/pkg/tracker"
|
||||||
|
|
||||||
v1alpha13 "knative.dev/client/pkg/sources/v1alpha1"
|
clientv1alpha2 "knative.dev/client/pkg/sources/v1alpha2"
|
||||||
"knative.dev/client/pkg/util"
|
"knative.dev/client/pkg/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestSimpleDescribeWitName(t *testing.T) {
|
func TestSimpleDescribeWitName(t *testing.T) {
|
||||||
bindingClient := v1alpha13.NewMockKnSinkBindingClient(t, "mynamespace")
|
bindingClient := clientv1alpha2.NewMockKnSinkBindingClient(t, "mynamespace")
|
||||||
|
|
||||||
bindingRecorder := bindingClient.Recorder()
|
bindingRecorder := bindingClient.Recorder()
|
||||||
bindingRecorder.GetSinkBinding("mybinding", getSinkBindingSource("myapp", map[string]string{"foo": "bar"}), nil)
|
bindingRecorder.GetSinkBinding("mybinding", getSinkBindingSource("myapp", map[string]string{"foo": "bar"}), nil)
|
||||||
|
|
@ -44,7 +44,7 @@ func TestSimpleDescribeWitName(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSimpleDescribeWithSelector(t *testing.T) {
|
func TestSimpleDescribeWithSelector(t *testing.T) {
|
||||||
bindingClient := v1alpha13.NewMockKnSinkBindingClient(t, "mynamespace")
|
bindingClient := clientv1alpha2.NewMockKnSinkBindingClient(t, "mynamespace")
|
||||||
|
|
||||||
bindingRecorder := bindingClient.Recorder()
|
bindingRecorder := bindingClient.Recorder()
|
||||||
bindingRecorder.GetSinkBinding("mybinding", getSinkBindingSource("app=myapp,type=test", nil), nil)
|
bindingRecorder.GetSinkBinding("mybinding", getSinkBindingSource("app=myapp,type=test", nil), nil)
|
||||||
|
|
@ -57,7 +57,7 @@ func TestSimpleDescribeWithSelector(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDescribeError(t *testing.T) {
|
func TestDescribeError(t *testing.T) {
|
||||||
bindingClient := v1alpha13.NewMockKnSinkBindingClient(t, "mynamespace")
|
bindingClient := clientv1alpha2.NewMockKnSinkBindingClient(t, "mynamespace")
|
||||||
|
|
||||||
bindingRecorder := bindingClient.Recorder()
|
bindingRecorder := bindingClient.Recorder()
|
||||||
bindingRecorder.GetSinkBinding("mybinding", nil, errors.New("no sink binding mybinding found"))
|
bindingRecorder.GetSinkBinding("mybinding", nil, errors.New("no sink binding mybinding found"))
|
||||||
|
|
@ -69,13 +69,13 @@ func TestDescribeError(t *testing.T) {
|
||||||
bindingRecorder.Validate()
|
bindingRecorder.Validate()
|
||||||
}
|
}
|
||||||
|
|
||||||
func getSinkBindingSource(nameOrSelector string, ceOverrides map[string]string) *v1alpha14.SinkBinding {
|
func getSinkBindingSource(nameOrSelector string, ceOverrides map[string]string) *v1alpha2.SinkBinding {
|
||||||
binding := &v1alpha14.SinkBinding{
|
binding := &v1alpha2.SinkBinding{
|
||||||
TypeMeta: v1.TypeMeta{},
|
TypeMeta: v1.TypeMeta{},
|
||||||
ObjectMeta: v1.ObjectMeta{
|
ObjectMeta: v1.ObjectMeta{
|
||||||
Name: "mysinkbinding",
|
Name: "mysinkbinding",
|
||||||
},
|
},
|
||||||
Spec: v1alpha14.SinkBindingSpec{
|
Spec: v1alpha2.SinkBindingSpec{
|
||||||
SourceSpec: duckv1.SourceSpec{
|
SourceSpec: duckv1.SourceSpec{
|
||||||
Sink: duckv1.Destination{
|
Sink: duckv1.Destination{
|
||||||
Ref: &duckv1.KReference{
|
Ref: &duckv1.KReference{
|
||||||
|
|
@ -93,7 +93,7 @@ func getSinkBindingSource(nameOrSelector string, ceOverrides map[string]string)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Status: v1alpha14.SinkBindingStatus{},
|
Status: v1alpha2.SinkBindingStatus{},
|
||||||
}
|
}
|
||||||
|
|
||||||
if strings.Contains(nameOrSelector, "=") {
|
if strings.Contains(nameOrSelector, "=") {
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ import (
|
||||||
"knative.dev/client/pkg/kn/commands/flags"
|
"knative.dev/client/pkg/kn/commands/flags"
|
||||||
hprinters "knative.dev/client/pkg/printers"
|
hprinters "knative.dev/client/pkg/printers"
|
||||||
|
|
||||||
"knative.dev/eventing/pkg/apis/sources/v1alpha1"
|
v1alpha2 "knative.dev/eventing/pkg/apis/sources/v1alpha2"
|
||||||
)
|
)
|
||||||
|
|
||||||
type bindingUpdateFlags struct {
|
type bindingUpdateFlags struct {
|
||||||
|
|
@ -52,7 +52,7 @@ func BindingListHandlers(h hprinters.PrintHandler) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// printSinkBinding populates a single row of source sink binding list table
|
// printSinkBinding populates a single row of source sink binding list table
|
||||||
func printSinkBinding(binding *v1alpha1.SinkBinding, options hprinters.PrintOptions) ([]metav1beta1.TableRow, error) {
|
func printSinkBinding(binding *v1alpha2.SinkBinding, options hprinters.PrintOptions) ([]metav1beta1.TableRow, error) {
|
||||||
row := metav1beta1.TableRow{
|
row := metav1beta1.TableRow{
|
||||||
Object: runtime.RawExtension{Object: binding},
|
Object: runtime.RawExtension{Object: binding},
|
||||||
}
|
}
|
||||||
|
|
@ -73,7 +73,7 @@ func printSinkBinding(binding *v1alpha1.SinkBinding, options hprinters.PrintOpti
|
||||||
return []metav1beta1.TableRow{row}, nil
|
return []metav1beta1.TableRow{row}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func printSinkBindingList(sinkBindingList *v1alpha1.SinkBindingList, options hprinters.PrintOptions) ([]metav1beta1.TableRow, error) {
|
func printSinkBindingList(sinkBindingList *v1alpha2.SinkBindingList, options hprinters.PrintOptions) ([]metav1beta1.TableRow, error) {
|
||||||
|
|
||||||
rows := make([]metav1beta1.TableRow, 0, len(sinkBindingList.Items))
|
rows := make([]metav1beta1.TableRow, 0, len(sinkBindingList.Items))
|
||||||
for _, binding := range sinkBindingList.Items {
|
for _, binding := range sinkBindingList.Items {
|
||||||
|
|
|
||||||
|
|
@ -18,19 +18,19 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"gotest.tools/assert"
|
"gotest.tools/assert"
|
||||||
v1alpha1 "knative.dev/eventing/pkg/apis/sources/v1alpha1"
|
v1alpha2 "knative.dev/eventing/pkg/apis/sources/v1alpha2"
|
||||||
|
|
||||||
client_sources_v1alpha1 "knative.dev/client/pkg/sources/v1alpha1"
|
clientv1alpha2 "knative.dev/client/pkg/sources/v1alpha2"
|
||||||
"knative.dev/client/pkg/util"
|
"knative.dev/client/pkg/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestListSimple(t *testing.T) {
|
func TestListBindingSimple(t *testing.T) {
|
||||||
bindingClient := client_sources_v1alpha1.NewMockKnSinkBindingClient(t)
|
bindingClient := clientv1alpha2.NewMockKnSinkBindingClient(t)
|
||||||
|
|
||||||
bindingRecorder := bindingClient.Recorder()
|
bindingRecorder := bindingClient.Recorder()
|
||||||
binding := createSinkBinding("testbinding", "mysvc", deploymentGvk, "mydeploy", nil)
|
binding := createSinkBinding("testbinding", "mysvc", deploymentGvk, "mydeploy", nil)
|
||||||
bindingList := v1alpha1.SinkBindingList{
|
bindingList := v1alpha2.SinkBindingList{
|
||||||
Items: []v1alpha1.SinkBinding{
|
Items: []v1alpha2.SinkBinding{
|
||||||
*binding,
|
*binding,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
@ -44,11 +44,11 @@ func TestListSimple(t *testing.T) {
|
||||||
bindingRecorder.Validate()
|
bindingRecorder.Validate()
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestListEmpty(t *testing.T) {
|
func TestListBindingEmpty(t *testing.T) {
|
||||||
bindingClient := client_sources_v1alpha1.NewMockKnSinkBindingClient(t)
|
bindingClient := clientv1alpha2.NewMockKnSinkBindingClient(t)
|
||||||
|
|
||||||
bindingRecorder := bindingClient.Recorder()
|
bindingRecorder := bindingClient.Recorder()
|
||||||
bindingList := v1alpha1.SinkBindingList{}
|
bindingList := v1alpha2.SinkBindingList{}
|
||||||
bindingRecorder.ListSinkBindings(&bindingList, nil)
|
bindingRecorder.ListSinkBindings(&bindingList, nil)
|
||||||
|
|
||||||
out, err := executeSinkBindingCommand(bindingClient, nil, "list")
|
out, err := executeSinkBindingCommand(bindingClient, nil, "list")
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ import (
|
||||||
|
|
||||||
"knative.dev/client/pkg/kn/commands"
|
"knative.dev/client/pkg/kn/commands"
|
||||||
"knative.dev/client/pkg/kn/commands/flags"
|
"knative.dev/client/pkg/kn/commands/flags"
|
||||||
v1alpha12 "knative.dev/client/pkg/sources/v1alpha1"
|
v1alpha12 "knative.dev/client/pkg/sources/v1alpha2"
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewBindingUpdateCommand prepares the command for a sink binding update
|
// NewBindingUpdateCommand prepares the command for a sink binding update
|
||||||
|
|
|
||||||
|
|
@ -23,11 +23,11 @@ import (
|
||||||
servingv1 "knative.dev/serving/pkg/apis/serving/v1"
|
servingv1 "knative.dev/serving/pkg/apis/serving/v1"
|
||||||
|
|
||||||
dynamicfake "knative.dev/client/pkg/dynamic/fake"
|
dynamicfake "knative.dev/client/pkg/dynamic/fake"
|
||||||
clientsourcesv1alpha1 "knative.dev/client/pkg/sources/v1alpha1"
|
clientsourcesv1alpha1 "knative.dev/client/pkg/sources/v1alpha2"
|
||||||
"knative.dev/client/pkg/util"
|
"knative.dev/client/pkg/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestSimpleUpdate(t *testing.T) {
|
func TestSimpleBindingUpdate(t *testing.T) {
|
||||||
sinkBindingClient := clientsourcesv1alpha1.NewMockKnSinkBindingClient(t)
|
sinkBindingClient := clientsourcesv1alpha1.NewMockKnSinkBindingClient(t)
|
||||||
|
|
||||||
mysvc := createService("myscv")
|
mysvc := createService("myscv")
|
||||||
|
|
|
||||||
|
|
@ -1,96 +0,0 @@
|
||||||
// Copyright © 2019 The Knative Authors
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
package cronjob
|
|
||||||
|
|
||||||
import (
|
|
||||||
"errors"
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
|
||||||
|
|
||||||
"knative.dev/client/pkg/eventing/legacysources/v1alpha1"
|
|
||||||
"knative.dev/client/pkg/kn/commands"
|
|
||||||
"knative.dev/client/pkg/kn/commands/flags"
|
|
||||||
)
|
|
||||||
|
|
||||||
// NewCronJobCreateCommand is for creating CronJob source COs
|
|
||||||
func NewCronJobCreateCommand(p *commands.KnParams) *cobra.Command {
|
|
||||||
var cronUpdateFlags cronJobUpdateFlags
|
|
||||||
var sinkFlags flags.SinkFlags
|
|
||||||
|
|
||||||
cmd := &cobra.Command{
|
|
||||||
Use: "create NAME --schedule SCHEDULE --sink SINK --data DATA",
|
|
||||||
Short: "Create a CronJob source.",
|
|
||||||
Example: `
|
|
||||||
# Create a crontab scheduler 'my-cron-trigger' which fires every minute and sends 'ping' to service 'mysvc' as a cloudevent
|
|
||||||
kn source cronjob create my-cron-trigger --schedule "* * * * */1" --data "ping" --sink svc:mysvc
|
|
||||||
|
|
||||||
# Create a crontab scheduler 'my-cron-trigger' with ServiceAccount name
|
|
||||||
kn source cronjob create my-cron-trigger1 --schedule "* * * * */1" --data "ping" --sink svc:event-display --service-account myaccount
|
|
||||||
|
|
||||||
# Create a crontab scheduler 'my-cron-trigger' with requested resources
|
|
||||||
kn source cronjob create my-cron-trigger1 --schedule "* * * * */1" --data "ping" --sink svc:event-display --requests-cpu 100m --requests-memory 128Mi`,
|
|
||||||
|
|
||||||
RunE: func(cmd *cobra.Command, args []string) (err error) {
|
|
||||||
if len(args) != 1 {
|
|
||||||
return errors.New("requires the name of the crojob source to create as single argument")
|
|
||||||
|
|
||||||
}
|
|
||||||
name := args[0]
|
|
||||||
|
|
||||||
cronSourceClient, err := newCronJobSourceClient(p, cmd)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace, err := p.GetNamespace(cmd)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
dynamicClient, err := p.NewDynamicClient(namespace)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
destination, err := sinkFlags.ResolveSink(dynamicClient, namespace)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = cronSourceClient.CreateCronJobSource(
|
|
||||||
v1alpha1.NewCronJobSourceBuilder(name).
|
|
||||||
Schedule(cronUpdateFlags.schedule).
|
|
||||||
Data(cronUpdateFlags.data).
|
|
||||||
Sink(toDuckV1Beta1(destination)).
|
|
||||||
ResourceRequestsCPU(cronUpdateFlags.resourceRequestsCPU).
|
|
||||||
ResourceRequestsMemory(cronUpdateFlags.resourceRequestsMemory).
|
|
||||||
ResourceLimitsCPU(cronUpdateFlags.resourceLimitsCPU).
|
|
||||||
ResourceLimitsMemory(cronUpdateFlags.resourceLimitsMemory).
|
|
||||||
ServiceAccount(cronUpdateFlags.serviceAccountName).
|
|
||||||
Build())
|
|
||||||
if err == nil {
|
|
||||||
fmt.Fprintf(cmd.OutOrStdout(), "CronJob source '%s' created in namespace '%s'.\n", args[0], cronSourceClient.Namespace())
|
|
||||||
}
|
|
||||||
return err
|
|
||||||
},
|
|
||||||
}
|
|
||||||
commands.AddNamespaceFlags(cmd.Flags(), false)
|
|
||||||
cronUpdateFlags.addCronJobFlags(cmd)
|
|
||||||
sinkFlags.Add(cmd)
|
|
||||||
cmd.MarkFlagRequired("schedule")
|
|
||||||
cmd.MarkFlagRequired("sink")
|
|
||||||
|
|
||||||
return cmd
|
|
||||||
}
|
|
||||||
|
|
@ -1,83 +0,0 @@
|
||||||
// Copyright © 2019 The Knative Authors
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
package cronjob
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/spf13/cobra"
|
|
||||||
corev1 "k8s.io/api/core/v1"
|
|
||||||
"k8s.io/client-go/tools/clientcmd"
|
|
||||||
sources_v1alpha1 "knative.dev/eventing/pkg/legacyclient/clientset/versioned/typed/legacysources/v1alpha1"
|
|
||||||
v1 "knative.dev/pkg/apis/duck/v1"
|
|
||||||
"knative.dev/pkg/apis/duck/v1beta1"
|
|
||||||
|
|
||||||
"knative.dev/client/pkg/eventing/legacysources/v1alpha1"
|
|
||||||
"knative.dev/client/pkg/kn/commands"
|
|
||||||
)
|
|
||||||
|
|
||||||
// NewCronJobCommand is the root command for all cronjob related commands
|
|
||||||
func NewCronJobCommand(p *commands.KnParams) *cobra.Command {
|
|
||||||
cronImporterCmd := &cobra.Command{
|
|
||||||
Use: "cronjob",
|
|
||||||
Short: "CronJob source command group",
|
|
||||||
}
|
|
||||||
cronImporterCmd.AddCommand(NewCronJobCreateCommand(p))
|
|
||||||
cronImporterCmd.AddCommand(NewCronJobDeleteCommand(p))
|
|
||||||
cronImporterCmd.AddCommand(NewCronJobDescribeCommand(p))
|
|
||||||
cronImporterCmd.AddCommand(NewCronJobUpdateCommand(p))
|
|
||||||
cronImporterCmd.AddCommand(NewCronJobListCommand(p))
|
|
||||||
return cronImporterCmd
|
|
||||||
}
|
|
||||||
|
|
||||||
var cronJobSourceClientFactory func(config clientcmd.ClientConfig, namespace string) (v1alpha1.KnCronJobSourcesClient, error)
|
|
||||||
|
|
||||||
func newCronJobSourceClient(p *commands.KnParams, cmd *cobra.Command) (v1alpha1.KnCronJobSourcesClient, error) {
|
|
||||||
namespace, err := p.GetNamespace(cmd)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if cronJobSourceClientFactory != nil {
|
|
||||||
config, err := p.GetClientConfig()
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return cronJobSourceClientFactory(config, namespace)
|
|
||||||
}
|
|
||||||
|
|
||||||
clientConfig, err := p.RestConfig()
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
client, err := sources_v1alpha1.NewForConfig(clientConfig)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return v1alpha1.NewKnSourcesClient(client, namespace).CronJobSourcesClient(), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func toDuckV1Beta1(destination *v1.Destination) *v1beta1.Destination {
|
|
||||||
r := destination.Ref
|
|
||||||
return &v1beta1.Destination{
|
|
||||||
Ref: &corev1.ObjectReference{
|
|
||||||
Kind: r.Kind,
|
|
||||||
Namespace: r.Namespace,
|
|
||||||
Name: r.Name,
|
|
||||||
APIVersion: r.APIVersion,
|
|
||||||
},
|
|
||||||
URI: destination.URI,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,90 +0,0 @@
|
||||||
// Copyright © 2019 The Knative Authors
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
package cronjob
|
|
||||||
|
|
||||||
import (
|
|
||||||
"errors"
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"gotest.tools/assert"
|
|
||||||
corev1 "k8s.io/api/core/v1"
|
|
||||||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
||||||
"knative.dev/eventing/pkg/apis/legacysources/v1alpha1"
|
|
||||||
"knative.dev/pkg/apis/duck/v1beta1"
|
|
||||||
|
|
||||||
v1alpha12 "knative.dev/client/pkg/eventing/legacysources/v1alpha1"
|
|
||||||
"knative.dev/client/pkg/util"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestSimpleDescribe(t *testing.T) {
|
|
||||||
cronjobClient := v1alpha12.NewMockKnCronJobSourceClient(t, "mynamespace")
|
|
||||||
|
|
||||||
cronJobRecorder := cronjobClient.Recorder()
|
|
||||||
cronJobRecorder.GetCronJobSource("testsource", getCronJobSource(), nil)
|
|
||||||
|
|
||||||
out, err := executeCronJobSourceCommand(cronjobClient, nil, "describe", "testsource")
|
|
||||||
assert.NilError(t, err)
|
|
||||||
util.ContainsAll(out, "1 2 3 4 5", "honeymoon", "myservicenamespace", "mysvc", "Service", "testsource")
|
|
||||||
util.ContainsAll(out, "myaccount", "100m", "128Mi", "200m", "256Mi")
|
|
||||||
|
|
||||||
cronJobRecorder.Validate()
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestDescribeError(t *testing.T) {
|
|
||||||
cronjobClient := v1alpha12.NewMockKnCronJobSourceClient(t, "mynamespace")
|
|
||||||
|
|
||||||
cronJobRecorder := cronjobClient.Recorder()
|
|
||||||
cronJobRecorder.GetCronJobSource("testsource", nil, errors.New("no cronjob source testsource"))
|
|
||||||
|
|
||||||
out, err := executeCronJobSourceCommand(cronjobClient, nil, "describe", "testsource")
|
|
||||||
assert.ErrorContains(t, err, "testsource")
|
|
||||||
util.ContainsAll(out, "Usage", "testsource")
|
|
||||||
|
|
||||||
cronJobRecorder.Validate()
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func getCronJobSource() *v1alpha1.CronJobSource {
|
|
||||||
return &v1alpha1.CronJobSource{
|
|
||||||
TypeMeta: v1.TypeMeta{},
|
|
||||||
ObjectMeta: v1.ObjectMeta{
|
|
||||||
Name: "testsource",
|
|
||||||
},
|
|
||||||
Spec: v1alpha1.CronJobSourceSpec{
|
|
||||||
Schedule: "1 2 3 4 5",
|
|
||||||
Data: "honeymoon",
|
|
||||||
Sink: &v1beta1.Destination{
|
|
||||||
Ref: &corev1.ObjectReference{
|
|
||||||
Kind: "Service",
|
|
||||||
Namespace: "myservicenamespace",
|
|
||||||
Name: "mysvc",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
ServiceAccountName: "myaccount",
|
|
||||||
Resources: v1alpha1.CronJobResourceSpec{
|
|
||||||
Requests: v1alpha1.CronJobRequestsSpec{
|
|
||||||
ResourceCPU: "100m",
|
|
||||||
ResourceMemory: "128Mi",
|
|
||||||
},
|
|
||||||
Limits: v1alpha1.CronJobLimitsSpec{
|
|
||||||
ResourceCPU: "200m",
|
|
||||||
ResourceMemory: "256Mi",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Status: v1alpha1.CronJobSourceStatus{},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,59 +0,0 @@
|
||||||
// Copyright © 2019 The Knative Authors
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
package cronjob
|
|
||||||
|
|
||||||
import (
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"gotest.tools/assert"
|
|
||||||
|
|
||||||
knsource_v1alpha1 "knative.dev/client/pkg/eventing/legacysources/v1alpha1"
|
|
||||||
"knative.dev/client/pkg/util"
|
|
||||||
"knative.dev/eventing/pkg/apis/legacysources/v1alpha1"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestListCronJobSource(t *testing.T) {
|
|
||||||
cronjobClient := knsource_v1alpha1.NewMockKnCronJobSourceClient(t)
|
|
||||||
|
|
||||||
cronJobRecorder := cronjobClient.Recorder()
|
|
||||||
cJSource := createCronJobSource("testsource", "* * * * */2", "maxwell", "mysvc", "mysa", "100m", "128Mi", "200m", "256Mi")
|
|
||||||
cJSourceList := v1alpha1.CronJobSourceList{}
|
|
||||||
cJSourceList.Items = []v1alpha1.CronJobSource{*cJSource}
|
|
||||||
|
|
||||||
cronJobRecorder.ListCronJobSource(&cJSourceList, nil)
|
|
||||||
|
|
||||||
out, err := executeCronJobSourceCommand(cronjobClient, nil, "list")
|
|
||||||
assert.NilError(t, err, "Sources should be listed")
|
|
||||||
util.ContainsAll(out, "NAME", "SCHEDULE", "SINK", "AGE", "CONDITIONS", "READY", "REASON")
|
|
||||||
util.ContainsAll(out, "testsource", "* * * * */2", "mysvc")
|
|
||||||
|
|
||||||
cronJobRecorder.Validate()
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestListCronJobSourceEmpty(t *testing.T) {
|
|
||||||
cronjobClient := knsource_v1alpha1.NewMockKnCronJobSourceClient(t)
|
|
||||||
|
|
||||||
cronJobRecorder := cronjobClient.Recorder()
|
|
||||||
cJSourceList := v1alpha1.CronJobSourceList{}
|
|
||||||
|
|
||||||
cronJobRecorder.ListCronJobSource(&cJSourceList, nil)
|
|
||||||
|
|
||||||
out, err := executeCronJobSourceCommand(cronjobClient, nil, "list")
|
|
||||||
assert.NilError(t, err, "Sources should be listed")
|
|
||||||
util.ContainsNone(out, "NAME", "SCHEDULE", "SINK", "AGE", "CONDITIONS", "READY", "REASON")
|
|
||||||
util.ContainsAll(out, "No", "CronJob", "source", "found")
|
|
||||||
|
|
||||||
cronJobRecorder.Validate()
|
|
||||||
}
|
|
||||||
|
|
@ -1,76 +0,0 @@
|
||||||
// Copyright © 2019 The Knative Authors
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
package cronjob
|
|
||||||
|
|
||||||
import (
|
|
||||||
"errors"
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"gotest.tools/assert"
|
|
||||||
corev1 "k8s.io/api/core/v1"
|
|
||||||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
||||||
"knative.dev/eventing/pkg/apis/legacysources/v1alpha1"
|
|
||||||
"knative.dev/pkg/apis/duck/v1beta1"
|
|
||||||
|
|
||||||
v1alpha12 "knative.dev/client/pkg/eventing/legacysources/v1alpha1"
|
|
||||||
"knative.dev/client/pkg/util"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestSimpleUpdate(t *testing.T) {
|
|
||||||
|
|
||||||
cronjobClient := v1alpha12.NewMockKnCronJobSourceClient(t)
|
|
||||||
|
|
||||||
cronJobRecorder := cronjobClient.Recorder()
|
|
||||||
cronJobRecorder.GetCronJobSource("testsource", &v1alpha1.CronJobSource{
|
|
||||||
TypeMeta: v1.TypeMeta{},
|
|
||||||
ObjectMeta: v1.ObjectMeta{
|
|
||||||
Name: "testsource",
|
|
||||||
},
|
|
||||||
Spec: v1alpha1.CronJobSourceSpec{
|
|
||||||
Schedule: "1 2 3 4 5",
|
|
||||||
Data: "maxwell",
|
|
||||||
Sink: &v1beta1.Destination{
|
|
||||||
Ref: &corev1.ObjectReference{
|
|
||||||
Kind: "Service",
|
|
||||||
Name: "mysvc",
|
|
||||||
APIVersion: "serving.knative.dev/v1",
|
|
||||||
Namespace: "default",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Status: v1alpha1.CronJobSourceStatus{},
|
|
||||||
}, nil)
|
|
||||||
cronJobRecorder.UpdateCronJobSource(createCronJobSource("testsource", "* * * * */3", "maxwell", "mysvc", "mysa", "100m", "128Mi", "200m", "256Mi"), nil)
|
|
||||||
|
|
||||||
out, err := executeCronJobSourceCommand(cronjobClient, nil, "update", "--schedule", "* * * * */3", "--service-account",
|
|
||||||
"mysa", "--requests-cpu", "100m", "--requests-memory", "128Mi", "--limits-cpu", "200m", "--limits-memory", "256Mi", "testsource")
|
|
||||||
assert.NilError(t, err)
|
|
||||||
util.ContainsAll(out, "updated", "default", "testsource")
|
|
||||||
|
|
||||||
cronJobRecorder.Validate()
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestUpdateError(t *testing.T) {
|
|
||||||
cronjobClient := v1alpha12.NewMockKnCronJobSourceClient(t, "mynamespace")
|
|
||||||
|
|
||||||
cronJobRecorder := cronjobClient.Recorder()
|
|
||||||
cronJobRecorder.GetCronJobSource("testsource", nil, errors.New("no cronjob source testsource"))
|
|
||||||
|
|
||||||
out, err := executeCronJobSourceCommand(cronjobClient, nil, "update", "testsource")
|
|
||||||
assert.ErrorContains(t, err, "testsource")
|
|
||||||
util.ContainsAll(out, "Usage", "testsource")
|
|
||||||
|
|
||||||
cronJobRecorder.Validate()
|
|
||||||
}
|
|
||||||
|
|
@ -27,8 +27,6 @@ import (
|
||||||
|
|
||||||
var sourceTypeDescription = map[string]string{
|
var sourceTypeDescription = map[string]string{
|
||||||
"ApiServerSource": "Watch and send Kubernetes API events to a sink",
|
"ApiServerSource": "Watch and send Kubernetes API events to a sink",
|
||||||
"ContainerSource": "Connect a custom container image to a sink",
|
|
||||||
"CronJobSource": "Send periodically constant data to a sink",
|
|
||||||
"SinkBinding": "Binding for connecting a PodSpecable to a sink",
|
"SinkBinding": "Binding for connecting a PodSpecable to a sink",
|
||||||
"PingSource": "Send periodically ping events to a sink",
|
"PingSource": "Send periodically ping events to a sink",
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,84 @@
|
||||||
|
// Copyright © 2019 The Knative Authors
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package ping
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
|
"knative.dev/client/pkg/kn/commands"
|
||||||
|
"knative.dev/client/pkg/kn/commands/flags"
|
||||||
|
"knative.dev/client/pkg/sources/v1alpha2"
|
||||||
|
)
|
||||||
|
|
||||||
|
// NewPingCreateCommand is for creating Ping source COs
|
||||||
|
func NewPingCreateCommand(p *commands.KnParams) *cobra.Command {
|
||||||
|
var pingUpdateFlags pingUpdateFlags
|
||||||
|
var sinkFlags flags.SinkFlags
|
||||||
|
|
||||||
|
cmd := &cobra.Command{
|
||||||
|
Use: "create NAME --schedule SCHEDULE --sink SINK --data DATA",
|
||||||
|
Short: "Create a Ping source.",
|
||||||
|
Example: `
|
||||||
|
# Create a Ping source 'my-ping' which fires every two minutes and sends '{ value: "hello" }' to service 'mysvc' as a cloudevent
|
||||||
|
kn source ping create my-ping --schedule "*/2 * * * *" --data '{ value: "hello" }' --sink svc:mysvc`,
|
||||||
|
|
||||||
|
RunE: func(cmd *cobra.Command, args []string) (err error) {
|
||||||
|
if len(args) != 1 {
|
||||||
|
return errors.New("requires the name of the Ping source to create as single argument")
|
||||||
|
|
||||||
|
}
|
||||||
|
name := args[0]
|
||||||
|
|
||||||
|
pingSourceClient, err := newPingSourceClient(p, cmd)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace, err := p.GetNamespace(cmd)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
dynamicClient, err := p.NewDynamicClient(namespace)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
destination, err := sinkFlags.ResolveSink(dynamicClient, namespace)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = pingSourceClient.CreatePingSource(
|
||||||
|
v1alpha2.NewPingSourceBuilder(name).
|
||||||
|
Schedule(pingUpdateFlags.schedule).
|
||||||
|
JsonData(pingUpdateFlags.data).
|
||||||
|
Sink(*destination).
|
||||||
|
Build())
|
||||||
|
if err == nil {
|
||||||
|
fmt.Fprintf(cmd.OutOrStdout(), "Ping source '%s' created in namespace '%s'.\n", args[0], pingSourceClient.Namespace())
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
},
|
||||||
|
}
|
||||||
|
commands.AddNamespaceFlags(cmd.Flags(), false)
|
||||||
|
pingUpdateFlags.addPingFlags(cmd)
|
||||||
|
sinkFlags.Add(cmd)
|
||||||
|
cmd.MarkFlagRequired("sink")
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
|
@ -12,7 +12,7 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
package cronjob
|
package ping
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
@ -22,57 +22,49 @@ import (
|
||||||
servingv1 "knative.dev/serving/pkg/apis/serving/v1"
|
servingv1 "knative.dev/serving/pkg/apis/serving/v1"
|
||||||
|
|
||||||
dynamicfake "knative.dev/client/pkg/dynamic/fake"
|
dynamicfake "knative.dev/client/pkg/dynamic/fake"
|
||||||
|
"knative.dev/client/pkg/sources/v1alpha2"
|
||||||
|
|
||||||
clientsourcesv1alpha1 "knative.dev/client/pkg/eventing/legacysources/v1alpha1"
|
|
||||||
"knative.dev/client/pkg/util"
|
"knative.dev/client/pkg/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestSimpleCreateCronJobSource(t *testing.T) {
|
func TestSimpleCreatePingSource(t *testing.T) {
|
||||||
mysvc := &servingv1.Service{
|
mysvc := &servingv1.Service{
|
||||||
TypeMeta: v1.TypeMeta{Kind: "Service", APIVersion: "serving.knative.dev/v1"},
|
TypeMeta: v1.TypeMeta{Kind: "Service", APIVersion: "serving.knative.dev/v1"},
|
||||||
ObjectMeta: v1.ObjectMeta{Name: "mysvc", Namespace: "default"},
|
ObjectMeta: v1.ObjectMeta{Name: "mysvc", Namespace: "default"},
|
||||||
}
|
}
|
||||||
dynamicClient := dynamicfake.CreateFakeKnDynamicClient("default", mysvc)
|
dynamicClient := dynamicfake.CreateFakeKnDynamicClient("default", mysvc)
|
||||||
|
|
||||||
cronjobClient := clientsourcesv1alpha1.NewMockKnCronJobSourceClient(t)
|
pingClient := v1alpha2.NewMockKnPingSourceClient(t)
|
||||||
|
|
||||||
cronJobRecorder := cronjobClient.Recorder()
|
pingRecorder := pingClient.Recorder()
|
||||||
cronJobRecorder.CreateCronJobSource(createCronJobSource("testsource", "* * * * */2", "maxwell", "mysvc", "mysa", "100m", "128Mi", "200m", "256Mi"), nil)
|
pingRecorder.CreatePingSource(createPingSource("testsource", "* * * * */2", "maxwell", "mysvc"), nil)
|
||||||
|
|
||||||
out, err := executeCronJobSourceCommand(cronjobClient, dynamicClient, "create", "--sink", "svc:mysvc", "--schedule", "* * * * */2", "--data", "maxwell",
|
out, err := executePingSourceCommand(pingClient, dynamicClient, "create", "--sink", "svc:mysvc", "--schedule", "* * * * */2", "--data", "maxwell", "testsource")
|
||||||
"--service-account", "mysa", "--requests-cpu", "100m", "--requests-memory", "128Mi", "--limits-cpu", "200m", "--limits-memory", "256Mi", "testsource")
|
|
||||||
assert.NilError(t, err, "Source should have been created")
|
assert.NilError(t, err, "Source should have been created")
|
||||||
util.ContainsAll(out, "created", "default", "testsource")
|
util.ContainsAll(out, "created", "default", "testsource")
|
||||||
|
|
||||||
cronJobRecorder.Validate()
|
pingRecorder.Validate()
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestNoSinkError(t *testing.T) {
|
func TestNoSinkError(t *testing.T) {
|
||||||
cronjobClient := clientsourcesv1alpha1.NewMockKnCronJobSourceClient(t)
|
pingClient := v1alpha2.NewMockKnPingSourceClient(t)
|
||||||
|
|
||||||
dynamicClient := dynamicfake.CreateFakeKnDynamicClient("default")
|
dynamicClient := dynamicfake.CreateFakeKnDynamicClient("default")
|
||||||
|
|
||||||
out, err := executeCronJobSourceCommand(cronjobClient, dynamicClient, "create", "--sink", "svc:mysvc", "--schedule", "* * * * */2", "--data", "maxwell", "testsource")
|
out, err := executePingSourceCommand(pingClient, dynamicClient, "create", "--sink", "svc:mysvc", "--schedule", "* * * * */2", "--data", "maxwell", "testsource")
|
||||||
assert.Error(t, err, "services.serving.knative.dev \"mysvc\" not found")
|
assert.Error(t, err, "services.serving.knative.dev \"mysvc\" not found")
|
||||||
assert.Assert(t, util.ContainsAll(out, "Usage"))
|
assert.Assert(t, util.ContainsAll(out, "Usage"))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestNoSinkGivenError(t *testing.T) {
|
func TestNoSinkGivenError(t *testing.T) {
|
||||||
out, err := executeCronJobSourceCommand(nil, nil, "create", "--schedule", "* * * * */2", "--data", "maxwell", "testsource")
|
out, err := executePingSourceCommand(nil, nil, "create", "--schedule", "* * * * */2", "--data", "maxwell", "testsource")
|
||||||
assert.ErrorContains(t, err, "sink")
|
assert.ErrorContains(t, err, "sink")
|
||||||
assert.ErrorContains(t, err, "required")
|
assert.ErrorContains(t, err, "required")
|
||||||
assert.Assert(t, util.ContainsAll(out, "Usage", "not set", "required"))
|
assert.Assert(t, util.ContainsAll(out, "Usage", "not set", "required"))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestNoScheduleGivenError(t *testing.T) {
|
|
||||||
out, err := executeCronJobSourceCommand(nil, nil, "create", "--sink", "svc:mysvc", "--data", "maxwell", "testsource")
|
|
||||||
assert.ErrorContains(t, err, "schedule")
|
|
||||||
assert.ErrorContains(t, err, "required")
|
|
||||||
assert.Assert(t, util.ContainsAll(out, "Usage", "not set", "required"))
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestNoNameGivenError(t *testing.T) {
|
func TestNoNameGivenError(t *testing.T) {
|
||||||
out, err := executeCronJobSourceCommand(nil, nil, "create", "--sink", "svc:mysvc", "--schedule", "* * * * */2")
|
out, err := executePingSourceCommand(nil, nil, "create", "--sink", "svc:mysvc", "--schedule", "* * * * */2")
|
||||||
assert.ErrorContains(t, err, "name")
|
assert.ErrorContains(t, err, "name")
|
||||||
assert.ErrorContains(t, err, "require")
|
assert.ErrorContains(t, err, "require")
|
||||||
assert.Assert(t, util.ContainsAll(out, "Usage", "require", "name"))
|
assert.Assert(t, util.ContainsAll(out, "Usage", "require", "name"))
|
||||||
|
|
@ -12,7 +12,7 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
package cronjob
|
package ping
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
|
@ -22,34 +22,34 @@ import (
|
||||||
"knative.dev/client/pkg/kn/commands"
|
"knative.dev/client/pkg/kn/commands"
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewCronJobDeleteCommand is for deleting a CronJob source
|
// NewPingDeleteCommand is for deleting a Ping source
|
||||||
func NewCronJobDeleteCommand(p *commands.KnParams) *cobra.Command {
|
func NewPingDeleteCommand(p *commands.KnParams) *cobra.Command {
|
||||||
CronJobDeleteCommand := &cobra.Command{
|
pingDeleteCommand := &cobra.Command{
|
||||||
Use: "delete NAME",
|
Use: "delete NAME",
|
||||||
Short: "Delete a CronJob source.",
|
Short: "Delete a Ping source.",
|
||||||
Example: `
|
Example: `
|
||||||
# Delete a CronJob source 'my-cron-trigger'
|
# Delete a Ping source 'my-ping'
|
||||||
kn source cronjob delete my-cron-trigger`,
|
kn source ping delete my-ping`,
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
if len(args) != 1 {
|
if len(args) != 1 {
|
||||||
return errors.New("'requires the name of the cronjob source to delete as single argument")
|
return errors.New("'requires the name of the Ping source to delete as single argument")
|
||||||
}
|
}
|
||||||
name := args[0]
|
name := args[0]
|
||||||
|
|
||||||
cronSourceClient, err := newCronJobSourceClient(p, cmd)
|
pingClient, err := newPingSourceClient(p, cmd)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = cronSourceClient.DeleteCronJobSource(name)
|
err = pingClient.DeletePingSource(name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Fprintf(cmd.OutOrStdout(), "CronJob source '%s' deleted in namespace '%s'.\n", name, cronSourceClient.Namespace())
|
fmt.Fprintf(cmd.OutOrStdout(), "Ping source '%s' deleted in namespace '%s'.\n", name, pingClient.Namespace())
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
commands.AddNamespaceFlags(CronJobDeleteCommand.Flags(), false)
|
commands.AddNamespaceFlags(pingDeleteCommand.Flags(), false)
|
||||||
return CronJobDeleteCommand
|
return pingDeleteCommand
|
||||||
}
|
}
|
||||||
|
|
@ -12,7 +12,7 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
package cronjob
|
package ping
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
|
@ -20,34 +20,34 @@ import (
|
||||||
|
|
||||||
"gotest.tools/assert"
|
"gotest.tools/assert"
|
||||||
|
|
||||||
v1alpha12 "knative.dev/client/pkg/eventing/legacysources/v1alpha1"
|
"knative.dev/client/pkg/sources/v1alpha2"
|
||||||
"knative.dev/client/pkg/util"
|
"knative.dev/client/pkg/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestSimpleDelete(t *testing.T) {
|
func TestSimpleDelete(t *testing.T) {
|
||||||
|
|
||||||
cronjobClient := v1alpha12.NewMockKnCronJobSourceClient(t, "mynamespace")
|
pingClient := v1alpha2.NewMockKnPingSourceClient(t, "mynamespace")
|
||||||
|
|
||||||
cronJobRecorder := cronjobClient.Recorder()
|
pingRecorder := pingClient.Recorder()
|
||||||
cronJobRecorder.DeleteCronJobSource("testsource", nil)
|
pingRecorder.DeletePingSource("testsource", nil)
|
||||||
|
|
||||||
out, err := executeCronJobSourceCommand(cronjobClient, nil, "delete", "testsource")
|
out, err := executePingSourceCommand(pingClient, nil, "delete", "testsource")
|
||||||
assert.NilError(t, err)
|
assert.NilError(t, err)
|
||||||
util.ContainsAll(out, "deleted", "mynamespace", "testsource", "cronjob")
|
util.ContainsAll(out, "deleted", "mynamespace", "testsource", "ping")
|
||||||
|
|
||||||
cronJobRecorder.Validate()
|
pingRecorder.Validate()
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDeleteWithError(t *testing.T) {
|
func TestDeleteWithError(t *testing.T) {
|
||||||
|
|
||||||
cronjobClient := v1alpha12.NewMockKnCronJobSourceClient(t, "mynamespace")
|
pingClient := v1alpha2.NewMockKnPingSourceClient(t, "mynamespace")
|
||||||
|
|
||||||
cronJobRecorder := cronjobClient.Recorder()
|
pingRecorder := pingClient.Recorder()
|
||||||
cronJobRecorder.DeleteCronJobSource("testsource", errors.New("no such cronjob source testsource"))
|
pingRecorder.DeletePingSource("testsource", errors.New("no such Ping source testsource"))
|
||||||
|
|
||||||
out, err := executeCronJobSourceCommand(cronjobClient, nil, "delete", "testsource")
|
out, err := executePingSourceCommand(pingClient, nil, "delete", "testsource")
|
||||||
assert.ErrorContains(t, err, "testsource")
|
assert.ErrorContains(t, err, "testsource")
|
||||||
util.ContainsAll(out, "Usage", "no such", "testsource")
|
util.ContainsAll(out, "Usage", "no such", "testsource")
|
||||||
|
|
||||||
cronJobRecorder.Validate()
|
pingRecorder.Validate()
|
||||||
}
|
}
|
||||||
|
|
@ -12,41 +12,41 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
package cronjob
|
package ping
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"knative.dev/eventing/pkg/apis/legacysources/v1alpha1"
|
v1alpha2 "knative.dev/eventing/pkg/apis/sources/v1alpha2"
|
||||||
duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1"
|
duckv1 "knative.dev/pkg/apis/duck/v1"
|
||||||
|
|
||||||
"knative.dev/client/pkg/kn/commands"
|
"knative.dev/client/pkg/kn/commands"
|
||||||
"knative.dev/client/pkg/printers"
|
"knative.dev/client/pkg/printers"
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewCronJobDescribeCommand returns a new command for describe a CronJob source object
|
// NewPingDescribeCommand returns a new command for describe a Ping source object
|
||||||
func NewCronJobDescribeCommand(p *commands.KnParams) *cobra.Command {
|
func NewPingDescribeCommand(p *commands.KnParams) *cobra.Command {
|
||||||
|
|
||||||
cronJobDescribe := &cobra.Command{
|
pingDescribe := &cobra.Command{
|
||||||
Use: "describe NAME",
|
Use: "describe NAME",
|
||||||
Short: "Show details of a CronJob source",
|
Short: "Show details of a Ping source",
|
||||||
Example: `
|
Example: `
|
||||||
# Describe a cronjob source with name 'mycronjob'
|
# Describe a Ping source with name 'myping'
|
||||||
kn source cronjob describe mycronjob`,
|
kn source ping describe myping`,
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
if len(args) != 1 {
|
if len(args) != 1 {
|
||||||
return errors.New("'kn source cronjob describe' requires name of the source as single argument")
|
return errors.New("'kn source ping describe' requires name of the source as single argument")
|
||||||
}
|
}
|
||||||
name := args[0]
|
name := args[0]
|
||||||
|
|
||||||
cronSourceClient, err := newCronJobSourceClient(p, cmd)
|
pingSourceClient, err := newPingSourceClient(p, cmd)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
cjSource, err := cronSourceClient.GetCronJobSource(name)
|
cjSource, err := pingSourceClient.GetPingSource(name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
@ -59,14 +59,14 @@ func NewCronJobDescribeCommand(p *commands.KnParams) *cobra.Command {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
writeCronJobSource(dw, cjSource, printDetails)
|
writePingSource(dw, cjSource, printDetails)
|
||||||
dw.WriteLine()
|
dw.WriteLine()
|
||||||
if err := dw.Flush(); err != nil {
|
if err := dw.Flush(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Revisions summary info
|
// Revisions summary info
|
||||||
writeSink(dw, cjSource.Spec.Sink)
|
writeSink(dw, &cjSource.Spec.Sink)
|
||||||
dw.WriteLine()
|
dw.WriteLine()
|
||||||
if err := dw.Flush(); err != nil {
|
if err := dw.Flush(); err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
@ -81,14 +81,14 @@ func NewCronJobDescribeCommand(p *commands.KnParams) *cobra.Command {
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
flags := cronJobDescribe.Flags()
|
flags := pingDescribe.Flags()
|
||||||
commands.AddNamespaceFlags(flags, false)
|
commands.AddNamespaceFlags(flags, false)
|
||||||
flags.BoolP("verbose", "v", false, "More output.")
|
flags.BoolP("verbose", "v", false, "More output.")
|
||||||
|
|
||||||
return cronJobDescribe
|
return pingDescribe
|
||||||
}
|
}
|
||||||
|
|
||||||
func writeSink(dw printers.PrefixWriter, sink *duckv1beta1.Destination) {
|
func writeSink(dw printers.PrefixWriter, sink *duckv1.Destination) {
|
||||||
subWriter := dw.WriteAttribute("Sink", "")
|
subWriter := dw.WriteAttribute("Sink", "")
|
||||||
subWriter.WriteAttribute("Name", sink.Ref.Name)
|
subWriter.WriteAttribute("Name", sink.Ref.Name)
|
||||||
subWriter.WriteAttribute("Namespace", sink.Ref.Namespace)
|
subWriter.WriteAttribute("Namespace", sink.Ref.Namespace)
|
||||||
|
|
@ -102,16 +102,8 @@ func writeSink(dw printers.PrefixWriter, sink *duckv1beta1.Destination) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func writeCronJobSource(dw printers.PrefixWriter, source *v1alpha1.CronJobSource, printDetails bool) {
|
func writePingSource(dw printers.PrefixWriter, source *v1alpha2.PingSource, printDetails bool) {
|
||||||
commands.WriteMetadata(dw, &source.ObjectMeta, printDetails)
|
commands.WriteMetadata(dw, &source.ObjectMeta, printDetails)
|
||||||
dw.WriteAttribute("Schedule", source.Spec.Schedule)
|
dw.WriteAttribute("Schedule", source.Spec.Schedule)
|
||||||
dw.WriteAttribute("Data", source.Spec.Data)
|
dw.WriteAttribute("Data", source.Spec.JsonData)
|
||||||
dw.WriteAttribute("ServiceAccountName", source.Spec.ServiceAccountName)
|
|
||||||
subWriter1 := dw.WriteAttribute("Resources", "")
|
|
||||||
subWriter2 := subWriter1.WriteAttribute("Requests", "")
|
|
||||||
subWriter2.WriteAttribute("CPU", source.Spec.Resources.Requests.ResourceCPU)
|
|
||||||
subWriter2.WriteAttribute("Memory", source.Spec.Resources.Requests.ResourceMemory)
|
|
||||||
subWriter2 = subWriter1.WriteAttribute("Limits", "")
|
|
||||||
subWriter2.WriteAttribute("CPU", source.Spec.Resources.Limits.ResourceCPU)
|
|
||||||
subWriter2.WriteAttribute("Memory", source.Spec.Resources.Limits.ResourceMemory)
|
|
||||||
}
|
}
|
||||||
|
|
@ -0,0 +1,80 @@
|
||||||
|
// Copyright © 2019 The Knative Authors
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package ping
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"gotest.tools/assert"
|
||||||
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
v1alpha2 "knative.dev/eventing/pkg/apis/sources/v1alpha2"
|
||||||
|
duckv1 "knative.dev/pkg/apis/duck/v1"
|
||||||
|
|
||||||
|
clientv1alpha2 "knative.dev/client/pkg/sources/v1alpha2"
|
||||||
|
"knative.dev/client/pkg/util"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestSimpleDescribe(t *testing.T) {
|
||||||
|
pingClient := clientv1alpha2.NewMockKnPingSourceClient(t, "mynamespace")
|
||||||
|
|
||||||
|
pingRecorder := pingClient.Recorder()
|
||||||
|
pingRecorder.GetPingSource("testsource", getPingSource(), nil)
|
||||||
|
|
||||||
|
out, err := executePingSourceCommand(pingClient, nil, "describe", "testsource")
|
||||||
|
assert.NilError(t, err)
|
||||||
|
util.ContainsAll(out, "1 2 3 4 5", "honeymoon", "myservicenamespace", "mysvc", "Service", "testsource")
|
||||||
|
util.ContainsAll(out, "myaccount", "100m", "128Mi", "200m", "256Mi")
|
||||||
|
|
||||||
|
pingRecorder.Validate()
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestDescribeError(t *testing.T) {
|
||||||
|
pingClient := clientv1alpha2.NewMockKnPingSourceClient(t, "mynamespace")
|
||||||
|
|
||||||
|
pingRecorder := pingClient.Recorder()
|
||||||
|
pingRecorder.GetPingSource("testsource", nil, errors.New("no Ping source testsource"))
|
||||||
|
|
||||||
|
out, err := executePingSourceCommand(pingClient, nil, "describe", "testsource")
|
||||||
|
assert.ErrorContains(t, err, "testsource")
|
||||||
|
util.ContainsAll(out, "Usage", "testsource")
|
||||||
|
|
||||||
|
pingRecorder.Validate()
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func getPingSource() *v1alpha2.PingSource {
|
||||||
|
return &v1alpha2.PingSource{
|
||||||
|
TypeMeta: metav1.TypeMeta{},
|
||||||
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
|
Name: "testsource",
|
||||||
|
},
|
||||||
|
Spec: v1alpha2.PingSourceSpec{
|
||||||
|
Schedule: "1 2 3 4 5",
|
||||||
|
JsonData: "honeymoon",
|
||||||
|
SourceSpec: duckv1.SourceSpec{
|
||||||
|
Sink: duckv1.Destination{
|
||||||
|
Ref: &duckv1.KReference{
|
||||||
|
Kind: "Service",
|
||||||
|
Namespace: "myservicenamespace",
|
||||||
|
Name: "mysvc",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Status: v1alpha2.PingSourceStatus{},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -12,7 +12,7 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
package cronjob
|
package ping
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
@ -25,48 +25,37 @@ import (
|
||||||
"knative.dev/client/pkg/kn/commands"
|
"knative.dev/client/pkg/kn/commands"
|
||||||
hprinters "knative.dev/client/pkg/printers"
|
hprinters "knative.dev/client/pkg/printers"
|
||||||
|
|
||||||
"knative.dev/eventing/pkg/apis/legacysources/v1alpha1"
|
v1alpha2 "knative.dev/eventing/pkg/apis/sources/v1alpha2"
|
||||||
)
|
)
|
||||||
|
|
||||||
type cronJobUpdateFlags struct {
|
type pingUpdateFlags struct {
|
||||||
schedule string
|
schedule string
|
||||||
data string
|
data string
|
||||||
resourceRequestsCPU string
|
|
||||||
resourceRequestsMemory string
|
|
||||||
resourceLimitsCPU string
|
|
||||||
resourceLimitsMemory string
|
|
||||||
serviceAccountName string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *cronJobUpdateFlags) addCronJobFlags(cmd *cobra.Command) {
|
func (c *pingUpdateFlags) addPingFlags(cmd *cobra.Command) {
|
||||||
cmd.Flags().StringVar(&c.schedule, "schedule", "", "Schedule specification in crontab format (e.g. '* * * * */2' for every two minutes")
|
cmd.Flags().StringVar(&c.schedule, "schedule", "", "Optional schedule specification in crontab format (e.g. '*/2 * * * *' for every two minutes. By default fire every minute.")
|
||||||
cmd.Flags().StringVarP(&c.data, "data", "d", "", "String data to send")
|
cmd.Flags().StringVarP(&c.data, "data", "d", "", "Json data to send")
|
||||||
cmd.Flags().StringVar(&c.resourceRequestsCPU, "requests-cpu", "", "The requested CPU (e.g., 250m).")
|
|
||||||
cmd.Flags().StringVar(&c.resourceRequestsMemory, "requests-memory", "", "The requested memory (e.g., 64Mi).")
|
|
||||||
cmd.Flags().StringVar(&c.resourceLimitsCPU, "limits-cpu", "", "The limits on the requested CPU (e.g., 1000m).")
|
|
||||||
cmd.Flags().StringVar(&c.resourceLimitsMemory, "limits-memory", "",
|
|
||||||
"The limits on the requested memory (e.g., 1024Mi).")
|
|
||||||
cmd.Flags().StringVar(&c.serviceAccountName, "service-account", "", "Name of the service account to use to run this source")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// CronJobListHandlers handles printing human readable table for `kn source cronjob list` command's output
|
// PingListHandlers handles printing human readable table for `kn source ping list` command's output
|
||||||
func CronJobSourceListHandlers(h hprinters.PrintHandler) {
|
func PingSourceListHandlers(h hprinters.PrintHandler) {
|
||||||
sourceColumnDefinitions := []metav1beta1.TableColumnDefinition{
|
sourceColumnDefinitions := []metav1beta1.TableColumnDefinition{
|
||||||
{Name: "Namespace", Type: "string", Description: "Namespace of the CronJob source", Priority: 0},
|
{Name: "Namespace", Type: "string", Description: "Namespace of the Ping source", Priority: 0},
|
||||||
{Name: "Name", Type: "string", Description: "Name of the CronJob source", Priority: 1},
|
{Name: "Name", Type: "string", Description: "Name of the Ping source", Priority: 1},
|
||||||
{Name: "Schedule", Type: "string", Description: "Schedule of the CronJob source", Priority: 1},
|
{Name: "Schedule", Type: "string", Description: "Schedule of the Ping source", Priority: 1},
|
||||||
{Name: "Sink", Type: "string", Description: "Sink of the CronJob source", Priority: 1},
|
{Name: "Sink", Type: "string", Description: "Sink of the Ping source", Priority: 1},
|
||||||
{Name: "Age", Type: "string", Description: "Age of the CronJob source", Priority: 1},
|
{Name: "Age", Type: "string", Description: "Age of the Ping source", Priority: 1},
|
||||||
{Name: "Conditions", Type: "string", Description: "Ready state conditions", Priority: 1},
|
{Name: "Conditions", Type: "string", Description: "Ready state conditions", Priority: 1},
|
||||||
{Name: "Ready", Type: "string", Description: "Ready state of the CronJob source", Priority: 1},
|
{Name: "Ready", Type: "string", Description: "Ready state of the Ping source", Priority: 1},
|
||||||
{Name: "Reason", Type: "string", Description: "Reason if state is not Ready", Priority: 1},
|
{Name: "Reason", Type: "string", Description: "Reason if state is not Ready", Priority: 1},
|
||||||
}
|
}
|
||||||
h.TableHandler(sourceColumnDefinitions, printSource)
|
h.TableHandler(sourceColumnDefinitions, printSource)
|
||||||
h.TableHandler(sourceColumnDefinitions, printSourceList)
|
h.TableHandler(sourceColumnDefinitions, printSourceList)
|
||||||
}
|
}
|
||||||
|
|
||||||
// printSource populates a single row of source cronjob list table
|
// printSource populates a single row of Ping source list
|
||||||
func printSource(source *v1alpha1.CronJobSource, options hprinters.PrintOptions) ([]metav1beta1.TableRow, error) {
|
func printSource(source *v1alpha2.PingSource, options hprinters.PrintOptions) ([]metav1beta1.TableRow, error) {
|
||||||
row := metav1beta1.TableRow{
|
row := metav1beta1.TableRow{
|
||||||
Object: runtime.RawExtension{Object: source},
|
Object: runtime.RawExtension{Object: source},
|
||||||
}
|
}
|
||||||
|
|
@ -82,13 +71,11 @@ func printSource(source *v1alpha1.CronJobSource, options hprinters.PrintOptions)
|
||||||
// This source is going to be moved/removed soon to v1, so no need to move
|
// This source is going to be moved/removed soon to v1, so no need to move
|
||||||
// it now
|
// it now
|
||||||
var sink string
|
var sink string
|
||||||
if source.Spec.Sink != nil {
|
if source.Spec.Sink.Ref != nil {
|
||||||
if source.Spec.Sink.Ref != nil {
|
if source.Spec.Sink.Ref.Kind == "Service" {
|
||||||
if source.Spec.Sink.Ref.Kind == "Service" {
|
sink = fmt.Sprintf("svc:%s", source.Spec.Sink.Ref.Name)
|
||||||
sink = fmt.Sprintf("svc:%s", source.Spec.Sink.Ref.Name)
|
} else {
|
||||||
} else {
|
sink = fmt.Sprintf("%s:%s", source.Spec.Sink.Ref.Kind, source.Spec.Sink.Ref.Name)
|
||||||
sink = fmt.Sprintf("%s:%s", source.Spec.Sink.Ref.Kind, source.Spec.Sink.Ref.Name)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -100,8 +87,8 @@ func printSource(source *v1alpha1.CronJobSource, options hprinters.PrintOptions)
|
||||||
return []metav1beta1.TableRow{row}, nil
|
return []metav1beta1.TableRow{row}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// printSourceList populates the source cronjob list table rows
|
// printSourceList populates the Ping source list table rows
|
||||||
func printSourceList(sourceList *v1alpha1.CronJobSourceList, options hprinters.PrintOptions) ([]metav1beta1.TableRow, error) {
|
func printSourceList(sourceList *v1alpha2.PingSourceList, options hprinters.PrintOptions) ([]metav1beta1.TableRow, error) {
|
||||||
if options.AllNamespaces {
|
if options.AllNamespaces {
|
||||||
return printSourceListWithNamespace(sourceList, options)
|
return printSourceListWithNamespace(sourceList, options)
|
||||||
}
|
}
|
||||||
|
|
@ -124,11 +111,11 @@ func printSourceList(sourceList *v1alpha1.CronJobSourceList, options hprinters.P
|
||||||
}
|
}
|
||||||
|
|
||||||
// printSourceListWithNamespace populates the knative service table rows with namespace column
|
// printSourceListWithNamespace populates the knative service table rows with namespace column
|
||||||
func printSourceListWithNamespace(sourceList *v1alpha1.CronJobSourceList, options hprinters.PrintOptions) ([]metav1beta1.TableRow, error) {
|
func printSourceListWithNamespace(sourceList *v1alpha2.PingSourceList, options hprinters.PrintOptions) ([]metav1beta1.TableRow, error) {
|
||||||
rows := make([]metav1beta1.TableRow, 0, len(sourceList.Items))
|
rows := make([]metav1beta1.TableRow, 0, len(sourceList.Items))
|
||||||
|
|
||||||
// temporary slice for sorting services in non-default namespace
|
// temporary slice for sorting services in non-default namespace
|
||||||
others := []metav1beta1.TableRow{}
|
var others []metav1beta1.TableRow
|
||||||
|
|
||||||
for _, source := range sourceList.Items {
|
for _, source := range sourceList.Items {
|
||||||
// Fill in with services in `default` namespace at first
|
// Fill in with services in `default` namespace at first
|
||||||
|
|
@ -12,49 +12,50 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
package cronjob
|
package ping
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
"knative.dev/client/pkg/kn/commands"
|
"knative.dev/client/pkg/kn/commands"
|
||||||
"knative.dev/client/pkg/kn/commands/flags"
|
"knative.dev/client/pkg/kn/commands/flags"
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewCronJobListCommand is for listing CronJob source COs
|
// NewPingListCommand is for listing Ping source COs
|
||||||
func NewCronJobListCommand(p *commands.KnParams) *cobra.Command {
|
func NewPingListCommand(p *commands.KnParams) *cobra.Command {
|
||||||
listFlags := flags.NewListPrintFlags(CronJobSourceListHandlers)
|
listFlags := flags.NewListPrintFlags(PingSourceListHandlers)
|
||||||
|
|
||||||
listCommand := &cobra.Command{
|
listCommand := &cobra.Command{
|
||||||
Use: "list",
|
Use: "list",
|
||||||
Short: "List CronJob sources.",
|
Short: "List Ping sources.",
|
||||||
Example: `
|
Example: `
|
||||||
# List all CronJob sources
|
# List all Ping sources
|
||||||
kn source cronjob list
|
kn source ping list
|
||||||
|
|
||||||
# List all CronJob sources in YAML format
|
# List all Ping sources in YAML format
|
||||||
kn source cronjob list -o yaml`,
|
kn source ping list -o yaml`,
|
||||||
|
|
||||||
RunE: func(cmd *cobra.Command, args []string) (err error) {
|
RunE: func(cmd *cobra.Command, args []string) (err error) {
|
||||||
// TODO: filter list by given source name
|
// TODO: filter list by given source name
|
||||||
|
|
||||||
cronSourceClient, err := newCronJobSourceClient(p, cmd)
|
pingClient, err := newPingSourceClient(p, cmd)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
sourceList, err := cronSourceClient.ListCronJobSource()
|
sourceList, err := pingClient.ListPingSource()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(sourceList.Items) == 0 {
|
if len(sourceList.Items) == 0 {
|
||||||
fmt.Fprintf(cmd.OutOrStdout(), "No CronJob source found.\n")
|
fmt.Fprintf(cmd.OutOrStdout(), "No Ping source found.\n")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if cronSourceClient.Namespace() == "" {
|
if pingClient.Namespace() == "" {
|
||||||
listFlags.EnsureWithNamespace()
|
listFlags.EnsureWithNamespace()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,60 @@
|
||||||
|
// Copyright © 2019 The Knative Authors
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package ping
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"gotest.tools/assert"
|
||||||
|
|
||||||
|
v1alpha2 "knative.dev/eventing/pkg/apis/sources/v1alpha2"
|
||||||
|
|
||||||
|
clientv1alpha2 "knative.dev/client/pkg/sources/v1alpha2"
|
||||||
|
"knative.dev/client/pkg/util"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestListPingSource(t *testing.T) {
|
||||||
|
pingClient := clientv1alpha2.NewMockKnPingSourceClient(t)
|
||||||
|
|
||||||
|
pingRecorder := pingClient.Recorder()
|
||||||
|
cJSource := createPingSource("testsource", "* * * * */2", "maxwell", "mysvc")
|
||||||
|
cJSourceList := v1alpha2.PingSourceList{}
|
||||||
|
cJSourceList.Items = []v1alpha2.PingSource{*cJSource}
|
||||||
|
|
||||||
|
pingRecorder.ListPingSource(&cJSourceList, nil)
|
||||||
|
|
||||||
|
out, err := executePingSourceCommand(pingClient, nil, "list")
|
||||||
|
assert.NilError(t, err, "Sources should be listed")
|
||||||
|
util.ContainsAll(out, "NAME", "SCHEDULE", "SINK", "AGE", "CONDITIONS", "READY", "REASON")
|
||||||
|
util.ContainsAll(out, "testsource", "* * * * */2", "mysvc")
|
||||||
|
|
||||||
|
pingRecorder.Validate()
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestListPingJobSourceEmpty(t *testing.T) {
|
||||||
|
pingClient := clientv1alpha2.NewMockKnPingSourceClient(t)
|
||||||
|
|
||||||
|
pingRecorder := pingClient.Recorder()
|
||||||
|
cJSourceList := v1alpha2.PingSourceList{}
|
||||||
|
|
||||||
|
pingRecorder.ListPingSource(&cJSourceList, nil)
|
||||||
|
|
||||||
|
out, err := executePingSourceCommand(pingClient, nil, "list")
|
||||||
|
assert.NilError(t, err, "Sources should be listed")
|
||||||
|
util.ContainsNone(out, "NAME", "SCHEDULE", "SINK", "AGE", "CONDITIONS", "READY", "REASON")
|
||||||
|
util.ContainsAll(out, "No", "ping", "source", "found")
|
||||||
|
|
||||||
|
pingRecorder.Validate()
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,67 @@
|
||||||
|
// Copyright © 2019 The Knative Authors
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package ping
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
"k8s.io/client-go/tools/clientcmd"
|
||||||
|
v1alpha2 "knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha2"
|
||||||
|
|
||||||
|
"knative.dev/client/pkg/kn/commands"
|
||||||
|
clientv1alpha2 "knative.dev/client/pkg/sources/v1alpha2"
|
||||||
|
)
|
||||||
|
|
||||||
|
// NewPingCommand is the root command for all Ping source related commands
|
||||||
|
func NewPingCommand(p *commands.KnParams) *cobra.Command {
|
||||||
|
pingImporterCmd := &cobra.Command{
|
||||||
|
Use: "ping",
|
||||||
|
Short: "Ping source command group",
|
||||||
|
}
|
||||||
|
pingImporterCmd.AddCommand(NewPingCreateCommand(p))
|
||||||
|
pingImporterCmd.AddCommand(NewPingDeleteCommand(p))
|
||||||
|
pingImporterCmd.AddCommand(NewPingDescribeCommand(p))
|
||||||
|
pingImporterCmd.AddCommand(NewPingUpdateCommand(p))
|
||||||
|
pingImporterCmd.AddCommand(NewPingListCommand(p))
|
||||||
|
return pingImporterCmd
|
||||||
|
}
|
||||||
|
|
||||||
|
var pingSourceClientFactory func(config clientcmd.ClientConfig, namespace string) (clientv1alpha2.KnPingSourcesClient, error)
|
||||||
|
|
||||||
|
func newPingSourceClient(p *commands.KnParams, cmd *cobra.Command) (clientv1alpha2.KnPingSourcesClient, error) {
|
||||||
|
namespace, err := p.GetNamespace(cmd)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if pingSourceClientFactory != nil {
|
||||||
|
config, err := p.GetClientConfig()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return pingSourceClientFactory(config, namespace)
|
||||||
|
}
|
||||||
|
|
||||||
|
clientConfig, err := p.RestConfig()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
client, err := v1alpha2.NewForConfig(clientConfig)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return clientv1alpha2.NewKnSourcesClient(client, namespace).PingSourcesClient(), nil
|
||||||
|
}
|
||||||
|
|
@ -12,19 +12,18 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
package cronjob
|
package ping
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
|
||||||
corev1 "k8s.io/api/core/v1"
|
|
||||||
"k8s.io/client-go/tools/clientcmd"
|
"k8s.io/client-go/tools/clientcmd"
|
||||||
"knative.dev/eventing/pkg/apis/legacysources/v1alpha1"
|
v1alpha2 "knative.dev/eventing/pkg/apis/sources/v1alpha2"
|
||||||
"knative.dev/pkg/apis/duck/v1beta1"
|
v1 "knative.dev/pkg/apis/duck/v1"
|
||||||
|
|
||||||
kn_dynamic "knative.dev/client/pkg/dynamic"
|
kndynamic "knative.dev/client/pkg/dynamic"
|
||||||
source_client_v1alpha1 "knative.dev/client/pkg/eventing/legacysources/v1alpha1"
|
|
||||||
"knative.dev/client/pkg/kn/commands"
|
"knative.dev/client/pkg/kn/commands"
|
||||||
|
clientv1alpha2 "knative.dev/client/pkg/sources/v1alpha2"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Helper methods
|
// Helper methods
|
||||||
|
|
@ -54,46 +53,41 @@ current-context: x
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func executeCronJobSourceCommand(cronJobSourceClient source_client_v1alpha1.KnCronJobSourcesClient, dynamicClient kn_dynamic.KnDynamicClient, args ...string) (string, error) {
|
func executePingSourceCommand(pingSourceClient clientv1alpha2.KnPingSourcesClient, dynamicClient kndynamic.KnDynamicClient, args ...string) (string, error) {
|
||||||
knParams := &commands.KnParams{}
|
knParams := &commands.KnParams{}
|
||||||
knParams.ClientConfig = blankConfig
|
knParams.ClientConfig = blankConfig
|
||||||
|
|
||||||
output := new(bytes.Buffer)
|
output := new(bytes.Buffer)
|
||||||
knParams.Output = output
|
knParams.Output = output
|
||||||
knParams.NewDynamicClient = func(namespace string) (kn_dynamic.KnDynamicClient, error) {
|
knParams.NewDynamicClient = func(namespace string) (kndynamic.KnDynamicClient, error) {
|
||||||
return dynamicClient, nil
|
return dynamicClient, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd := NewCronJobCommand(knParams)
|
cmd := NewPingCommand(knParams)
|
||||||
cmd.SetArgs(args)
|
cmd.SetArgs(args)
|
||||||
cmd.SetOutput(output)
|
cmd.SetOutput(output)
|
||||||
|
|
||||||
cronJobSourceClientFactory = func(config clientcmd.ClientConfig, namespace string) (source_client_v1alpha1.KnCronJobSourcesClient, error) {
|
pingSourceClientFactory = func(config clientcmd.ClientConfig, namespace string) (clientv1alpha2.KnPingSourcesClient, error) {
|
||||||
return cronJobSourceClient, nil
|
return pingSourceClient, nil
|
||||||
}
|
}
|
||||||
defer cleanupCronJobMockClient()
|
defer cleanupPingMockClient()
|
||||||
|
|
||||||
err := cmd.Execute()
|
err := cmd.Execute()
|
||||||
|
|
||||||
return output.String(), err
|
return output.String(), err
|
||||||
}
|
}
|
||||||
|
|
||||||
func cleanupCronJobMockClient() {
|
func cleanupPingMockClient() {
|
||||||
cronJobSourceClientFactory = nil
|
pingSourceClientFactory = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func createCronJobSource(name, schedule, data, service string, sa string, requestcpu string, requestmm string, limitcpu string, limitmm string) *v1alpha1.CronJobSource {
|
func createPingSource(name, schedule, data, service string) *v1alpha2.PingSource {
|
||||||
sink := &v1beta1.Destination{
|
sink := &v1.Destination{
|
||||||
Ref: &corev1.ObjectReference{Name: service, Kind: "Service", APIVersion: "serving.knative.dev/v1", Namespace: "default"},
|
Ref: &v1.KReference{Name: service, Kind: "Service", APIVersion: "serving.knative.dev/v1", Namespace: "default"},
|
||||||
}
|
}
|
||||||
return source_client_v1alpha1.NewCronJobSourceBuilder(name).
|
return clientv1alpha2.NewPingSourceBuilder(name).
|
||||||
Schedule(schedule).
|
Schedule(schedule).
|
||||||
Data(data).
|
JsonData(data).
|
||||||
Sink(sink).
|
Sink(*sink).
|
||||||
ResourceRequestsCPU(requestcpu).
|
|
||||||
ResourceRequestsMemory(requestmm).
|
|
||||||
ResourceLimitsCPU(limitcpu).
|
|
||||||
ResourceLimitsMemory(limitmm).
|
|
||||||
ServiceAccount(sa).
|
|
||||||
Build()
|
Build()
|
||||||
}
|
}
|
||||||
|
|
@ -12,7 +12,7 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
package cronjob
|
package ping
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
|
@ -20,30 +20,30 @@ import (
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
"knative.dev/client/pkg/eventing/legacysources/v1alpha1"
|
|
||||||
"knative.dev/client/pkg/kn/commands"
|
"knative.dev/client/pkg/kn/commands"
|
||||||
"knative.dev/client/pkg/kn/commands/flags"
|
"knative.dev/client/pkg/kn/commands/flags"
|
||||||
|
"knative.dev/client/pkg/sources/v1alpha2"
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewCronJobUpdateCommand prepares the command for a CronJobSource update
|
// NewPingUpdateCommand prepares the command for a PingSource update
|
||||||
func NewCronJobUpdateCommand(p *commands.KnParams) *cobra.Command {
|
func NewPingUpdateCommand(p *commands.KnParams) *cobra.Command {
|
||||||
var cronUpdateFlags cronJobUpdateFlags
|
var pingUpdateFlags pingUpdateFlags
|
||||||
var sinkFlags flags.SinkFlags
|
var sinkFlags flags.SinkFlags
|
||||||
|
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "update NAME --schedule SCHEDULE --sink SERVICE --data DATA",
|
Use: "update NAME --schedule SCHEDULE --sink SERVICE --data DATA",
|
||||||
Short: "Update a CronJob source.",
|
Short: "Update a Ping source.",
|
||||||
Example: `
|
Example: `
|
||||||
# Update the schedule of a crontab source 'my-cron-trigger' to fire every minute
|
# Update the schedule of a Ping source 'my-ping' to fire every minute
|
||||||
kn source cronjob update my-cron-trigger --schedule "* * * * */1"`,
|
kn source ping update my-ping --schedule "* * * * *"`,
|
||||||
|
|
||||||
RunE: func(cmd *cobra.Command, args []string) (err error) {
|
RunE: func(cmd *cobra.Command, args []string) (err error) {
|
||||||
if len(args) != 1 {
|
if len(args) != 1 {
|
||||||
return errors.New("name of cronjob source required")
|
return errors.New("name of Ping source required")
|
||||||
}
|
}
|
||||||
name := args[0]
|
name := args[0]
|
||||||
|
|
||||||
cronSourceClient, err := newCronJobSourceClient(p, cmd)
|
pingSourceClient, err := newPingSourceClient(p, cmd)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
@ -57,49 +57,34 @@ func NewCronJobUpdateCommand(p *commands.KnParams) *cobra.Command {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
source, err := cronSourceClient.GetCronJobSource(name)
|
source, err := pingSourceClient.GetPingSource(name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
b := v1alpha1.NewCronJobSourceBuilderFromExisting(source)
|
b := v1alpha2.NewPingSourceBuilderFromExisting(source)
|
||||||
if cmd.Flags().Changed("schedule") {
|
if cmd.Flags().Changed("schedule") {
|
||||||
b.Schedule(cronUpdateFlags.schedule)
|
b.Schedule(pingUpdateFlags.schedule)
|
||||||
}
|
}
|
||||||
if cmd.Flags().Changed("data") {
|
if cmd.Flags().Changed("data") {
|
||||||
b.Data(cronUpdateFlags.data)
|
b.JsonData(pingUpdateFlags.data)
|
||||||
}
|
}
|
||||||
if cmd.Flags().Changed("sink") {
|
if cmd.Flags().Changed("sink") {
|
||||||
destination, err := sinkFlags.ResolveSink(dynamicClient, namespace)
|
destination, err := sinkFlags.ResolveSink(dynamicClient, namespace)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
b.Sink(toDuckV1Beta1(destination))
|
b.Sink(*destination)
|
||||||
}
|
}
|
||||||
if cmd.Flags().Changed("requests-cpu") {
|
err = pingSourceClient.UpdatePingSource(b.Build())
|
||||||
b.ResourceRequestsCPU(cronUpdateFlags.resourceRequestsCPU)
|
|
||||||
}
|
|
||||||
if cmd.Flags().Changed("requests-memory") {
|
|
||||||
b.ResourceRequestsMemory(cronUpdateFlags.resourceRequestsMemory)
|
|
||||||
}
|
|
||||||
if cmd.Flags().Changed("limits-cpu") {
|
|
||||||
b.ResourceLimitsCPU(cronUpdateFlags.resourceLimitsCPU)
|
|
||||||
}
|
|
||||||
if cmd.Flags().Changed("limits-memory") {
|
|
||||||
b.ResourceLimitsMemory(cronUpdateFlags.resourceLimitsMemory)
|
|
||||||
}
|
|
||||||
if cmd.Flags().Changed("service-account") {
|
|
||||||
b.ServiceAccount(cronUpdateFlags.serviceAccountName)
|
|
||||||
}
|
|
||||||
err = cronSourceClient.UpdateCronJobSource(b.Build())
|
|
||||||
if err == nil {
|
if err == nil {
|
||||||
fmt.Fprintf(cmd.OutOrStdout(), "CronJob source '%s' updated in namespace '%s'.\n", name, cronSourceClient.Namespace())
|
fmt.Fprintf(cmd.OutOrStdout(), "Ping source '%s' updated in namespace '%s'.\n", name, pingSourceClient.Namespace())
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
commands.AddNamespaceFlags(cmd.Flags(), false)
|
commands.AddNamespaceFlags(cmd.Flags(), false)
|
||||||
cronUpdateFlags.addCronJobFlags(cmd)
|
pingUpdateFlags.addPingFlags(cmd)
|
||||||
sinkFlags.Add(cmd)
|
sinkFlags.Add(cmd)
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
|
|
@ -0,0 +1,76 @@
|
||||||
|
// Copyright © 2019 The Knative Authors
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package ping
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"gotest.tools/assert"
|
||||||
|
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
v1alpha2 "knative.dev/eventing/pkg/apis/sources/v1alpha2"
|
||||||
|
duckv1 "knative.dev/pkg/apis/duck/v1"
|
||||||
|
|
||||||
|
clientv1alpha2 "knative.dev/client/pkg/sources/v1alpha2"
|
||||||
|
"knative.dev/client/pkg/util"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestSimplePingUpdate(t *testing.T) {
|
||||||
|
|
||||||
|
pingSourceClient := clientv1alpha2.NewMockKnPingSourceClient(t)
|
||||||
|
|
||||||
|
pingRecorder := pingSourceClient.Recorder()
|
||||||
|
pingRecorder.GetPingSource("testsource", &v1alpha2.PingSource{
|
||||||
|
TypeMeta: v1.TypeMeta{},
|
||||||
|
ObjectMeta: v1.ObjectMeta{
|
||||||
|
Name: "testsource",
|
||||||
|
},
|
||||||
|
Spec: v1alpha2.PingSourceSpec{
|
||||||
|
Schedule: "1 2 3 4 5",
|
||||||
|
JsonData: "maxwell",
|
||||||
|
SourceSpec: duckv1.SourceSpec{
|
||||||
|
Sink: duckv1.Destination{
|
||||||
|
Ref: &duckv1.KReference{
|
||||||
|
Kind: "Service",
|
||||||
|
Name: "mysvc",
|
||||||
|
APIVersion: "serving.knative.dev/v1",
|
||||||
|
Namespace: "default",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Status: v1alpha2.PingSourceStatus{},
|
||||||
|
}, nil)
|
||||||
|
pingRecorder.UpdatePingSource(createPingSource("testsource", "* * * * */3", "maxwell", "mysvc"), nil)
|
||||||
|
|
||||||
|
out, err := executePingSourceCommand(pingSourceClient, nil, "update", "--schedule", "* * * * */3", "testsource")
|
||||||
|
assert.NilError(t, err)
|
||||||
|
util.ContainsAll(out, "updated", "default", "testsource")
|
||||||
|
|
||||||
|
pingRecorder.Validate()
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestUpdateError(t *testing.T) {
|
||||||
|
pingClient := clientv1alpha2.NewMockKnPingSourceClient(t, "mynamespace")
|
||||||
|
|
||||||
|
pingRecorder := pingClient.Recorder()
|
||||||
|
pingRecorder.GetPingSource("testsource", nil, errors.New("no Ping source testsource"))
|
||||||
|
|
||||||
|
out, err := executePingSourceCommand(pingClient, nil, "update", "testsource")
|
||||||
|
assert.ErrorContains(t, err, "testsource")
|
||||||
|
util.ContainsAll(out, "Usage", "testsource")
|
||||||
|
|
||||||
|
pingRecorder.Validate()
|
||||||
|
}
|
||||||
|
|
@ -20,7 +20,7 @@ import (
|
||||||
"knative.dev/client/pkg/kn/commands"
|
"knative.dev/client/pkg/kn/commands"
|
||||||
"knative.dev/client/pkg/kn/commands/source/apiserver"
|
"knative.dev/client/pkg/kn/commands/source/apiserver"
|
||||||
"knative.dev/client/pkg/kn/commands/source/binding"
|
"knative.dev/client/pkg/kn/commands/source/binding"
|
||||||
"knative.dev/client/pkg/kn/commands/source/cronjob"
|
"knative.dev/client/pkg/kn/commands/source/ping"
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewSourceCommand(p *commands.KnParams) *cobra.Command {
|
func NewSourceCommand(p *commands.KnParams) *cobra.Command {
|
||||||
|
|
@ -30,7 +30,7 @@ func NewSourceCommand(p *commands.KnParams) *cobra.Command {
|
||||||
}
|
}
|
||||||
sourceCmd.AddCommand(apiserver.NewAPIServerCommand(p))
|
sourceCmd.AddCommand(apiserver.NewAPIServerCommand(p))
|
||||||
sourceCmd.AddCommand(NewListTypesCommand(p))
|
sourceCmd.AddCommand(NewListTypesCommand(p))
|
||||||
sourceCmd.AddCommand(cronjob.NewCronJobCommand(p))
|
sourceCmd.AddCommand(ping.NewPingCommand(p))
|
||||||
sourceCmd.AddCommand(binding.NewBindingCommand(p))
|
sourceCmd.AddCommand(binding.NewBindingCommand(p))
|
||||||
return sourceCmd
|
return sourceCmd
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,13 +30,13 @@ import (
|
||||||
|
|
||||||
"knative.dev/client/pkg/kn/flags"
|
"knative.dev/client/pkg/kn/flags"
|
||||||
clientservingv1 "knative.dev/client/pkg/serving/v1"
|
clientservingv1 "knative.dev/client/pkg/serving/v1"
|
||||||
|
"knative.dev/client/pkg/sources/v1alpha2"
|
||||||
|
|
||||||
dynamicfake "k8s.io/client-go/dynamic/fake"
|
dynamicfake "k8s.io/client-go/dynamic/fake"
|
||||||
eventingv1alpha1fake "knative.dev/eventing/pkg/client/clientset/versioned/typed/eventing/v1alpha1/fake"
|
eventingv1alpha1fake "knative.dev/eventing/pkg/client/clientset/versioned/typed/eventing/v1alpha1/fake"
|
||||||
sourcesv1alpha1fake "knative.dev/eventing/pkg/legacyclient/clientset/versioned/typed/legacysources/v1alpha1/fake"
|
sourcesv1alpha2fake "knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha2/fake"
|
||||||
|
|
||||||
clientdynamic "knative.dev/client/pkg/dynamic"
|
clientdynamic "knative.dev/client/pkg/dynamic"
|
||||||
sourcesv1alpha1 "knative.dev/client/pkg/eventing/legacysources/v1alpha1"
|
|
||||||
eventingv1alpha1 "knative.dev/client/pkg/eventing/v1alpha1"
|
eventingv1alpha1 "knative.dev/client/pkg/eventing/v1alpha1"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -64,7 +64,7 @@ func CreateTestKnCommand(cmd *cobra.Command, knParams *KnParams) (*cobra.Command
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateSourcesTestKnCommand helper for creating test commands
|
// CreateSourcesTestKnCommand helper for creating test commands
|
||||||
func CreateSourcesTestKnCommand(cmd *cobra.Command, knParams *KnParams) (*cobra.Command, *sourcesv1alpha1fake.FakeSourcesV1alpha1, *bytes.Buffer) {
|
func CreateSourcesTestKnCommand(cmd *cobra.Command, knParams *KnParams) (*cobra.Command, *sourcesv1alpha2fake.FakeSourcesV1alpha2, *bytes.Buffer) {
|
||||||
buf := new(bytes.Buffer)
|
buf := new(bytes.Buffer)
|
||||||
// create fake serving client because the sink of source depends on serving client
|
// create fake serving client because the sink of source depends on serving client
|
||||||
fakeServing := &servingv1fake.FakeServingV1{&clienttesting.Fake{}}
|
fakeServing := &servingv1fake.FakeServingV1{&clienttesting.Fake{}}
|
||||||
|
|
@ -72,10 +72,10 @@ func CreateSourcesTestKnCommand(cmd *cobra.Command, knParams *KnParams) (*cobra.
|
||||||
return clientservingv1.NewKnServingClient(fakeServing, FakeNamespace), nil
|
return clientservingv1.NewKnServingClient(fakeServing, FakeNamespace), nil
|
||||||
}
|
}
|
||||||
// create fake sources client
|
// create fake sources client
|
||||||
fakeEventing := &sourcesv1alpha1fake.FakeSourcesV1alpha1{&clienttesting.Fake{}}
|
fakeEventing := &sourcesv1alpha2fake.FakeSourcesV1alpha2{&clienttesting.Fake{}}
|
||||||
knParams.Output = buf
|
knParams.Output = buf
|
||||||
knParams.NewSourcesClient = func(namespace string) (sourcesv1alpha1.KnSourcesClient, error) {
|
knParams.NewSourcesClient = func(namespace string) (v1alpha2.KnSourcesClient, error) {
|
||||||
return sourcesv1alpha1.NewKnSourcesClient(fakeEventing, FakeNamespace), nil
|
return v1alpha2.NewKnSourcesClient(fakeEventing, FakeNamespace), nil
|
||||||
}
|
}
|
||||||
knParams.fixedCurrentNamespace = FakeNamespace
|
knParams.fixedCurrentNamespace = FakeNamespace
|
||||||
knCommand := NewKnTestCommand(cmd, knParams)
|
knCommand := NewKnTestCommand(cmd, knParams)
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ import (
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"gotest.tools/assert"
|
"gotest.tools/assert"
|
||||||
dynamicfake "k8s.io/client-go/dynamic/fake"
|
dynamicfake "k8s.io/client-go/dynamic/fake"
|
||||||
sourcesv1alpha1fake "knative.dev/eventing/pkg/legacyclient/clientset/versioned/typed/legacysources/v1alpha1/fake"
|
sourcesv1alpha2fake "knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha2/fake"
|
||||||
servingv1fake "knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1/fake"
|
servingv1fake "knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1/fake"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -60,7 +60,7 @@ func TestCreateTestKnCommand(t *testing.T) {
|
||||||
func TestCreateSourcesTestKnCommand(t *testing.T) {
|
func TestCreateSourcesTestKnCommand(t *testing.T) {
|
||||||
var (
|
var (
|
||||||
knCmd *cobra.Command
|
knCmd *cobra.Command
|
||||||
sources *sourcesv1alpha1fake.FakeSourcesV1alpha1
|
sources *sourcesv1alpha2fake.FakeSourcesV1alpha2
|
||||||
buffer *bytes.Buffer
|
buffer *bytes.Buffer
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,13 +24,13 @@ import (
|
||||||
"k8s.io/client-go/rest"
|
"k8s.io/client-go/rest"
|
||||||
"k8s.io/client-go/tools/clientcmd"
|
"k8s.io/client-go/tools/clientcmd"
|
||||||
eventing "knative.dev/eventing/pkg/client/clientset/versioned/typed/eventing/v1alpha1"
|
eventing "knative.dev/eventing/pkg/client/clientset/versioned/typed/eventing/v1alpha1"
|
||||||
sourcesv1alpha1client "knative.dev/eventing/pkg/legacyclient/clientset/versioned/typed/legacysources/v1alpha1"
|
sourcesv1alpha2client "knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha2"
|
||||||
servingv1client "knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1"
|
servingv1client "knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1"
|
||||||
|
|
||||||
|
"knative.dev/client/pkg/sources/v1alpha2"
|
||||||
"knative.dev/client/pkg/util"
|
"knative.dev/client/pkg/util"
|
||||||
|
|
||||||
clientdynamic "knative.dev/client/pkg/dynamic"
|
clientdynamic "knative.dev/client/pkg/dynamic"
|
||||||
clientsourcesv1alpha1 "knative.dev/client/pkg/eventing/legacysources/v1alpha1"
|
|
||||||
clienteventingv1alpha1 "knative.dev/client/pkg/eventing/v1alpha1"
|
clienteventingv1alpha1 "knative.dev/client/pkg/eventing/v1alpha1"
|
||||||
clientservingv1 "knative.dev/client/pkg/serving/v1"
|
clientservingv1 "knative.dev/client/pkg/serving/v1"
|
||||||
)
|
)
|
||||||
|
|
@ -69,7 +69,7 @@ type KnParams struct {
|
||||||
KubeCfgPath string
|
KubeCfgPath string
|
||||||
ClientConfig clientcmd.ClientConfig
|
ClientConfig clientcmd.ClientConfig
|
||||||
NewServingClient func(namespace string) (clientservingv1.KnServingClient, error)
|
NewServingClient func(namespace string) (clientservingv1.KnServingClient, error)
|
||||||
NewSourcesClient func(namespace string) (clientsourcesv1alpha1.KnSourcesClient, error)
|
NewSourcesClient func(namespace string) (v1alpha2.KnSourcesClient, error)
|
||||||
NewEventingClient func(namespace string) (clienteventingv1alpha1.KnEventingClient, error)
|
NewEventingClient func(namespace string) (clienteventingv1alpha1.KnEventingClient, error)
|
||||||
NewDynamicClient func(namespace string) (clientdynamic.KnDynamicClient, error)
|
NewDynamicClient func(namespace string) (clientdynamic.KnDynamicClient, error)
|
||||||
|
|
||||||
|
|
@ -108,14 +108,14 @@ func (params *KnParams) newServingClient(namespace string) (clientservingv1.KnSe
|
||||||
return clientservingv1.NewKnServingClient(client, namespace), nil
|
return clientservingv1.NewKnServingClient(client, namespace), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (params *KnParams) newSourcesClient(namespace string) (clientsourcesv1alpha1.KnSourcesClient, error) {
|
func (params *KnParams) newSourcesClient(namespace string) (v1alpha2.KnSourcesClient, error) {
|
||||||
restConfig, err := params.RestConfig()
|
restConfig, err := params.RestConfig()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
client, _ := sourcesv1alpha1client.NewForConfig(restConfig)
|
client, _ := sourcesv1alpha2client.NewForConfig(restConfig)
|
||||||
return clientsourcesv1alpha1.NewKnSourcesClient(client, namespace), nil
|
return v1alpha2.NewKnSourcesClient(client, namespace), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (params *KnParams) newEventingClient(namespace string) (clienteventingv1alpha1.KnEventingClient, error) {
|
func (params *KnParams) newEventingClient(namespace string) (clienteventingv1alpha1.KnEventingClient, error) {
|
||||||
|
|
|
||||||
|
|
@ -187,8 +187,8 @@ func TestNewSourcesClient(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if sourcesClient != nil {
|
if sourcesClient != nil {
|
||||||
assert.Assert(t, sourcesClient.APIServerSourcesClient().Namespace() == namespace)
|
assert.Assert(t, sourcesClient.SinkBindingClient().Namespace() == namespace)
|
||||||
assert.Assert(t, sourcesClient.CronJobSourcesClient().Namespace() == namespace)
|
assert.Assert(t, sourcesClient.PingSourcesClient().Namespace() == namespace)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,11 +29,12 @@ var GitRevision string
|
||||||
// update this var as we add more deps
|
// update this var as we add more deps
|
||||||
var apiVersions = map[string][]string{
|
var apiVersions = map[string][]string{
|
||||||
"serving": {
|
"serving": {
|
||||||
"serving.knative.dev/v1 (knative-serving v0.12.1-0.20200206201132-525b15d87dc1)",
|
"serving.knative.dev/v1 (knative-serving v0.13.0)",
|
||||||
},
|
},
|
||||||
"eventing": {
|
"eventing": {
|
||||||
"sources.eventing.knative.dev/v1alpha1 (knative-eventing v0.12.1-0.20200206203632-b0a7d8a77cc7)",
|
"sources.eventing.knative.dev/v1alpha1 (knative-eventing v0.13.1)",
|
||||||
"eventing.knative.dev/v1alpha1 (knative-eventing v0.12.1-0.20200206203632-b0a7d8a77cc7)",
|
"sources.eventing.knative.dev/v1alpha2 (knative-eventing v0.13.1)",
|
||||||
|
"eventing.knative.dev/v1alpha1 (knative-eventing v0.13.1)",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -36,10 +36,11 @@ Build Date: {{.BuildDate}}
|
||||||
Git Revision: {{.GitRevision}}
|
Git Revision: {{.GitRevision}}
|
||||||
Supported APIs:
|
Supported APIs:
|
||||||
* Serving
|
* Serving
|
||||||
- serving.knative.dev/v1 (knative-serving v0.12.1-0.20200206201132-525b15d87dc1)
|
- serving.knative.dev/v1 (knative-serving v0.13.0)
|
||||||
* Eventing
|
* Eventing
|
||||||
- sources.eventing.knative.dev/v1alpha1 (knative-eventing v0.12.1-0.20200206203632-b0a7d8a77cc7)
|
- sources.eventing.knative.dev/v1alpha1 (knative-eventing v0.13.1)
|
||||||
- eventing.knative.dev/v1alpha1 (knative-eventing v0.12.1-0.20200206203632-b0a7d8a77cc7)
|
- sources.eventing.knative.dev/v1alpha2 (knative-eventing v0.13.1)
|
||||||
|
- eventing.knative.dev/v1alpha1 (knative-eventing v0.13.1)
|
||||||
`
|
`
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|
|
||||||
|
|
@ -245,7 +245,7 @@ func defaultConfigDir() (string, error) {
|
||||||
"Please move your configuration to: %s", migrationPath)
|
"Please move your configuration to: %s", migrationPath)
|
||||||
}
|
}
|
||||||
// Respect %APPDATA% on MS Windows
|
// Respect %APPDATA% on MS Windows
|
||||||
// C:\Documents and Settings\username\Application Data
|
// C:\Documents and Settings\username\Application JsonData
|
||||||
if runtime.GOOS == "windows" {
|
if runtime.GOOS == "windows" {
|
||||||
return filepath.Join(os.Getenv("APPDATA"), "kn"), nil
|
return filepath.Join(os.Getenv("APPDATA"), "kn"), nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,10 +16,15 @@ package v1alpha1
|
||||||
|
|
||||||
import (
|
import (
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
kn_errors "knative.dev/client/pkg/errors"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
"knative.dev/eventing/pkg/apis/legacysources/v1alpha1"
|
v1alpha1 "knative.dev/eventing/pkg/apis/sources/v1alpha1"
|
||||||
client_v1alpha1 "knative.dev/eventing/pkg/legacyclient/clientset/versioned/typed/legacysources/v1alpha1"
|
clientv1alpha1 "knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha1"
|
||||||
duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1"
|
duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1"
|
||||||
|
|
||||||
|
"knative.dev/eventing/pkg/client/clientset/versioned/scheme"
|
||||||
|
|
||||||
|
knerrors "knative.dev/client/pkg/errors"
|
||||||
|
"knative.dev/client/pkg/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
// KnAPIServerSourcesClient interface for working with ApiServer sources
|
// KnAPIServerSourcesClient interface for working with ApiServer sources
|
||||||
|
|
@ -49,12 +54,12 @@ type KnAPIServerSourcesClient interface {
|
||||||
// Temporarily help to add sources dependencies
|
// Temporarily help to add sources dependencies
|
||||||
// May be changed when adding real sources features
|
// May be changed when adding real sources features
|
||||||
type apiServerSourcesClient struct {
|
type apiServerSourcesClient struct {
|
||||||
client client_v1alpha1.ApiServerSourceInterface
|
client clientv1alpha1.ApiServerSourceInterface
|
||||||
namespace string
|
namespace string
|
||||||
}
|
}
|
||||||
|
|
||||||
// newKnAPIServerSourcesClient is to invoke Eventing Sources Client API to create object
|
// newKnAPIServerSourcesClient is to invoke Eventing Sources Client API to create object
|
||||||
func newKnAPIServerSourcesClient(client client_v1alpha1.ApiServerSourceInterface, namespace string) KnAPIServerSourcesClient {
|
func newKnAPIServerSourcesClient(client clientv1alpha1.ApiServerSourceInterface, namespace string) KnAPIServerSourcesClient {
|
||||||
return &apiServerSourcesClient{
|
return &apiServerSourcesClient{
|
||||||
client: client,
|
client: client,
|
||||||
namespace: namespace,
|
namespace: namespace,
|
||||||
|
|
@ -65,7 +70,7 @@ func newKnAPIServerSourcesClient(client client_v1alpha1.ApiServerSourceInterface
|
||||||
func (c *apiServerSourcesClient) GetAPIServerSource(name string) (*v1alpha1.ApiServerSource, error) {
|
func (c *apiServerSourcesClient) GetAPIServerSource(name string) (*v1alpha1.ApiServerSource, error) {
|
||||||
apiSource, err := c.client.Get(name, metav1.GetOptions{})
|
apiSource, err := c.client.Get(name, metav1.GetOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, kn_errors.GetError(err)
|
return nil, knerrors.GetError(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return apiSource, nil
|
return apiSource, nil
|
||||||
|
|
@ -75,7 +80,7 @@ func (c *apiServerSourcesClient) GetAPIServerSource(name string) (*v1alpha1.ApiS
|
||||||
func (c *apiServerSourcesClient) CreateAPIServerSource(apiSource *v1alpha1.ApiServerSource) error {
|
func (c *apiServerSourcesClient) CreateAPIServerSource(apiSource *v1alpha1.ApiServerSource) error {
|
||||||
_, err := c.client.Create(apiSource)
|
_, err := c.client.Create(apiSource)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return kn_errors.GetError(err)
|
return knerrors.GetError(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
@ -85,7 +90,7 @@ func (c *apiServerSourcesClient) CreateAPIServerSource(apiSource *v1alpha1.ApiSe
|
||||||
func (c *apiServerSourcesClient) UpdateAPIServerSource(apiSource *v1alpha1.ApiServerSource) error {
|
func (c *apiServerSourcesClient) UpdateAPIServerSource(apiSource *v1alpha1.ApiServerSource) error {
|
||||||
_, err := c.client.Update(apiSource)
|
_, err := c.client.Update(apiSource)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return kn_errors.GetError(err)
|
return knerrors.GetError(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
@ -131,6 +136,10 @@ func updateAPIServerSourceListGVK(sourceList *v1alpha1.ApiServerSourceList) (*v1
|
||||||
return sourceListNew, nil
|
return sourceListNew, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func updateSourceGVK(obj runtime.Object) error {
|
||||||
|
return util.UpdateGroupVersionKindWithScheme(obj, v1alpha1.SchemeGroupVersion, scheme.Scheme)
|
||||||
|
}
|
||||||
|
|
||||||
// APIServerSourceBuilder is for building the source
|
// APIServerSourceBuilder is for building the source
|
||||||
type APIServerSourceBuilder struct {
|
type APIServerSourceBuilder struct {
|
||||||
apiServerSource *v1alpha1.ApiServerSource
|
apiServerSource *v1alpha1.ApiServerSource
|
||||||
|
|
@ -17,7 +17,7 @@ package v1alpha1
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"knative.dev/eventing/pkg/apis/legacysources/v1alpha1"
|
v1alpha1 "knative.dev/eventing/pkg/apis/sources/v1alpha1"
|
||||||
|
|
||||||
"knative.dev/client/pkg/util/mock"
|
"knative.dev/client/pkg/util/mock"
|
||||||
)
|
)
|
||||||
|
|
@ -17,7 +17,7 @@ package v1alpha1
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"knative.dev/eventing/pkg/apis/legacysources/v1alpha1"
|
v1alpha1 "knative.dev/eventing/pkg/apis/sources/v1alpha1"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestMockKnAPIServerSourceClient(t *testing.T) {
|
func TestMockKnAPIServerSourceClient(t *testing.T) {
|
||||||
|
|
@ -21,18 +21,18 @@ import (
|
||||||
"gotest.tools/assert"
|
"gotest.tools/assert"
|
||||||
v1 "k8s.io/api/core/v1"
|
v1 "k8s.io/api/core/v1"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
|
v1alpha1 "knative.dev/eventing/pkg/apis/sources/v1alpha1"
|
||||||
|
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
client_testing "k8s.io/client-go/testing"
|
clienttesting "k8s.io/client-go/testing"
|
||||||
"knative.dev/eventing/pkg/apis/legacysources/v1alpha1"
|
fake "knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha1/fake"
|
||||||
"knative.dev/eventing/pkg/legacyclient/clientset/versioned/typed/legacysources/v1alpha1/fake"
|
duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1"
|
||||||
"knative.dev/pkg/apis/duck/v1beta1"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var testAPIServerSourceNamespace = "test-ns"
|
var testAPIServerSourceNamespace = "test-ns"
|
||||||
|
|
||||||
func setupAPIServerSourcesClient(t *testing.T) (fakeSources fake.FakeSourcesV1alpha1, client KnAPIServerSourcesClient) {
|
func setupAPIServerSourcesClient(t *testing.T) (fakeSources fake.FakeSourcesV1alpha1, client KnAPIServerSourcesClient) {
|
||||||
fakeSources = fake.FakeSourcesV1alpha1{Fake: &client_testing.Fake{}}
|
fakeSources = fake.FakeSourcesV1alpha1{Fake: &clienttesting.Fake{}}
|
||||||
client = NewKnSourcesClient(&fakeSources, testAPIServerSourceNamespace).APIServerSourcesClient()
|
client = NewKnSourcesClient(&fakeSources, testAPIServerSourceNamespace).APIServerSourcesClient()
|
||||||
assert.Equal(t, client.Namespace(), testAPIServerSourceNamespace)
|
assert.Equal(t, client.Namespace(), testAPIServerSourceNamespace)
|
||||||
return
|
return
|
||||||
|
|
@ -42,8 +42,8 @@ func TestDeleteApiServerSource(t *testing.T) {
|
||||||
sourcesServer, client := setupAPIServerSourcesClient(t)
|
sourcesServer, client := setupAPIServerSourcesClient(t)
|
||||||
|
|
||||||
sourcesServer.AddReactor("delete", "apiserversources",
|
sourcesServer.AddReactor("delete", "apiserversources",
|
||||||
func(a client_testing.Action) (bool, runtime.Object, error) {
|
func(a clienttesting.Action) (bool, runtime.Object, error) {
|
||||||
name := a.(client_testing.DeleteAction).GetName()
|
name := a.(clienttesting.DeleteAction).GetName()
|
||||||
if name == "errorSource" {
|
if name == "errorSource" {
|
||||||
return true, nil, fmt.Errorf("error while deleting ApiServer source %s", name)
|
return true, nil, fmt.Errorf("error while deleting ApiServer source %s", name)
|
||||||
}
|
}
|
||||||
|
|
@ -61,8 +61,8 @@ func TestCreateApiServerSource(t *testing.T) {
|
||||||
sourcesServer, client := setupAPIServerSourcesClient(t)
|
sourcesServer, client := setupAPIServerSourcesClient(t)
|
||||||
|
|
||||||
sourcesServer.AddReactor("create", "apiserversources",
|
sourcesServer.AddReactor("create", "apiserversources",
|
||||||
func(a client_testing.Action) (bool, runtime.Object, error) {
|
func(a clienttesting.Action) (bool, runtime.Object, error) {
|
||||||
newSource := a.(client_testing.CreateAction).GetObject()
|
newSource := a.(clienttesting.CreateAction).GetObject()
|
||||||
name := newSource.(metav1.Object).GetName()
|
name := newSource.(metav1.Object).GetName()
|
||||||
if name == "errorSource" {
|
if name == "errorSource" {
|
||||||
return true, nil, fmt.Errorf("error while creating ApiServer source %s", name)
|
return true, nil, fmt.Errorf("error while creating ApiServer source %s", name)
|
||||||
|
|
@ -81,8 +81,8 @@ func TestGetApiServerSource(t *testing.T) {
|
||||||
sourcesServer, client := setupAPIServerSourcesClient(t)
|
sourcesServer, client := setupAPIServerSourcesClient(t)
|
||||||
|
|
||||||
sourcesServer.AddReactor("get", "apiserversources",
|
sourcesServer.AddReactor("get", "apiserversources",
|
||||||
func(a client_testing.Action) (bool, runtime.Object, error) {
|
func(a clienttesting.Action) (bool, runtime.Object, error) {
|
||||||
name := a.(client_testing.GetAction).GetName()
|
name := a.(clienttesting.GetAction).GetName()
|
||||||
if name == "errorSource" {
|
if name == "errorSource" {
|
||||||
return true, nil, fmt.Errorf("error while getting ApiServer source %s", name)
|
return true, nil, fmt.Errorf("error while getting ApiServer source %s", name)
|
||||||
}
|
}
|
||||||
|
|
@ -101,8 +101,8 @@ func TestUpdateApiServerSource(t *testing.T) {
|
||||||
sourcesServer, client := setupAPIServerSourcesClient(t)
|
sourcesServer, client := setupAPIServerSourcesClient(t)
|
||||||
|
|
||||||
sourcesServer.AddReactor("update", "apiserversources",
|
sourcesServer.AddReactor("update", "apiserversources",
|
||||||
func(a client_testing.Action) (bool, runtime.Object, error) {
|
func(a clienttesting.Action) (bool, runtime.Object, error) {
|
||||||
updatedSource := a.(client_testing.UpdateAction).GetObject()
|
updatedSource := a.(clienttesting.UpdateAction).GetObject()
|
||||||
name := updatedSource.(metav1.Object).GetName()
|
name := updatedSource.(metav1.Object).GetName()
|
||||||
if name == "errorSource" {
|
if name == "errorSource" {
|
||||||
return true, nil, fmt.Errorf("error while updating ApiServer source %s", name)
|
return true, nil, fmt.Errorf("error while updating ApiServer source %s", name)
|
||||||
|
|
@ -120,7 +120,7 @@ func TestListAPIServerSource(t *testing.T) {
|
||||||
sourcesServer, client := setupAPIServerSourcesClient(t)
|
sourcesServer, client := setupAPIServerSourcesClient(t)
|
||||||
|
|
||||||
sourcesServer.AddReactor("list", "apiserversources",
|
sourcesServer.AddReactor("list", "apiserversources",
|
||||||
func(a client_testing.Action) (bool, runtime.Object, error) {
|
func(a clienttesting.Action) (bool, runtime.Object, error) {
|
||||||
cJSource := newAPIServerSource("testsource", "Event")
|
cJSource := newAPIServerSource("testsource", "Event")
|
||||||
return true, &v1alpha1.ApiServerSourceList{Items: []v1alpha1.ApiServerSource{*cJSource}}, nil
|
return true, &v1alpha1.ApiServerSourceList{Items: []v1alpha1.ApiServerSource{*cJSource}}, nil
|
||||||
})
|
})
|
||||||
|
|
@ -132,7 +132,7 @@ func TestListAPIServerSource(t *testing.T) {
|
||||||
|
|
||||||
func newAPIServerSource(name, resource string) *v1alpha1.ApiServerSource {
|
func newAPIServerSource(name, resource string) *v1alpha1.ApiServerSource {
|
||||||
b := NewAPIServerSourceBuilder(name).ServiceAccount("testsa").Mode("Ref")
|
b := NewAPIServerSourceBuilder(name).ServiceAccount("testsa").Mode("Ref")
|
||||||
b.Sink(&v1beta1.Destination{
|
b.Sink(&duckv1beta1.Destination{
|
||||||
Ref: &v1.ObjectReference{
|
Ref: &v1.ObjectReference{
|
||||||
Kind: "Service",
|
Kind: "Service",
|
||||||
Name: "foosvc",
|
Name: "foosvc",
|
||||||
|
|
@ -143,7 +143,6 @@ func newAPIServerSource(name, resource string) *v1alpha1.ApiServerSource {
|
||||||
b.Resources([]v1alpha1.ApiServerResource{{
|
b.Resources([]v1alpha1.ApiServerResource{{
|
||||||
APIVersion: "v1",
|
APIVersion: "v1",
|
||||||
Kind: resource,
|
Kind: resource,
|
||||||
Controller: false,
|
|
||||||
}})
|
}})
|
||||||
}
|
}
|
||||||
return b.Build()
|
return b.Build()
|
||||||
|
|
@ -15,26 +15,26 @@
|
||||||
package v1alpha1
|
package v1alpha1
|
||||||
|
|
||||||
import (
|
import (
|
||||||
client_v1alpha1 "knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha1"
|
clientv1alpha1 "knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha1"
|
||||||
)
|
)
|
||||||
|
|
||||||
// KnSinkBindingClient to Eventing Sources. All methods are relative to the
|
// KnSinkBindingClient to Eventing Sources. All methods are relative to the
|
||||||
// namespace specified during construction
|
// namespace specified during construction
|
||||||
type KnSourcesClient interface {
|
type KnSourcesClient interface {
|
||||||
// Get client for sink binding sources
|
// Get client for ApiServer sources
|
||||||
SinkBindingClient() KnSinkBindingClient
|
APIServerSourcesClient() KnAPIServerSourcesClient
|
||||||
}
|
}
|
||||||
|
|
||||||
// sourcesClient is a combination of Sources client interface and namespace
|
// sourcesClient is a combination of Sources client interface and namespace
|
||||||
// Temporarily help to add sources dependencies
|
// Temporarily help to add sources dependencies
|
||||||
// May be changed when adding real sources features
|
// May be changed when adding real sources features
|
||||||
type sourcesClient struct {
|
type sourcesClient struct {
|
||||||
client client_v1alpha1.SourcesV1alpha1Interface
|
client clientv1alpha1.SourcesV1alpha1Interface
|
||||||
namespace string
|
namespace string
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewKnSourcesClient for managing all eventing built-in sources
|
// NewKnSourcesClient for managing all eventing built-in sources
|
||||||
func NewKnSourcesClient(client client_v1alpha1.SourcesV1alpha1Interface, namespace string) KnSourcesClient {
|
func NewKnSourcesClient(client clientv1alpha1.SourcesV1alpha1Interface, namespace string) KnSourcesClient {
|
||||||
return &sourcesClient{
|
return &sourcesClient{
|
||||||
client: client,
|
client: client,
|
||||||
namespace: namespace,
|
namespace: namespace,
|
||||||
|
|
@ -42,6 +42,6 @@ func NewKnSourcesClient(client client_v1alpha1.SourcesV1alpha1Interface, namespa
|
||||||
}
|
}
|
||||||
|
|
||||||
// ApiServerSourcesClient for dealing with ApiServer sources
|
// ApiServerSourcesClient for dealing with ApiServer sources
|
||||||
func (c *sourcesClient) SinkBindingClient() KnSinkBindingClient {
|
func (c *sourcesClient) APIServerSourcesClient() KnAPIServerSourcesClient {
|
||||||
return newKnSinkBindingClient(c.client.SinkBindings(c.namespace), c.namespace)
|
return newKnAPIServerSourcesClient(c.client.ApiServerSources(c.namespace), c.namespace)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,22 +12,22 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
package v1alpha1
|
package v1alpha2
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
apis_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
apisv1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
"knative.dev/eventing/pkg/apis/sources/v1alpha1"
|
v1alpha2 "knative.dev/eventing/pkg/apis/sources/v1alpha2"
|
||||||
"knative.dev/eventing/pkg/client/clientset/versioned/scheme"
|
"knative.dev/eventing/pkg/client/clientset/versioned/scheme"
|
||||||
client_v1alpha1 "knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha1"
|
clientv1alpha2 "knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha2"
|
||||||
duckv1 "knative.dev/pkg/apis/duck/v1"
|
duckv1 "knative.dev/pkg/apis/duck/v1"
|
||||||
"knative.dev/pkg/tracker"
|
"knative.dev/pkg/tracker"
|
||||||
|
|
||||||
kn_errors "knative.dev/client/pkg/errors"
|
knerrors "knative.dev/client/pkg/errors"
|
||||||
"knative.dev/client/pkg/util"
|
"knative.dev/client/pkg/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -37,27 +37,27 @@ type KnSinkBindingClient interface {
|
||||||
// Namespace in which this client is operating for
|
// Namespace in which this client is operating for
|
||||||
Namespace() string
|
Namespace() string
|
||||||
// CreateSinkBinding is used to create an instance of binding
|
// CreateSinkBinding is used to create an instance of binding
|
||||||
CreateSinkBinding(binding *v1alpha1.SinkBinding) error
|
CreateSinkBinding(binding *v1alpha2.SinkBinding) error
|
||||||
// DeleteSinkBinding is used to delete an instance of binding
|
// DeleteSinkBinding is used to delete an instance of binding
|
||||||
DeleteSinkBinding(name string) error
|
DeleteSinkBinding(name string) error
|
||||||
// GetSinkBinding is used to get an instance of binding
|
// GetSinkBinding is used to get an instance of binding
|
||||||
GetSinkBinding(name string) (*v1alpha1.SinkBinding, error)
|
GetSinkBinding(name string) (*v1alpha2.SinkBinding, error)
|
||||||
// ListSinkBinding returns list of binding CRDs
|
// ListSinkBinding returns list of binding CRDs
|
||||||
ListSinkBindings() (*v1alpha1.SinkBindingList, error)
|
ListSinkBindings() (*v1alpha2.SinkBindingList, error)
|
||||||
// UpdateSinkBinding is used to update an instance of binding
|
// UpdateSinkBinding is used to update an instance of binding
|
||||||
UpdateSinkBinding(binding *v1alpha1.SinkBinding) error
|
UpdateSinkBinding(binding *v1alpha2.SinkBinding) error
|
||||||
}
|
}
|
||||||
|
|
||||||
// KnSinkBindingClient is a combination of Sources client interface and namespace
|
// KnSinkBindingClient is a combination of Sources client interface and namespace
|
||||||
// Temporarily help to add sources dependencies
|
// Temporarily help to add sources dependencies
|
||||||
// May be changed when adding real sources features
|
// May be changed when adding real sources features
|
||||||
type knBindingClient struct {
|
type knBindingClient struct {
|
||||||
client client_v1alpha1.SinkBindingInterface
|
client clientv1alpha2.SinkBindingInterface
|
||||||
namespace string
|
namespace string
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewKnSourcesClient is to invoke Eventing Sources Client API to create object
|
// NewKnSourcesClient is to invoke Eventing Sources Client API to create object
|
||||||
func newKnSinkBindingClient(client client_v1alpha1.SinkBindingInterface, namespace string) KnSinkBindingClient {
|
func newKnSinkBindingClient(client clientv1alpha2.SinkBindingInterface, namespace string) KnSinkBindingClient {
|
||||||
return &knBindingClient{
|
return &knBindingClient{
|
||||||
client: client,
|
client: client,
|
||||||
namespace: namespace,
|
namespace: namespace,
|
||||||
|
|
@ -65,36 +65,36 @@ func newKnSinkBindingClient(client client_v1alpha1.SinkBindingInterface, namespa
|
||||||
}
|
}
|
||||||
|
|
||||||
//CreateSinkBinding is used to create an instance of binding
|
//CreateSinkBinding is used to create an instance of binding
|
||||||
func (c *knBindingClient) CreateSinkBinding(binding *v1alpha1.SinkBinding) error {
|
func (c *knBindingClient) CreateSinkBinding(binding *v1alpha2.SinkBinding) error {
|
||||||
binding, err := c.client.Create(binding)
|
binding, err := c.client.Create(binding)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return kn_errors.GetError(err)
|
return knerrors.GetError(err)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
//DeleteSinkBinding is used to delete an instance of binding
|
//DeleteSinkBinding is used to delete an instance of binding
|
||||||
func (c *knBindingClient) DeleteSinkBinding(name string) error {
|
func (c *knBindingClient) DeleteSinkBinding(name string) error {
|
||||||
err := c.client.Delete(name, &apis_v1.DeleteOptions{})
|
err := c.client.Delete(name, &apisv1.DeleteOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return kn_errors.GetError(err)
|
return knerrors.GetError(err)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
//GetSinkBinding is used to get an instance of binding
|
//GetSinkBinding is used to get an instance of binding
|
||||||
func (c *knBindingClient) GetSinkBinding(name string) (*v1alpha1.SinkBinding, error) {
|
func (c *knBindingClient) GetSinkBinding(name string) (*v1alpha2.SinkBinding, error) {
|
||||||
binding, err := c.client.Get(name, apis_v1.GetOptions{})
|
binding, err := c.client.Get(name, apisv1.GetOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, kn_errors.GetError(err)
|
return nil, knerrors.GetError(err)
|
||||||
}
|
}
|
||||||
return binding, nil
|
return binding, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *knBindingClient) ListSinkBindings() (*v1alpha1.SinkBindingList, error) {
|
func (c *knBindingClient) ListSinkBindings() (*v1alpha2.SinkBindingList, error) {
|
||||||
bindingList, err := c.client.List(apis_v1.ListOptions{})
|
bindingList, err := c.client.List(apisv1.ListOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, kn_errors.GetError(err)
|
return nil, knerrors.GetError(err)
|
||||||
}
|
}
|
||||||
bindingListNew := bindingList.DeepCopy()
|
bindingListNew := bindingList.DeepCopy()
|
||||||
err = updateSinkBindingGvk(bindingListNew)
|
err = updateSinkBindingGvk(bindingListNew)
|
||||||
|
|
@ -102,7 +102,7 @@ func (c *knBindingClient) ListSinkBindings() (*v1alpha1.SinkBindingList, error)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
bindingListNew.Items = make([]v1alpha1.SinkBinding, len(bindingList.Items))
|
bindingListNew.Items = make([]v1alpha2.SinkBinding, len(bindingList.Items))
|
||||||
for idx, binding := range bindingList.Items {
|
for idx, binding := range bindingList.Items {
|
||||||
bindingClone := binding.DeepCopy()
|
bindingClone := binding.DeepCopy()
|
||||||
err := updateSinkBindingGvk(bindingClone)
|
err := updateSinkBindingGvk(bindingClone)
|
||||||
|
|
@ -115,10 +115,10 @@ func (c *knBindingClient) ListSinkBindings() (*v1alpha1.SinkBindingList, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
//CreateSinkBinding is used to create an instance of binding
|
//CreateSinkBinding is used to create an instance of binding
|
||||||
func (c *knBindingClient) UpdateSinkBinding(binding *v1alpha1.SinkBinding) error {
|
func (c *knBindingClient) UpdateSinkBinding(binding *v1alpha2.SinkBinding) error {
|
||||||
binding, err := c.client.Update(binding)
|
binding, err := c.client.Update(binding)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return kn_errors.GetError(err)
|
return knerrors.GetError(err)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
@ -128,14 +128,14 @@ func (c *knBindingClient) Namespace() string {
|
||||||
return c.namespace
|
return c.namespace
|
||||||
}
|
}
|
||||||
|
|
||||||
// update with the v1alpha1 group + version
|
// update with the v1alpha2 group + version
|
||||||
func updateSinkBindingGvk(obj runtime.Object) error {
|
func updateSinkBindingGvk(obj runtime.Object) error {
|
||||||
return util.UpdateGroupVersionKindWithScheme(obj, v1alpha1.SchemeGroupVersion, scheme.Scheme)
|
return util.UpdateGroupVersionKindWithScheme(obj, v1alpha2.SchemeGroupVersion, scheme.Scheme)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SinkBindingBuilder is for building the binding
|
// SinkBindingBuilder is for building the binding
|
||||||
type SinkBindingBuilder struct {
|
type SinkBindingBuilder struct {
|
||||||
binding *v1alpha1.SinkBinding
|
binding *v1alpha2.SinkBinding
|
||||||
sGvk *schema.GroupVersionKind
|
sGvk *schema.GroupVersionKind
|
||||||
sName string
|
sName string
|
||||||
sLabelSelector map[string]string
|
sLabelSelector map[string]string
|
||||||
|
|
@ -147,15 +147,15 @@ type SinkBindingBuilder struct {
|
||||||
|
|
||||||
// NewSinkBindingBuilder for building binding object
|
// NewSinkBindingBuilder for building binding object
|
||||||
func NewSinkBindingBuilder(name string) *SinkBindingBuilder {
|
func NewSinkBindingBuilder(name string) *SinkBindingBuilder {
|
||||||
return &SinkBindingBuilder{binding: &v1alpha1.SinkBinding{
|
return &SinkBindingBuilder{binding: &v1alpha2.SinkBinding{
|
||||||
ObjectMeta: meta_v1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: name,
|
Name: name,
|
||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewSinkBindingBuilderFromExisting for building the object from existing SinkBinding object
|
// NewSinkBindingBuilderFromExisting for building the object from existing SinkBinding object
|
||||||
func NewSinkBindingBuilderFromExisting(binding *v1alpha1.SinkBinding) *SinkBindingBuilder {
|
func NewSinkBindingBuilderFromExisting(binding *v1alpha2.SinkBinding) *SinkBindingBuilder {
|
||||||
return &SinkBindingBuilder{binding: binding.DeepCopy()}
|
return &SinkBindingBuilder{binding: binding.DeepCopy()}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -217,7 +217,7 @@ func (b *SinkBindingBuilder) AddCloudEventOverrides(ceo map[string]string) *Sink
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build to return an instance of binding object
|
// Build to return an instance of binding object
|
||||||
func (b *SinkBindingBuilder) Build() (*v1alpha1.SinkBinding, error) {
|
func (b *SinkBindingBuilder) Build() (*v1alpha2.SinkBinding, error) {
|
||||||
// If set directly, return the sink binding directly
|
// If set directly, return the sink binding directly
|
||||||
if b.subject != nil {
|
if b.subject != nil {
|
||||||
b.binding.Spec.Subject = *b.subject
|
b.binding.Spec.Subject = *b.subject
|
||||||
|
|
@ -242,7 +242,7 @@ func (b *SinkBindingBuilder) Build() (*v1alpha1.SinkBinding, error) {
|
||||||
if b.sName != "" {
|
if b.sName != "" {
|
||||||
subject.Name = b.sName
|
subject.Name = b.sName
|
||||||
} else {
|
} else {
|
||||||
subject.Selector = &meta_v1.LabelSelector{
|
subject.Selector = &metav1.LabelSelector{
|
||||||
MatchLabels: b.sLabelSelector,
|
MatchLabels: b.sLabelSelector,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -12,12 +12,12 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
package v1alpha1
|
package v1alpha2
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"knative.dev/eventing/pkg/apis/sources/v1alpha1"
|
v1alpha2 "knative.dev/eventing/pkg/apis/sources/v1alpha2"
|
||||||
|
|
||||||
"knative.dev/client/pkg/util/mock"
|
"knative.dev/client/pkg/util/mock"
|
||||||
)
|
)
|
||||||
|
|
@ -65,20 +65,20 @@ func (sr *EventingRecorder) CreateSinkBinding(binding interface{}, err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateSinkBinding performs a previously recorded action
|
// CreateSinkBinding performs a previously recorded action
|
||||||
func (c *MockKnSinkBindingClient) CreateSinkBinding(binding *v1alpha1.SinkBinding) error {
|
func (c *MockKnSinkBindingClient) CreateSinkBinding(binding *v1alpha2.SinkBinding) error {
|
||||||
call := c.recorder.r.VerifyCall("CreateSinkBinding", binding)
|
call := c.recorder.r.VerifyCall("CreateSinkBinding", binding)
|
||||||
return mock.ErrorOrNil(call.Result[0])
|
return mock.ErrorOrNil(call.Result[0])
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetSinkBinding records a call for GetSinkBinding with the expected object or error. Either binding or err should be nil
|
// GetSinkBinding records a call for GetSinkBinding with the expected object or error. Either binding or err should be nil
|
||||||
func (sr *EventingRecorder) GetSinkBinding(name interface{}, binding *v1alpha1.SinkBinding, err error) {
|
func (sr *EventingRecorder) GetSinkBinding(name interface{}, binding *v1alpha2.SinkBinding, err error) {
|
||||||
sr.r.Add("GetSinkBinding", []interface{}{name}, []interface{}{binding, err})
|
sr.r.Add("GetSinkBinding", []interface{}{name}, []interface{}{binding, err})
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetSinkBinding performs a previously recorded action
|
// GetSinkBinding performs a previously recorded action
|
||||||
func (c *MockKnSinkBindingClient) GetSinkBinding(name string) (*v1alpha1.SinkBinding, error) {
|
func (c *MockKnSinkBindingClient) GetSinkBinding(name string) (*v1alpha2.SinkBinding, error) {
|
||||||
call := c.recorder.r.VerifyCall("GetSinkBinding", name)
|
call := c.recorder.r.VerifyCall("GetSinkBinding", name)
|
||||||
return call.Result[0].(*v1alpha1.SinkBinding), mock.ErrorOrNil(call.Result[1])
|
return call.Result[0].(*v1alpha2.SinkBinding), mock.ErrorOrNil(call.Result[1])
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeleteSinkBinding records a call for DeleteSinkBinding with the expected error (nil if none)
|
// DeleteSinkBinding records a call for DeleteSinkBinding with the expected error (nil if none)
|
||||||
|
|
@ -93,14 +93,14 @@ func (c *MockKnSinkBindingClient) DeleteSinkBinding(name string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListSinkBindings records a call for ListSinkBindings with the expected result and error (nil if none)
|
// ListSinkBindings records a call for ListSinkBindings with the expected result and error (nil if none)
|
||||||
func (sr *EventingRecorder) ListSinkBindings(bindingList *v1alpha1.SinkBindingList, err error) {
|
func (sr *EventingRecorder) ListSinkBindings(bindingList *v1alpha2.SinkBindingList, err error) {
|
||||||
sr.r.Add("ListSinkBindings", nil, []interface{}{bindingList, err})
|
sr.r.Add("ListSinkBindings", nil, []interface{}{bindingList, err})
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListSinkBindings performs a previously recorded action
|
// ListSinkBindings performs a previously recorded action
|
||||||
func (c *MockKnSinkBindingClient) ListSinkBindings() (*v1alpha1.SinkBindingList, error) {
|
func (c *MockKnSinkBindingClient) ListSinkBindings() (*v1alpha2.SinkBindingList, error) {
|
||||||
call := c.recorder.r.VerifyCall("ListSinkBindings")
|
call := c.recorder.r.VerifyCall("ListSinkBindings")
|
||||||
return call.Result[0].(*v1alpha1.SinkBindingList), mock.ErrorOrNil(call.Result[1])
|
return call.Result[0].(*v1alpha2.SinkBindingList), mock.ErrorOrNil(call.Result[1])
|
||||||
}
|
}
|
||||||
|
|
||||||
// UpdateSinkBinding records a call for ListSinkBindings with the expected result and error (nil if none)
|
// UpdateSinkBinding records a call for ListSinkBindings with the expected result and error (nil if none)
|
||||||
|
|
@ -109,7 +109,7 @@ func (sr *EventingRecorder) UpdateSinkBinding(binding interface{}, err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// UpdateSinkBinding performs a previously recorded action
|
// UpdateSinkBinding performs a previously recorded action
|
||||||
func (c *MockKnSinkBindingClient) UpdateSinkBinding(binding *v1alpha1.SinkBinding) error {
|
func (c *MockKnSinkBindingClient) UpdateSinkBinding(binding *v1alpha2.SinkBinding) error {
|
||||||
call := c.recorder.r.VerifyCall("UpdateSinkBinding")
|
call := c.recorder.r.VerifyCall("UpdateSinkBinding")
|
||||||
return mock.ErrorOrNil(call.Result[0])
|
return mock.ErrorOrNil(call.Result[0])
|
||||||
}
|
}
|
||||||
|
|
@ -12,12 +12,12 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
package v1alpha1
|
package v1alpha2
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"knative.dev/eventing/pkg/apis/sources/v1alpha1"
|
v1alpha2 "knative.dev/eventing/pkg/apis/sources/v1alpha2"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestMockKnClient(t *testing.T) {
|
func TestMockKnClient(t *testing.T) {
|
||||||
|
|
@ -27,17 +27,17 @@ func TestMockKnClient(t *testing.T) {
|
||||||
|
|
||||||
// Record all services
|
// Record all services
|
||||||
recorder.GetSinkBinding("hello", nil, nil)
|
recorder.GetSinkBinding("hello", nil, nil)
|
||||||
recorder.CreateSinkBinding(&v1alpha1.SinkBinding{}, nil)
|
recorder.CreateSinkBinding(&v1alpha2.SinkBinding{}, nil)
|
||||||
recorder.DeleteSinkBinding("hello", nil)
|
recorder.DeleteSinkBinding("hello", nil)
|
||||||
recorder.ListSinkBindings(nil, nil)
|
recorder.ListSinkBindings(nil, nil)
|
||||||
recorder.UpdateSinkBinding(&v1alpha1.SinkBinding{}, nil)
|
recorder.UpdateSinkBinding(&v1alpha2.SinkBinding{}, nil)
|
||||||
|
|
||||||
// Call all service
|
// Call all service
|
||||||
client.GetSinkBinding("hello")
|
client.GetSinkBinding("hello")
|
||||||
client.CreateSinkBinding(&v1alpha1.SinkBinding{})
|
client.CreateSinkBinding(&v1alpha2.SinkBinding{})
|
||||||
client.DeleteSinkBinding("hello")
|
client.DeleteSinkBinding("hello")
|
||||||
client.ListSinkBindings()
|
client.ListSinkBindings()
|
||||||
client.UpdateSinkBinding(&v1alpha1.SinkBinding{})
|
client.UpdateSinkBinding(&v1alpha2.SinkBinding{})
|
||||||
|
|
||||||
// Validate
|
// Validate
|
||||||
recorder.Validate()
|
recorder.Validate()
|
||||||
|
|
@ -12,7 +12,7 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
package v1alpha1
|
package v1alpha2
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
@ -23,16 +23,16 @@ import (
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
clienttesting "k8s.io/client-go/testing"
|
clienttesting "k8s.io/client-go/testing"
|
||||||
"knative.dev/eventing/pkg/apis/sources/v1alpha1"
|
"knative.dev/eventing/pkg/apis/sources/v1alpha2"
|
||||||
"knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha1/fake"
|
"knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha2/fake"
|
||||||
duckv1 "knative.dev/pkg/apis/duck/v1"
|
duckv1 "knative.dev/pkg/apis/duck/v1"
|
||||||
"knative.dev/pkg/tracker"
|
"knative.dev/pkg/tracker"
|
||||||
)
|
)
|
||||||
|
|
||||||
var testNamespace = "test-ns"
|
var testNamespace = "test-ns"
|
||||||
|
|
||||||
func setup() (fakeSvr fake.FakeSourcesV1alpha1, client KnSinkBindingClient) {
|
func setup() (fakeSvr fake.FakeSourcesV1alpha2, client KnSinkBindingClient) {
|
||||||
fakeE := fake.FakeSourcesV1alpha1{Fake: &clienttesting.Fake{}}
|
fakeE := fake.FakeSourcesV1alpha2{Fake: &clienttesting.Fake{}}
|
||||||
cli := NewKnSourcesClient(&fakeE, "test-ns").SinkBindingClient()
|
cli := NewKnSourcesClient(&fakeE, "test-ns").SinkBindingClient()
|
||||||
return fakeE, cli
|
return fakeE, cli
|
||||||
}
|
}
|
||||||
|
|
@ -61,7 +61,7 @@ func TestCreateSinkBinding(t *testing.T) {
|
||||||
var name = "new-binding"
|
var name = "new-binding"
|
||||||
server, client := setup()
|
server, client := setup()
|
||||||
|
|
||||||
objNew := newSinkBinding(name, "mysvc", "mycronjob")
|
objNew := newSinkBinding(name, "mysvc", "myping")
|
||||||
|
|
||||||
server.AddReactor("create", "sinkbindings",
|
server.AddReactor("create", "sinkbindings",
|
||||||
func(a clienttesting.Action) (bool, runtime.Object, error) {
|
func(a clienttesting.Action) (bool, runtime.Object, error) {
|
||||||
|
|
@ -80,7 +80,7 @@ func TestCreateSinkBinding(t *testing.T) {
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("create binding with an error returns an error object", func(t *testing.T) {
|
t.Run("create binding with an error returns an error object", func(t *testing.T) {
|
||||||
err := client.CreateSinkBinding(newSinkBinding("unknown", "mysvc", "mycronjobs"))
|
err := client.CreateSinkBinding(newSinkBinding("unknown", "mysvc", "mypings"))
|
||||||
assert.ErrorContains(t, err, "unknown")
|
assert.ErrorContains(t, err, "unknown")
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
@ -95,14 +95,14 @@ func TestGetSinkBinding(t *testing.T) {
|
||||||
if name == "errorSinkBinding" {
|
if name == "errorSinkBinding" {
|
||||||
return true, nil, fmt.Errorf("error while getting binding %s", name)
|
return true, nil, fmt.Errorf("error while getting binding %s", name)
|
||||||
}
|
}
|
||||||
return true, newSinkBinding(name, "mysvc", "mycronjob"), nil
|
return true, newSinkBinding(name, "mysvc", "myping"), nil
|
||||||
})
|
})
|
||||||
|
|
||||||
binding, err := client.GetSinkBinding(name)
|
binding, err := client.GetSinkBinding(name)
|
||||||
assert.NilError(t, err)
|
assert.NilError(t, err)
|
||||||
assert.Equal(t, binding.Name, name)
|
assert.Equal(t, binding.Name, name)
|
||||||
assert.Equal(t, binding.Spec.Sink.Ref.Name, "mysvc")
|
assert.Equal(t, binding.Spec.Sink.Ref.Name, "mysvc")
|
||||||
assert.Equal(t, binding.Spec.Subject.Name, "mycronjob")
|
assert.Equal(t, binding.Spec.Subject.Name, "myping")
|
||||||
|
|
||||||
_, err = client.GetSinkBinding("errorSinkBinding")
|
_, err = client.GetSinkBinding("errorSinkBinding")
|
||||||
assert.ErrorContains(t, err, "errorSinkBinding")
|
assert.ErrorContains(t, err, "errorSinkBinding")
|
||||||
|
|
@ -112,13 +112,13 @@ func TestListSinkBinding(t *testing.T) {
|
||||||
serving, client := setup()
|
serving, client := setup()
|
||||||
|
|
||||||
t.Run("list binding returns a list of sink-bindings", func(t *testing.T) {
|
t.Run("list binding returns a list of sink-bindings", func(t *testing.T) {
|
||||||
binding1 := newSinkBinding("binding-1", "mysvc-1", "mycronjob")
|
binding1 := newSinkBinding("binding-1", "mysvc-1", "myping")
|
||||||
binding2 := newSinkBinding("binding-2", "mysvc-2", "mycronjob")
|
binding2 := newSinkBinding("binding-2", "mysvc-2", "myping")
|
||||||
|
|
||||||
serving.AddReactor("list", "sinkbindings",
|
serving.AddReactor("list", "sinkbindings",
|
||||||
func(a clienttesting.Action) (bool, runtime.Object, error) {
|
func(a clienttesting.Action) (bool, runtime.Object, error) {
|
||||||
assert.Equal(t, testNamespace, a.GetNamespace())
|
assert.Equal(t, testNamespace, a.GetNamespace())
|
||||||
return true, &v1alpha1.SinkBindingList{Items: []v1alpha1.SinkBinding{*binding1, *binding2}}, nil
|
return true, &v1alpha2.SinkBindingList{Items: []v1alpha2.SinkBinding{*binding1, *binding2}}, nil
|
||||||
})
|
})
|
||||||
|
|
||||||
listSinkBindings, err := client.ListSinkBindings()
|
listSinkBindings, err := client.ListSinkBindings()
|
||||||
|
|
@ -126,10 +126,10 @@ func TestListSinkBinding(t *testing.T) {
|
||||||
assert.Assert(t, len(listSinkBindings.Items) == 2)
|
assert.Assert(t, len(listSinkBindings.Items) == 2)
|
||||||
assert.Equal(t, listSinkBindings.Items[0].Name, "binding-1")
|
assert.Equal(t, listSinkBindings.Items[0].Name, "binding-1")
|
||||||
assert.Equal(t, listSinkBindings.Items[0].Spec.Sink.Ref.Name, "mysvc-1")
|
assert.Equal(t, listSinkBindings.Items[0].Spec.Sink.Ref.Name, "mysvc-1")
|
||||||
assert.Equal(t, listSinkBindings.Items[0].Spec.Subject.Name, "mycronjob")
|
assert.Equal(t, listSinkBindings.Items[0].Spec.Subject.Name, "myping")
|
||||||
assert.Equal(t, listSinkBindings.Items[1].Name, "binding-2")
|
assert.Equal(t, listSinkBindings.Items[1].Name, "binding-2")
|
||||||
assert.Equal(t, listSinkBindings.Items[1].Spec.Sink.Ref.Name, "mysvc-2")
|
assert.Equal(t, listSinkBindings.Items[1].Spec.Sink.Ref.Name, "mysvc-2")
|
||||||
assert.Equal(t, listSinkBindings.Items[1].Spec.Subject.Name, "mycronjob")
|
assert.Equal(t, listSinkBindings.Items[1].Spec.Subject.Name, "myping")
|
||||||
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
@ -237,7 +237,7 @@ func TestSinkBindingBuilderForSubjectDirect(t *testing.T) {
|
||||||
assert.Assert(t, subject.Selector == nil)
|
assert.Assert(t, subject.Selector == nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func newSinkBinding(name, sinkService, cronJobName string) *v1alpha1.SinkBinding {
|
func newSinkBinding(name, sinkService, pingName string) *v1alpha2.SinkBinding {
|
||||||
sink := &duckv1.Destination{
|
sink := &duckv1.Destination{
|
||||||
Ref: &duckv1.KReference{Name: sinkService, Kind: "Service", Namespace: "default", APIVersion: "serving.knative.dev/v1"},
|
Ref: &duckv1.KReference{Name: sinkService, Kind: "Service", Namespace: "default", APIVersion: "serving.knative.dev/v1"},
|
||||||
}
|
}
|
||||||
|
|
@ -245,7 +245,7 @@ func newSinkBinding(name, sinkService, cronJobName string) *v1alpha1.SinkBinding
|
||||||
Namespace(testNamespace).
|
Namespace(testNamespace).
|
||||||
Sink(sink).
|
Sink(sink).
|
||||||
SubjectGVK(&schema.GroupVersionKind{"batch", "v1beta1", "CronJob"}).
|
SubjectGVK(&schema.GroupVersionKind{"batch", "v1beta1", "CronJob"}).
|
||||||
SubjectName(cronJobName).
|
SubjectName(pingName).
|
||||||
AddCloudEventOverrides(map[string]string{"type": "foo"}).
|
AddCloudEventOverrides(map[string]string{"type": "foo"}).
|
||||||
Build()
|
Build()
|
||||||
return b
|
return b
|
||||||
|
|
@ -12,44 +12,44 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
package v1alpha1
|
package v1alpha2
|
||||||
|
|
||||||
import (
|
import (
|
||||||
client_v1alpha1 "knative.dev/eventing/pkg/legacyclient/clientset/versioned/typed/legacysources/v1alpha1"
|
clientv1alpha2 "knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha2"
|
||||||
)
|
)
|
||||||
|
|
||||||
// KnSourcesClient to Eventing Sources. All methods are relative to the
|
// KnSinkBindingClient to Eventing Sources. All methods are relative to the
|
||||||
// namespace specified during construction
|
// namespace specified during construction
|
||||||
type KnSourcesClient interface {
|
type KnSourcesClient interface {
|
||||||
// Get client for ApiServer sources
|
// Get client for Ping sources
|
||||||
APIServerSourcesClient() KnAPIServerSourcesClient
|
PingSourcesClient() KnPingSourcesClient
|
||||||
|
|
||||||
// Get client for CronJob sources
|
// Get client for sink binding sources
|
||||||
CronJobSourcesClient() KnCronJobSourcesClient
|
SinkBindingClient() KnSinkBindingClient
|
||||||
}
|
}
|
||||||
|
|
||||||
// sourcesClient is a combination of Sources client interface and namespace
|
// sourcesClient is a combination of Sources client interface and namespace
|
||||||
// Temporarily help to add sources dependencies
|
// Temporarily help to add sources dependencies
|
||||||
// May be changed when adding real sources features
|
// May be changed when adding real sources features
|
||||||
type sourcesClient struct {
|
type sourcesClient struct {
|
||||||
client client_v1alpha1.SourcesV1alpha1Interface
|
client clientv1alpha2.SourcesV1alpha2Interface
|
||||||
namespace string
|
namespace string
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewKnSourcesClient for managing all eventing built-in sources
|
// NewKnSourcesClient for managing all eventing built-in sources
|
||||||
func NewKnSourcesClient(client client_v1alpha1.SourcesV1alpha1Interface, namespace string) KnSourcesClient {
|
func NewKnSourcesClient(client clientv1alpha2.SourcesV1alpha2Interface, namespace string) KnSourcesClient {
|
||||||
return &sourcesClient{
|
return &sourcesClient{
|
||||||
client: client,
|
client: client,
|
||||||
namespace: namespace,
|
namespace: namespace,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ApiServerSourcesClient for dealing with ApiServer sources
|
// Get the client for dealing with Ping sources
|
||||||
func (c *sourcesClient) APIServerSourcesClient() KnAPIServerSourcesClient {
|
func (c *sourcesClient) PingSourcesClient() KnPingSourcesClient {
|
||||||
return newKnAPIServerSourcesClient(c.client.ApiServerSources(c.namespace), c.namespace)
|
return newKnPingSourcesClient(c.client.PingSources(c.namespace), c.namespace)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the client for dealing with cronjob sources
|
// ApiServerSourcesClient for dealing with ApiServer sources
|
||||||
func (c *sourcesClient) CronJobSourcesClient() KnCronJobSourcesClient {
|
func (c *sourcesClient) SinkBindingClient() KnSinkBindingClient {
|
||||||
return newKnCronJobSourcesClient(c.client.CronJobSources(c.namespace), c.namespace)
|
return newKnSinkBindingClient(c.client.SinkBindings(c.namespace), c.namespace)
|
||||||
}
|
}
|
||||||
|
|
@ -0,0 +1,164 @@
|
||||||
|
// Copyright © 2019 The Knative Authors
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package v1alpha2
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
|
"knative.dev/eventing/pkg/apis/sources/v1alpha2"
|
||||||
|
|
||||||
|
"knative.dev/eventing/pkg/client/clientset/versioned/scheme"
|
||||||
|
clientv1alpha2 "knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha2"
|
||||||
|
duckv1 "knative.dev/pkg/apis/duck/v1"
|
||||||
|
|
||||||
|
"knative.dev/client/pkg/util"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Interface for interacting with a Ping source
|
||||||
|
type KnPingSourcesClient interface {
|
||||||
|
|
||||||
|
// GetPingSource fetches a Ping source by its name
|
||||||
|
GetPingSource(name string) (*v1alpha2.PingSource, error)
|
||||||
|
|
||||||
|
// CreatePingSource creates a Ping source
|
||||||
|
CreatePingSource(pingSource *v1alpha2.PingSource) error
|
||||||
|
|
||||||
|
// UpdatePingSource updates a Ping source
|
||||||
|
UpdatePingSource(pingSource *v1alpha2.PingSource) error
|
||||||
|
|
||||||
|
// DeletePingSource deletes a Ping source
|
||||||
|
DeletePingSource(name string) error
|
||||||
|
|
||||||
|
// ListPingSource lists all Ping sources
|
||||||
|
// TODO: Support list configs like in service list
|
||||||
|
ListPingSource() (*v1alpha2.PingSourceList, error)
|
||||||
|
|
||||||
|
// Get namespace for this source
|
||||||
|
Namespace() string
|
||||||
|
}
|
||||||
|
|
||||||
|
// knSourcesClient is a combination of Sources client interface and namespace
|
||||||
|
// Temporarily help to add sources dependencies
|
||||||
|
// May be changed when adding real sources features
|
||||||
|
type pingSourcesClient struct {
|
||||||
|
client clientv1alpha2.PingSourceInterface
|
||||||
|
namespace string
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewKnSourcesClient is to invoke Eventing Sources Client API to create object
|
||||||
|
func newKnPingSourcesClient(client clientv1alpha2.PingSourceInterface, namespace string) KnPingSourcesClient {
|
||||||
|
return &pingSourcesClient{
|
||||||
|
client: client,
|
||||||
|
namespace: namespace,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the namespace for which this client has been created
|
||||||
|
func (c *pingSourcesClient) Namespace() string {
|
||||||
|
return c.namespace
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *pingSourcesClient) CreatePingSource(pingsource *v1alpha2.PingSource) error {
|
||||||
|
if pingsource.Spec.Sink.Ref == nil && pingsource.Spec.Sink.URI == nil {
|
||||||
|
return fmt.Errorf("a sink is required for creating a source")
|
||||||
|
}
|
||||||
|
_, err := c.client.Create(pingsource)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *pingSourcesClient) UpdatePingSource(pingSource *v1alpha2.PingSource) error {
|
||||||
|
_, err := c.client.Update(pingSource)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *pingSourcesClient) DeletePingSource(name string) error {
|
||||||
|
return c.client.Delete(name, &metav1.DeleteOptions{})
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *pingSourcesClient) GetPingSource(name string) (*v1alpha2.PingSource, error) {
|
||||||
|
return c.client.Get(name, metav1.GetOptions{})
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListPingSource returns the available Ping sources
|
||||||
|
func (c *pingSourcesClient) ListPingSource() (*v1alpha2.PingSourceList, error) {
|
||||||
|
sourceList, err := c.client.List(metav1.ListOptions{})
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return updatePingSourceListGVK(sourceList)
|
||||||
|
}
|
||||||
|
|
||||||
|
func updatePingSourceListGVK(sourceList *v1alpha2.PingSourceList) (*v1alpha2.PingSourceList, error) {
|
||||||
|
sourceListNew := sourceList.DeepCopy()
|
||||||
|
err := updateSourceGVK(sourceListNew)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
sourceListNew.Items = make([]v1alpha2.PingSource, len(sourceList.Items))
|
||||||
|
for idx, source := range sourceList.Items {
|
||||||
|
sourceClone := source.DeepCopy()
|
||||||
|
err := updateSourceGVK(sourceClone)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
sourceListNew.Items[idx] = *sourceClone
|
||||||
|
}
|
||||||
|
return sourceListNew, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func updateSourceGVK(obj runtime.Object) error {
|
||||||
|
return util.UpdateGroupVersionKindWithScheme(obj, v1alpha2.SchemeGroupVersion, scheme.Scheme)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Builder for building up Ping sources
|
||||||
|
|
||||||
|
type PingSourceBuilder struct {
|
||||||
|
pingSource *v1alpha2.PingSource
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewPingSourceBuilder(name string) *PingSourceBuilder {
|
||||||
|
return &PingSourceBuilder{pingSource: &v1alpha2.PingSource{
|
||||||
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
|
Name: name,
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewPingSourceBuilderFromExisting(pingsource *v1alpha2.PingSource) *PingSourceBuilder {
|
||||||
|
return &PingSourceBuilder{pingSource: pingsource.DeepCopy()}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *PingSourceBuilder) Schedule(schedule string) *PingSourceBuilder {
|
||||||
|
b.pingSource.Spec.Schedule = schedule
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *PingSourceBuilder) JsonData(data string) *PingSourceBuilder {
|
||||||
|
b.pingSource.Spec.JsonData = data
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *PingSourceBuilder) Sink(sink duckv1.Destination) *PingSourceBuilder {
|
||||||
|
b.pingSource.Spec.Sink = sink
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *PingSourceBuilder) Build() *v1alpha2.PingSource {
|
||||||
|
return b.pingSource
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,119 @@
|
||||||
|
// Copyright © 2019 The Knative Authors
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package v1alpha2
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"knative.dev/eventing/pkg/apis/sources/v1alpha2"
|
||||||
|
|
||||||
|
"knative.dev/client/pkg/util/mock"
|
||||||
|
)
|
||||||
|
|
||||||
|
type MockKnPingSourceClient struct {
|
||||||
|
t *testing.T
|
||||||
|
recorder *PingSourcesRecorder
|
||||||
|
namespace string
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewMockKnPingSourceClient returns a new mock instance which you need to record for
|
||||||
|
func NewMockKnPingSourceClient(t *testing.T, ns ...string) *MockKnPingSourceClient {
|
||||||
|
namespace := "default"
|
||||||
|
if len(ns) > 0 {
|
||||||
|
namespace = ns[0]
|
||||||
|
}
|
||||||
|
return &MockKnPingSourceClient{
|
||||||
|
t: t,
|
||||||
|
recorder: &PingSourcesRecorder{mock.NewRecorder(t, namespace)},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ensure that the interface is implemented
|
||||||
|
var _ KnPingSourcesClient = &MockKnPingSourceClient{}
|
||||||
|
|
||||||
|
// recorder for service
|
||||||
|
type PingSourcesRecorder struct {
|
||||||
|
r *mock.Recorder
|
||||||
|
}
|
||||||
|
|
||||||
|
// Recorder returns the recorder for registering API calls
|
||||||
|
func (c *MockKnPingSourceClient) Recorder() *PingSourcesRecorder {
|
||||||
|
return c.recorder
|
||||||
|
}
|
||||||
|
|
||||||
|
// Namespace of this client
|
||||||
|
func (c *MockKnPingSourceClient) Namespace() string {
|
||||||
|
return c.recorder.r.Namespace()
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreatePingSource records a call for CreatePingSource with the expected error
|
||||||
|
func (sr *PingSourcesRecorder) CreatePingSource(pingSource interface{}, err error) {
|
||||||
|
sr.r.Add("CreatePingSource", []interface{}{pingSource}, []interface{}{err})
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreatePingSource performs a previously recorded action, failing if non has been registered
|
||||||
|
func (c *MockKnPingSourceClient) CreatePingSource(pingSource *v1alpha2.PingSource) error {
|
||||||
|
call := c.recorder.r.VerifyCall("CreatePingSource", pingSource)
|
||||||
|
return mock.ErrorOrNil(call.Result[0])
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetPingSource records a call for GetPingSource with the expected object or error. Either pingsource or err should be nil
|
||||||
|
func (sr *PingSourcesRecorder) GetPingSource(name interface{}, pingSource *v1alpha2.PingSource, err error) {
|
||||||
|
sr.r.Add("GetPingSource", []interface{}{name}, []interface{}{pingSource, err})
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetPingSource performs a previously recorded action, failing if non has been registered
|
||||||
|
func (c *MockKnPingSourceClient) GetPingSource(name string) (*v1alpha2.PingSource, error) {
|
||||||
|
call := c.recorder.r.VerifyCall("GetPingSource", name)
|
||||||
|
return call.Result[0].(*v1alpha2.PingSource), mock.ErrorOrNil(call.Result[1])
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdatePingSource records a call for UpdatePingSource with the expected error (nil if none)
|
||||||
|
func (sr *PingSourcesRecorder) UpdatePingSource(pingSource interface{}, err error) {
|
||||||
|
sr.r.Add("UpdatePingSource", []interface{}{pingSource}, []interface{}{err})
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdatePingSource performs a previously recorded action, failing if non has been registered
|
||||||
|
func (c *MockKnPingSourceClient) UpdatePingSource(pingSource *v1alpha2.PingSource) error {
|
||||||
|
call := c.recorder.r.VerifyCall("UpdatePingSource", pingSource)
|
||||||
|
return mock.ErrorOrNil(call.Result[0])
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdatePingSource records a call for DeletePingSource with the expected error (nil if none)
|
||||||
|
func (sr *PingSourcesRecorder) DeletePingSource(name interface{}, err error) {
|
||||||
|
sr.r.Add("DeletePingSource", []interface{}{name}, []interface{}{err})
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeletePingSource performs a previously recorded action, failing if non has been registered
|
||||||
|
func (c *MockKnPingSourceClient) DeletePingSource(name string) error {
|
||||||
|
call := c.recorder.r.VerifyCall("DeletePingSource", name)
|
||||||
|
return mock.ErrorOrNil(call.Result[0])
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListPingSource records a call for ListPingSource with the expected error (nil if none)
|
||||||
|
func (sr *PingSourcesRecorder) ListPingSource(pingSourceList *v1alpha2.PingSourceList, err error) {
|
||||||
|
sr.r.Add("ListPingSource", []interface{}{}, []interface{}{pingSourceList, err})
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListPingSource performs a previously recorded action, failing if non has been registered
|
||||||
|
func (c *MockKnPingSourceClient) ListPingSource() (*v1alpha2.PingSourceList, error) {
|
||||||
|
call := c.recorder.r.VerifyCall("ListPingSource")
|
||||||
|
return call.Result[0].(*v1alpha2.PingSourceList), mock.ErrorOrNil(call.Result[1])
|
||||||
|
}
|
||||||
|
|
||||||
|
// Validates validates whether every recorded action has been called
|
||||||
|
func (sr *PingSourcesRecorder) Validate() {
|
||||||
|
sr.r.CheckThatAllRecordedMethodsHaveBeenCalled()
|
||||||
|
}
|
||||||
|
|
@ -12,31 +12,31 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
package v1alpha1
|
package v1alpha2
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"knative.dev/eventing/pkg/apis/legacysources/v1alpha1"
|
"knative.dev/eventing/pkg/apis/sources/v1alpha2"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestMockKnCronJobSourceClient(t *testing.T) {
|
func TestMockKnPingSourceClient(t *testing.T) {
|
||||||
|
|
||||||
client := NewMockKnCronJobSourceClient(t)
|
client := NewMockKnPingSourceClient(t)
|
||||||
|
|
||||||
recorder := client.Recorder()
|
recorder := client.Recorder()
|
||||||
|
|
||||||
// Record all services
|
// Record all services
|
||||||
recorder.GetCronJobSource("hello", nil, nil)
|
recorder.GetPingSource("hello", nil, nil)
|
||||||
recorder.CreateCronJobSource(&v1alpha1.CronJobSource{}, nil)
|
recorder.CreatePingSource(&v1alpha2.PingSource{}, nil)
|
||||||
recorder.UpdateCronJobSource(&v1alpha1.CronJobSource{}, nil)
|
recorder.UpdatePingSource(&v1alpha2.PingSource{}, nil)
|
||||||
recorder.DeleteCronJobSource("hello", nil)
|
recorder.DeletePingSource("hello", nil)
|
||||||
|
|
||||||
// Call all service
|
// Call all service
|
||||||
client.GetCronJobSource("hello")
|
client.GetPingSource("hello")
|
||||||
client.CreateCronJobSource(&v1alpha1.CronJobSource{})
|
client.CreatePingSource(&v1alpha2.PingSource{})
|
||||||
client.UpdateCronJobSource(&v1alpha1.CronJobSource{})
|
client.UpdatePingSource(&v1alpha2.PingSource{})
|
||||||
client.DeleteCronJobSource("hello")
|
client.DeletePingSource("hello")
|
||||||
|
|
||||||
// Validate
|
// Validate
|
||||||
recorder.Validate()
|
recorder.Validate()
|
||||||
|
|
@ -0,0 +1,151 @@
|
||||||
|
// Copyright © 2019 The Knative Authors
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package v1alpha2
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"gotest.tools/assert"
|
||||||
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
|
clienttesting "k8s.io/client-go/testing"
|
||||||
|
"knative.dev/eventing/pkg/apis/sources/v1alpha2"
|
||||||
|
"knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha2/fake"
|
||||||
|
duckv1 "knative.dev/pkg/apis/duck/v1"
|
||||||
|
)
|
||||||
|
|
||||||
|
func setupPingSourcesClient(t *testing.T) (sources fake.FakeSourcesV1alpha2, client KnPingSourcesClient) {
|
||||||
|
sources = fake.FakeSourcesV1alpha2{Fake: &clienttesting.Fake{}}
|
||||||
|
client = NewKnSourcesClient(&sources, "test-ns").PingSourcesClient()
|
||||||
|
assert.Equal(t, client.Namespace(), "test-ns")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestCreatePingSource(t *testing.T) {
|
||||||
|
sourcesServer, client := setupPingSourcesClient(t)
|
||||||
|
|
||||||
|
sourcesServer.AddReactor("create", "pingsources",
|
||||||
|
func(a clienttesting.Action) (bool, runtime.Object, error) {
|
||||||
|
newSource := a.(clienttesting.CreateAction).GetObject()
|
||||||
|
name := newSource.(metav1.Object).GetName()
|
||||||
|
if name == "errorSource" {
|
||||||
|
return true, nil, fmt.Errorf("error while creating pingsource %s", name)
|
||||||
|
}
|
||||||
|
return true, newSource, nil
|
||||||
|
})
|
||||||
|
|
||||||
|
err := client.CreatePingSource(newPingSource("testsource", "mysvc"))
|
||||||
|
assert.NilError(t, err)
|
||||||
|
|
||||||
|
err = client.CreatePingSource(newPingSource("testsource", ""))
|
||||||
|
assert.ErrorContains(t, err, "sink")
|
||||||
|
assert.ErrorContains(t, err, "required")
|
||||||
|
|
||||||
|
err = client.CreatePingSource(newPingSource("errorSource", "mysvc"))
|
||||||
|
assert.ErrorContains(t, err, "errorSource")
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestUpdatePingSource(t *testing.T) {
|
||||||
|
sourcesServer, client := setupPingSourcesClient(t)
|
||||||
|
|
||||||
|
sourcesServer.AddReactor("update", "pingsources",
|
||||||
|
func(a clienttesting.Action) (bool, runtime.Object, error) {
|
||||||
|
newSource := a.(clienttesting.UpdateAction).GetObject()
|
||||||
|
name := newSource.(metav1.Object).GetName()
|
||||||
|
if name == "errorSource" {
|
||||||
|
return true, nil, fmt.Errorf("error while updating pingsource %s", name)
|
||||||
|
}
|
||||||
|
return true, NewPingSourceBuilderFromExisting(newSource.(*v1alpha2.PingSource)).Build(), nil
|
||||||
|
})
|
||||||
|
|
||||||
|
err := client.UpdatePingSource(newPingSource("testsource", ""))
|
||||||
|
assert.NilError(t, err)
|
||||||
|
|
||||||
|
err = client.UpdatePingSource(newPingSource("errorSource", ""))
|
||||||
|
assert.ErrorContains(t, err, "errorSource")
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestDeletePingSource(t *testing.T) {
|
||||||
|
sourcesServer, client := setupPingSourcesClient(t)
|
||||||
|
|
||||||
|
sourcesServer.AddReactor("delete", "pingsources",
|
||||||
|
func(a clienttesting.Action) (bool, runtime.Object, error) {
|
||||||
|
name := a.(clienttesting.DeleteAction).GetName()
|
||||||
|
if name == "errorSource" {
|
||||||
|
return true, nil, fmt.Errorf("error while updating pingsource %s", name)
|
||||||
|
}
|
||||||
|
return true, nil, nil
|
||||||
|
})
|
||||||
|
|
||||||
|
err := client.DeletePingSource("testsource")
|
||||||
|
assert.NilError(t, err)
|
||||||
|
|
||||||
|
err = client.DeletePingSource("errorSource")
|
||||||
|
assert.ErrorContains(t, err, "errorSource")
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestGetPingSource(t *testing.T) {
|
||||||
|
sourcesServer, client := setupPingSourcesClient(t)
|
||||||
|
|
||||||
|
sourcesServer.AddReactor("get", "pingsources",
|
||||||
|
func(a clienttesting.Action) (bool, runtime.Object, error) {
|
||||||
|
name := a.(clienttesting.GetAction).GetName()
|
||||||
|
if name == "errorSource" {
|
||||||
|
return true, nil, fmt.Errorf("error while updating pingsource %s", name)
|
||||||
|
}
|
||||||
|
return true, newPingSource(name, "mysvc"), nil
|
||||||
|
})
|
||||||
|
|
||||||
|
source, err := client.GetPingSource("testsource")
|
||||||
|
assert.NilError(t, err)
|
||||||
|
assert.Equal(t, source.Name, "testsource")
|
||||||
|
assert.Equal(t, source.Spec.Sink.Ref.Name, "mysvc")
|
||||||
|
|
||||||
|
_, err = client.GetPingSource("errorSource")
|
||||||
|
assert.ErrorContains(t, err, "errorSource")
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestListPingSource(t *testing.T) {
|
||||||
|
sourcesServer, client := setupPingSourcesClient(t)
|
||||||
|
|
||||||
|
sourcesServer.AddReactor("list", "pingsources",
|
||||||
|
func(a clienttesting.Action) (bool, runtime.Object, error) {
|
||||||
|
cJSource := newPingSource("testsource", "mysvc")
|
||||||
|
return true, &v1alpha2.PingSourceList{Items: []v1alpha2.PingSource{*cJSource}}, nil
|
||||||
|
})
|
||||||
|
|
||||||
|
sourceList, err := client.ListPingSource()
|
||||||
|
assert.NilError(t, err)
|
||||||
|
assert.Equal(t, len(sourceList.Items), 1)
|
||||||
|
}
|
||||||
|
|
||||||
|
func newPingSource(name string, sink string) *v1alpha2.PingSource {
|
||||||
|
b := NewPingSourceBuilder(name).
|
||||||
|
Schedule("* * * * *").
|
||||||
|
JsonData("mydata")
|
||||||
|
|
||||||
|
if sink != "" {
|
||||||
|
b.Sink(
|
||||||
|
duckv1.Destination{
|
||||||
|
Ref: &duckv1.KReference{
|
||||||
|
Kind: "Service",
|
||||||
|
Name: sink,
|
||||||
|
Namespace: "default",
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return b.Build()
|
||||||
|
}
|
||||||
|
|
@ -1,64 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
# Copyright 2019 The Knative Authors
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
|
|
||||||
# This script runs the end-to-end tests for the kn client.
|
|
||||||
|
|
||||||
# If you already have the `KO_DOCKER_REPO` environment variable set and a
|
|
||||||
# cluster setup and currently selected in your kubeconfig, call the script
|
|
||||||
# with the `--run-tests` argument and it will use the cluster and run the tests.
|
|
||||||
|
|
||||||
# Calling this script without arguments will create a new cluster in
|
|
||||||
# project $PROJECT_ID, start Knative serving, run the tests and delete
|
|
||||||
# the cluster.
|
|
||||||
|
|
||||||
source $(dirname $0)/e2e-common.sh
|
|
||||||
|
|
||||||
# Will create and delete this namespace and use it for smoke tests
|
|
||||||
export KN_E2E_SMOKE_TESTS_NAMESPACE=kne2esmoketests
|
|
||||||
|
|
||||||
# Script entry point.
|
|
||||||
|
|
||||||
initialize $@
|
|
||||||
|
|
||||||
header "Running smoke tests"
|
|
||||||
|
|
||||||
kubectl create ns $KN_E2E_SMOKE_TESTS_NAMESPACE || fail_test
|
|
||||||
|
|
||||||
sleep 4 # Wait for the namespace to get initialized by kube-controller-manager
|
|
||||||
|
|
||||||
#TODO: deprecated tests remove once --async is gone
|
|
||||||
./kn service create svc1 --async --image gcr.io/knative-samples/helloworld-go -e TARGET=Knative -n $KN_E2E_SMOKE_TESTS_NAMESPACE || fail_test
|
|
||||||
./kn service create svc2 --no-wait --image gcr.io/knative-samples/helloworld-go -e TARGET=Knative -n $KN_E2E_SMOKE_TESTS_NAMESPACE || fail_test
|
|
||||||
./kn service create hello --image gcr.io/knative-samples/helloworld-go -e TARGET=Knative -n $KN_E2E_SMOKE_TESTS_NAMESPACE || fail_test
|
|
||||||
./kn service list hello -n $KN_E2E_SMOKE_TESTS_NAMESPACE || fail_test
|
|
||||||
./kn service update hello --env TARGET=kn -n $KN_E2E_SMOKE_TESTS_NAMESPACE || fail_test
|
|
||||||
./kn revision list hello -n $KN_E2E_SMOKE_TESTS_NAMESPACE || fail_test
|
|
||||||
./kn service list -n $KN_E2E_SMOKE_TESTS_NAMESPACE || fail_test
|
|
||||||
./kn service create hello --force --image gcr.io/knative-samples/helloworld-go -e TARGET=Awesome -n $KN_E2E_SMOKE_TESTS_NAMESPACE || fail_test
|
|
||||||
./kn service create foo --force --image gcr.io/knative-samples/helloworld-go -e TARGET=foo -n $KN_E2E_SMOKE_TESTS_NAMESPACE || fail_test
|
|
||||||
./kn revision list -n $KN_E2E_SMOKE_TESTS_NAMESPACE || fail_test
|
|
||||||
./kn service list -n $KN_E2E_SMOKE_TESTS_NAMESPACE || fail_test
|
|
||||||
./kn service describe hello -n $KN_E2E_SMOKE_TESTS_NAMESPACE || fail_test
|
|
||||||
./kn service describe svc1 -n $KN_E2E_SMOKE_TESTS_NAMESPACE || fail_test
|
|
||||||
./kn route list -n $KN_E2E_SMOKE_TESTS_NAMESPACE || fail_test
|
|
||||||
./kn service delete hello -n $KN_E2E_SMOKE_TESTS_NAMESPACE || fail_test
|
|
||||||
./kn service delete foo -n $KN_E2E_SMOKE_TESTS_NAMESPACE || fail_test
|
|
||||||
./kn service list -n $KN_E2E_SMOKE_TESTS_NAMESPACE | grep -q svc1 || fail_test
|
|
||||||
./kn service delete svc1 -n $KN_E2E_SMOKE_TESTS_NAMESPACE || fail_test
|
|
||||||
./kn source list-types || fail_test
|
|
||||||
kubectl delete ns $KN_E2E_SMOKE_TESTS_NAMESPACE || fail_test
|
|
||||||
|
|
||||||
success
|
|
||||||
|
|
@ -1,29 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
# Copyright 2019 The Knative Authors
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
|
|
||||||
export PATH=$PWD:$PATH
|
|
||||||
|
|
||||||
dir=$(dirname "${BASH_SOURCE[0]}")
|
|
||||||
base=$(cd "$dir/.." && pwd)
|
|
||||||
|
|
||||||
# Will create and delete this namespace (used for all tests, modify if you want a different one used)
|
|
||||||
export KN_E2E_NAMESPACE=kne2etests
|
|
||||||
|
|
||||||
echo "📋 Formatting"
|
|
||||||
go fmt ${base}/test/e2e/...
|
|
||||||
|
|
||||||
echo "🧪 Testing"
|
|
||||||
go test ${base}/test/e2e/ -test.v -tags "e2e ${E2E_TAGS}" "$@"
|
|
||||||
|
|
@ -30,16 +30,66 @@
|
||||||
# installed in the Kubernetes cluster, and all the tests will run against
|
# installed in the Kubernetes cluster, and all the tests will run against
|
||||||
# Knative Serving / Eventing of this specific version.
|
# Knative Serving / Eventing of this specific version.
|
||||||
|
|
||||||
source $(dirname $0)/e2e-common.sh
|
source $(dirname $0)/common.sh
|
||||||
|
|
||||||
# Add local dir to have access to built kn
|
# Add local dir to have access to built kn
|
||||||
export PATH=$PATH:${REPO_ROOT_DIR}
|
export PATH=$PATH:${REPO_ROOT_DIR}
|
||||||
|
|
||||||
# Script entry point.
|
|
||||||
|
|
||||||
initialize $@
|
run() {
|
||||||
|
# Create cluster
|
||||||
|
initialize $@
|
||||||
|
|
||||||
header "Running tests for Knative Serving $KNATIVE_SERVING_VERSION and Eventing $KNATIVE_EVENTING_VERSION"
|
# Smoke test
|
||||||
|
eval smoke_test || fail_test
|
||||||
|
|
||||||
go_test_e2e -timeout=45m ./test/e2e || fail_test
|
# Integration test
|
||||||
success
|
eval integration_test || fail_test
|
||||||
|
|
||||||
|
success
|
||||||
|
}
|
||||||
|
|
||||||
|
integration_test() {
|
||||||
|
header "Running tests for Knative Serving $KNATIVE_SERVING_VERSION and Eventing $KNATIVE_EVENTING_VERSION"
|
||||||
|
|
||||||
|
go_test_e2e -timeout=45m ./test/e2e || fail_test
|
||||||
|
}
|
||||||
|
|
||||||
|
smoke_test() {
|
||||||
|
header "Running smoke tests"
|
||||||
|
|
||||||
|
# Test namespace
|
||||||
|
ns="kne2esmoketests"
|
||||||
|
|
||||||
|
set -x
|
||||||
|
|
||||||
|
kubectl create ns $ns || fail_test
|
||||||
|
trap "kubectl delete ns $ns" EXIT
|
||||||
|
|
||||||
|
sleep 4 # Wait for the namespace to get initialized by kube-controller-manager
|
||||||
|
|
||||||
|
./kn service create svc1 --no-wait --image gcr.io/knative-samples/helloworld-go -e TARGET=Knative -n $ns || fail_test
|
||||||
|
./kn service create svc2 --no-wait --image gcr.io/knative-samples/helloworld-go -e TARGET=Knative -n $ns || fail_test
|
||||||
|
./kn service create hello --image gcr.io/knative-samples/helloworld-go -e TARGET=Knative -n $ns || fail_test
|
||||||
|
./kn service list hello -n $ns || fail_test
|
||||||
|
./kn service update hello --env TARGET=kn -n $ns || fail_test
|
||||||
|
./kn revision list hello -n $ns || fail_test
|
||||||
|
./kn service list -n $ns || fail_test
|
||||||
|
./kn service create hello --force --image gcr.io/knative-samples/helloworld-go -e TARGET=Awesome -n $ns || fail_test
|
||||||
|
./kn service create foo --force --image gcr.io/knative-samples/helloworld-go -e TARGET=foo -n $ns || fail_test
|
||||||
|
./kn revision list -n $ns || fail_test
|
||||||
|
./kn service list -n $ns || fail_test
|
||||||
|
./kn service describe hello -n $ns || fail_test
|
||||||
|
./kn service describe svc1 -n $ns || fail_test
|
||||||
|
./kn route list -n $ns || fail_test
|
||||||
|
./kn service delete hello -n $ns || fail_test
|
||||||
|
./kn service delete foo -n $ns || fail_test
|
||||||
|
./kn service list -n $ns | grep -q svc1 || fail_test
|
||||||
|
./kn service delete svc1 -n $ns || fail_test
|
||||||
|
./kn source list-types || fail_test
|
||||||
|
|
||||||
|
set +x
|
||||||
|
}
|
||||||
|
|
||||||
|
# Fire up
|
||||||
|
run $@
|
||||||
|
|
@ -174,6 +174,10 @@ func RunKn(namespace string, args []string) KnRunResult {
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
command := args[0]
|
command := args[0]
|
||||||
|
if command == "source" && len(args) > 1 {
|
||||||
|
command = "source " + args[1]
|
||||||
|
args = args[1:]
|
||||||
|
}
|
||||||
result.DumpInfo = extractDumpInfo(command, args, namespace)
|
result.DumpInfo = extractDumpInfo(command, args, namespace)
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
|
|
@ -209,11 +213,11 @@ type dumpFunc func(namespace string, args []string) string
|
||||||
// Dump handler for specific commands ("service", "revision") which should add extra infos
|
// Dump handler for specific commands ("service", "revision") which should add extra infos
|
||||||
// Relies on that argv[1] is the command and argv[3] is the name of the object
|
// Relies on that argv[1] is the command and argv[3] is the name of the object
|
||||||
var dumpHandlers = map[string]dumpFunc{
|
var dumpHandlers = map[string]dumpFunc{
|
||||||
"service": dumpService,
|
"service": dumpService,
|
||||||
"revision": dumpRevision,
|
"revision": dumpRevision,
|
||||||
"route": dumpRoute,
|
"route": dumpRoute,
|
||||||
"trigger": dumpTrigger,
|
"trigger": dumpTrigger,
|
||||||
// TODO: "source",
|
"source apiserver": dumpApiServerSource,
|
||||||
}
|
}
|
||||||
|
|
||||||
func extractDumpInfoWithName(command string, name string, namespace string) string {
|
func extractDumpInfoWithName(command string, name string, namespace string) string {
|
||||||
|
|
@ -257,6 +261,10 @@ func dumpRoute(namespace string, args []string) string {
|
||||||
return simpleDump("route", args, namespace)
|
return simpleDump("route", args, namespace)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func dumpApiServerSource(namespace string, args []string) string {
|
||||||
|
return simpleDump("apiserversource", args, namespace)
|
||||||
|
}
|
||||||
|
|
||||||
func dumpTrigger(namespace string, args []string) string {
|
func dumpTrigger(namespace string, args []string) string {
|
||||||
return simpleDump("trigger", args, namespace)
|
return simpleDump("trigger", args, namespace)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,114 +0,0 @@
|
||||||
// Copyright 2019 The Knative Authors
|
|
||||||
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or im
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
// +build e2e
|
|
||||||
// +build !serving
|
|
||||||
|
|
||||||
package e2e
|
|
||||||
|
|
||||||
import (
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"gotest.tools/assert"
|
|
||||||
|
|
||||||
"knative.dev/client/pkg/util"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestSourceCronJob(t *testing.T) {
|
|
||||||
t.Parallel()
|
|
||||||
test, err := NewE2eTest()
|
|
||||||
assert.NilError(t, err)
|
|
||||||
defer func() {
|
|
||||||
assert.NilError(t, test.Teardown())
|
|
||||||
}()
|
|
||||||
|
|
||||||
r := NewKnRunResultCollector(t)
|
|
||||||
defer r.DumpIfFailed()
|
|
||||||
|
|
||||||
t.Log("Creating a testservice")
|
|
||||||
test.serviceCreate(t, r, "testsvc0")
|
|
||||||
|
|
||||||
t.Log("create cronJob sources with a sink to a service")
|
|
||||||
|
|
||||||
test.cronJobSourceCreate(t, r, "testcronjobsource0", "* * * * */1", "ping", "svc:testsvc0")
|
|
||||||
|
|
||||||
t.Log("delete cronJob sources")
|
|
||||||
test.cronJobSourceDelete(t, r, "testcronjobsource0")
|
|
||||||
|
|
||||||
t.Log("create cronJob source with a missing sink service")
|
|
||||||
test.cronJobSourceCreateMissingSink(t, r, "testcronjobsource1", "* * * * */1", "ping", "svc:unknown")
|
|
||||||
|
|
||||||
t.Log("update cronJob source sink service")
|
|
||||||
test.cronJobSourceCreate(t, r, "testcronjobsource2", "* * * * */1", "ping", "svc:testsvc0")
|
|
||||||
test.serviceCreate(t, r, "testsvc1")
|
|
||||||
test.cronJobSourceUpdateSink(t, r, "testcronjobsource2", "svc:testsvc1")
|
|
||||||
jpSinkRefNameInSpec := "jsonpath={.spec.sink.ref.name}"
|
|
||||||
out, err := test.getResourceFieldsWithJSONPath("cronjobsource", "testcronjobsource2", jpSinkRefNameInSpec)
|
|
||||||
assert.NilError(t, err)
|
|
||||||
assert.Equal(t, out, "testsvc1")
|
|
||||||
|
|
||||||
t.Log("create cronJob source with service account and resources")
|
|
||||||
test.cronJobSourceCreateWithResources(t, r, "testcronjobsource3", "* * * * */1", "ping", "svc:testsvc0", "default", "100m", "128Mi", "200m", "256Mi")
|
|
||||||
test.verifyCronJobSourceDescribe(t, r, "testcronjobsource3", "* * * * */1", "ping", "testsvc0", "default", "100m", "128Mi", "200m", "256Mi")
|
|
||||||
test.cronJobSourceUpdateResources(t, r, "testcronjobsource3", "101m", "129Mi", "201m", "257Mi")
|
|
||||||
test.verifyCronJobSourceDescribe(t, r, "testcronjobsource3", "* * * * */1", "ping", "testsvc0", "default", "101m", "129Mi", "201m", "257Mi")
|
|
||||||
}
|
|
||||||
|
|
||||||
func (test *e2eTest) cronJobSourceCreate(t *testing.T, r *KnRunResultCollector, sourceName string, schedule string, data string, sink string) {
|
|
||||||
out := test.kn.Run("source", "cronjob", "create", sourceName,
|
|
||||||
"--schedule", schedule, "--data", data, "--sink", sink)
|
|
||||||
assert.Check(t, util.ContainsAllIgnoreCase(out.Stdout, "cronjob", "source", sourceName, "created", "namespace", test.kn.namespace))
|
|
||||||
r.AssertNoError(out)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (test *e2eTest) cronJobSourceDelete(t *testing.T, r *KnRunResultCollector, sourceName string) {
|
|
||||||
out := test.kn.Run("source", "cronjob", "delete", sourceName)
|
|
||||||
assert.Check(t, util.ContainsAllIgnoreCase(out.Stdout, "cronjob", "source", sourceName, "deleted", "namespace", test.kn.namespace))
|
|
||||||
r.AssertNoError(out)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func (test *e2eTest) cronJobSourceCreateMissingSink(t *testing.T, r *KnRunResultCollector, sourceName string, schedule string, data string, sink string) {
|
|
||||||
out := test.kn.Run("source", "cronjob", "create", sourceName,
|
|
||||||
"--schedule", schedule, "--data", data, "--sink", sink)
|
|
||||||
assert.Check(t, util.ContainsAll(out.Stderr, "services.serving.knative.dev", "not found"))
|
|
||||||
r.AssertError(out)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (test *e2eTest) cronJobSourceUpdateSink(t *testing.T, r *KnRunResultCollector, sourceName string, sink string) {
|
|
||||||
out := test.kn.Run("source", "cronjob", "update", sourceName, "--sink", sink)
|
|
||||||
assert.Check(t, util.ContainsAll(out.Stdout, sourceName, "updated", "namespace", test.kn.namespace))
|
|
||||||
r.AssertNoError(out)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (test *e2eTest) cronJobSourceCreateWithResources(t *testing.T, r *KnRunResultCollector, sourceName string, schedule string, data string, sink string, sa string, requestcpu string, requestmm string, limitcpu string, limitmm string) {
|
|
||||||
out := test.kn.Run("source", "cronjob", "create", sourceName,
|
|
||||||
"--schedule", schedule, "--data", data, "--sink", sink, "--service-account", sa,
|
|
||||||
"--requests-cpu", requestcpu, "--requests-memory", requestmm, "--limits-cpu", limitcpu, "--limits-memory", limitmm)
|
|
||||||
assert.Check(t, util.ContainsAllIgnoreCase(out.Stdout, "cronjob", "source", sourceName, "created", "namespace", test.kn.namespace))
|
|
||||||
r.AssertNoError(out)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (test *e2eTest) cronJobSourceUpdateResources(t *testing.T, r *KnRunResultCollector, sourceName string, requestcpu string, requestmm string, limitcpu string, limitmm string) {
|
|
||||||
out := test.kn.Run("source", "cronjob", "update", sourceName,
|
|
||||||
"--requests-cpu", requestcpu, "--requests-memory", requestmm, "--limits-cpu", limitcpu, "--limits-memory", limitmm)
|
|
||||||
assert.Check(t, util.ContainsAllIgnoreCase(out.Stdout, sourceName, "updated", "namespace", test.kn.namespace))
|
|
||||||
r.AssertNoError(out)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (test *e2eTest) verifyCronJobSourceDescribe(t *testing.T, r *KnRunResultCollector, sourceName string, schedule string, data string, sink string, sa string, requestcpu string, requestmm string, limitcpu string, limitmm string) {
|
|
||||||
out := test.kn.Run("source", "cronjob", "describe", sourceName)
|
|
||||||
assert.Check(t, util.ContainsAllIgnoreCase(out.Stdout, sourceName, schedule, data, sink, sa, requestcpu, requestmm, limitcpu, limitmm))
|
|
||||||
r.AssertNoError(out)
|
|
||||||
}
|
|
||||||
|
|
@ -0,0 +1,108 @@
|
||||||
|
// Copyright 2019 The Knative Authors
|
||||||
|
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or im
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
// +build e2e
|
||||||
|
// +build !serving
|
||||||
|
|
||||||
|
package e2e
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"gotest.tools/assert"
|
||||||
|
|
||||||
|
"knative.dev/client/pkg/util"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestSourcePing(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
test, err := NewE2eTest()
|
||||||
|
assert.NilError(t, err)
|
||||||
|
defer func() {
|
||||||
|
assert.NilError(t, test.Teardown())
|
||||||
|
}()
|
||||||
|
|
||||||
|
r := NewKnRunResultCollector(t)
|
||||||
|
defer r.DumpIfFailed()
|
||||||
|
|
||||||
|
t.Log("Creating a testservice")
|
||||||
|
test.serviceCreate(t, r, "testsvc0")
|
||||||
|
|
||||||
|
t.Log("create Ping sources with a sink to a service")
|
||||||
|
|
||||||
|
test.pingSourceCreate(t, r, "testpingsource0", "* * * * */1", "ping", "svc:testsvc0")
|
||||||
|
|
||||||
|
t.Log("delete Ping sources")
|
||||||
|
test.pingSourceDelete(t, r, "testpingsource0")
|
||||||
|
|
||||||
|
t.Log("create Ping source with a missing sink service")
|
||||||
|
test.pingSourceCreateMissingSink(t, r, "testpingsource1", "* * * * */1", "ping", "svc:unknown")
|
||||||
|
|
||||||
|
t.Log("update Ping source sink service")
|
||||||
|
test.pingSourceCreate(t, r, "testpingsource2", "* * * * */1", "ping", "svc:testsvc0")
|
||||||
|
test.serviceCreate(t, r, "testsvc1")
|
||||||
|
test.pingSourceUpdateSink(t, r, "testpingsource2", "svc:testsvc1")
|
||||||
|
jpSinkRefNameInSpec := "jsonpath={.spec.sink.ref.name}"
|
||||||
|
out, err := test.getResourceFieldsWithJSONPath("pingsource", "testpingsource2", jpSinkRefNameInSpec)
|
||||||
|
assert.NilError(t, err)
|
||||||
|
assert.Equal(t, out, "testsvc1")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (test *e2eTest) pingSourceCreate(t *testing.T, r *KnRunResultCollector, sourceName string, schedule string, data string, sink string) {
|
||||||
|
out := test.kn.Run("source", "ping", "create", sourceName,
|
||||||
|
"--schedule", schedule, "--data", data, "--sink", sink)
|
||||||
|
assert.Check(t, util.ContainsAllIgnoreCase(out.Stdout, "ping", "source", sourceName, "created", "namespace", test.kn.namespace))
|
||||||
|
r.AssertNoError(out)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (test *e2eTest) pingSourceDelete(t *testing.T, r *KnRunResultCollector, sourceName string) {
|
||||||
|
out := test.kn.Run("source", "ping", "delete", sourceName)
|
||||||
|
assert.Check(t, util.ContainsAllIgnoreCase(out.Stdout, "ping", "source", sourceName, "deleted", "namespace", test.kn.namespace))
|
||||||
|
r.AssertNoError(out)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func (test *e2eTest) pingSourceCreateMissingSink(t *testing.T, r *KnRunResultCollector, sourceName string, schedule string, data string, sink string) {
|
||||||
|
out := test.kn.Run("source", "ping", "create", sourceName,
|
||||||
|
"--schedule", schedule, "--data", data, "--sink", sink)
|
||||||
|
assert.Check(t, util.ContainsAll(out.Stderr, "services.serving.knative.dev", "not found"))
|
||||||
|
r.AssertError(out)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (test *e2eTest) pingSourceUpdateSink(t *testing.T, r *KnRunResultCollector, sourceName string, sink string) {
|
||||||
|
out := test.kn.Run("source", "ping", "update", sourceName, "--sink", sink)
|
||||||
|
assert.Check(t, util.ContainsAll(out.Stdout, sourceName, "updated", "namespace", test.kn.namespace))
|
||||||
|
r.AssertNoError(out)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (test *e2eTest) pingSourceCreateWithResources(t *testing.T, r *KnRunResultCollector, sourceName string, schedule string, data string, sink string, sa string, requestcpu string, requestmm string, limitcpu string, limitmm string) {
|
||||||
|
out := test.kn.Run("source", "ping", "create", sourceName,
|
||||||
|
"--schedule", schedule, "--data", data, "--sink", sink, "--service-account", sa,
|
||||||
|
"--requests-cpu", requestcpu, "--requests-memory", requestmm, "--limits-cpu", limitcpu, "--limits-memory", limitmm)
|
||||||
|
assert.Check(t, util.ContainsAllIgnoreCase(out.Stdout, "ping", "source", sourceName, "created", "namespace", test.kn.namespace))
|
||||||
|
r.AssertNoError(out)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (test *e2eTest) pingSourceUpdateResources(t *testing.T, r *KnRunResultCollector, sourceName string, requestcpu string, requestmm string, limitcpu string, limitmm string) {
|
||||||
|
out := test.kn.Run("source", "ping", "update", sourceName,
|
||||||
|
"--requests-cpu", requestcpu, "--requests-memory", requestmm, "--limits-cpu", limitcpu, "--limits-memory", limitmm)
|
||||||
|
assert.Check(t, util.ContainsAllIgnoreCase(out.Stdout, sourceName, "updated", "namespace", test.kn.namespace))
|
||||||
|
r.AssertNoError(out)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (test *e2eTest) verifyPingSourceDescribe(t *testing.T, r *KnRunResultCollector, sourceName string, schedule string, data string, sink string, sa string, requestcpu string, requestmm string, limitcpu string, limitmm string) {
|
||||||
|
out := test.kn.Run("source", "ping", "describe", sourceName)
|
||||||
|
assert.Check(t, util.ContainsAllIgnoreCase(out.Stdout, sourceName, schedule, data, sink, sa, requestcpu, requestmm, limitcpu, limitmm))
|
||||||
|
r.AssertNoError(out)
|
||||||
|
}
|
||||||
|
|
@ -72,21 +72,21 @@ func TestSinkPrefixConfig(t *testing.T) {
|
||||||
|
|
||||||
t.Log("Creating a testservice")
|
t.Log("Creating a testservice")
|
||||||
test.serviceCreate(t, r, "testsvc0")
|
test.serviceCreate(t, r, "testsvc0")
|
||||||
t.Log("create cronJob sources with a sink to hello:testsvc0")
|
t.Log("create Ping sources with a sink to hello:testsvc0")
|
||||||
test.cronJobSourceCreateWithConfig(t, r, "testcronjobsource0", "* * * * */1", "ping", "hello:testsvc0", tc.knConfigPath)
|
test.pingSourceCreateWithConfig(t, r, "testpingsource0", "* * * * */1", "ping", "hello:testsvc0", tc.knConfigPath)
|
||||||
|
|
||||||
jpSinkRefNameInSpec := "jsonpath={.spec.sink.ref.name}"
|
jpSinkRefNameInSpec := "jsonpath={.spec.sink.ref.name}"
|
||||||
out, err := test.getResourceFieldsWithJSONPath("cronjobsource", "testcronjobsource0", jpSinkRefNameInSpec)
|
out, err := test.getResourceFieldsWithJSONPath("pingsource", "testpingsource0", jpSinkRefNameInSpec)
|
||||||
assert.NilError(t, err)
|
assert.NilError(t, err)
|
||||||
assert.Equal(t, out, "testsvc0")
|
assert.Equal(t, out, "testsvc0")
|
||||||
|
|
||||||
t.Log("delete cronJob sources")
|
t.Log("delete Ping sources")
|
||||||
test.cronJobSourceDelete(t, r, "testcronjobsource0")
|
test.pingSourceDelete(t, r, "testpingsource0")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (test *e2eTest) cronJobSourceCreateWithConfig(t *testing.T, r *KnRunResultCollector, sourceName string, schedule string, data string, sink string, config string) {
|
func (test *e2eTest) pingSourceCreateWithConfig(t *testing.T, r *KnRunResultCollector, sourceName string, schedule string, data string, sink string, config string) {
|
||||||
out := test.kn.Run("source", "cronjob", "create", sourceName,
|
out := test.kn.Run("source", "ping", "create", sourceName,
|
||||||
"--schedule", schedule, "--data", data, "--sink", sink, "--config", config)
|
"--schedule", schedule, "--data", data, "--sink", sink, "--config", config)
|
||||||
assert.Check(t, util.ContainsAllIgnoreCase(out.Stdout, "cronjob", "source", sourceName, "created", "namespace", test.kn.namespace))
|
assert.Check(t, util.ContainsAllIgnoreCase(out.Stdout, "ping", "source", sourceName, "created", "namespace", test.kn.namespace))
|
||||||
r.AssertNoError(out)
|
r.AssertNoError(out)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,7 @@ func TestSourceApiServer(t *testing.T) {
|
||||||
test.serviceCreate(t, r, "testsvc1")
|
test.serviceCreate(t, r, "testsvc1")
|
||||||
test.apiServerSourceUpdateSink(t, r, "testapisource3", "svc:testsvc1")
|
test.apiServerSourceUpdateSink(t, r, "testapisource3", "svc:testsvc1")
|
||||||
jpSinkRefNameInSpec := "jsonpath={.spec.sink.ref.name}"
|
jpSinkRefNameInSpec := "jsonpath={.spec.sink.ref.name}"
|
||||||
out, err := test.getResourceFieldsWithJSONPath("apiserversource", "testapisource3", jpSinkRefNameInSpec)
|
out, err := test.getResourceFieldsWithJSONPath("apiserversource.sources.knative.dev", "testapisource3", jpSinkRefNameInSpec)
|
||||||
assert.NilError(t, err)
|
assert.NilError(t, err)
|
||||||
assert.Equal(t, out, "testsvc1")
|
assert.Equal(t, out, "testsvc1")
|
||||||
// TODO(navidshaikh): Verify the source's status with synchronous create/update
|
// TODO(navidshaikh): Verify the source's status with synchronous create/update
|
||||||
|
|
|
||||||
|
|
@ -37,12 +37,12 @@ func TestSourceListTypes(t *testing.T) {
|
||||||
|
|
||||||
t.Log("List available source types")
|
t.Log("List available source types")
|
||||||
output := test.sourceListTypes(t, r)
|
output := test.sourceListTypes(t, r)
|
||||||
assert.Check(t, util.ContainsAll(output, "TYPE", "NAME", "DESCRIPTION", "CronJob", "ApiServer"))
|
assert.Check(t, util.ContainsAll(output, "TYPE", "NAME", "DESCRIPTION", "Ping", "ApiServer"))
|
||||||
|
|
||||||
t.Log("List available source types in YAML format")
|
t.Log("List available source types in YAML format")
|
||||||
|
|
||||||
output = test.sourceListTypes(t, r, "-oyaml")
|
output = test.sourceListTypes(t, r, "-oyaml")
|
||||||
assert.Check(t, util.ContainsAll(output, "apiextensions.k8s.io/v1beta1", "CustomResourceDefinition", "CronJob", "ApiServer"))
|
assert.Check(t, util.ContainsAll(output, "apiextensions.k8s.io/v1beta1", "CustomResourceDefinition", "Ping", "ApiServer"))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (test *e2eTest) sourceListTypes(t *testing.T, r *KnRunResultCollector, args ...string) string {
|
func (test *e2eTest) sourceListTypes(t *testing.T, r *KnRunResultCollector, args ...string) string {
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ func TestBrokerTrigger(t *testing.T) {
|
||||||
|
|
||||||
t.Log("create triggers and list them")
|
t.Log("create triggers and list them")
|
||||||
test.triggerCreate(t, r, "trigger1", "sinksvc0", []string{"a=b"})
|
test.triggerCreate(t, r, "trigger1", "sinksvc0", []string{"a=b"})
|
||||||
test.triggerCreate(t, r, "trigger2", "sinksvc1", []string{"type=knative.dev.bar", "source=cronjob"})
|
test.triggerCreate(t, r, "trigger2", "sinksvc1", []string{"type=knative.dev.bar", "source=ping"})
|
||||||
test.verifyTriggerList(t, r, "trigger1", "trigger2")
|
test.verifyTriggerList(t, r, "trigger1", "trigger2")
|
||||||
test.triggerDelete(t, r, "trigger1")
|
test.triggerDelete(t, r, "trigger1")
|
||||||
test.triggerDelete(t, r, "trigger2")
|
test.triggerDelete(t, r, "trigger2")
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
# This script is used in Knative/test-infra as a custom prow job to run the
|
# This script is used in Knative/test-infra as a custom prow job to run the
|
||||||
# integration tests against Knative Serving / Eventing of a specific version.
|
# integration tests against Knative Serving / Eventing of a specific version.
|
||||||
|
|
||||||
export KNATIVE_SERVING_VERSION="0.12.0"
|
export KNATIVE_SERVING_VERSION="0.13.0"
|
||||||
export KNATIVE_EVENTING_VERSION="0.12.0"
|
export KNATIVE_EVENTING_VERSION="0.13.1"
|
||||||
|
|
||||||
$(dirname $0)/presubmit-tests.sh --integration-tests
|
$(dirname $0)/presubmit-tests.sh --integration-tests
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
# and container registry, you must set the $CONTAINER_REGISTRY and $DOCKER_CONFIG_JSON
|
# and container registry, you must set the $CONTAINER_REGISTRY and $DOCKER_CONFIG_JSON
|
||||||
# environment variables and login to your registry of choice.
|
# environment variables and login to your registry of choice.
|
||||||
|
|
||||||
source $(dirname $0)/e2e-common.sh
|
source $(dirname $0)/common.sh
|
||||||
|
|
||||||
# Add local dir to have access to built kn
|
# Add local dir to have access to built kn
|
||||||
export PATH=$PATH:${REPO_ROOT_DIR}
|
export PATH=$PATH:${REPO_ROOT_DIR}
|
||||||
|
|
|
||||||
|
|
@ -1,676 +0,0 @@
|
||||||
// Copyright 2018 Google LLC
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// https://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
// AUTO-GENERATED CODE. DO NOT EDIT.
|
|
||||||
|
|
||||||
package container
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"cloud.google.com/go/internal/version"
|
|
||||||
gax "github.com/googleapis/gax-go/v2"
|
|
||||||
"google.golang.org/api/option"
|
|
||||||
"google.golang.org/api/transport"
|
|
||||||
containerpb "google.golang.org/genproto/googleapis/container/v1"
|
|
||||||
"google.golang.org/grpc"
|
|
||||||
"google.golang.org/grpc/codes"
|
|
||||||
"google.golang.org/grpc/metadata"
|
|
||||||
)
|
|
||||||
|
|
||||||
// ClusterManagerCallOptions contains the retry settings for each method of ClusterManagerClient.
|
|
||||||
type ClusterManagerCallOptions struct {
|
|
||||||
ListClusters []gax.CallOption
|
|
||||||
GetCluster []gax.CallOption
|
|
||||||
CreateCluster []gax.CallOption
|
|
||||||
UpdateCluster []gax.CallOption
|
|
||||||
UpdateNodePool []gax.CallOption
|
|
||||||
SetNodePoolAutoscaling []gax.CallOption
|
|
||||||
SetLoggingService []gax.CallOption
|
|
||||||
SetMonitoringService []gax.CallOption
|
|
||||||
SetAddonsConfig []gax.CallOption
|
|
||||||
SetLocations []gax.CallOption
|
|
||||||
UpdateMaster []gax.CallOption
|
|
||||||
SetMasterAuth []gax.CallOption
|
|
||||||
DeleteCluster []gax.CallOption
|
|
||||||
ListOperations []gax.CallOption
|
|
||||||
GetOperation []gax.CallOption
|
|
||||||
CancelOperation []gax.CallOption
|
|
||||||
GetServerConfig []gax.CallOption
|
|
||||||
ListNodePools []gax.CallOption
|
|
||||||
GetNodePool []gax.CallOption
|
|
||||||
CreateNodePool []gax.CallOption
|
|
||||||
DeleteNodePool []gax.CallOption
|
|
||||||
RollbackNodePoolUpgrade []gax.CallOption
|
|
||||||
SetNodePoolManagement []gax.CallOption
|
|
||||||
SetLabels []gax.CallOption
|
|
||||||
SetLegacyAbac []gax.CallOption
|
|
||||||
StartIPRotation []gax.CallOption
|
|
||||||
CompleteIPRotation []gax.CallOption
|
|
||||||
SetNodePoolSize []gax.CallOption
|
|
||||||
SetNetworkPolicy []gax.CallOption
|
|
||||||
SetMaintenancePolicy []gax.CallOption
|
|
||||||
}
|
|
||||||
|
|
||||||
func defaultClusterManagerClientOptions() []option.ClientOption {
|
|
||||||
return []option.ClientOption{
|
|
||||||
option.WithEndpoint("container.googleapis.com:443"),
|
|
||||||
option.WithScopes(DefaultAuthScopes()...),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func defaultClusterManagerCallOptions() *ClusterManagerCallOptions {
|
|
||||||
retry := map[[2]string][]gax.CallOption{
|
|
||||||
{"default", "idempotent"}: {
|
|
||||||
gax.WithRetry(func() gax.Retryer {
|
|
||||||
return gax.OnCodes([]codes.Code{
|
|
||||||
codes.DeadlineExceeded,
|
|
||||||
codes.Unavailable,
|
|
||||||
}, gax.Backoff{
|
|
||||||
Initial: 100 * time.Millisecond,
|
|
||||||
Max: 60000 * time.Millisecond,
|
|
||||||
Multiplier: 1.3,
|
|
||||||
})
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
}
|
|
||||||
return &ClusterManagerCallOptions{
|
|
||||||
ListClusters: retry[[2]string{"default", "idempotent"}],
|
|
||||||
GetCluster: retry[[2]string{"default", "idempotent"}],
|
|
||||||
CreateCluster: retry[[2]string{"default", "non_idempotent"}],
|
|
||||||
UpdateCluster: retry[[2]string{"default", "non_idempotent"}],
|
|
||||||
UpdateNodePool: retry[[2]string{"default", "non_idempotent"}],
|
|
||||||
SetNodePoolAutoscaling: retry[[2]string{"default", "non_idempotent"}],
|
|
||||||
SetLoggingService: retry[[2]string{"default", "non_idempotent"}],
|
|
||||||
SetMonitoringService: retry[[2]string{"default", "non_idempotent"}],
|
|
||||||
SetAddonsConfig: retry[[2]string{"default", "non_idempotent"}],
|
|
||||||
SetLocations: retry[[2]string{"default", "non_idempotent"}],
|
|
||||||
UpdateMaster: retry[[2]string{"default", "non_idempotent"}],
|
|
||||||
SetMasterAuth: retry[[2]string{"default", "non_idempotent"}],
|
|
||||||
DeleteCluster: retry[[2]string{"default", "idempotent"}],
|
|
||||||
ListOperations: retry[[2]string{"default", "idempotent"}],
|
|
||||||
GetOperation: retry[[2]string{"default", "idempotent"}],
|
|
||||||
CancelOperation: retry[[2]string{"default", "non_idempotent"}],
|
|
||||||
GetServerConfig: retry[[2]string{"default", "idempotent"}],
|
|
||||||
ListNodePools: retry[[2]string{"default", "idempotent"}],
|
|
||||||
GetNodePool: retry[[2]string{"default", "idempotent"}],
|
|
||||||
CreateNodePool: retry[[2]string{"default", "non_idempotent"}],
|
|
||||||
DeleteNodePool: retry[[2]string{"default", "idempotent"}],
|
|
||||||
RollbackNodePoolUpgrade: retry[[2]string{"default", "non_idempotent"}],
|
|
||||||
SetNodePoolManagement: retry[[2]string{"default", "non_idempotent"}],
|
|
||||||
SetLabels: retry[[2]string{"default", "non_idempotent"}],
|
|
||||||
SetLegacyAbac: retry[[2]string{"default", "non_idempotent"}],
|
|
||||||
StartIPRotation: retry[[2]string{"default", "non_idempotent"}],
|
|
||||||
CompleteIPRotation: retry[[2]string{"default", "non_idempotent"}],
|
|
||||||
SetNodePoolSize: retry[[2]string{"default", "non_idempotent"}],
|
|
||||||
SetNetworkPolicy: retry[[2]string{"default", "non_idempotent"}],
|
|
||||||
SetMaintenancePolicy: retry[[2]string{"default", "non_idempotent"}],
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ClusterManagerClient is a client for interacting with Google Container Engine API.
|
|
||||||
//
|
|
||||||
// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
|
|
||||||
type ClusterManagerClient struct {
|
|
||||||
// The connection to the service.
|
|
||||||
conn *grpc.ClientConn
|
|
||||||
|
|
||||||
// The gRPC API client.
|
|
||||||
clusterManagerClient containerpb.ClusterManagerClient
|
|
||||||
|
|
||||||
// The call options for this service.
|
|
||||||
CallOptions *ClusterManagerCallOptions
|
|
||||||
|
|
||||||
// The x-goog-* metadata to be sent with each request.
|
|
||||||
xGoogMetadata metadata.MD
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewClusterManagerClient creates a new cluster manager client.
|
|
||||||
//
|
|
||||||
// Google Container Engine Cluster Manager v1
|
|
||||||
func NewClusterManagerClient(ctx context.Context, opts ...option.ClientOption) (*ClusterManagerClient, error) {
|
|
||||||
conn, err := transport.DialGRPC(ctx, append(defaultClusterManagerClientOptions(), opts...)...)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
c := &ClusterManagerClient{
|
|
||||||
conn: conn,
|
|
||||||
CallOptions: defaultClusterManagerCallOptions(),
|
|
||||||
|
|
||||||
clusterManagerClient: containerpb.NewClusterManagerClient(conn),
|
|
||||||
}
|
|
||||||
c.setGoogleClientInfo()
|
|
||||||
return c, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Connection returns the client's connection to the API service.
|
|
||||||
func (c *ClusterManagerClient) Connection() *grpc.ClientConn {
|
|
||||||
return c.conn
|
|
||||||
}
|
|
||||||
|
|
||||||
// Close closes the connection to the API service. The user should invoke this when
|
|
||||||
// the client is no longer required.
|
|
||||||
func (c *ClusterManagerClient) Close() error {
|
|
||||||
return c.conn.Close()
|
|
||||||
}
|
|
||||||
|
|
||||||
// setGoogleClientInfo sets the name and version of the application in
|
|
||||||
// the `x-goog-api-client` header passed on each request. Intended for
|
|
||||||
// use by Google-written clients.
|
|
||||||
func (c *ClusterManagerClient) setGoogleClientInfo(keyval ...string) {
|
|
||||||
kv := append([]string{"gl-go", version.Go()}, keyval...)
|
|
||||||
kv = append(kv, "gapic", version.Repo, "gax", gax.Version, "grpc", grpc.Version)
|
|
||||||
c.xGoogMetadata = metadata.Pairs("x-goog-api-client", gax.XGoogHeader(kv...))
|
|
||||||
}
|
|
||||||
|
|
||||||
// ListClusters lists all clusters owned by a project in either the specified zone or all
|
|
||||||
// zones.
|
|
||||||
func (c *ClusterManagerClient) ListClusters(ctx context.Context, req *containerpb.ListClustersRequest, opts ...gax.CallOption) (*containerpb.ListClustersResponse, error) {
|
|
||||||
ctx = insertMetadata(ctx, c.xGoogMetadata)
|
|
||||||
opts = append(c.CallOptions.ListClusters[0:len(c.CallOptions.ListClusters):len(c.CallOptions.ListClusters)], opts...)
|
|
||||||
var resp *containerpb.ListClustersResponse
|
|
||||||
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
|
|
||||||
var err error
|
|
||||||
resp, err = c.clusterManagerClient.ListClusters(ctx, req, settings.GRPC...)
|
|
||||||
return err
|
|
||||||
}, opts...)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return resp, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetCluster gets the details of a specific cluster.
|
|
||||||
func (c *ClusterManagerClient) GetCluster(ctx context.Context, req *containerpb.GetClusterRequest, opts ...gax.CallOption) (*containerpb.Cluster, error) {
|
|
||||||
ctx = insertMetadata(ctx, c.xGoogMetadata)
|
|
||||||
opts = append(c.CallOptions.GetCluster[0:len(c.CallOptions.GetCluster):len(c.CallOptions.GetCluster)], opts...)
|
|
||||||
var resp *containerpb.Cluster
|
|
||||||
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
|
|
||||||
var err error
|
|
||||||
resp, err = c.clusterManagerClient.GetCluster(ctx, req, settings.GRPC...)
|
|
||||||
return err
|
|
||||||
}, opts...)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return resp, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// CreateCluster creates a cluster, consisting of the specified number and type of Google
|
|
||||||
// Compute Engine instances.
|
|
||||||
//
|
|
||||||
// By default, the cluster is created in the project's
|
|
||||||
// default network (at /compute/docs/networks-and-firewalls#networks).
|
|
||||||
//
|
|
||||||
// One firewall is added for the cluster. After cluster creation,
|
|
||||||
// the cluster creates routes for each node to allow the containers
|
|
||||||
// on that node to communicate with all other instances in the
|
|
||||||
// cluster.
|
|
||||||
//
|
|
||||||
// Finally, an entry is added to the project's global metadata indicating
|
|
||||||
// which CIDR range is being used by the cluster.
|
|
||||||
func (c *ClusterManagerClient) CreateCluster(ctx context.Context, req *containerpb.CreateClusterRequest, opts ...gax.CallOption) (*containerpb.Operation, error) {
|
|
||||||
ctx = insertMetadata(ctx, c.xGoogMetadata)
|
|
||||||
opts = append(c.CallOptions.CreateCluster[0:len(c.CallOptions.CreateCluster):len(c.CallOptions.CreateCluster)], opts...)
|
|
||||||
var resp *containerpb.Operation
|
|
||||||
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
|
|
||||||
var err error
|
|
||||||
resp, err = c.clusterManagerClient.CreateCluster(ctx, req, settings.GRPC...)
|
|
||||||
return err
|
|
||||||
}, opts...)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return resp, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// UpdateCluster updates the settings of a specific cluster.
|
|
||||||
func (c *ClusterManagerClient) UpdateCluster(ctx context.Context, req *containerpb.UpdateClusterRequest, opts ...gax.CallOption) (*containerpb.Operation, error) {
|
|
||||||
ctx = insertMetadata(ctx, c.xGoogMetadata)
|
|
||||||
opts = append(c.CallOptions.UpdateCluster[0:len(c.CallOptions.UpdateCluster):len(c.CallOptions.UpdateCluster)], opts...)
|
|
||||||
var resp *containerpb.Operation
|
|
||||||
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
|
|
||||||
var err error
|
|
||||||
resp, err = c.clusterManagerClient.UpdateCluster(ctx, req, settings.GRPC...)
|
|
||||||
return err
|
|
||||||
}, opts...)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return resp, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// UpdateNodePool updates the version and/or image type of a specific node pool.
|
|
||||||
func (c *ClusterManagerClient) UpdateNodePool(ctx context.Context, req *containerpb.UpdateNodePoolRequest, opts ...gax.CallOption) (*containerpb.Operation, error) {
|
|
||||||
ctx = insertMetadata(ctx, c.xGoogMetadata)
|
|
||||||
opts = append(c.CallOptions.UpdateNodePool[0:len(c.CallOptions.UpdateNodePool):len(c.CallOptions.UpdateNodePool)], opts...)
|
|
||||||
var resp *containerpb.Operation
|
|
||||||
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
|
|
||||||
var err error
|
|
||||||
resp, err = c.clusterManagerClient.UpdateNodePool(ctx, req, settings.GRPC...)
|
|
||||||
return err
|
|
||||||
}, opts...)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return resp, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetNodePoolAutoscaling sets the autoscaling settings of a specific node pool.
|
|
||||||
func (c *ClusterManagerClient) SetNodePoolAutoscaling(ctx context.Context, req *containerpb.SetNodePoolAutoscalingRequest, opts ...gax.CallOption) (*containerpb.Operation, error) {
|
|
||||||
ctx = insertMetadata(ctx, c.xGoogMetadata)
|
|
||||||
opts = append(c.CallOptions.SetNodePoolAutoscaling[0:len(c.CallOptions.SetNodePoolAutoscaling):len(c.CallOptions.SetNodePoolAutoscaling)], opts...)
|
|
||||||
var resp *containerpb.Operation
|
|
||||||
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
|
|
||||||
var err error
|
|
||||||
resp, err = c.clusterManagerClient.SetNodePoolAutoscaling(ctx, req, settings.GRPC...)
|
|
||||||
return err
|
|
||||||
}, opts...)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return resp, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetLoggingService sets the logging service of a specific cluster.
|
|
||||||
func (c *ClusterManagerClient) SetLoggingService(ctx context.Context, req *containerpb.SetLoggingServiceRequest, opts ...gax.CallOption) (*containerpb.Operation, error) {
|
|
||||||
ctx = insertMetadata(ctx, c.xGoogMetadata)
|
|
||||||
opts = append(c.CallOptions.SetLoggingService[0:len(c.CallOptions.SetLoggingService):len(c.CallOptions.SetLoggingService)], opts...)
|
|
||||||
var resp *containerpb.Operation
|
|
||||||
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
|
|
||||||
var err error
|
|
||||||
resp, err = c.clusterManagerClient.SetLoggingService(ctx, req, settings.GRPC...)
|
|
||||||
return err
|
|
||||||
}, opts...)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return resp, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetMonitoringService sets the monitoring service of a specific cluster.
|
|
||||||
func (c *ClusterManagerClient) SetMonitoringService(ctx context.Context, req *containerpb.SetMonitoringServiceRequest, opts ...gax.CallOption) (*containerpb.Operation, error) {
|
|
||||||
ctx = insertMetadata(ctx, c.xGoogMetadata)
|
|
||||||
opts = append(c.CallOptions.SetMonitoringService[0:len(c.CallOptions.SetMonitoringService):len(c.CallOptions.SetMonitoringService)], opts...)
|
|
||||||
var resp *containerpb.Operation
|
|
||||||
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
|
|
||||||
var err error
|
|
||||||
resp, err = c.clusterManagerClient.SetMonitoringService(ctx, req, settings.GRPC...)
|
|
||||||
return err
|
|
||||||
}, opts...)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return resp, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetAddonsConfig sets the addons of a specific cluster.
|
|
||||||
func (c *ClusterManagerClient) SetAddonsConfig(ctx context.Context, req *containerpb.SetAddonsConfigRequest, opts ...gax.CallOption) (*containerpb.Operation, error) {
|
|
||||||
ctx = insertMetadata(ctx, c.xGoogMetadata)
|
|
||||||
opts = append(c.CallOptions.SetAddonsConfig[0:len(c.CallOptions.SetAddonsConfig):len(c.CallOptions.SetAddonsConfig)], opts...)
|
|
||||||
var resp *containerpb.Operation
|
|
||||||
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
|
|
||||||
var err error
|
|
||||||
resp, err = c.clusterManagerClient.SetAddonsConfig(ctx, req, settings.GRPC...)
|
|
||||||
return err
|
|
||||||
}, opts...)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return resp, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetLocations sets the locations of a specific cluster.
|
|
||||||
func (c *ClusterManagerClient) SetLocations(ctx context.Context, req *containerpb.SetLocationsRequest, opts ...gax.CallOption) (*containerpb.Operation, error) {
|
|
||||||
ctx = insertMetadata(ctx, c.xGoogMetadata)
|
|
||||||
opts = append(c.CallOptions.SetLocations[0:len(c.CallOptions.SetLocations):len(c.CallOptions.SetLocations)], opts...)
|
|
||||||
var resp *containerpb.Operation
|
|
||||||
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
|
|
||||||
var err error
|
|
||||||
resp, err = c.clusterManagerClient.SetLocations(ctx, req, settings.GRPC...)
|
|
||||||
return err
|
|
||||||
}, opts...)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return resp, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// UpdateMaster updates the master of a specific cluster.
|
|
||||||
func (c *ClusterManagerClient) UpdateMaster(ctx context.Context, req *containerpb.UpdateMasterRequest, opts ...gax.CallOption) (*containerpb.Operation, error) {
|
|
||||||
ctx = insertMetadata(ctx, c.xGoogMetadata)
|
|
||||||
opts = append(c.CallOptions.UpdateMaster[0:len(c.CallOptions.UpdateMaster):len(c.CallOptions.UpdateMaster)], opts...)
|
|
||||||
var resp *containerpb.Operation
|
|
||||||
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
|
|
||||||
var err error
|
|
||||||
resp, err = c.clusterManagerClient.UpdateMaster(ctx, req, settings.GRPC...)
|
|
||||||
return err
|
|
||||||
}, opts...)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return resp, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetMasterAuth used to set master auth materials. Currently supports :-
|
|
||||||
// Changing the admin password of a specific cluster.
|
|
||||||
// This can be either via password generation or explicitly set the password.
|
|
||||||
func (c *ClusterManagerClient) SetMasterAuth(ctx context.Context, req *containerpb.SetMasterAuthRequest, opts ...gax.CallOption) (*containerpb.Operation, error) {
|
|
||||||
ctx = insertMetadata(ctx, c.xGoogMetadata)
|
|
||||||
opts = append(c.CallOptions.SetMasterAuth[0:len(c.CallOptions.SetMasterAuth):len(c.CallOptions.SetMasterAuth)], opts...)
|
|
||||||
var resp *containerpb.Operation
|
|
||||||
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
|
|
||||||
var err error
|
|
||||||
resp, err = c.clusterManagerClient.SetMasterAuth(ctx, req, settings.GRPC...)
|
|
||||||
return err
|
|
||||||
}, opts...)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return resp, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// DeleteCluster deletes the cluster, including the Kubernetes endpoint and all worker
|
|
||||||
// nodes.
|
|
||||||
//
|
|
||||||
// Firewalls and routes that were configured during cluster creation
|
|
||||||
// are also deleted.
|
|
||||||
//
|
|
||||||
// Other Google Compute Engine resources that might be in use by the cluster
|
|
||||||
// (e.g. load balancer resources) will not be deleted if they weren't present
|
|
||||||
// at the initial create time.
|
|
||||||
func (c *ClusterManagerClient) DeleteCluster(ctx context.Context, req *containerpb.DeleteClusterRequest, opts ...gax.CallOption) (*containerpb.Operation, error) {
|
|
||||||
ctx = insertMetadata(ctx, c.xGoogMetadata)
|
|
||||||
opts = append(c.CallOptions.DeleteCluster[0:len(c.CallOptions.DeleteCluster):len(c.CallOptions.DeleteCluster)], opts...)
|
|
||||||
var resp *containerpb.Operation
|
|
||||||
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
|
|
||||||
var err error
|
|
||||||
resp, err = c.clusterManagerClient.DeleteCluster(ctx, req, settings.GRPC...)
|
|
||||||
return err
|
|
||||||
}, opts...)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return resp, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// ListOperations lists all operations in a project in a specific zone or all zones.
|
|
||||||
func (c *ClusterManagerClient) ListOperations(ctx context.Context, req *containerpb.ListOperationsRequest, opts ...gax.CallOption) (*containerpb.ListOperationsResponse, error) {
|
|
||||||
ctx = insertMetadata(ctx, c.xGoogMetadata)
|
|
||||||
opts = append(c.CallOptions.ListOperations[0:len(c.CallOptions.ListOperations):len(c.CallOptions.ListOperations)], opts...)
|
|
||||||
var resp *containerpb.ListOperationsResponse
|
|
||||||
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
|
|
||||||
var err error
|
|
||||||
resp, err = c.clusterManagerClient.ListOperations(ctx, req, settings.GRPC...)
|
|
||||||
return err
|
|
||||||
}, opts...)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return resp, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetOperation gets the specified operation.
|
|
||||||
func (c *ClusterManagerClient) GetOperation(ctx context.Context, req *containerpb.GetOperationRequest, opts ...gax.CallOption) (*containerpb.Operation, error) {
|
|
||||||
ctx = insertMetadata(ctx, c.xGoogMetadata)
|
|
||||||
opts = append(c.CallOptions.GetOperation[0:len(c.CallOptions.GetOperation):len(c.CallOptions.GetOperation)], opts...)
|
|
||||||
var resp *containerpb.Operation
|
|
||||||
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
|
|
||||||
var err error
|
|
||||||
resp, err = c.clusterManagerClient.GetOperation(ctx, req, settings.GRPC...)
|
|
||||||
return err
|
|
||||||
}, opts...)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return resp, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// CancelOperation cancels the specified operation.
|
|
||||||
func (c *ClusterManagerClient) CancelOperation(ctx context.Context, req *containerpb.CancelOperationRequest, opts ...gax.CallOption) error {
|
|
||||||
ctx = insertMetadata(ctx, c.xGoogMetadata)
|
|
||||||
opts = append(c.CallOptions.CancelOperation[0:len(c.CallOptions.CancelOperation):len(c.CallOptions.CancelOperation)], opts...)
|
|
||||||
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
|
|
||||||
var err error
|
|
||||||
_, err = c.clusterManagerClient.CancelOperation(ctx, req, settings.GRPC...)
|
|
||||||
return err
|
|
||||||
}, opts...)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetServerConfig returns configuration info about the Container Engine service.
|
|
||||||
func (c *ClusterManagerClient) GetServerConfig(ctx context.Context, req *containerpb.GetServerConfigRequest, opts ...gax.CallOption) (*containerpb.ServerConfig, error) {
|
|
||||||
ctx = insertMetadata(ctx, c.xGoogMetadata)
|
|
||||||
opts = append(c.CallOptions.GetServerConfig[0:len(c.CallOptions.GetServerConfig):len(c.CallOptions.GetServerConfig)], opts...)
|
|
||||||
var resp *containerpb.ServerConfig
|
|
||||||
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
|
|
||||||
var err error
|
|
||||||
resp, err = c.clusterManagerClient.GetServerConfig(ctx, req, settings.GRPC...)
|
|
||||||
return err
|
|
||||||
}, opts...)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return resp, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// ListNodePools lists the node pools for a cluster.
|
|
||||||
func (c *ClusterManagerClient) ListNodePools(ctx context.Context, req *containerpb.ListNodePoolsRequest, opts ...gax.CallOption) (*containerpb.ListNodePoolsResponse, error) {
|
|
||||||
ctx = insertMetadata(ctx, c.xGoogMetadata)
|
|
||||||
opts = append(c.CallOptions.ListNodePools[0:len(c.CallOptions.ListNodePools):len(c.CallOptions.ListNodePools)], opts...)
|
|
||||||
var resp *containerpb.ListNodePoolsResponse
|
|
||||||
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
|
|
||||||
var err error
|
|
||||||
resp, err = c.clusterManagerClient.ListNodePools(ctx, req, settings.GRPC...)
|
|
||||||
return err
|
|
||||||
}, opts...)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return resp, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetNodePool retrieves the node pool requested.
|
|
||||||
func (c *ClusterManagerClient) GetNodePool(ctx context.Context, req *containerpb.GetNodePoolRequest, opts ...gax.CallOption) (*containerpb.NodePool, error) {
|
|
||||||
ctx = insertMetadata(ctx, c.xGoogMetadata)
|
|
||||||
opts = append(c.CallOptions.GetNodePool[0:len(c.CallOptions.GetNodePool):len(c.CallOptions.GetNodePool)], opts...)
|
|
||||||
var resp *containerpb.NodePool
|
|
||||||
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
|
|
||||||
var err error
|
|
||||||
resp, err = c.clusterManagerClient.GetNodePool(ctx, req, settings.GRPC...)
|
|
||||||
return err
|
|
||||||
}, opts...)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return resp, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// CreateNodePool creates a node pool for a cluster.
|
|
||||||
func (c *ClusterManagerClient) CreateNodePool(ctx context.Context, req *containerpb.CreateNodePoolRequest, opts ...gax.CallOption) (*containerpb.Operation, error) {
|
|
||||||
ctx = insertMetadata(ctx, c.xGoogMetadata)
|
|
||||||
opts = append(c.CallOptions.CreateNodePool[0:len(c.CallOptions.CreateNodePool):len(c.CallOptions.CreateNodePool)], opts...)
|
|
||||||
var resp *containerpb.Operation
|
|
||||||
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
|
|
||||||
var err error
|
|
||||||
resp, err = c.clusterManagerClient.CreateNodePool(ctx, req, settings.GRPC...)
|
|
||||||
return err
|
|
||||||
}, opts...)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return resp, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// DeleteNodePool deletes a node pool from a cluster.
|
|
||||||
func (c *ClusterManagerClient) DeleteNodePool(ctx context.Context, req *containerpb.DeleteNodePoolRequest, opts ...gax.CallOption) (*containerpb.Operation, error) {
|
|
||||||
ctx = insertMetadata(ctx, c.xGoogMetadata)
|
|
||||||
opts = append(c.CallOptions.DeleteNodePool[0:len(c.CallOptions.DeleteNodePool):len(c.CallOptions.DeleteNodePool)], opts...)
|
|
||||||
var resp *containerpb.Operation
|
|
||||||
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
|
|
||||||
var err error
|
|
||||||
resp, err = c.clusterManagerClient.DeleteNodePool(ctx, req, settings.GRPC...)
|
|
||||||
return err
|
|
||||||
}, opts...)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return resp, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// RollbackNodePoolUpgrade roll back the previously Aborted or Failed NodePool upgrade.
|
|
||||||
// This will be an no-op if the last upgrade successfully completed.
|
|
||||||
func (c *ClusterManagerClient) RollbackNodePoolUpgrade(ctx context.Context, req *containerpb.RollbackNodePoolUpgradeRequest, opts ...gax.CallOption) (*containerpb.Operation, error) {
|
|
||||||
ctx = insertMetadata(ctx, c.xGoogMetadata)
|
|
||||||
opts = append(c.CallOptions.RollbackNodePoolUpgrade[0:len(c.CallOptions.RollbackNodePoolUpgrade):len(c.CallOptions.RollbackNodePoolUpgrade)], opts...)
|
|
||||||
var resp *containerpb.Operation
|
|
||||||
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
|
|
||||||
var err error
|
|
||||||
resp, err = c.clusterManagerClient.RollbackNodePoolUpgrade(ctx, req, settings.GRPC...)
|
|
||||||
return err
|
|
||||||
}, opts...)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return resp, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetNodePoolManagement sets the NodeManagement options for a node pool.
|
|
||||||
func (c *ClusterManagerClient) SetNodePoolManagement(ctx context.Context, req *containerpb.SetNodePoolManagementRequest, opts ...gax.CallOption) (*containerpb.Operation, error) {
|
|
||||||
ctx = insertMetadata(ctx, c.xGoogMetadata)
|
|
||||||
opts = append(c.CallOptions.SetNodePoolManagement[0:len(c.CallOptions.SetNodePoolManagement):len(c.CallOptions.SetNodePoolManagement)], opts...)
|
|
||||||
var resp *containerpb.Operation
|
|
||||||
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
|
|
||||||
var err error
|
|
||||||
resp, err = c.clusterManagerClient.SetNodePoolManagement(ctx, req, settings.GRPC...)
|
|
||||||
return err
|
|
||||||
}, opts...)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return resp, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetLabels sets labels on a cluster.
|
|
||||||
func (c *ClusterManagerClient) SetLabels(ctx context.Context, req *containerpb.SetLabelsRequest, opts ...gax.CallOption) (*containerpb.Operation, error) {
|
|
||||||
ctx = insertMetadata(ctx, c.xGoogMetadata)
|
|
||||||
opts = append(c.CallOptions.SetLabels[0:len(c.CallOptions.SetLabels):len(c.CallOptions.SetLabels)], opts...)
|
|
||||||
var resp *containerpb.Operation
|
|
||||||
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
|
|
||||||
var err error
|
|
||||||
resp, err = c.clusterManagerClient.SetLabels(ctx, req, settings.GRPC...)
|
|
||||||
return err
|
|
||||||
}, opts...)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return resp, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetLegacyAbac enables or disables the ABAC authorization mechanism on a cluster.
|
|
||||||
func (c *ClusterManagerClient) SetLegacyAbac(ctx context.Context, req *containerpb.SetLegacyAbacRequest, opts ...gax.CallOption) (*containerpb.Operation, error) {
|
|
||||||
ctx = insertMetadata(ctx, c.xGoogMetadata)
|
|
||||||
opts = append(c.CallOptions.SetLegacyAbac[0:len(c.CallOptions.SetLegacyAbac):len(c.CallOptions.SetLegacyAbac)], opts...)
|
|
||||||
var resp *containerpb.Operation
|
|
||||||
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
|
|
||||||
var err error
|
|
||||||
resp, err = c.clusterManagerClient.SetLegacyAbac(ctx, req, settings.GRPC...)
|
|
||||||
return err
|
|
||||||
}, opts...)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return resp, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// StartIPRotation start master IP rotation.
|
|
||||||
func (c *ClusterManagerClient) StartIPRotation(ctx context.Context, req *containerpb.StartIPRotationRequest, opts ...gax.CallOption) (*containerpb.Operation, error) {
|
|
||||||
ctx = insertMetadata(ctx, c.xGoogMetadata)
|
|
||||||
opts = append(c.CallOptions.StartIPRotation[0:len(c.CallOptions.StartIPRotation):len(c.CallOptions.StartIPRotation)], opts...)
|
|
||||||
var resp *containerpb.Operation
|
|
||||||
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
|
|
||||||
var err error
|
|
||||||
resp, err = c.clusterManagerClient.StartIPRotation(ctx, req, settings.GRPC...)
|
|
||||||
return err
|
|
||||||
}, opts...)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return resp, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// CompleteIPRotation completes master IP rotation.
|
|
||||||
func (c *ClusterManagerClient) CompleteIPRotation(ctx context.Context, req *containerpb.CompleteIPRotationRequest, opts ...gax.CallOption) (*containerpb.Operation, error) {
|
|
||||||
ctx = insertMetadata(ctx, c.xGoogMetadata)
|
|
||||||
opts = append(c.CallOptions.CompleteIPRotation[0:len(c.CallOptions.CompleteIPRotation):len(c.CallOptions.CompleteIPRotation)], opts...)
|
|
||||||
var resp *containerpb.Operation
|
|
||||||
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
|
|
||||||
var err error
|
|
||||||
resp, err = c.clusterManagerClient.CompleteIPRotation(ctx, req, settings.GRPC...)
|
|
||||||
return err
|
|
||||||
}, opts...)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return resp, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetNodePoolSize sets the size of a specific node pool.
|
|
||||||
func (c *ClusterManagerClient) SetNodePoolSize(ctx context.Context, req *containerpb.SetNodePoolSizeRequest, opts ...gax.CallOption) (*containerpb.Operation, error) {
|
|
||||||
ctx = insertMetadata(ctx, c.xGoogMetadata)
|
|
||||||
opts = append(c.CallOptions.SetNodePoolSize[0:len(c.CallOptions.SetNodePoolSize):len(c.CallOptions.SetNodePoolSize)], opts...)
|
|
||||||
var resp *containerpb.Operation
|
|
||||||
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
|
|
||||||
var err error
|
|
||||||
resp, err = c.clusterManagerClient.SetNodePoolSize(ctx, req, settings.GRPC...)
|
|
||||||
return err
|
|
||||||
}, opts...)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return resp, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetNetworkPolicy enables/Disables Network Policy for a cluster.
|
|
||||||
func (c *ClusterManagerClient) SetNetworkPolicy(ctx context.Context, req *containerpb.SetNetworkPolicyRequest, opts ...gax.CallOption) (*containerpb.Operation, error) {
|
|
||||||
ctx = insertMetadata(ctx, c.xGoogMetadata)
|
|
||||||
opts = append(c.CallOptions.SetNetworkPolicy[0:len(c.CallOptions.SetNetworkPolicy):len(c.CallOptions.SetNetworkPolicy)], opts...)
|
|
||||||
var resp *containerpb.Operation
|
|
||||||
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
|
|
||||||
var err error
|
|
||||||
resp, err = c.clusterManagerClient.SetNetworkPolicy(ctx, req, settings.GRPC...)
|
|
||||||
return err
|
|
||||||
}, opts...)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return resp, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetMaintenancePolicy sets the maintenance policy for a cluster.
|
|
||||||
func (c *ClusterManagerClient) SetMaintenancePolicy(ctx context.Context, req *containerpb.SetMaintenancePolicyRequest, opts ...gax.CallOption) (*containerpb.Operation, error) {
|
|
||||||
ctx = insertMetadata(ctx, c.xGoogMetadata)
|
|
||||||
opts = append(c.CallOptions.SetMaintenancePolicy[0:len(c.CallOptions.SetMaintenancePolicy):len(c.CallOptions.SetMaintenancePolicy)], opts...)
|
|
||||||
var resp *containerpb.Operation
|
|
||||||
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
|
|
||||||
var err error
|
|
||||||
resp, err = c.clusterManagerClient.SetMaintenancePolicy(ctx, req, settings.GRPC...)
|
|
||||||
return err
|
|
||||||
}, opts...)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return resp, nil
|
|
||||||
}
|
|
||||||
|
|
@ -1,49 +0,0 @@
|
||||||
// Copyright 2018 Google LLC
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// https://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
// AUTO-GENERATED CODE. DO NOT EDIT.
|
|
||||||
|
|
||||||
// Package container is an auto-generated package for the
|
|
||||||
// Google Container Engine API.
|
|
||||||
//
|
|
||||||
// NOTE: This package is in alpha. It is not stable, and is likely to change.
|
|
||||||
//
|
|
||||||
// The Google Kubernetes Engine API is used for building and managing
|
|
||||||
// container
|
|
||||||
// based applications, powered by the open source Kubernetes technology.
|
|
||||||
package container // import "cloud.google.com/go/container/apiv1"
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
|
|
||||||
"google.golang.org/grpc/metadata"
|
|
||||||
)
|
|
||||||
|
|
||||||
func insertMetadata(ctx context.Context, mds ...metadata.MD) context.Context {
|
|
||||||
out, _ := metadata.FromOutgoingContext(ctx)
|
|
||||||
out = out.Copy()
|
|
||||||
for _, md := range mds {
|
|
||||||
for k, v := range md {
|
|
||||||
out[k] = append(out[k], v...)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return metadata.NewOutgoingContext(ctx, out)
|
|
||||||
}
|
|
||||||
|
|
||||||
// DefaultAuthScopes reports the default set of authentication scopes to use with this package.
|
|
||||||
func DefaultAuthScopes() []string {
|
|
||||||
return []string{
|
|
||||||
"https://www.googleapis.com/auth/cloud-platform",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,19 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
# Copyright 2019 Google LLC
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
|
|
||||||
today=$(date +%Y%m%d)
|
|
||||||
|
|
||||||
sed -i -r -e 's/const Repo = "([0-9]{8})"/const Repo = "'$today'"/' $GOFILE
|
|
||||||
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue