diff --git a/docs/cmd/kn_source_apiserver_create.md b/docs/cmd/kn_source_apiserver_create.md index d8328665f2..fda6dcc546 100644 --- a/docs/cmd/kn_source_apiserver_create.md +++ b/docs/cmd/kn_source_apiserver_create.md @@ -23,8 +23,8 @@ kn source apiserver create NAME --resource RESOURCE --service-account ACCOUNTNAM ``` -h, --help help for create --mode string The mode the receive adapter controller runs under:, - "Ref" sends only the reference to the resource, - "Resource" send the full resource. (default "Ref") + "Reference" sends only the reference to the resource, + "Resource" send the full resource. (default "Reference") -n, --namespace string Specify the namespace to operate in. --resource stringArray Specification for which events to listen, in the format Kind:APIVersion:isController, e.g. "Event:v1:true". "isController" can be omitted and is "false" by default, e.g. "Event:v1". diff --git a/docs/cmd/kn_source_apiserver_update.md b/docs/cmd/kn_source_apiserver_update.md index 45ff4ba35d..82fac73ac0 100644 --- a/docs/cmd/kn_source_apiserver_update.md +++ b/docs/cmd/kn_source_apiserver_update.md @@ -23,8 +23,8 @@ kn source apiserver update NAME --resource RESOURCE --service-account ACCOUNTNAM ``` -h, --help help for update --mode string The mode the receive adapter controller runs under:, - "Ref" sends only the reference to the resource, - "Resource" send the full resource. (default "Ref") + "Reference" sends only the reference to the resource, + "Resource" send the full resource. (default "Reference") -n, --namespace string Specify the namespace to operate in. --resource stringArray Specification for which events to listen, in the format Kind:APIVersion:isController, e.g. "Event:v1:true". "isController" can be omitted and is "false" by default, e.g. "Event:v1". diff --git a/go.mod b/go.mod index c4c1e0b565..d2cb53897b 100644 --- a/go.mod +++ b/go.mod @@ -3,8 +3,8 @@ module knative.dev/client require ( 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/stackdriver v0.13.0 // indirect - github.com/google/go-containerregistry v0.0.0-20200304201134-fcc8ea80e26f // indirect + contrib.go.opencensus.io/exporter/stackdriver v0.13.1 // indirect + github.com/google/go-containerregistry v0.0.0-20200413145205-82d30a103c0a // indirect github.com/mitchellh/go-homedir v1.1.0 github.com/openzipkin/zipkin-go v0.2.2 // indirect github.com/pkg/errors v0.8.1 @@ -12,18 +12,17 @@ require ( github.com/spf13/cobra v0.0.5 github.com/spf13/pflag v1.0.5 github.com/spf13/viper v1.4.0 - golang.org/x/crypto v0.0.0-20191206172530-e9b2fee46413 + golang.org/x/crypto v0.0.0-20200220183623-bac4c82f6975 gomodules.xyz/jsonpatch/v2 v2.1.0 // indirect - gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect gotest.tools v2.2.0+incompatible - k8s.io/api v0.17.0 - k8s.io/apimachinery v0.17.0 + k8s.io/api v0.17.4 + k8s.io/apimachinery v0.17.4 k8s.io/cli-runtime v0.17.0 - k8s.io/client-go v0.17.0 - knative.dev/eventing v0.13.6 - knative.dev/pkg v0.0.0-20200409225505-9147309d5366 - knative.dev/serving v0.13.2 - knative.dev/test-infra v0.0.0-20200409221904-5e04d955cdb9 + k8s.io/client-go v0.17.4 + knative.dev/eventing v0.14.0 + knative.dev/pkg v0.0.0-20200414233146-0eed424fa4ee + knative.dev/serving v0.14.0 + knative.dev/test-infra v0.0.0-20200413202711-9cf64fb1b912 sigs.k8s.io/yaml v1.1.0 ) diff --git a/go.sum b/go.sum index 2d847082b8..6c12dcf6a5 100644 --- a/go.sum +++ b/go.sum @@ -11,8 +11,8 @@ contrib.go.opencensus.io/exporter/ocagent v0.6.0 h1:Z1n6UAyr0QwM284yUuh5Zd8JlvxU contrib.go.opencensus.io/exporter/ocagent v0.6.0/go.mod h1:zmKjrJcdo0aYcVS7bmEeSEBLPA9YJp5bjrofdU3pIXs= contrib.go.opencensus.io/exporter/prometheus v0.1.0 h1:SByaIoWwNgMdPSgl5sMqM2KDE5H/ukPWBRo314xiDvg= contrib.go.opencensus.io/exporter/prometheus v0.1.0/go.mod h1:cGFniUXGZlKRjzOyuZJ6mgB+PgBcCIa79kEKR8YCW+A= -contrib.go.opencensus.io/exporter/stackdriver v0.13.0 h1:Jaz7WbqjtfoCPa1KbfisCX+P5aM3DizEY9pQMU0oAQo= -contrib.go.opencensus.io/exporter/stackdriver v0.13.0/go.mod h1:z2tyTZtPmQ2HvWH4cOmVDgtY+1lomfKdbLnkJvZdc8c= +contrib.go.opencensus.io/exporter/stackdriver v0.13.1 h1:RX9W6FelAqTVnBi/bRXJLXr9n18v4QkQwZYIdnNS51I= +contrib.go.opencensus.io/exporter/stackdriver v0.13.1/go.mod h1:z2tyTZtPmQ2HvWH4cOmVDgtY+1lomfKdbLnkJvZdc8c= github.com/Azure/azure-sdk-for-go v35.0.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc= github.com/Azure/azure-sdk-for-go v38.0.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc= github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78/go.mod h1:LmzpDX56iTiv29bbRTIsUNlaFfuhWRQBWjQdVyAevI8= @@ -162,8 +162,8 @@ github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5a 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/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-containerregistry v0.0.0-20200304201134-fcc8ea80e26f h1:tc00QCOHwGF/IyStWQnJN7zmrPP9LBJTKyulXzApCfw= -github.com/google/go-containerregistry v0.0.0-20200304201134-fcc8ea80e26f/go.mod h1:m8YvHwSOuBCq25yrj1DaX/fIMrv6ec3CNg8jY8+5PEA= +github.com/google/go-containerregistry v0.0.0-20200413145205-82d30a103c0a h1:XNvUa41C0oOgPmTmZKrWKhOCCFPLnOwLfm+pWU75sNs= +github.com/google/go-containerregistry v0.0.0-20200413145205-82d30a103c0a/go.mod h1:pD1UFYs7MCAx+ZLShBdttcaOSbyc8F9Na/9IZLNwJeA= 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/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= @@ -356,7 +356,7 @@ github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1 github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc= github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= -github.com/vdemeester/k8s-pkg-credentialprovider v0.0.0-20200107171650-7c61ffa44238/go.mod h1:JwQJCMWpUDqjZrB5jpw0f5VbN7U95zxFy1ZDpoEarGo= +github.com/vdemeester/k8s-pkg-credentialprovider v1.17.4/go.mod h1:inCTmtUdr5KJbreVojo06krnTgaeAz/Z7lynpPk/Q2c= github.com/vmware/govmomi v0.20.3/go.mod h1:URlwyTFZX72RmxtxuaFL2Uj3fD1JTvZdx59bHWk6aFU= github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= @@ -382,8 +382,9 @@ golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20190611184440-5c40567a22f8/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20191206172530-e9b2fee46413 h1:ULYEB3JvPRE/IfO+9uO7vKV/xzVTO7XPAwm8xbf4w2g= golang.org/x/crypto v0.0.0-20191206172530-e9b2fee46413/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20200220183623-bac4c82f6975 h1:/Tl7pH94bvbAAHBdZJT947M/+gp0+CqQXDtMRC0fseo= +golang.org/x/crypto v0.0.0-20200220183623-bac4c82f6975/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190125153040-c74c464bbbf2/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190312203227-4b39c73a6495/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -394,7 +395,6 @@ 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-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-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/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= @@ -483,7 +483,6 @@ 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-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-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200210192313-1ace956b0e17 h1:a/Fd23DJvg1CaeDH0dYHahE+hCI0v9rFgxSNIThoUcM= 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= @@ -528,9 +527,8 @@ google.golang.org/grpc v1.24.0 h1:vb/1TCsVn3DcJlQ0Gs1yB1pKI6Do2/QNwxdKqmc/b0s= google.golang.org/grpc v1.24.0/go.mod h1:XDChyiUovWa60DnaeDeZmSW86xtLtjtZbwvSiRnRtcA= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= -gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/cheggaaa/pb.v1 v1.0.25/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= @@ -547,8 +545,9 @@ gopkg.in/warnings.v0 v0.1.1/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRN gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.4 h1:/eiJrUcujPVeJ3xlSWaiNi3uSVmDGBK1pDHUHAnao1I= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= +gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo= gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= @@ -556,19 +555,22 @@ honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWh honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= -k8s.io/api v0.17.0 h1:H9d/lw+VkZKEVIUc8F3wgiQ+FUXTTr21M87jXLU7yqM= k8s.io/api v0.17.0/go.mod h1:npsyOePkeP0CPwyGfXDHxvypiYMJxBWAMpQxCaJ4ZxI= -k8s.io/apimachinery v0.17.0 h1:xRBnuie9rXcPxUkDizUsGvPf1cnlZCFu210op7J7LJo= +k8s.io/api v0.17.4 h1:HbwOhDapkguO8lTAE8OX3hdF2qp8GtpC9CW/MQATXXo= +k8s.io/api v0.17.4/go.mod h1:5qxx6vjmwUVG2nHQTKGlLts8Tbok8PzHl4vHtVFuZCA= k8s.io/apimachinery v0.17.0/go.mod h1:b9qmWdKlLuU9EBh+06BtLcSf/Mu89rWL33naRxs1uZg= -k8s.io/apiserver v0.17.0/go.mod h1:ABM+9x/prjINN6iiffRVNCBR2Wk7uY4z+EtEGZD48cg= +k8s.io/apimachinery v0.17.4 h1:UzM+38cPUJnzqSQ+E1PY4YxMHIzQyCg29LOoGfo79Zw= +k8s.io/apimachinery v0.17.4/go.mod h1:gxLnyZcGNdZTCLnq3fgzyg2A5BVCHTNDFrw8AmuJ+0g= +k8s.io/apiserver v0.17.4/go.mod h1:5ZDQ6Xr5MNBxyi3iUZXS84QOhZl+W7Oq2us/29c0j9I= k8s.io/cli-runtime v0.17.0 h1:XEuStbJBHCQlEKFyTQmceDKEWOSYHZkcYWKp3SsQ9Hk= 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/go.mod h1:TYgR6EUHs6k45hb6KWjVD6jFZvJV4gHDikv/It0xz+k= -k8s.io/cloud-provider v0.17.0/go.mod h1:Ze4c3w2C0bRsjkBUoHpFi+qWe3ob1wI2/7cUn+YQIDE= +k8s.io/client-go v0.17.4 h1:VVdVbpTY70jiNHS1eiFkUt7ZIJX3txd29nDxxXH4en8= +k8s.io/client-go v0.17.4/go.mod h1:ouF6o5pz3is8qU0/qYL2RnoxOPqgfuidYLowytyLJmc= +k8s.io/cloud-provider v0.17.4/go.mod h1:XEjKDzfD+b9MTLXQFlDGkk6Ho8SGMpaU8Uugx/KNK9U= 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/csi-translation-lib v0.17.0/go.mod h1:HEF7MEz7pOLJCnxabi45IPkhSsE/KmxPQksuCrHKWls= +k8s.io/component-base v0.17.4/go.mod h1:5BRqHMbbQPm2kKu35v3G+CpVq4K0RJKC7TRioF0I9lE= +k8s.io/csi-translation-lib v0.17.4/go.mod h1:CsxmjwxEI0tTNMzffIAcgR9lX4wOh6AKHdxQrT7L0oo= k8s.io/gengo v0.0.0-20190128074634-0689ccc1d7d6/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0= k8s.io/gengo v0.0.0-20190822140433-26a664648505/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0= k8s.io/klog v0.0.0-20181102134211-b9b56d5dfc92/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk= @@ -577,17 +579,17 @@ k8s.io/klog v1.0.0 h1:Pt+yjF5aB1xDSVbau4VsWe+dQNzA0qv1LlXdC2dF6Q8= k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I= k8s.io/kube-openapi v0.0.0-20191107075043-30be4d16710a h1:UcxjrRMyNx/i/y8G7kPvLyy7rfbeuf1PYyBf973pgyU= k8s.io/kube-openapi v0.0.0-20191107075043-30be4d16710a/go.mod h1:1TqjTSzOxsLGIKfj0lK8EeCP7K1iUG65v09OM0/WG5E= -k8s.io/legacy-cloud-providers v0.17.0/go.mod h1:DdzaepJ3RtRy+e5YhNtrCYwlgyK87j/5+Yfp0L9Syp8= +k8s.io/legacy-cloud-providers v0.17.4/go.mod h1:FikRNoD64ECjkxO36gkDgJeiQWwyZTuBkhu+yxOc1Js= k8s.io/utils v0.0.0-20191114184206-e782cd3c129f h1:GiPwtSzdP43eI1hpPCbROQCCIgCuiMMNF8YUVLF3vJo= k8s.io/utils v0.0.0-20191114184206-e782cd3c129f/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew= -knative.dev/eventing v0.13.6 h1:TT2w7qjsMTvYcEfTih7Gzv5Nm0GMLe5Y8dxJG3s1wbM= -knative.dev/eventing v0.13.6/go.mod h1:UxweNv8yXhsdHJitcb9R6rmfNaUD2DFi9GWwNRyIs58= -knative.dev/pkg v0.0.0-20200409225505-9147309d5366 h1:86q+/OWhTkiAXymH8F2NCoWqQLKuX4y8jntTXVq/PDI= -knative.dev/pkg v0.0.0-20200409225505-9147309d5366/go.mod h1:pgODObA1dTyhNoFxPZTTjNWfx6F0aKsKzn+vaT9XO/Q= -knative.dev/serving v0.13.2 h1:y/XGEVNZeoZ36P7+Xa76ap2r/o9LKXVfxMNiFvxPxTg= -knative.dev/serving v0.13.2/go.mod h1:x2n255JS2XBI39tmjZ8CwTxIf9EKNMCrkVuiOttLRm0= -knative.dev/test-infra v0.0.0-20200409221904-5e04d955cdb9 h1:x6htuzuQ7K4AcVAH/uNRf135X7TPac0eaBFyw6SY2qA= -knative.dev/test-infra v0.0.0-20200409221904-5e04d955cdb9/go.mod h1:xcdUkMJrLlBswIZqL5zCuBFOC22WIPMQoVX1L35i0vQ= +knative.dev/eventing v0.14.0 h1:OsA/1j6A4095eQOUTo9+RH+PV0jLJLfibEYvxGkHgOE= +knative.dev/eventing v0.14.0/go.mod h1:UxweNv8yXhsdHJitcb9R6rmfNaUD2DFi9GWwNRyIs58= +knative.dev/pkg v0.0.0-20200414233146-0eed424fa4ee h1:G1QedLB/RxF4QTyL1Pq9M1QK1uj8khQgTypofUXrG20= +knative.dev/pkg v0.0.0-20200414233146-0eed424fa4ee/go.mod h1:pgODObA1dTyhNoFxPZTTjNWfx6F0aKsKzn+vaT9XO/Q= +knative.dev/serving v0.14.0 h1:9iDyOqTciNuAh2D5KJP0soOq23FDR4HQHdIQNBQ/rAE= +knative.dev/serving v0.14.0/go.mod h1:x2n255JS2XBI39tmjZ8CwTxIf9EKNMCrkVuiOttLRm0= +knative.dev/test-infra v0.0.0-20200413202711-9cf64fb1b912 h1:RZJe3OFkal3m9lorMSS2BaEnBs4OPj2o5/Oiw0JXlQY= +knative.dev/test-infra v0.0.0-20200413202711-9cf64fb1b912/go.mod h1:xcdUkMJrLlBswIZqL5zCuBFOC22WIPMQoVX1L35i0vQ= modernc.org/cc v1.0.0/go.mod h1:1Sk4//wdnYJiUIxnW8ddKpaOJCF37yAdqYnkxUpaYxw= modernc.org/golex v1.0.0/go.mod h1:b/QX9oBD/LhixY6NDh+IdGv17hgB+51fET1i2kPSmvk= modernc.org/mathutil v1.0.0/go.mod h1:wU0vUrJsVWBZ4P6e7xtFJEhFSNsfRLJ8H458uRjg03k= diff --git a/pkg/dynamic/client_test.go b/pkg/dynamic/client_test.go index 55f7b1ece1..df7a73d729 100644 --- a/pkg/dynamic/client_test.go +++ b/pkg/dynamic/client_test.go @@ -108,7 +108,6 @@ func TestListSources(t *testing.T) { client := createFakeKnDynamicClient(testNamespace, newSourceCRDObjWithSpec("pingsources", "sources.knative.dev", "v1alpha1", "PingSource"), newSourceCRDObjWithSpec("apiserversources", "sources.knative.dev", "v1alpha1", "ApiServerSource"), - newSourceCRDObjWithSpec("cronjobsources", "sources.knative.dev", "v1alpha1", "CronJobSource"), newSourceUnstructuredObj("p1", "sources.knative.dev/v1alpha1", "PingSource"), newSourceUnstructuredObj("a1", "sources.knative.dev/v1alpha1", "ApiServerSource"), newSourceUnstructuredObj("c1", "sources.knative.dev/v1alpha1", "CronJobSource"), diff --git a/pkg/kn/commands/source/apiserver/apiserver.go b/pkg/kn/commands/source/apiserver/apiserver.go index c8a6ba271d..7cbdabe445 100644 --- a/pkg/kn/commands/source/apiserver/apiserver.go +++ b/pkg/kn/commands/source/apiserver/apiserver.go @@ -16,15 +16,11 @@ package apiserver import ( "github.com/spf13/cobra" - corev1 "k8s.io/api/core/v1" "k8s.io/client-go/tools/clientcmd" - v1 "knative.dev/pkg/apis/duck/v1" - "knative.dev/pkg/apis/duck/v1beta1" - - clientv1alpha1 "knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha1" + clientv1alpha2 "knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha2" "knative.dev/client/pkg/kn/commands" - v1alpha1 "knative.dev/client/pkg/sources/v1alpha1" + "knative.dev/client/pkg/sources/v1alpha2" ) // NewAPIServerCommand for managing ApiServer source @@ -41,9 +37,9 @@ func NewAPIServerCommand(p *commands.KnParams) *cobra.Command { return apiServerSourceCmd } -var apiServerSourceClientFactory func(config clientcmd.ClientConfig, namespace string) (v1alpha1.KnAPIServerSourcesClient, error) +var apiServerSourceClientFactory func(config clientcmd.ClientConfig, namespace string) (v1alpha2.KnAPIServerSourcesClient, error) -func newAPIServerSourceClient(p *commands.KnParams, cmd *cobra.Command) (v1alpha1.KnAPIServerSourcesClient, error) { +func newAPIServerSourceClient(p *commands.KnParams, cmd *cobra.Command) (v1alpha2.KnAPIServerSourcesClient, error) { namespace, err := p.GetNamespace(cmd) if err != nil { return nil, err @@ -62,23 +58,10 @@ func newAPIServerSourceClient(p *commands.KnParams, cmd *cobra.Command) (v1alpha return nil, err } - client, err := clientv1alpha1.NewForConfig(clientConfig) + client, err := clientv1alpha2.NewForConfig(clientConfig) if err != nil { return nil, err } - return v1alpha1.NewKnSourcesClient(client, namespace).APIServerSourcesClient(), 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, - } + return v1alpha2.NewKnSourcesClient(client, namespace).APIServerSourcesClient(), nil } diff --git a/pkg/kn/commands/source/apiserver/apiserver_test.go b/pkg/kn/commands/source/apiserver/apiserver_test.go index 182abfffb9..c3444ea438 100644 --- a/pkg/kn/commands/source/apiserver/apiserver_test.go +++ b/pkg/kn/commands/source/apiserver/apiserver_test.go @@ -17,15 +17,14 @@ package apiserver import ( "bytes" - corev1 "k8s.io/api/core/v1" "k8s.io/client-go/tools/clientcmd" - "knative.dev/eventing/pkg/apis/sources/v1alpha1" - duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" + v1alpha2 "knative.dev/eventing/pkg/apis/sources/v1alpha2" + duckv1 "knative.dev/pkg/apis/duck/v1" kndynamic "knative.dev/client/pkg/dynamic" + clientv1alpha2 "knative.dev/client/pkg/sources/v1alpha2" "knative.dev/client/pkg/kn/commands" - clientv1alpha1 "knative.dev/client/pkg/sources/v1alpha1" ) const testNamespace = "default" @@ -56,7 +55,7 @@ current-context: x } } -func executeAPIServerSourceCommand(apiServerSourceClient clientv1alpha1.KnAPIServerSourcesClient, dynamicClient kndynamic.KnDynamicClient, args ...string) (string, error) { +func executeAPIServerSourceCommand(apiServerSourceClient clientv1alpha2.KnAPIServerSourcesClient, dynamicClient kndynamic.KnDynamicClient, args ...string) (string, error) { knParams := &commands.KnParams{} knParams.ClientConfig = blankConfig @@ -70,7 +69,7 @@ func executeAPIServerSourceCommand(apiServerSourceClient clientv1alpha1.KnAPISer cmd.SetArgs(args) cmd.SetOutput(output) - apiServerSourceClientFactory = func(config clientcmd.ClientConfig, namespace string) (clientv1alpha1.KnAPIServerSourcesClient, error) { + apiServerSourceClientFactory = func(config clientcmd.ClientConfig, namespace string) (clientv1alpha2.KnAPIServerSourcesClient, error) { return apiServerSourceClient, nil } defer cleanupAPIServerMockClient() @@ -84,25 +83,24 @@ func cleanupAPIServerMockClient() { apiServerSourceClientFactory = nil } -func createAPIServerSource(name, resourceKind, resourceVersion, serviceAccount, mode, service string, isController bool) *v1alpha1.ApiServerSource { - resources := []v1alpha1.ApiServerResource{{ +func createAPIServerSource(name, resourceKind, resourceVersion, serviceAccount, mode, service string, isController bool) *v1alpha2.ApiServerSource { + resources := []v1alpha2.APIVersionKindSelector{{ APIVersion: resourceVersion, Kind: resourceKind, - Controller: isController, }} - sink := &duckv1beta1.Destination{ - Ref: &corev1.ObjectReference{ + sink := duckv1.Destination{ + Ref: &duckv1.KReference{ Kind: "Service", Name: service, APIVersion: "serving.knative.dev/v1", Namespace: "default", }} - return clientv1alpha1.NewAPIServerSourceBuilder(name). + return clientv1alpha2.NewAPIServerSourceBuilder(name). Resources(resources). ServiceAccount(serviceAccount). - Mode(mode). + EventMode(mode). Sink(sink). Build() } diff --git a/pkg/kn/commands/source/apiserver/create.go b/pkg/kn/commands/source/apiserver/create.go index d8df782419..fcd4c647c0 100644 --- a/pkg/kn/commands/source/apiserver/create.go +++ b/pkg/kn/commands/source/apiserver/create.go @@ -22,7 +22,7 @@ import ( "knative.dev/client/pkg/kn/commands" "knative.dev/client/pkg/kn/commands/flags" - "knative.dev/client/pkg/sources/v1alpha1" + "knative.dev/client/pkg/sources/v1alpha2" ) // NewAPIServerCreateCommand for creating source @@ -62,12 +62,12 @@ func NewAPIServerCreateCommand(p *commands.KnParams) *cobra.Command { "because: %s", name, namespace, err) } - b := v1alpha1.NewAPIServerSourceBuilder(name). + b := v1alpha2.NewAPIServerSourceBuilder(name). ServiceAccount(updateFlags.ServiceAccountName). - Mode(updateFlags.Mode). - Sink(toDuckV1Beta1(objectRef)) + EventMode(updateFlags.Mode). + Sink(*objectRef) - resources, err := updateFlags.getAPIServerResourceArray() + resources, err := updateFlags.getAPIServerVersionKindSelector() if err != nil { return err } diff --git a/pkg/kn/commands/source/apiserver/create_test.go b/pkg/kn/commands/source/apiserver/create_test.go index c811e9823b..06b58cb707 100644 --- a/pkg/kn/commands/source/apiserver/create_test.go +++ b/pkg/kn/commands/source/apiserver/create_test.go @@ -22,7 +22,7 @@ import ( servingv1 "knative.dev/serving/pkg/apis/serving/v1" dynamicfake "knative.dev/client/pkg/dynamic/fake" - clientv1alpha1 "knative.dev/client/pkg/sources/v1alpha1" + "knative.dev/client/pkg/sources/v1alpha2" "knative.dev/client/pkg/util" ) @@ -32,12 +32,12 @@ func TestCreateApiServerSource(t *testing.T) { ObjectMeta: metav1.ObjectMeta{Name: "testsvc", Namespace: "default"}, } dynamicClient := dynamicfake.CreateFakeKnDynamicClient("default", testsvc) - apiServerClient := clientv1alpha1.NewMockKnAPIServerSourceClient(t) + apiServerClient := v1alpha2.NewMockKnAPIServerSourceClient(t) apiServerRecorder := apiServerClient.Recorder() - apiServerRecorder.CreateAPIServerSource(createAPIServerSource("testsource", "Event", "v1", "testsa", "Ref", "testsvc", false), nil) + apiServerRecorder.CreateAPIServerSource(createAPIServerSource("testsource", "Event", "v1", "testsa", "Reference", "testsvc", false), nil) - 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", "--service-account", "testsa", "--sink", "svc:testsvc", "--mode", "Reference") assert.NilError(t, err, "ApiServer source should be created") util.ContainsAll(out, "created", "default", "testsource") @@ -46,15 +46,15 @@ func TestCreateApiServerSource(t *testing.T) { func TestSinkNotFoundError(t *testing.T) { dynamicClient := dynamicfake.CreateFakeKnDynamicClient("default") - apiServerClient := clientv1alpha1.NewMockKnAPIServerSourceClient(t) + apiServerClient := v1alpha2.NewMockKnAPIServerSourceClient(t) 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:key1=value1", "--service-account", "testsa", "--sink", "svc:testsvc", "--mode", "Reference") assert.Error(t, err, errorMsg) assert.Assert(t, util.ContainsAll(out, errorMsg, "Usage")) } func TestNoSinkError(t *testing.T) { - apiServerClient := clientv1alpha1.NewMockKnAPIServerSourceClient(t) - _, err := executeAPIServerSourceCommand(apiServerClient, nil, "create", "testsource", "--resource", "Event:v1:false", "--service-account", "testsa", "--mode", "Ref") + apiServerClient := v1alpha2.NewMockKnAPIServerSourceClient(t) + _, err := executeAPIServerSourceCommand(apiServerClient, nil, "create", "testsource", "--resource", "Event:v1", "--service-account", "testsa", "--mode", "Reference") assert.ErrorContains(t, err, "required flag(s)", "sink", "not set") } diff --git a/pkg/kn/commands/source/apiserver/delete_test.go b/pkg/kn/commands/source/apiserver/delete_test.go index 89928de0e5..cc91235b93 100644 --- a/pkg/kn/commands/source/apiserver/delete_test.go +++ b/pkg/kn/commands/source/apiserver/delete_test.go @@ -20,13 +20,13 @@ import ( "gotest.tools/assert" - clientv1alpha1 "knative.dev/client/pkg/sources/v1alpha1" + "knative.dev/client/pkg/sources/v1alpha2" "knative.dev/client/pkg/util" ) func TestApiServerSourceDelete(t *testing.T) { - apiServerClient := clientv1alpha1.NewMockKnAPIServerSourceClient(t, "testns") + apiServerClient := v1alpha2.NewMockKnAPIServerSourceClient(t, "testns") apiServerRecorder := apiServerClient.Recorder() apiServerRecorder.DeleteAPIServerSource("testsource", nil) @@ -40,7 +40,7 @@ func TestApiServerSourceDelete(t *testing.T) { func TestDeleteWithError(t *testing.T) { - apiServerClient := clientv1alpha1.NewMockKnAPIServerSourceClient(t, "mynamespace") + apiServerClient := v1alpha2.NewMockKnAPIServerSourceClient(t, "mynamespace") apiServerRecorder := apiServerClient.Recorder() apiServerRecorder.DeleteAPIServerSource("testsource", errors.New("apiserver source testsource not found")) diff --git a/pkg/kn/commands/source/apiserver/describe.go b/pkg/kn/commands/source/apiserver/describe.go index de6aea9611..5605cb619b 100644 --- a/pkg/kn/commands/source/apiserver/describe.go +++ b/pkg/kn/commands/source/apiserver/describe.go @@ -17,11 +17,10 @@ package apiserver import ( "errors" "fmt" - "strconv" "github.com/spf13/cobra" - "knative.dev/eventing/pkg/apis/sources/v1alpha1" - duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" + v1alpha2 "knative.dev/eventing/pkg/apis/sources/v1alpha2" + duckv1 "knative.dev/pkg/apis/duck/v1" "knative.dev/client/pkg/kn/commands" "knative.dev/client/pkg/printers" @@ -94,16 +93,17 @@ func NewAPIServerDescribeCommand(p *commands.KnParams) *cobra.Command { return apiServerDescribe } -func writeResources(dw printers.PrefixWriter, resources []v1alpha1.ApiServerResource) { +func writeResources(dw printers.PrefixWriter, apiVersionKindSelectors []v1alpha2.APIVersionKindSelector) { subWriter := dw.WriteAttribute("Resources", "") - for _, resource := range resources { + for _, resource := range apiVersionKindSelectors { subWriter.WriteAttribute("Kind", fmt.Sprintf("%s (%s)", resource.Kind, resource.APIVersion)) - subWriter.WriteAttribute("Controller", strconv.FormatBool(resource.Controller)) - // TODO : Add Controller Selector section here for --verbose + if resource.LabelSelector != nil { + subWriter.WriteAttribute("Selector", labelSelectorToString(resource.LabelSelector)) + } } } -func writeSink(dw printers.PrefixWriter, sink *duckv1beta1.Destination) { +func writeSink(dw printers.PrefixWriter, sink duckv1.Destination) { subWriter := dw.WriteAttribute("Sink", "") subWriter.WriteAttribute("Name", sink.Ref.Name) subWriter.WriteAttribute("Namespace", sink.Ref.Namespace) @@ -117,8 +117,8 @@ func writeSink(dw printers.PrefixWriter, sink *duckv1beta1.Destination) { } } -func writeAPIServerSource(dw printers.PrefixWriter, source *v1alpha1.ApiServerSource, printDetails bool) { +func writeAPIServerSource(dw printers.PrefixWriter, source *v1alpha2.ApiServerSource, printDetails bool) { commands.WriteMetadata(dw, &source.ObjectMeta, printDetails) dw.WriteAttribute("ServiceAccountName", source.Spec.ServiceAccountName) - dw.WriteAttribute("Mode", source.Spec.Mode) + dw.WriteAttribute("EventMode", source.Spec.EventMode) } diff --git a/pkg/kn/commands/source/apiserver/describe_test.go b/pkg/kn/commands/source/apiserver/describe_test.go index 78ffe0ea7e..25abdc740a 100644 --- a/pkg/kn/commands/source/apiserver/describe_test.go +++ b/pkg/kn/commands/source/apiserver/describe_test.go @@ -20,26 +20,26 @@ import ( "gotest.tools/assert" - clientv1alpha1 "knative.dev/client/pkg/sources/v1alpha1" + "knative.dev/client/pkg/sources/v1alpha2" "knative.dev/client/pkg/util" ) func TestSimpleDescribe(t *testing.T) { - apiServerClient := clientv1alpha1.NewMockKnAPIServerSourceClient(t, "mynamespace") + apiServerClient := v1alpha2.NewMockKnAPIServerSourceClient(t, "mynamespace") apiServerRecorder := apiServerClient.Recorder() - sampleSource := createAPIServerSource("testsource", "Event", "v1", "testsa", "Ref", "testsvc", false) + sampleSource := createAPIServerSource("testsource", "Event", "v1", "testsa", "Reference", "testsvc", false) apiServerRecorder.GetAPIServerSource("testsource", sampleSource, nil) out, err := executeAPIServerSourceCommand(apiServerClient, nil, "describe", "testsource") assert.NilError(t, err) - util.ContainsAll(out, "testsource", "testsa", "Ref", "testsvc", "Service", "Resources", "Event", "v1", "false", "Conditions") + util.ContainsAll(out, "testsource", "testsa", "Reference", "testsvc", "Service", "Resources", "Event", "v1", "false", "Conditions") apiServerRecorder.Validate() } func TestDescribeError(t *testing.T) { - apiServerClient := clientv1alpha1.NewMockKnAPIServerSourceClient(t, "mynamespace") + apiServerClient := v1alpha2.NewMockKnAPIServerSourceClient(t, "mynamespace") apiServerRecorder := apiServerClient.Recorder() apiServerRecorder.GetAPIServerSource("testsource", nil, errors.New("no apiserver source testsource")) diff --git a/pkg/kn/commands/source/apiserver/flags.go b/pkg/kn/commands/source/apiserver/flags.go index 269912e94f..446a334371 100644 --- a/pkg/kn/commands/source/apiserver/flags.go +++ b/pkg/kn/commands/source/apiserver/flags.go @@ -18,14 +18,15 @@ import ( "fmt" "reflect" "sort" - "strconv" "strings" "github.com/spf13/cobra" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" - "knative.dev/eventing/pkg/apis/sources/v1alpha1" + v1alpha2 "knative.dev/eventing/pkg/apis/sources/v1alpha2" "knative.dev/client/pkg/kn/commands" + "knative.dev/client/pkg/kn/commands/flags" metav1beta1 "k8s.io/apimachinery/pkg/apis/meta/v1beta1" @@ -34,7 +35,9 @@ import ( ) const ( - apiVersionSplitChar = ":" + resourceSplitChar = ":" + labelSplitChar = "," + keyValueSplitChar = "=" ) // APIServerSourceUpdateFlags are flags for create and update a ApiServerSource @@ -44,11 +47,11 @@ type APIServerSourceUpdateFlags struct { Resources []string } -// getAPIServerResourceArray is to construct an array of resources. -func (f *APIServerSourceUpdateFlags) getAPIServerResourceArray() ([]v1alpha1.ApiServerResource, error) { - var resourceList []v1alpha1.ApiServerResource +// getAPIServerVersionKindSelector is to construct an array of resources. +func (f *APIServerSourceUpdateFlags) getAPIServerVersionKindSelector() ([]v1alpha2.APIVersionKindSelector, error) { + var resourceList []v1alpha2.APIVersionKindSelector for _, r := range f.Resources { - resourceSpec, err := getValidResource(r) + resourceSpec, err := getValidAPIVersionKindSelector(r) if err != nil { return nil, err } @@ -57,55 +60,60 @@ func (f *APIServerSourceUpdateFlags) getAPIServerResourceArray() ([]v1alpha1.Api return resourceList, nil } -// updateExistingAPIServerResourceArray is to update an array of resources. -func (f *APIServerSourceUpdateFlags) updateExistingAPIServerResourceArray(existing []v1alpha1.ApiServerResource) ([]v1alpha1.ApiServerResource, error) { - var found bool - - added, removed, err := f.getUpdateAPIServerResourceArray() +// updateExistingAPIVersionKindSelectorArray is to update an array of resources. +func (f *APIServerSourceUpdateFlags) updateExistingAPIVersionKindSelectorArray(existing []v1alpha2.APIVersionKindSelector) ([]v1alpha2.APIVersionKindSelector, error) { + added, removed, err := f.getUpdateAPIVersionKindSelectorArray() if err != nil { return nil, err } if existing == nil { - existing = []v1alpha1.ApiServerResource{} + existing = []v1alpha2.APIVersionKindSelector{} } existing = append(existing, added...) - for _, item := range removed { - found = false - for i, ref := range existing { + var updated []v1alpha2.APIVersionKindSelector +OUTER: + for _, ref := range existing { + for i, item := range removed { if reflect.DeepEqual(item, ref) { - existing = append(existing[:i], existing[i+1:]...) - found = true - break + removed = append(removed[:i], removed[i+1:]...) + continue OUTER } } - if !found { - return nil, fmt.Errorf("cannot find resource %s:%s:%t to remove", item.Kind, item.APIVersion, item.Controller) + updated = append(updated, ref) + } + + if len(removed) > 0 { + var errTxt []string + for _, item := range removed { + errTxt = append(errTxt, apiVersionKindSelectorToString(item)) } + return nil, fmt.Errorf("cannot find resources to remove: %s", strings.Join(errTxt, ", ")) } - return existing, nil + + return updated, nil } -// getUpdateAPIServerResourceArray is to construct an array of resources for update action. -func (f *APIServerSourceUpdateFlags) getUpdateAPIServerResourceArray() ([]v1alpha1.ApiServerResource, []v1alpha1.ApiServerResource, error) { +// getUpdateAPIVersionKindSelectorArray is to construct an array of resources for update action. +func (f *APIServerSourceUpdateFlags) getUpdateAPIVersionKindSelectorArray() ([]v1alpha2.APIVersionKindSelector, []v1alpha2.APIVersionKindSelector, error) { addedArray, removedArray := util.AddedAndRemovalListsFromArray(f.Resources) - added, err := constructApiServerResourceArray(addedArray) + added, err := constructAPIVersionKindSelector(addedArray) if err != nil { return nil, nil, err } - removed, err := constructApiServerResourceArray(removedArray) + removed, err := constructAPIVersionKindSelector(removedArray) if err != nil { return nil, nil, err } return added, removed, nil } -func constructApiServerResourceArray(s []string) ([]v1alpha1.ApiServerResource, error) { - array := make([]v1alpha1.ApiServerResource, 0) +func constructAPIVersionKindSelector(s []string) ([]v1alpha2.APIVersionKindSelector, error) { + array := make([]v1alpha2.APIVersionKindSelector, 0) for _, r := range s { - resourceSpec, err := getValidResource(r) + resourceSpec, err := getValidAPIVersionKindSelector(r) if err != nil { return array, err } @@ -114,31 +122,26 @@ func constructApiServerResourceArray(s []string) ([]v1alpha1.ApiServerResource, return array, nil } -//getValidResource is to parse resource spec from a string -func getValidResource(resource string) (*v1alpha1.ApiServerResource, error) { - var isController bool +//getValidAPIVersionKindSelector is to parse resource spec from a string +func getValidAPIVersionKindSelector(resource string) (*v1alpha2.APIVersionKindSelector, error) { var err error - parts := strings.SplitN(resource, apiVersionSplitChar, 3) + parts := strings.SplitN(resource, resourceSplitChar, 3) if len(parts[0]) == 0 { - return nil, fmt.Errorf("cannot find 'Kind' part in resource specification %s (expected: ", resource) + return nil, fmt.Errorf("cannot find 'kind' part in resource specification %s (expected: ", resource) } kind := parts[0] if len(parts) < 2 || len(parts[1]) == 0 { - return nil, fmt.Errorf("cannot find 'APIVersion' part in resource specification %s (expected: ", resource) + return nil, fmt.Errorf("cannot find 'APIVersion' part in resource specification %s (expected: ", resource) } version := parts[1] - if len(parts) >= 3 && len(parts[2]) > 0 { - isController, err = strconv.ParseBool(parts[2]) - if err != nil { - return nil, fmt.Errorf("controller flag is not a boolean in resource specification %s (expected: )", resource) - } - } else { - isController = false + labelSelector, err := extractLabelSelector(parts) + if err != nil { + return nil, err } - return &v1alpha1.ApiServerResource{Kind: kind, APIVersion: version, Controller: isController}, nil + return &v1alpha2.APIVersionKindSelector{Kind: kind, APIVersion: version, LabelSelector: labelSelector}, nil } //Add is to set parameters @@ -149,9 +152,9 @@ func (f *APIServerSourceUpdateFlags) Add(cmd *cobra.Command) { "Name of the service account to use to run this source") cmd.Flags().StringVar(&f.Mode, "mode", - "Ref", + "Reference", `The mode the receive adapter controller runs under:, -"Ref" sends only the reference to the resource, +"Reference" sends only the reference to the resource, "Resource" send the full resource.`) cmd.Flags().StringArrayVar(&f.Resources, "resource", @@ -177,7 +180,7 @@ func APIServerSourceListHandlers(h hprinters.PrintHandler) { } // printSource populates a single row of source apiserver list table -func printSource(source *v1alpha1.ApiServerSource, options hprinters.PrintOptions) ([]metav1beta1.TableRow, error) { +func printSource(source *v1alpha2.ApiServerSource, options hprinters.PrintOptions) ([]metav1beta1.TableRow, error) { row := metav1beta1.TableRow{ Object: runtime.RawExtension{Object: source}, } @@ -189,22 +192,13 @@ func printSource(source *v1alpha1.ApiServerSource, options hprinters.PrintOption reason := strings.TrimSpace(commands.NonReadyConditionReason(source.Status.Conditions)) var resources []string for _, resource := range source.Spec.Resources { - resources = append(resources, fmt.Sprintf("%s:%s:%s", resource.Kind, resource.APIVersion, strconv.FormatBool(resource.Controller))) + resources = append(resources, apiVersionKindSelectorToString(resource)) } // Not moving to SinkToString() as it references v1beta1.Destination // This source is going to be moved/removed soon to v1, so no need to move // it now - var sink string - if source.Spec.Sink != nil { - if source.Spec.Sink.Ref != nil { - if source.Spec.Sink.Ref.Kind == "Service" { - sink = fmt.Sprintf("svc:%s", source.Spec.Sink.Ref.Name) - } else { - sink = fmt.Sprintf("%s:%s", source.Spec.Sink.Ref.Kind, source.Spec.Sink.Ref.Name) - } - } - } + sink := flags.SinkToString(source.Spec.Sink) if options.AllNamespaces { row.Cells = append(row.Cells, source.Namespace) @@ -214,8 +208,40 @@ func printSource(source *v1alpha1.ApiServerSource, options hprinters.PrintOption return []metav1beta1.TableRow{row}, nil } +func apiVersionKindSelectorToString(apiVersionKindSelector v1alpha2.APIVersionKindSelector) string { + lTxt := labelSelectorToString(apiVersionKindSelector.LabelSelector) + if lTxt != "" { + lTxt = ":" + lTxt + } + return fmt.Sprintf("%s:%s%s", apiVersionKindSelector.Kind, apiVersionKindSelector.APIVersion, lTxt) +} + +func labelSelectorToString(labelSelector *v1.LabelSelector) string { + if labelSelector == nil { + return "" + } + labelsMap := labelSelector.MatchLabels + if len(labelsMap) != 9 { + keys := make([]string, 0, len(labelsMap)) + labels := make([]string, 0, len(labelsMap)) + for k := range labelsMap { + keys = append(keys, k) + } + sort.Strings(keys) + + for i, k := range keys { + labels[i] = k + "=" + labelsMap[k] + } + return strings.Join(labels, ",") + } + if len(labelSelector.MatchExpressions) > 0 { + return "[match expressions]" + } + return "" +} + // printSourceList populates the source apiserver list table rows -func printSourceList(sourceList *v1alpha1.ApiServerSourceList, options hprinters.PrintOptions) ([]metav1beta1.TableRow, error) { +func printSourceList(sourceList *v1alpha2.ApiServerSourceList, options hprinters.PrintOptions) ([]metav1beta1.TableRow, error) { if options.AllNamespaces { return printSourceListWithNamespace(sourceList, options) } @@ -238,7 +264,7 @@ func printSourceList(sourceList *v1alpha1.ApiServerSourceList, options hprinters } // printSourceListWithNamespace populates the knative service table rows with namespace column -func printSourceListWithNamespace(sourceList *v1alpha1.ApiServerSourceList, options hprinters.PrintOptions) ([]metav1beta1.TableRow, error) { +func printSourceListWithNamespace(sourceList *v1alpha2.ApiServerSourceList, options hprinters.PrintOptions) ([]metav1beta1.TableRow, error) { rows := make([]metav1beta1.TableRow, 0, len(sourceList.Items)) // temporary slice for sorting services in non-default namespace @@ -269,3 +295,21 @@ func printSourceListWithNamespace(sourceList *v1alpha1.ApiServerSourceList, opti return append(rows, others...), nil } + +func extractLabelSelector(parts []string) (*v1.LabelSelector, error) { + var labelSelector *v1.LabelSelector + if len(parts) >= 3 && len(parts[2]) > 0 { + labelParts := strings.Split(parts[2], labelSplitChar) + + labels := make(map[string]string) + for _, keyValue := range labelParts { + keyValueParts := strings.SplitN(keyValue, keyValueSplitChar, 2) + if len(keyValueParts) != 2 { + return nil, fmt.Errorf("invalid label selector in resource specification %s (expected: ", strings.Join(parts, resourceSplitChar)) + } + labels[keyValueParts[0]] = keyValueParts[1] + } + labelSelector = &v1.LabelSelector{MatchLabels: labels} + } + return labelSelector, nil +} diff --git a/pkg/kn/commands/source/apiserver/flags_test.go b/pkg/kn/commands/source/apiserver/flags_test.go index ba1f70d77b..7f4b7d00ac 100644 --- a/pkg/kn/commands/source/apiserver/flags_test.go +++ b/pkg/kn/commands/source/apiserver/flags_test.go @@ -18,21 +18,23 @@ import ( "testing" "gotest.tools/assert" - "knative.dev/eventing/pkg/apis/sources/v1alpha1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + v1alpha2 "knative.dev/eventing/pkg/apis/sources/v1alpha2" ) func TestGetAPIServerResourceArray(t *testing.T) { t.Run("get single apiserver resource", func(t *testing.T) { createFlag := APIServerSourceUpdateFlags{ ServiceAccountName: "test-sa", - Mode: "Ref", - Resources: []string{"Service:serving.knative.dev/v1:true"}, + Mode: "Reference", + Resources: []string{"Service:serving.knative.dev/v1:key1=val1"}, } - created, _ := createFlag.getAPIServerResourceArray() - wanted := []v1alpha1.ApiServerResource{{ - Kind: "Service", - APIVersion: "serving.knative.dev/v1", - Controller: true, + created, _ := createFlag.getAPIServerVersionKindSelector() + + wanted := []v1alpha2.APIVersionKindSelector{{ + Kind: "Service", + APIVersion: "serving.knative.dev/v1", + LabelSelector: createLabelSelector("key1", "val1"), }} assert.DeepEqual(t, wanted, created) }) @@ -40,14 +42,13 @@ func TestGetAPIServerResourceArray(t *testing.T) { t.Run("get single apiserver resource when isController is default", func(t *testing.T) { createFlag := APIServerSourceUpdateFlags{ ServiceAccountName: "test-sa", - Mode: "Ref", + Mode: "Reference", Resources: []string{"Service:serving.knative.dev/v1"}, } - created, _ := createFlag.getAPIServerResourceArray() - wanted := []v1alpha1.ApiServerResource{{ + created, _ := createFlag.getAPIServerVersionKindSelector() + wanted := []v1alpha2.APIVersionKindSelector{{ Kind: "Service", APIVersion: "serving.knative.dev/v1", - Controller: false, }} assert.DeepEqual(t, wanted, created) }) @@ -56,71 +57,68 @@ func TestGetAPIServerResourceArray(t *testing.T) { createFlag := APIServerSourceUpdateFlags{ ServiceAccountName: "test-sa", Mode: "Resource", - Resources: []string{"Event:v1:true", "Pod:v2:false"}, + Resources: []string{"Event:v1", "Pod:v2:key1=val1,key2=val2"}, } - created, _ := createFlag.getAPIServerResourceArray() - wanted := []v1alpha1.ApiServerResource{{ + created, _ := createFlag.getAPIServerVersionKindSelector() + wanted := []v1alpha2.APIVersionKindSelector{{ Kind: "Event", APIVersion: "v1", - Controller: true, }, { - Kind: "Pod", - APIVersion: "v2", - Controller: false, + Kind: "Pod", + APIVersion: "v2", + LabelSelector: createLabelSelector("key1", "val1", "key2", "val2"), }} assert.DeepEqual(t, wanted, created) }) - t.Run("get multiple apiserver resources when isController is default", func(t *testing.T) { + t.Run("get multiple apiserver resources without label selector", func(t *testing.T) { createFlag := APIServerSourceUpdateFlags{ ServiceAccountName: "test-sa", Mode: "Resource", Resources: []string{"Event:v1", "Pod:v1"}, } - created, _ := createFlag.getAPIServerResourceArray() + created, _ := createFlag.getAPIServerVersionKindSelector() - wanted := []v1alpha1.ApiServerResource{{ + wanted := []v1alpha2.APIVersionKindSelector{{ Kind: "Event", APIVersion: "v1", - Controller: false, }, { Kind: "Pod", APIVersion: "v1", - Controller: false, }} assert.DeepEqual(t, wanted, created) }) - t.Run("get apiserver resource when isController has error", func(t *testing.T) { + t.Run("get apiserver resource when label controller has error", func(t *testing.T) { createFlag := APIServerSourceUpdateFlags{ ServiceAccountName: "test-sa", - Mode: "Ref", - Resources: []string{"Event:v1:xxx"}, + Mode: "Reference", + Resources: []string{"Event:v1:xxx,bla"}, } - _, err := createFlag.getAPIServerResourceArray() - errorMsg := "controller flag is not a boolean in resource specification Event:v1:xxx (expected: )" + _, err := createFlag.getAPIServerVersionKindSelector() + errorMsg := "invalid label selector in resource specification Event:v1:xxx,bla (expected: " assert.Error(t, err, errorMsg) }) t.Run("get apiserver resources when kind has error", func(t *testing.T) { createFlag := APIServerSourceUpdateFlags{ ServiceAccountName: "test-sa", - Mode: "Ref", - Resources: []string{":v2:true"}, + Mode: "Reference", + Resources: []string{":v2"}, } - _, err := createFlag.getAPIServerResourceArray() - errorMsg := "cannot find 'Kind' part in resource specification :v2:true (expected: " + _, err := createFlag.getAPIServerVersionKindSelector() + errorMsg := "cannot find 'kind' part in resource specification :v2 (expected: " assert.Error(t, err, errorMsg) }) t.Run("get apiserver resources when APIVersion has error", func(t *testing.T) { createFlag := APIServerSourceUpdateFlags{ ServiceAccountName: "test-sa", - Mode: "Ref", + Mode: "Reference", Resources: []string{"kind"}, } - _, err := createFlag.getAPIServerResourceArray() - errorMsg := "cannot find 'APIVersion' part in resource specification kind (expected: " + _, err := createFlag.getAPIServerVersionKindSelector() + errorMsg := "cannot find 'APIVersion' part in resource specification kind (expected: " assert.Error(t, err, errorMsg) }) } @@ -130,18 +128,16 @@ func TestGetUpdateAPIServerResourceArray(t *testing.T) { createFlag := APIServerSourceUpdateFlags{ ServiceAccountName: "test-sa", Mode: "Resource", - Resources: []string{"Event:v1:true", "Pod:v2:false-"}, + Resources: []string{"Event:v1", "Pod:v2-"}, } - added, removed, _ := createFlag.getUpdateAPIServerResourceArray() - addwanted := []v1alpha1.ApiServerResource{{ + added, removed, _ := createFlag.getUpdateAPIVersionKindSelectorArray() + addwanted := []v1alpha2.APIVersionKindSelector{{ Kind: "Event", APIVersion: "v1", - Controller: true, }} - removewanted := []v1alpha1.ApiServerResource{{ + removewanted := []v1alpha2.APIVersionKindSelector{{ Kind: "Pod", APIVersion: "v2", - Controller: false, }} assert.DeepEqual(t, added, addwanted) assert.DeepEqual(t, removed, removewanted) @@ -150,19 +146,18 @@ func TestGetUpdateAPIServerResourceArray(t *testing.T) { createFlag = APIServerSourceUpdateFlags{ ServiceAccountName: "test-sa", Mode: "Resource", - Resources: []string{"Event:v1-", "Pod:v1"}, + Resources: []string{"Event:v1:key1=val1,key2=val2-", "Pod:v1"}, } - added, removed, _ = createFlag.getUpdateAPIServerResourceArray() + added, removed, _ = createFlag.getUpdateAPIVersionKindSelectorArray() - removewanted = []v1alpha1.ApiServerResource{{ - Kind: "Event", - APIVersion: "v1", - Controller: false, + removewanted = []v1alpha2.APIVersionKindSelector{{ + Kind: "Event", + APIVersion: "v1", + LabelSelector: createLabelSelector("key1", "val1", "key2", "val2"), }} - addwanted = []v1alpha1.ApiServerResource{{ + addwanted = []v1alpha2.APIVersionKindSelector{{ Kind: "Pod", APIVersion: "v1", - Controller: false, }} assert.DeepEqual(t, added, addwanted) assert.DeepEqual(t, removed, removewanted) @@ -170,31 +165,28 @@ func TestGetUpdateAPIServerResourceArray(t *testing.T) { } func TestUpdateExistingAPIServerResourceArray(t *testing.T) { - existing := []v1alpha1.ApiServerResource{{ + existing := []v1alpha2.APIVersionKindSelector{{ Kind: "Event", APIVersion: "v1", - Controller: false, }, { Kind: "Pod", APIVersion: "v1", - Controller: false, }} t.Run("update existing apiserver resources", func(t *testing.T) { createFlag := APIServerSourceUpdateFlags{ ServiceAccountName: "test-sa", Mode: "Resource", - Resources: []string{"Deployment:v1:true", "Pod:v1:false-"}, + Resources: []string{"Deployment:v1:key1=val1,key2=val2", "Pod:v1-"}, } - updated, _ := createFlag.updateExistingAPIServerResourceArray(existing) - updatedWanted := []v1alpha1.ApiServerResource{{ + updated, _ := createFlag.updateExistingAPIVersionKindSelectorArray(existing) + updatedWanted := []v1alpha2.APIVersionKindSelector{{ Kind: "Event", APIVersion: "v1", - Controller: false, }, { - Kind: "Deployment", - APIVersion: "v1", - Controller: true, + Kind: "Deployment", + APIVersion: "v1", + LabelSelector: createLabelSelector("key1", "val1", "key2", "val2"), }} assert.DeepEqual(t, updated, updatedWanted) }) @@ -203,10 +195,18 @@ func TestUpdateExistingAPIServerResourceArray(t *testing.T) { createFlag := APIServerSourceUpdateFlags{ ServiceAccountName: "test-sa", Mode: "Resource", - Resources: []string{"Deployment:v1:true", "Pod:v2:false-"}, + Resources: []string{"Deployment:v1", "Pod:v2-"}, } - _, err := createFlag.updateExistingAPIServerResourceArray(existing) - errorMsg := "cannot find resource Pod:v2:false to remove" + _, err := createFlag.updateExistingAPIVersionKindSelectorArray(existing) + errorMsg := "cannot find resources to remove: Pod:v2" assert.Error(t, err, errorMsg) }) } + +func createLabelSelector(keyAndVal ...string) *metav1.LabelSelector { + labels := make(map[string]string) + for i := 0; i < len(keyAndVal); i += 2 { + labels[keyAndVal[i]] = keyAndVal[i+1] + } + return &metav1.LabelSelector{MatchLabels: labels} +} diff --git a/pkg/kn/commands/source/apiserver/list_test.go b/pkg/kn/commands/source/apiserver/list_test.go index aef95dd7d3..b5419226b0 100644 --- a/pkg/kn/commands/source/apiserver/list_test.go +++ b/pkg/kn/commands/source/apiserver/list_test.go @@ -19,19 +19,19 @@ import ( "gotest.tools/assert" - "knative.dev/eventing/pkg/apis/sources/v1alpha1" + v1alpha2 "knative.dev/eventing/pkg/apis/sources/v1alpha2" - clientv1alpha1 "knative.dev/client/pkg/sources/v1alpha1" + v1alpha22 "knative.dev/client/pkg/sources/v1alpha2" "knative.dev/client/pkg/util" ) func TestListAPIServerSource(t *testing.T) { - apiServerClient := clientv1alpha1.NewMockKnAPIServerSourceClient(t) + apiServerClient := v1alpha22.NewMockKnAPIServerSourceClient(t) apiServerRecorder := apiServerClient.Recorder() - sampleSource := createAPIServerSource("testsource", "Event", "v1", "testsa", "Ref", "testsvc", false) - sampleSourceList := v1alpha1.ApiServerSourceList{} - sampleSourceList.Items = []v1alpha1.ApiServerSource{*sampleSource} + sampleSource := createAPIServerSource("testsource", "Event", "v1", "testsa", "Reference", "testsvc", false) + sampleSourceList := v1alpha2.ApiServerSourceList{} + sampleSourceList.Items = []v1alpha2.ApiServerSource{*sampleSource} apiServerRecorder.ListAPIServerSource(&sampleSourceList, nil) @@ -44,10 +44,10 @@ func TestListAPIServerSource(t *testing.T) { } func TestListAPIServerSourceEmpty(t *testing.T) { - apiServerClient := clientv1alpha1.NewMockKnAPIServerSourceClient(t) + apiServerClient := v1alpha22.NewMockKnAPIServerSourceClient(t) apiServerRecorder := apiServerClient.Recorder() - sampleSourceList := v1alpha1.ApiServerSourceList{} + sampleSourceList := v1alpha2.ApiServerSourceList{} apiServerRecorder.ListAPIServerSource(&sampleSourceList, nil) diff --git a/pkg/kn/commands/source/apiserver/update.go b/pkg/kn/commands/source/apiserver/update.go index 9d0fec5073..146dc1cf12 100644 --- a/pkg/kn/commands/source/apiserver/update.go +++ b/pkg/kn/commands/source/apiserver/update.go @@ -22,7 +22,7 @@ import ( "knative.dev/client/pkg/kn/commands" "knative.dev/client/pkg/kn/commands/flags" - clientv1alpha1 "knative.dev/client/pkg/sources/v1alpha1" + "knative.dev/client/pkg/sources/v1alpha2" ) // NewAPIServerUpdateCommand for managing source update @@ -64,17 +64,17 @@ func NewAPIServerUpdateCommand(p *commands.KnParams) *cobra.Command { return err } - b := clientv1alpha1.NewAPIServerSourceBuilderFromExisting(source) + b := v1alpha2.NewAPIServerSourceBuilderFromExisting(source) if cmd.Flags().Changed("service-account") { b.ServiceAccount(apiServerUpdateFlags.ServiceAccountName) } if cmd.Flags().Changed("mode") { - b.Mode(apiServerUpdateFlags.Mode) + b.EventMode(apiServerUpdateFlags.Mode) } if cmd.Flags().Changed("resource") { - updateExisting, err := apiServerUpdateFlags.updateExistingAPIServerResourceArray(source.Spec.Resources) + updateExisting, err := apiServerUpdateFlags.updateExistingAPIVersionKindSelectorArray(source.Spec.Resources) if err != nil { return err } @@ -86,7 +86,7 @@ func NewAPIServerUpdateCommand(p *commands.KnParams) *cobra.Command { if err != nil { return err } - b.Sink(toDuckV1Beta1(objectRef)) + b.Sink(*objectRef) } err = sourcesClient.UpdateAPIServerSource(b.Build()) diff --git a/pkg/kn/commands/source/apiserver/update_test.go b/pkg/kn/commands/source/apiserver/update_test.go index fd0093d01f..3b6bf807fd 100644 --- a/pkg/kn/commands/source/apiserver/update_test.go +++ b/pkg/kn/commands/source/apiserver/update_test.go @@ -23,12 +23,12 @@ import ( servingv1 "knative.dev/serving/pkg/apis/serving/v1" dynamicfake "knative.dev/client/pkg/dynamic/fake" - clientsourcesv1alpha1 "knative.dev/client/pkg/sources/v1alpha1" + "knative.dev/client/pkg/sources/v1alpha2" "knative.dev/client/pkg/util" ) func TestApiServerSourceUpdate(t *testing.T) { - apiServerClient := clientsourcesv1alpha1.NewMockKnAPIServerSourceClient(t) + apiServerClient := v1alpha2.NewMockKnAPIServerSourceClient(t) dynamicClient := dynamicfake.CreateFakeKnDynamicClient("default", &servingv1.Service{ TypeMeta: metav1.TypeMeta{Kind: "Service", APIVersion: "serving.knative.dev/v1"}, ObjectMeta: metav1.ObjectMeta{Name: "svc2", Namespace: "default"}, @@ -36,10 +36,10 @@ func TestApiServerSourceUpdate(t *testing.T) { apiServerRecorder := apiServerClient.Recorder() - present := createAPIServerSource("testsource", "Event", "v1", "testsa1", "Ref", "svc1", false) + present := createAPIServerSource("testsource", "Event", "v1", "testsa1", "Reference", "svc1", false) apiServerRecorder.GetAPIServerSource("testsource", present, nil) - updated := createAPIServerSource("testsource", "Event", "v1", "testsa2", "Ref", "svc2", false) + updated := createAPIServerSource("testsource", "Event", "v1", "testsa2", "Reference", "svc2", false) apiServerRecorder.UpdateAPIServerSource(updated, nil) output, err := executeAPIServerSourceCommand(apiServerClient, dynamicClient, "update", "testsource", "--service-account", "testsa2", "--sink", "svc:svc2") diff --git a/pkg/kn/commands/source/duck/multisourcelist.go b/pkg/kn/commands/source/duck/multisourcelist.go index dd02f908a9..707064bdd8 100644 --- a/pkg/kn/commands/source/duck/multisourcelist.go +++ b/pkg/kn/commands/source/duck/multisourcelist.go @@ -22,10 +22,8 @@ import ( "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" - eventinglegacy "knative.dev/eventing/pkg/apis/legacysources/v1alpha1" - sourcesv1alpha1 "knative.dev/eventing/pkg/apis/sources/v1alpha1" - pkgduck "knative.dev/pkg/apis/duck" - pkgduckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" + sourcesv1alpha2 "knative.dev/eventing/pkg/apis/sources/v1alpha2" + duck "knative.dev/pkg/apis/duck" "knative.dev/client/pkg/kn/commands" "knative.dev/client/pkg/kn/commands/flags" @@ -108,24 +106,19 @@ func getSourceTypeName(source *unstructured.Unstructured) string { func findSink(source *unstructured.Unstructured) string { switch source.GetKind() { case "ApiServerSource": - var apiSource eventinglegacy.ApiServerSource - if err := pkgduck.FromUnstructured(source, &apiSource); err == nil { - return sinkToString(apiSource.Spec.Sink) - } - case "CronJobSource": - var cronSource eventinglegacy.CronJobSource - if err := pkgduck.FromUnstructured(source, &cronSource); err == nil { - return sinkToString(cronSource.Spec.Sink) + var apiSource sourcesv1alpha2.ApiServerSource + if err := duck.FromUnstructured(source, &apiSource); err == nil { + return flags.SinkToString(apiSource.Spec.Sink) } case "SinkBinding": - var binding sourcesv1alpha1.SinkBinding - if err := pkgduck.FromUnstructured(source, &binding); err == nil { + var binding sourcesv1alpha2.SinkBinding + if err := duck.FromUnstructured(source, &binding); err == nil { return flags.SinkToString(binding.Spec.Sink) } case "PingSource": - var pingSource sourcesv1alpha1.PingSource - if err := pkgduck.FromUnstructured(source, &pingSource); err == nil { - return flags.SinkToString(*pingSource.Spec.Sink) + var pingSource sourcesv1alpha2.PingSource + if err := duck.FromUnstructured(source, &pingSource); err == nil { + return flags.SinkToString(pingSource.Spec.Sink) } } // TODO: Find out how to find sink in untyped sources @@ -135,43 +128,21 @@ func findSink(source *unstructured.Unstructured) string { func isReady(source *unstructured.Unstructured) string { switch source.GetKind() { case "ApiServerSource": - var tSource eventinglegacy.ApiServerSource - if err := pkgduck.FromUnstructured(source, &tSource); err == nil { - return commands.ReadyCondition(tSource.Status.Conditions) - } - case "CronJobSource": - var tSource eventinglegacy.CronJobSource - if err := pkgduck.FromUnstructured(source, &tSource); err == nil { + var tSource sourcesv1alpha2.ApiServerSource + if err := duck.FromUnstructured(source, &tSource); err == nil { return commands.ReadyCondition(tSource.Status.Conditions) } case "SinkBinding": - var tSource eventinglegacy.SinkBinding - if err := pkgduck.FromUnstructured(source, &tSource); err == nil { + var tSource sourcesv1alpha2.SinkBinding + if err := duck.FromUnstructured(source, &tSource); err == nil { return commands.ReadyCondition(tSource.Status.Conditions) } case "PingSource": - var tSource sourcesv1alpha1.PingSource - if err := pkgduck.FromUnstructured(source, &tSource); err == nil { + var tSource sourcesv1alpha2.PingSource + if err := duck.FromUnstructured(source, &tSource); err == nil { return commands.ReadyCondition(tSource.Status.Conditions) } } // TODO: Find out how to find ready conditions for untyped sources return "" } - -// temporary sinkToString for deprecated sources -func sinkToString(sink *pkgduckv1beta1.Destination) string { - if sink != nil { - if sink.Ref != nil { - if sink.Ref.Kind == "Service" { - return fmt.Sprintf("svc:%s", sink.Ref.Name) - } - return fmt.Sprintf("%s:%s", strings.ToLower(sink.Ref.Kind), sink.Ref.Name) - } - - if sink.URI != nil { - return sink.URI.String() - } - } - return "" -} diff --git a/pkg/kn/commands/source/list_test.go b/pkg/kn/commands/source/list_test.go index 30c15a84f4..48d732ee0b 100644 --- a/pkg/kn/commands/source/list_test.go +++ b/pkg/kn/commands/source/list_test.go @@ -76,18 +76,15 @@ func TestSourceList(t *testing.T) { newSourceCRDObjWithSpec("pingsources", "sources.knative.dev", "v1alpha1", "PingSource"), newSourceCRDObjWithSpec("sinkbindings", "sources.knative.dev", "v1alpha1", "SinkBinding"), newSourceCRDObjWithSpec("apiserversources", "sources.knative.dev", "v1alpha1", "ApiServerSource"), - newSourceCRDObjWithSpec("cronjobsources", "sources.eventing.knative.dev", "v1alpha1", "CronJobSource"), newSourceUnstructuredObj("p1", "sources.knative.dev/v1alpha1", "PingSource"), newSourceUnstructuredObj("s1", "sources.knative.dev/v1alpha1", "SinkBinding"), newSourceUnstructuredObj("a1", "sources.knative.dev/v1alpha1", "ApiServerSource"), - newSourceUnstructuredObj("c1", "sources.eventing.knative.dev/v1alpha1", "CronJobSource"), ) assert.NilError(t, err) assert.Check(t, util.ContainsAll(output[0], "NAME", "TYPE", "RESOURCE", "SINK", "READY")) assert.Check(t, util.ContainsAll(output[1], "a1", "ApiServerSource", "apiserversources.sources.knative.dev", "svc:foo", "")) - assert.Check(t, util.ContainsAll(output[2], "c1", "CronJobSource", "cronjobsources.sources.eventing.knative.dev", "svc:foo", "")) - assert.Check(t, util.ContainsAll(output[3], "p1", "PingSource", "pingsources.sources.knative.dev", "svc:foo", "")) - assert.Check(t, util.ContainsAll(output[4], "s1", "SinkBinding", "sinkbindings.sources.knative.dev", "svc:foo", "")) + assert.Check(t, util.ContainsAll(output[2], "p1", "PingSource", "pingsources.sources.knative.dev", "svc:foo", "")) + assert.Check(t, util.ContainsAll(output[3], "s1", "SinkBinding", "sinkbindings.sources.knative.dev", "svc:foo", "")) } func TestSourceListNoHeaders(t *testing.T) { diff --git a/pkg/kn/commands/version/version.go b/pkg/kn/commands/version/version.go index 7d5149d7ad..9b53131302 100644 --- a/pkg/kn/commands/version/version.go +++ b/pkg/kn/commands/version/version.go @@ -31,12 +31,12 @@ var GitRevision string // update this var as we add more deps var apiVersions = map[string][]string{ "serving": { - "serving.knative.dev/v1 (knative-serving v0.13.2)", + "serving.knative.dev/v1 (knative-serving v0.14.0)", }, "eventing": { - "sources.eventing.knative.dev/v1alpha1 (knative-eventing v0.13.6)", - "sources.eventing.knative.dev/v1alpha2 (knative-eventing v0.13.6)", - "eventing.knative.dev/v1alpha1 (knative-eventing v0.13.6)", + "sources.knative.dev/v1alpha1 (knative-eventing v0.14.0)", + "sources.knative.dev/v1alpha2 (knative-eventing v0.14.0)", + "eventing.knative.dev/v1alpha1 (knative-eventing v0.14.0)", }, } diff --git a/pkg/sources/v1alpha1/client.go b/pkg/sources/v1alpha1/client.go deleted file mode 100644 index e87df1b6d0..0000000000 --- a/pkg/sources/v1alpha1/client.go +++ /dev/null @@ -1,47 +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 ( - clientv1alpha1 "knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha1" -) - -// KnSinkBindingClient to Eventing Sources. All methods are relative to the -// namespace specified during construction -type KnSourcesClient interface { - // Get client for ApiServer sources - APIServerSourcesClient() KnAPIServerSourcesClient -} - -// sourcesClient is a combination of Sources client interface and namespace -// Temporarily help to add sources dependencies -// May be changed when adding real sources features -type sourcesClient struct { - client clientv1alpha1.SourcesV1alpha1Interface - namespace string -} - -// NewKnSourcesClient for managing all eventing built-in sources -func NewKnSourcesClient(client clientv1alpha1.SourcesV1alpha1Interface, namespace string) KnSourcesClient { - return &sourcesClient{ - client: client, - namespace: namespace, - } -} - -// ApiServerSourcesClient for dealing with ApiServer sources -func (c *sourcesClient) APIServerSourcesClient() KnAPIServerSourcesClient { - return newKnAPIServerSourcesClient(c.client.ApiServerSources(c.namespace), c.namespace) -} diff --git a/pkg/sources/v1alpha1/apiserver_client.go b/pkg/sources/v1alpha2/apiserver_client.go similarity index 74% rename from pkg/sources/v1alpha1/apiserver_client.go rename to pkg/sources/v1alpha2/apiserver_client.go index cc0a8cd228..8fafb34308 100644 --- a/pkg/sources/v1alpha1/apiserver_client.go +++ b/pkg/sources/v1alpha2/apiserver_client.go @@ -12,14 +12,14 @@ // See the License for the specific language governing permissions and // limitations under the License. -package v1alpha1 +package v1alpha2 import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" - v1alpha1 "knative.dev/eventing/pkg/apis/sources/v1alpha1" - clientv1alpha1 "knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha1" - duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" + v1alpha2 "knative.dev/eventing/pkg/apis/sources/v1alpha2" + clientv1alpha2 "knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha2" + duckv1 "knative.dev/pkg/apis/duck/v1" "knative.dev/eventing/pkg/client/clientset/versioned/scheme" @@ -31,20 +31,20 @@ import ( type KnAPIServerSourcesClient interface { // Get an ApiServerSource by name - GetAPIServerSource(name string) (*v1alpha1.ApiServerSource, error) + GetAPIServerSource(name string) (*v1alpha2.ApiServerSource, error) // Create an ApiServerSource by object - CreateAPIServerSource(apiSource *v1alpha1.ApiServerSource) error + CreateAPIServerSource(apiSource *v1alpha2.ApiServerSource) error // Update an ApiServerSource by object - UpdateAPIServerSource(apiSource *v1alpha1.ApiServerSource) error + UpdateAPIServerSource(apiSource *v1alpha2.ApiServerSource) error // Delete an ApiServerSource by name DeleteAPIServerSource(name string) error // List ApiServerSource // TODO: Support list configs like in service list - ListAPIServerSource() (*v1alpha1.ApiServerSourceList, error) + ListAPIServerSource() (*v1alpha2.ApiServerSourceList, error) // Get namespace for this client Namespace() string @@ -54,12 +54,12 @@ type KnAPIServerSourcesClient interface { // Temporarily help to add sources dependencies // May be changed when adding real sources features type apiServerSourcesClient struct { - client clientv1alpha1.ApiServerSourceInterface + client clientv1alpha2.ApiServerSourceInterface namespace string } // newKnAPIServerSourcesClient is to invoke Eventing Sources Client API to create object -func newKnAPIServerSourcesClient(client clientv1alpha1.ApiServerSourceInterface, namespace string) KnAPIServerSourcesClient { +func newKnAPIServerSourcesClient(client clientv1alpha2.ApiServerSourceInterface, namespace string) KnAPIServerSourcesClient { return &apiServerSourcesClient{ client: client, namespace: namespace, @@ -67,7 +67,7 @@ func newKnAPIServerSourcesClient(client clientv1alpha1.ApiServerSourceInterface, } //GetAPIServerSource returns apiSource object if present -func (c *apiServerSourcesClient) GetAPIServerSource(name string) (*v1alpha1.ApiServerSource, error) { +func (c *apiServerSourcesClient) GetAPIServerSource(name string) (*v1alpha2.ApiServerSource, error) { apiSource, err := c.client.Get(name, metav1.GetOptions{}) if err != nil { return nil, knerrors.GetError(err) @@ -77,7 +77,7 @@ func (c *apiServerSourcesClient) GetAPIServerSource(name string) (*v1alpha1.ApiS } //CreateAPIServerSource is used to create an instance of ApiServerSource -func (c *apiServerSourcesClient) CreateAPIServerSource(apiSource *v1alpha1.ApiServerSource) error { +func (c *apiServerSourcesClient) CreateAPIServerSource(apiSource *v1alpha2.ApiServerSource) error { _, err := c.client.Create(apiSource) if err != nil { return knerrors.GetError(err) @@ -87,7 +87,7 @@ func (c *apiServerSourcesClient) CreateAPIServerSource(apiSource *v1alpha1.ApiSe } //UpdateAPIServerSource is used to update an instance of ApiServerSource -func (c *apiServerSourcesClient) UpdateAPIServerSource(apiSource *v1alpha1.ApiServerSource) error { +func (c *apiServerSourcesClient) UpdateAPIServerSource(apiSource *v1alpha2.ApiServerSource) error { _, err := c.client.Update(apiSource) if err != nil { return knerrors.GetError(err) @@ -108,7 +108,7 @@ func (c *apiServerSourcesClient) Namespace() string { } // ListAPIServerSource returns the available ApiServer type sources -func (c *apiServerSourcesClient) ListAPIServerSource() (*v1alpha1.ApiServerSourceList, error) { +func (c *apiServerSourcesClient) ListAPIServerSource() (*v1alpha2.ApiServerSourceList, error) { sourceList, err := c.client.List(metav1.ListOptions{}) if err != nil { return nil, err @@ -117,14 +117,14 @@ func (c *apiServerSourcesClient) ListAPIServerSource() (*v1alpha1.ApiServerSourc return updateAPIServerSourceListGVK(sourceList) } -func updateAPIServerSourceListGVK(sourceList *v1alpha1.ApiServerSourceList) (*v1alpha1.ApiServerSourceList, error) { +func updateAPIServerSourceListGVK(sourceList *v1alpha2.ApiServerSourceList) (*v1alpha2.ApiServerSourceList, error) { sourceListNew := sourceList.DeepCopy() err := updateSourceGVK(sourceListNew) if err != nil { return nil, err } - sourceListNew.Items = make([]v1alpha1.ApiServerSource, len(sourceList.Items)) + sourceListNew.Items = make([]v1alpha2.ApiServerSource, len(sourceList.Items)) for idx, source := range sourceList.Items { sourceClone := source.DeepCopy() err := updateSourceGVK(sourceClone) @@ -137,17 +137,17 @@ func updateAPIServerSourceListGVK(sourceList *v1alpha1.ApiServerSourceList) (*v1 } func updateSourceGVK(obj runtime.Object) error { - return util.UpdateGroupVersionKindWithScheme(obj, v1alpha1.SchemeGroupVersion, scheme.Scheme) + return util.UpdateGroupVersionKindWithScheme(obj, v1alpha2.SchemeGroupVersion, scheme.Scheme) } // APIServerSourceBuilder is for building the source type APIServerSourceBuilder struct { - apiServerSource *v1alpha1.ApiServerSource + apiServerSource *v1alpha2.ApiServerSource } // NewAPIServerSourceBuilder for building ApiServer source object func NewAPIServerSourceBuilder(name string) *APIServerSourceBuilder { - return &APIServerSourceBuilder{apiServerSource: &v1alpha1.ApiServerSource{ + return &APIServerSourceBuilder{apiServerSource: &v1alpha2.ApiServerSource{ ObjectMeta: metav1.ObjectMeta{ Name: name, }, @@ -155,12 +155,12 @@ func NewAPIServerSourceBuilder(name string) *APIServerSourceBuilder { } // NewAPIServerSourceBuilderFromExisting for building the object from existing ApiServerSource object -func NewAPIServerSourceBuilderFromExisting(apiServerSource *v1alpha1.ApiServerSource) *APIServerSourceBuilder { +func NewAPIServerSourceBuilderFromExisting(apiServerSource *v1alpha2.ApiServerSource) *APIServerSourceBuilder { return &APIServerSourceBuilder{apiServerSource: apiServerSource.DeepCopy()} } // Resources which should be streamed -func (b *APIServerSourceBuilder) Resources(resources []v1alpha1.ApiServerResource) *APIServerSourceBuilder { +func (b *APIServerSourceBuilder) Resources(resources []v1alpha2.APIVersionKindSelector) *APIServerSourceBuilder { b.apiServerSource.Spec.Resources = resources return b } @@ -171,19 +171,19 @@ func (b *APIServerSourceBuilder) ServiceAccount(sa string) *APIServerSourceBuild return b } -// Mode for whether to send resource 'Ref' or complete 'Resource' -func (b *APIServerSourceBuilder) Mode(mode string) *APIServerSourceBuilder { - b.apiServerSource.Spec.Mode = mode +// EventMode for whether to send resource 'Ref' or complete 'Resource' +func (b *APIServerSourceBuilder) EventMode(eventMode string) *APIServerSourceBuilder { + b.apiServerSource.Spec.EventMode = eventMode return b } // Sink or destination of the source -func (b *APIServerSourceBuilder) Sink(sink *duckv1beta1.Destination) *APIServerSourceBuilder { +func (b *APIServerSourceBuilder) Sink(sink duckv1.Destination) *APIServerSourceBuilder { b.apiServerSource.Spec.Sink = sink return b } // Build the ApiServerSource object -func (b *APIServerSourceBuilder) Build() *v1alpha1.ApiServerSource { +func (b *APIServerSourceBuilder) Build() *v1alpha2.ApiServerSource { return b.apiServerSource } diff --git a/pkg/sources/v1alpha1/apiserver_client_mock.go b/pkg/sources/v1alpha2/apiserver_client_mock.go similarity index 90% rename from pkg/sources/v1alpha1/apiserver_client_mock.go rename to pkg/sources/v1alpha2/apiserver_client_mock.go index 2fad1ecd9e..9066182a9b 100644 --- a/pkg/sources/v1alpha1/apiserver_client_mock.go +++ b/pkg/sources/v1alpha2/apiserver_client_mock.go @@ -12,12 +12,12 @@ // See the License for the specific language governing permissions and // limitations under the License. -package v1alpha1 +package v1alpha2 import ( "testing" - v1alpha1 "knative.dev/eventing/pkg/apis/sources/v1alpha1" + v1alpha2 "knative.dev/eventing/pkg/apis/sources/v1alpha2" "knative.dev/client/pkg/util/mock" ) @@ -60,14 +60,14 @@ func (c *MockKnAPIServerSourceClient) Namespace() string { } // GetAPIServerSource records a call for GetApiServerSource with the expected object or error. Either apiServerSource or err should be nil -func (sr *APIServerSourcesRecorder) GetAPIServerSource(name interface{}, apiServerSource *v1alpha1.ApiServerSource, err error) { +func (sr *APIServerSourcesRecorder) GetAPIServerSource(name interface{}, apiServerSource *v1alpha2.ApiServerSource, err error) { sr.r.Add("GetApiServerSource", []interface{}{name}, []interface{}{apiServerSource, err}) } // GetAPIServerSource performs a previously recorded action, failing if non has been registered -func (c *MockKnAPIServerSourceClient) GetAPIServerSource(name string) (*v1alpha1.ApiServerSource, error) { +func (c *MockKnAPIServerSourceClient) GetAPIServerSource(name string) (*v1alpha2.ApiServerSource, error) { call := c.recorder.r.VerifyCall("GetApiServerSource", name) - return call.Result[0].(*v1alpha1.ApiServerSource), mock.ErrorOrNil(call.Result[1]) + return call.Result[0].(*v1alpha2.ApiServerSource), mock.ErrorOrNil(call.Result[1]) } // CreateAPIServerSource records a call for CreateApiServerSource with the expected error @@ -76,7 +76,7 @@ func (sr *APIServerSourcesRecorder) CreateAPIServerSource(apiServerSource interf } // CreateAPIServerSource performs a previously recorded action, failing if non has been registered -func (c *MockKnAPIServerSourceClient) CreateAPIServerSource(apiServerSource *v1alpha1.ApiServerSource) error { +func (c *MockKnAPIServerSourceClient) CreateAPIServerSource(apiServerSource *v1alpha2.ApiServerSource) error { call := c.recorder.r.VerifyCall("CreateApiServerSource", apiServerSource) return mock.ErrorOrNil(call.Result[0]) } @@ -87,7 +87,7 @@ func (sr *APIServerSourcesRecorder) UpdateAPIServerSource(apiServerSource interf } // UpdateAPIServerSource performs a previously recorded action, failing if non has been registered -func (c *MockKnAPIServerSourceClient) UpdateAPIServerSource(apiServerSource *v1alpha1.ApiServerSource) error { +func (c *MockKnAPIServerSourceClient) UpdateAPIServerSource(apiServerSource *v1alpha2.ApiServerSource) error { call := c.recorder.r.VerifyCall("UpdateAPIServerSource", apiServerSource) return mock.ErrorOrNil(call.Result[0]) } @@ -104,14 +104,14 @@ func (c *MockKnAPIServerSourceClient) DeleteAPIServerSource(name string) error { } // ListAPIServerSource records a call for ListAPIServerSource with the expected error (nil if none) -func (sr *APIServerSourcesRecorder) ListAPIServerSource(apiJobSourceList *v1alpha1.ApiServerSourceList, err error) { +func (sr *APIServerSourcesRecorder) ListAPIServerSource(apiJobSourceList *v1alpha2.ApiServerSourceList, err error) { sr.r.Add("ListAPIServerSource", []interface{}{}, []interface{}{apiJobSourceList, err}) } // ListAPIServerSource performs a previously recorded action, failing if non has been registered -func (c *MockKnAPIServerSourceClient) ListAPIServerSource() (*v1alpha1.ApiServerSourceList, error) { +func (c *MockKnAPIServerSourceClient) ListAPIServerSource() (*v1alpha2.ApiServerSourceList, error) { call := c.recorder.r.VerifyCall("ListAPIServerSource") - return call.Result[0].(*v1alpha1.ApiServerSourceList), mock.ErrorOrNil(call.Result[1]) + return call.Result[0].(*v1alpha2.ApiServerSourceList), mock.ErrorOrNil(call.Result[1]) } // Validate validates whether every recorded action has been called diff --git a/pkg/sources/v1alpha1/apiserver_client_mock_test.go b/pkg/sources/v1alpha2/apiserver_client_mock_test.go similarity index 75% rename from pkg/sources/v1alpha1/apiserver_client_mock_test.go rename to pkg/sources/v1alpha2/apiserver_client_mock_test.go index eb9c758c20..f01fd9cef8 100644 --- a/pkg/sources/v1alpha1/apiserver_client_mock_test.go +++ b/pkg/sources/v1alpha2/apiserver_client_mock_test.go @@ -12,12 +12,12 @@ // See the License for the specific language governing permissions and // limitations under the License. -package v1alpha1 +package v1alpha2 import ( "testing" - v1alpha1 "knative.dev/eventing/pkg/apis/sources/v1alpha1" + v1alpha2 "knative.dev/eventing/pkg/apis/sources/v1alpha2" ) func TestMockKnAPIServerSourceClient(t *testing.T) { @@ -28,14 +28,14 @@ func TestMockKnAPIServerSourceClient(t *testing.T) { // Record all services recorder.GetAPIServerSource("hello", nil, nil) - recorder.CreateAPIServerSource(&v1alpha1.ApiServerSource{}, nil) - recorder.UpdateAPIServerSource(&v1alpha1.ApiServerSource{}, nil) + recorder.CreateAPIServerSource(&v1alpha2.ApiServerSource{}, nil) + recorder.UpdateAPIServerSource(&v1alpha2.ApiServerSource{}, nil) recorder.DeleteAPIServerSource("hello", nil) // Call all service client.GetAPIServerSource("hello") - client.CreateAPIServerSource(&v1alpha1.ApiServerSource{}) - client.UpdateAPIServerSource(&v1alpha1.ApiServerSource{}) + client.CreateAPIServerSource(&v1alpha2.ApiServerSource{}) + client.UpdateAPIServerSource(&v1alpha2.ApiServerSource{}) client.DeleteAPIServerSource("hello") // Validate diff --git a/pkg/sources/v1alpha1/apiserver_client_test.go b/pkg/sources/v1alpha2/apiserver_client_test.go similarity index 87% rename from pkg/sources/v1alpha1/apiserver_client_test.go rename to pkg/sources/v1alpha2/apiserver_client_test.go index 691dfefe3b..ad62142f53 100644 --- a/pkg/sources/v1alpha1/apiserver_client_test.go +++ b/pkg/sources/v1alpha2/apiserver_client_test.go @@ -12,27 +12,26 @@ // See the License for the specific language governing permissions and // limitations under the License. -package v1alpha1 +package v1alpha2 import ( "fmt" "testing" "gotest.tools/assert" - v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/runtime" - v1alpha1 "knative.dev/eventing/pkg/apis/sources/v1alpha1" + v1alpha2 "knative.dev/eventing/pkg/apis/sources/v1alpha2" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" clienttesting "k8s.io/client-go/testing" - fake "knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha1/fake" - duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" + fake "knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha2/fake" + duckv1 "knative.dev/pkg/apis/duck/v1" ) var testAPIServerSourceNamespace = "test-ns" -func setupAPIServerSourcesClient(t *testing.T) (fakeSources fake.FakeSourcesV1alpha1, client KnAPIServerSourcesClient) { - fakeSources = fake.FakeSourcesV1alpha1{Fake: &clienttesting.Fake{}} +func setupAPIServerSourcesClient(t *testing.T) (fakeSources fake.FakeSourcesV1alpha2, client KnAPIServerSourcesClient) { + fakeSources = fake.FakeSourcesV1alpha2{Fake: &clienttesting.Fake{}} client = NewKnSourcesClient(&fakeSources, testAPIServerSourceNamespace).APIServerSourcesClient() assert.Equal(t, client.Namespace(), testAPIServerSourceNamespace) return @@ -107,7 +106,7 @@ func TestUpdateApiServerSource(t *testing.T) { if name == "errorSource" { return true, nil, fmt.Errorf("error while updating ApiServer source %s", name) } - return true, NewAPIServerSourceBuilderFromExisting(updatedSource.(*v1alpha1.ApiServerSource)).Build(), nil + return true, NewAPIServerSourceBuilderFromExisting(updatedSource.(*v1alpha2.ApiServerSource)).Build(), nil }) err := client.UpdateAPIServerSource(newAPIServerSource("foo", "Event")) assert.NilError(t, err) @@ -122,7 +121,7 @@ func TestListAPIServerSource(t *testing.T) { sourcesServer.AddReactor("list", "apiserversources", func(a clienttesting.Action) (bool, runtime.Object, error) { cJSource := newAPIServerSource("testsource", "Event") - return true, &v1alpha1.ApiServerSourceList{Items: []v1alpha1.ApiServerSource{*cJSource}}, nil + return true, &v1alpha2.ApiServerSourceList{Items: []v1alpha2.ApiServerSource{*cJSource}}, nil }) sourceList, err := client.ListAPIServerSource() @@ -130,17 +129,17 @@ func TestListAPIServerSource(t *testing.T) { assert.Equal(t, len(sourceList.Items), 1) } -func newAPIServerSource(name, resource string) *v1alpha1.ApiServerSource { - b := NewAPIServerSourceBuilder(name).ServiceAccount("testsa").Mode("Ref") - b.Sink(&duckv1beta1.Destination{ - Ref: &v1.ObjectReference{ +func newAPIServerSource(name, resource string) *v1alpha2.ApiServerSource { + b := NewAPIServerSourceBuilder(name).ServiceAccount("testsa").EventMode("Reference") + b.Sink(duckv1.Destination{ + Ref: &duckv1.KReference{ Kind: "Service", Name: "foosvc", Namespace: "default", }}) if resource != "" { - b.Resources([]v1alpha1.ApiServerResource{{ + b.Resources([]v1alpha2.APIVersionKindSelector{{ APIVersion: "v1", Kind: resource, }}) diff --git a/pkg/sources/v1alpha2/client.go b/pkg/sources/v1alpha2/client.go index 5c9469001d..c97129a394 100644 --- a/pkg/sources/v1alpha2/client.go +++ b/pkg/sources/v1alpha2/client.go @@ -26,6 +26,9 @@ type KnSourcesClient interface { // Get client for sink binding sources SinkBindingClient() KnSinkBindingClient + + // Get client for ApiServer sources + APIServerSourcesClient() KnAPIServerSourcesClient } // sourcesClient is a combination of Sources client interface and namespace @@ -53,3 +56,8 @@ func (c *sourcesClient) PingSourcesClient() KnPingSourcesClient { func (c *sourcesClient) SinkBindingClient() KnSinkBindingClient { return newKnSinkBindingClient(c.client.SinkBindings(c.namespace), c.namespace) } + +// ApiServerSourcesClient for dealing with ApiServer sources +func (c *sourcesClient) APIServerSourcesClient() KnAPIServerSourcesClient { + return newKnAPIServerSourcesClient(c.client.ApiServerSources(c.namespace), c.namespace) +} diff --git a/pkg/sources/v1alpha2/ping_client.go b/pkg/sources/v1alpha2/ping_client.go index fc83ecfe80..b8d307af81 100644 --- a/pkg/sources/v1alpha2/ping_client.go +++ b/pkg/sources/v1alpha2/ping_client.go @@ -18,14 +18,10 @@ 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 @@ -122,10 +118,6 @@ func updatePingSourceListGVK(sourceList *v1alpha2.PingSourceList) (*v1alpha2.Pin 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 { diff --git a/pkg/v1alpha1/client.go b/pkg/v1alpha1/client.go deleted file mode 100644 index 2031a75a4b..0000000000 --- a/pkg/v1alpha1/client.go +++ /dev/null @@ -1,27 +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 ( - client_v1alpha1 "knative.dev/eventing/pkg/legacyclient/clientset/versioned/typed/legacysources/v1alpha1" -) - -// 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 knSourcesClient struct { - client client_v1alpha1.SourcesV1alpha1Interface - namespace string -} diff --git a/test/e2e/source_apiserver_test.go b/test/e2e/source_apiserver_test.go index dfde08fa2e..b9a5ef1e6f 100644 --- a/test/e2e/source_apiserver_test.go +++ b/test/e2e/source_apiserver_test.go @@ -54,7 +54,7 @@ func TestSourceApiServer(t *testing.T) { serviceCreate(r, "testsvc0") t.Log("create apiserver sources with a sink to a service") - apiServerSourceCreate(r, "testapisource0", "Event:v1:true", "testsa", "svc:testsvc0") + apiServerSourceCreate(r, "testapisource0", "Event:v1:key1=value1", "testsa", "svc:testsvc0") apiServerSourceCreate(r, "testapisource1", "Event:v1", "testsa", "svc:testsvc0") apiServerSourceListOutputName(r, "testapisource0", "testapisource1") @@ -73,10 +73,10 @@ func TestSourceApiServer(t *testing.T) { apiServerSourceDelete(r, "testapisource1") t.Log("create apiserver source with a missing sink service") - apiServerSourceCreateMissingSink(r, "testapisource2", "Event:v1:true", "testsa", "svc:unknown") + apiServerSourceCreateMissingSink(r, "testapisource2", "Event:v1", "testsa", "svc:unknown") t.Log("update apiserver source sink service") - apiServerSourceCreate(r, "testapisource3", "Event:v1:true", "testsa", "svc:testsvc0") + apiServerSourceCreate(r, "testapisource3", "Event:v1", "testsa", "svc:testsvc0") serviceCreate(r, "testsvc1") apiServerSourceUpdateSink(r, "testapisource3", "svc:testsvc1") jpSinkRefNameInSpec := "jsonpath={.spec.sink.ref.name}" diff --git a/vendor/github.com/google/uuid/.travis.yml b/vendor/github.com/google/uuid/.travis.yml new file mode 100644 index 0000000000..d8156a60ba --- /dev/null +++ b/vendor/github.com/google/uuid/.travis.yml @@ -0,0 +1,9 @@ +language: go + +go: + - 1.4.3 + - 1.5.3 + - tip + +script: + - go test -v ./... diff --git a/vendor/github.com/google/uuid/CONTRIBUTING.md b/vendor/github.com/google/uuid/CONTRIBUTING.md new file mode 100644 index 0000000000..04fdf09f13 --- /dev/null +++ b/vendor/github.com/google/uuid/CONTRIBUTING.md @@ -0,0 +1,10 @@ +# How to contribute + +We definitely welcome patches and contribution to this project! + +### Legal requirements + +In order to protect both you and ourselves, you will need to sign the +[Contributor License Agreement](https://cla.developers.google.com/clas). + +You may have already signed it for other Google projects. diff --git a/vendor/github.com/google/uuid/CONTRIBUTORS b/vendor/github.com/google/uuid/CONTRIBUTORS new file mode 100644 index 0000000000..b4bb97f6bc --- /dev/null +++ b/vendor/github.com/google/uuid/CONTRIBUTORS @@ -0,0 +1,9 @@ +Paul Borman +bmatsuo +shawnps +theory +jboverfelt +dsymonds +cd1 +wallclockbuilder +dansouza diff --git a/vendor/github.com/google/uuid/LICENSE b/vendor/github.com/google/uuid/LICENSE new file mode 100644 index 0000000000..5dc68268d9 --- /dev/null +++ b/vendor/github.com/google/uuid/LICENSE @@ -0,0 +1,27 @@ +Copyright (c) 2009,2014 Google Inc. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/vendor/github.com/google/uuid/README.md b/vendor/github.com/google/uuid/README.md new file mode 100644 index 0000000000..9d92c11f16 --- /dev/null +++ b/vendor/github.com/google/uuid/README.md @@ -0,0 +1,19 @@ +# uuid ![build status](https://travis-ci.org/google/uuid.svg?branch=master) +The uuid package generates and inspects UUIDs based on +[RFC 4122](http://tools.ietf.org/html/rfc4122) +and DCE 1.1: Authentication and Security Services. + +This package is based on the github.com/pborman/uuid package (previously named +code.google.com/p/go-uuid). It differs from these earlier packages in that +a UUID is a 16 byte array rather than a byte slice. One loss due to this +change is the ability to represent an invalid UUID (vs a NIL UUID). + +###### Install +`go get github.com/google/uuid` + +###### Documentation +[![GoDoc](https://godoc.org/github.com/google/uuid?status.svg)](http://godoc.org/github.com/google/uuid) + +Full `go doc` style documentation for the package can be viewed online without +installing this package by using the GoDoc site here: +http://godoc.org/github.com/google/uuid diff --git a/vendor/github.com/google/uuid/dce.go b/vendor/github.com/google/uuid/dce.go new file mode 100644 index 0000000000..fa820b9d30 --- /dev/null +++ b/vendor/github.com/google/uuid/dce.go @@ -0,0 +1,80 @@ +// Copyright 2016 Google Inc. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package uuid + +import ( + "encoding/binary" + "fmt" + "os" +) + +// A Domain represents a Version 2 domain +type Domain byte + +// Domain constants for DCE Security (Version 2) UUIDs. +const ( + Person = Domain(0) + Group = Domain(1) + Org = Domain(2) +) + +// NewDCESecurity returns a DCE Security (Version 2) UUID. +// +// The domain should be one of Person, Group or Org. +// On a POSIX system the id should be the users UID for the Person +// domain and the users GID for the Group. The meaning of id for +// the domain Org or on non-POSIX systems is site defined. +// +// For a given domain/id pair the same token may be returned for up to +// 7 minutes and 10 seconds. +func NewDCESecurity(domain Domain, id uint32) (UUID, error) { + uuid, err := NewUUID() + if err == nil { + uuid[6] = (uuid[6] & 0x0f) | 0x20 // Version 2 + uuid[9] = byte(domain) + binary.BigEndian.PutUint32(uuid[0:], id) + } + return uuid, err +} + +// NewDCEPerson returns a DCE Security (Version 2) UUID in the person +// domain with the id returned by os.Getuid. +// +// NewDCESecurity(Person, uint32(os.Getuid())) +func NewDCEPerson() (UUID, error) { + return NewDCESecurity(Person, uint32(os.Getuid())) +} + +// NewDCEGroup returns a DCE Security (Version 2) UUID in the group +// domain with the id returned by os.Getgid. +// +// NewDCESecurity(Group, uint32(os.Getgid())) +func NewDCEGroup() (UUID, error) { + return NewDCESecurity(Group, uint32(os.Getgid())) +} + +// Domain returns the domain for a Version 2 UUID. Domains are only defined +// for Version 2 UUIDs. +func (uuid UUID) Domain() Domain { + return Domain(uuid[9]) +} + +// ID returns the id for a Version 2 UUID. IDs are only defined for Version 2 +// UUIDs. +func (uuid UUID) ID() uint32 { + return binary.BigEndian.Uint32(uuid[0:4]) +} + +func (d Domain) String() string { + switch d { + case Person: + return "Person" + case Group: + return "Group" + case Org: + return "Org" + } + return fmt.Sprintf("Domain%d", int(d)) +} diff --git a/vendor/github.com/google/uuid/doc.go b/vendor/github.com/google/uuid/doc.go new file mode 100644 index 0000000000..5b8a4b9af8 --- /dev/null +++ b/vendor/github.com/google/uuid/doc.go @@ -0,0 +1,12 @@ +// Copyright 2016 Google Inc. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package uuid generates and inspects UUIDs. +// +// UUIDs are based on RFC 4122 and DCE 1.1: Authentication and Security +// Services. +// +// A UUID is a 16 byte (128 bit) array. UUIDs may be used as keys to +// maps or compared directly. +package uuid diff --git a/vendor/github.com/google/uuid/go.mod b/vendor/github.com/google/uuid/go.mod new file mode 100644 index 0000000000..fc84cd79d4 --- /dev/null +++ b/vendor/github.com/google/uuid/go.mod @@ -0,0 +1 @@ +module github.com/google/uuid diff --git a/vendor/github.com/google/uuid/hash.go b/vendor/github.com/google/uuid/hash.go new file mode 100644 index 0000000000..b174616315 --- /dev/null +++ b/vendor/github.com/google/uuid/hash.go @@ -0,0 +1,53 @@ +// Copyright 2016 Google Inc. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package uuid + +import ( + "crypto/md5" + "crypto/sha1" + "hash" +) + +// Well known namespace IDs and UUIDs +var ( + NameSpaceDNS = Must(Parse("6ba7b810-9dad-11d1-80b4-00c04fd430c8")) + NameSpaceURL = Must(Parse("6ba7b811-9dad-11d1-80b4-00c04fd430c8")) + NameSpaceOID = Must(Parse("6ba7b812-9dad-11d1-80b4-00c04fd430c8")) + NameSpaceX500 = Must(Parse("6ba7b814-9dad-11d1-80b4-00c04fd430c8")) + Nil UUID // empty UUID, all zeros +) + +// NewHash returns a new UUID derived from the hash of space concatenated with +// data generated by h. The hash should be at least 16 byte in length. The +// first 16 bytes of the hash are used to form the UUID. The version of the +// UUID will be the lower 4 bits of version. NewHash is used to implement +// NewMD5 and NewSHA1. +func NewHash(h hash.Hash, space UUID, data []byte, version int) UUID { + h.Reset() + h.Write(space[:]) + h.Write(data) + s := h.Sum(nil) + var uuid UUID + copy(uuid[:], s) + uuid[6] = (uuid[6] & 0x0f) | uint8((version&0xf)<<4) + uuid[8] = (uuid[8] & 0x3f) | 0x80 // RFC 4122 variant + return uuid +} + +// NewMD5 returns a new MD5 (Version 3) UUID based on the +// supplied name space and data. It is the same as calling: +// +// NewHash(md5.New(), space, data, 3) +func NewMD5(space UUID, data []byte) UUID { + return NewHash(md5.New(), space, data, 3) +} + +// NewSHA1 returns a new SHA1 (Version 5) UUID based on the +// supplied name space and data. It is the same as calling: +// +// NewHash(sha1.New(), space, data, 5) +func NewSHA1(space UUID, data []byte) UUID { + return NewHash(sha1.New(), space, data, 5) +} diff --git a/vendor/github.com/google/uuid/marshal.go b/vendor/github.com/google/uuid/marshal.go new file mode 100644 index 0000000000..7f9e0c6c0e --- /dev/null +++ b/vendor/github.com/google/uuid/marshal.go @@ -0,0 +1,37 @@ +// Copyright 2016 Google Inc. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package uuid + +import "fmt" + +// MarshalText implements encoding.TextMarshaler. +func (uuid UUID) MarshalText() ([]byte, error) { + var js [36]byte + encodeHex(js[:], uuid) + return js[:], nil +} + +// UnmarshalText implements encoding.TextUnmarshaler. +func (uuid *UUID) UnmarshalText(data []byte) error { + id, err := ParseBytes(data) + if err == nil { + *uuid = id + } + return err +} + +// MarshalBinary implements encoding.BinaryMarshaler. +func (uuid UUID) MarshalBinary() ([]byte, error) { + return uuid[:], nil +} + +// UnmarshalBinary implements encoding.BinaryUnmarshaler. +func (uuid *UUID) UnmarshalBinary(data []byte) error { + if len(data) != 16 { + return fmt.Errorf("invalid UUID (got %d bytes)", len(data)) + } + copy(uuid[:], data) + return nil +} diff --git a/vendor/github.com/google/uuid/node.go b/vendor/github.com/google/uuid/node.go new file mode 100644 index 0000000000..d651a2b061 --- /dev/null +++ b/vendor/github.com/google/uuid/node.go @@ -0,0 +1,90 @@ +// Copyright 2016 Google Inc. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package uuid + +import ( + "sync" +) + +var ( + nodeMu sync.Mutex + ifname string // name of interface being used + nodeID [6]byte // hardware for version 1 UUIDs + zeroID [6]byte // nodeID with only 0's +) + +// NodeInterface returns the name of the interface from which the NodeID was +// derived. The interface "user" is returned if the NodeID was set by +// SetNodeID. +func NodeInterface() string { + defer nodeMu.Unlock() + nodeMu.Lock() + return ifname +} + +// SetNodeInterface selects the hardware address to be used for Version 1 UUIDs. +// If name is "" then the first usable interface found will be used or a random +// Node ID will be generated. If a named interface cannot be found then false +// is returned. +// +// SetNodeInterface never fails when name is "". +func SetNodeInterface(name string) bool { + defer nodeMu.Unlock() + nodeMu.Lock() + return setNodeInterface(name) +} + +func setNodeInterface(name string) bool { + iname, addr := getHardwareInterface(name) // null implementation for js + if iname != "" && addr != nil { + ifname = iname + copy(nodeID[:], addr) + return true + } + + // We found no interfaces with a valid hardware address. If name + // does not specify a specific interface generate a random Node ID + // (section 4.1.6) + if name == "" { + ifname = "random" + randomBits(nodeID[:]) + return true + } + return false +} + +// NodeID returns a slice of a copy of the current Node ID, setting the Node ID +// if not already set. +func NodeID() []byte { + defer nodeMu.Unlock() + nodeMu.Lock() + if nodeID == zeroID { + setNodeInterface("") + } + nid := nodeID + return nid[:] +} + +// SetNodeID sets the Node ID to be used for Version 1 UUIDs. The first 6 bytes +// of id are used. If id is less than 6 bytes then false is returned and the +// Node ID is not set. +func SetNodeID(id []byte) bool { + if len(id) < 6 { + return false + } + defer nodeMu.Unlock() + nodeMu.Lock() + copy(nodeID[:], id) + ifname = "user" + return true +} + +// NodeID returns the 6 byte node id encoded in uuid. It returns nil if uuid is +// not valid. The NodeID is only well defined for version 1 and 2 UUIDs. +func (uuid UUID) NodeID() []byte { + var node [6]byte + copy(node[:], uuid[10:]) + return node[:] +} diff --git a/vendor/github.com/google/uuid/node_js.go b/vendor/github.com/google/uuid/node_js.go new file mode 100644 index 0000000000..24b78edc90 --- /dev/null +++ b/vendor/github.com/google/uuid/node_js.go @@ -0,0 +1,12 @@ +// Copyright 2017 Google Inc. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build js + +package uuid + +// getHardwareInterface returns nil values for the JS version of the code. +// This remvoves the "net" dependency, because it is not used in the browser. +// Using the "net" library inflates the size of the transpiled JS code by 673k bytes. +func getHardwareInterface(name string) (string, []byte) { return "", nil } diff --git a/vendor/github.com/google/uuid/node_net.go b/vendor/github.com/google/uuid/node_net.go new file mode 100644 index 0000000000..0cbbcddbd6 --- /dev/null +++ b/vendor/github.com/google/uuid/node_net.go @@ -0,0 +1,33 @@ +// Copyright 2017 Google Inc. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build !js + +package uuid + +import "net" + +var interfaces []net.Interface // cached list of interfaces + +// getHardwareInterface returns the name and hardware address of interface name. +// If name is "" then the name and hardware address of one of the system's +// interfaces is returned. If no interfaces are found (name does not exist or +// there are no interfaces) then "", nil is returned. +// +// Only addresses of at least 6 bytes are returned. +func getHardwareInterface(name string) (string, []byte) { + if interfaces == nil { + var err error + interfaces, err = net.Interfaces() + if err != nil { + return "", nil + } + } + for _, ifs := range interfaces { + if len(ifs.HardwareAddr) >= 6 && (name == "" || name == ifs.Name) { + return ifs.Name, ifs.HardwareAddr + } + } + return "", nil +} diff --git a/vendor/github.com/google/uuid/sql.go b/vendor/github.com/google/uuid/sql.go new file mode 100644 index 0000000000..f326b54db3 --- /dev/null +++ b/vendor/github.com/google/uuid/sql.go @@ -0,0 +1,59 @@ +// Copyright 2016 Google Inc. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package uuid + +import ( + "database/sql/driver" + "fmt" +) + +// Scan implements sql.Scanner so UUIDs can be read from databases transparently +// Currently, database types that map to string and []byte are supported. Please +// consult database-specific driver documentation for matching types. +func (uuid *UUID) Scan(src interface{}) error { + switch src := src.(type) { + case nil: + return nil + + case string: + // if an empty UUID comes from a table, we return a null UUID + if src == "" { + return nil + } + + // see Parse for required string format + u, err := Parse(src) + if err != nil { + return fmt.Errorf("Scan: %v", err) + } + + *uuid = u + + case []byte: + // if an empty UUID comes from a table, we return a null UUID + if len(src) == 0 { + return nil + } + + // assumes a simple slice of bytes if 16 bytes + // otherwise attempts to parse + if len(src) != 16 { + return uuid.Scan(string(src)) + } + copy((*uuid)[:], src) + + default: + return fmt.Errorf("Scan: unable to scan type %T into UUID", src) + } + + return nil +} + +// Value implements sql.Valuer so that UUIDs can be written to databases +// transparently. Currently, UUIDs map to strings. Please consult +// database-specific driver documentation for matching types. +func (uuid UUID) Value() (driver.Value, error) { + return uuid.String(), nil +} diff --git a/vendor/github.com/google/uuid/time.go b/vendor/github.com/google/uuid/time.go new file mode 100644 index 0000000000..e6ef06cdc8 --- /dev/null +++ b/vendor/github.com/google/uuid/time.go @@ -0,0 +1,123 @@ +// Copyright 2016 Google Inc. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package uuid + +import ( + "encoding/binary" + "sync" + "time" +) + +// A Time represents a time as the number of 100's of nanoseconds since 15 Oct +// 1582. +type Time int64 + +const ( + lillian = 2299160 // Julian day of 15 Oct 1582 + unix = 2440587 // Julian day of 1 Jan 1970 + epoch = unix - lillian // Days between epochs + g1582 = epoch * 86400 // seconds between epochs + g1582ns100 = g1582 * 10000000 // 100s of a nanoseconds between epochs +) + +var ( + timeMu sync.Mutex + lasttime uint64 // last time we returned + clockSeq uint16 // clock sequence for this run + + timeNow = time.Now // for testing +) + +// UnixTime converts t the number of seconds and nanoseconds using the Unix +// epoch of 1 Jan 1970. +func (t Time) UnixTime() (sec, nsec int64) { + sec = int64(t - g1582ns100) + nsec = (sec % 10000000) * 100 + sec /= 10000000 + return sec, nsec +} + +// GetTime returns the current Time (100s of nanoseconds since 15 Oct 1582) and +// clock sequence as well as adjusting the clock sequence as needed. An error +// is returned if the current time cannot be determined. +func GetTime() (Time, uint16, error) { + defer timeMu.Unlock() + timeMu.Lock() + return getTime() +} + +func getTime() (Time, uint16, error) { + t := timeNow() + + // If we don't have a clock sequence already, set one. + if clockSeq == 0 { + setClockSequence(-1) + } + now := uint64(t.UnixNano()/100) + g1582ns100 + + // If time has gone backwards with this clock sequence then we + // increment the clock sequence + if now <= lasttime { + clockSeq = ((clockSeq + 1) & 0x3fff) | 0x8000 + } + lasttime = now + return Time(now), clockSeq, nil +} + +// ClockSequence returns the current clock sequence, generating one if not +// already set. The clock sequence is only used for Version 1 UUIDs. +// +// The uuid package does not use global static storage for the clock sequence or +// the last time a UUID was generated. Unless SetClockSequence is used, a new +// random clock sequence is generated the first time a clock sequence is +// requested by ClockSequence, GetTime, or NewUUID. (section 4.2.1.1) +func ClockSequence() int { + defer timeMu.Unlock() + timeMu.Lock() + return clockSequence() +} + +func clockSequence() int { + if clockSeq == 0 { + setClockSequence(-1) + } + return int(clockSeq & 0x3fff) +} + +// SetClockSequence sets the clock sequence to the lower 14 bits of seq. Setting to +// -1 causes a new sequence to be generated. +func SetClockSequence(seq int) { + defer timeMu.Unlock() + timeMu.Lock() + setClockSequence(seq) +} + +func setClockSequence(seq int) { + if seq == -1 { + var b [2]byte + randomBits(b[:]) // clock sequence + seq = int(b[0])<<8 | int(b[1]) + } + oldSeq := clockSeq + clockSeq = uint16(seq&0x3fff) | 0x8000 // Set our variant + if oldSeq != clockSeq { + lasttime = 0 + } +} + +// Time returns the time in 100s of nanoseconds since 15 Oct 1582 encoded in +// uuid. The time is only defined for version 1 and 2 UUIDs. +func (uuid UUID) Time() Time { + time := int64(binary.BigEndian.Uint32(uuid[0:4])) + time |= int64(binary.BigEndian.Uint16(uuid[4:6])) << 32 + time |= int64(binary.BigEndian.Uint16(uuid[6:8])&0xfff) << 48 + return Time(time) +} + +// ClockSequence returns the clock sequence encoded in uuid. +// The clock sequence is only well defined for version 1 and 2 UUIDs. +func (uuid UUID) ClockSequence() int { + return int(binary.BigEndian.Uint16(uuid[8:10])) & 0x3fff +} diff --git a/vendor/github.com/google/uuid/util.go b/vendor/github.com/google/uuid/util.go new file mode 100644 index 0000000000..5ea6c73780 --- /dev/null +++ b/vendor/github.com/google/uuid/util.go @@ -0,0 +1,43 @@ +// Copyright 2016 Google Inc. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package uuid + +import ( + "io" +) + +// randomBits completely fills slice b with random data. +func randomBits(b []byte) { + if _, err := io.ReadFull(rander, b); err != nil { + panic(err.Error()) // rand should never fail + } +} + +// xvalues returns the value of a byte as a hexadecimal digit or 255. +var xvalues = [256]byte{ + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 255, 255, 255, 255, 255, 255, + 255, 10, 11, 12, 13, 14, 15, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 10, 11, 12, 13, 14, 15, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, +} + +// xtob converts hex characters x1 and x2 into a byte. +func xtob(x1, x2 byte) (byte, bool) { + b1 := xvalues[x1] + b2 := xvalues[x2] + return (b1 << 4) | b2, b1 != 255 && b2 != 255 +} diff --git a/vendor/github.com/google/uuid/uuid.go b/vendor/github.com/google/uuid/uuid.go new file mode 100644 index 0000000000..524404cc52 --- /dev/null +++ b/vendor/github.com/google/uuid/uuid.go @@ -0,0 +1,245 @@ +// Copyright 2018 Google Inc. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package uuid + +import ( + "bytes" + "crypto/rand" + "encoding/hex" + "errors" + "fmt" + "io" + "strings" +) + +// A UUID is a 128 bit (16 byte) Universal Unique IDentifier as defined in RFC +// 4122. +type UUID [16]byte + +// A Version represents a UUID's version. +type Version byte + +// A Variant represents a UUID's variant. +type Variant byte + +// Constants returned by Variant. +const ( + Invalid = Variant(iota) // Invalid UUID + RFC4122 // The variant specified in RFC4122 + Reserved // Reserved, NCS backward compatibility. + Microsoft // Reserved, Microsoft Corporation backward compatibility. + Future // Reserved for future definition. +) + +var rander = rand.Reader // random function + +// Parse decodes s into a UUID or returns an error. Both the standard UUID +// forms of xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx and +// urn:uuid:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx are decoded as well as the +// Microsoft encoding {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx} and the raw hex +// encoding: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx. +func Parse(s string) (UUID, error) { + var uuid UUID + switch len(s) { + // xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx + case 36: + + // urn:uuid:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx + case 36 + 9: + if strings.ToLower(s[:9]) != "urn:uuid:" { + return uuid, fmt.Errorf("invalid urn prefix: %q", s[:9]) + } + s = s[9:] + + // {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx} + case 36 + 2: + s = s[1:] + + // xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + case 32: + var ok bool + for i := range uuid { + uuid[i], ok = xtob(s[i*2], s[i*2+1]) + if !ok { + return uuid, errors.New("invalid UUID format") + } + } + return uuid, nil + default: + return uuid, fmt.Errorf("invalid UUID length: %d", len(s)) + } + // s is now at least 36 bytes long + // it must be of the form xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx + if s[8] != '-' || s[13] != '-' || s[18] != '-' || s[23] != '-' { + return uuid, errors.New("invalid UUID format") + } + for i, x := range [16]int{ + 0, 2, 4, 6, + 9, 11, + 14, 16, + 19, 21, + 24, 26, 28, 30, 32, 34} { + v, ok := xtob(s[x], s[x+1]) + if !ok { + return uuid, errors.New("invalid UUID format") + } + uuid[i] = v + } + return uuid, nil +} + +// ParseBytes is like Parse, except it parses a byte slice instead of a string. +func ParseBytes(b []byte) (UUID, error) { + var uuid UUID + switch len(b) { + case 36: // xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx + case 36 + 9: // urn:uuid:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx + if !bytes.Equal(bytes.ToLower(b[:9]), []byte("urn:uuid:")) { + return uuid, fmt.Errorf("invalid urn prefix: %q", b[:9]) + } + b = b[9:] + case 36 + 2: // {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx} + b = b[1:] + case 32: // xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + var ok bool + for i := 0; i < 32; i += 2 { + uuid[i/2], ok = xtob(b[i], b[i+1]) + if !ok { + return uuid, errors.New("invalid UUID format") + } + } + return uuid, nil + default: + return uuid, fmt.Errorf("invalid UUID length: %d", len(b)) + } + // s is now at least 36 bytes long + // it must be of the form xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx + if b[8] != '-' || b[13] != '-' || b[18] != '-' || b[23] != '-' { + return uuid, errors.New("invalid UUID format") + } + for i, x := range [16]int{ + 0, 2, 4, 6, + 9, 11, + 14, 16, + 19, 21, + 24, 26, 28, 30, 32, 34} { + v, ok := xtob(b[x], b[x+1]) + if !ok { + return uuid, errors.New("invalid UUID format") + } + uuid[i] = v + } + return uuid, nil +} + +// MustParse is like Parse but panics if the string cannot be parsed. +// It simplifies safe initialization of global variables holding compiled UUIDs. +func MustParse(s string) UUID { + uuid, err := Parse(s) + if err != nil { + panic(`uuid: Parse(` + s + `): ` + err.Error()) + } + return uuid +} + +// FromBytes creates a new UUID from a byte slice. Returns an error if the slice +// does not have a length of 16. The bytes are copied from the slice. +func FromBytes(b []byte) (uuid UUID, err error) { + err = uuid.UnmarshalBinary(b) + return uuid, err +} + +// Must returns uuid if err is nil and panics otherwise. +func Must(uuid UUID, err error) UUID { + if err != nil { + panic(err) + } + return uuid +} + +// String returns the string form of uuid, xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx +// , or "" if uuid is invalid. +func (uuid UUID) String() string { + var buf [36]byte + encodeHex(buf[:], uuid) + return string(buf[:]) +} + +// URN returns the RFC 2141 URN form of uuid, +// urn:uuid:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx, or "" if uuid is invalid. +func (uuid UUID) URN() string { + var buf [36 + 9]byte + copy(buf[:], "urn:uuid:") + encodeHex(buf[9:], uuid) + return string(buf[:]) +} + +func encodeHex(dst []byte, uuid UUID) { + hex.Encode(dst, uuid[:4]) + dst[8] = '-' + hex.Encode(dst[9:13], uuid[4:6]) + dst[13] = '-' + hex.Encode(dst[14:18], uuid[6:8]) + dst[18] = '-' + hex.Encode(dst[19:23], uuid[8:10]) + dst[23] = '-' + hex.Encode(dst[24:], uuid[10:]) +} + +// Variant returns the variant encoded in uuid. +func (uuid UUID) Variant() Variant { + switch { + case (uuid[8] & 0xc0) == 0x80: + return RFC4122 + case (uuid[8] & 0xe0) == 0xc0: + return Microsoft + case (uuid[8] & 0xe0) == 0xe0: + return Future + default: + return Reserved + } +} + +// Version returns the version of uuid. +func (uuid UUID) Version() Version { + return Version(uuid[6] >> 4) +} + +func (v Version) String() string { + if v > 15 { + return fmt.Sprintf("BAD_VERSION_%d", v) + } + return fmt.Sprintf("VERSION_%d", v) +} + +func (v Variant) String() string { + switch v { + case RFC4122: + return "RFC4122" + case Reserved: + return "Reserved" + case Microsoft: + return "Microsoft" + case Future: + return "Future" + case Invalid: + return "Invalid" + } + return fmt.Sprintf("BadVariant%d", int(v)) +} + +// SetRand sets the random number generator to r, which implements io.Reader. +// If r.Read returns an error when the package requests random data then +// a panic will be issued. +// +// Calling SetRand with nil sets the random number generator to the default +// generator. +func SetRand(r io.Reader) { + if r == nil { + rander = rand.Reader + return + } + rander = r +} diff --git a/vendor/github.com/google/uuid/version1.go b/vendor/github.com/google/uuid/version1.go new file mode 100644 index 0000000000..199a1ac654 --- /dev/null +++ b/vendor/github.com/google/uuid/version1.go @@ -0,0 +1,44 @@ +// Copyright 2016 Google Inc. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package uuid + +import ( + "encoding/binary" +) + +// NewUUID returns a Version 1 UUID based on the current NodeID and clock +// sequence, and the current time. If the NodeID has not been set by SetNodeID +// or SetNodeInterface then it will be set automatically. If the NodeID cannot +// be set NewUUID returns nil. If clock sequence has not been set by +// SetClockSequence then it will be set automatically. If GetTime fails to +// return the current NewUUID returns nil and an error. +// +// In most cases, New should be used. +func NewUUID() (UUID, error) { + nodeMu.Lock() + if nodeID == zeroID { + setNodeInterface("") + } + nodeMu.Unlock() + + var uuid UUID + now, seq, err := GetTime() + if err != nil { + return uuid, err + } + + timeLow := uint32(now & 0xffffffff) + timeMid := uint16((now >> 32) & 0xffff) + timeHi := uint16((now >> 48) & 0x0fff) + timeHi |= 0x1000 // Version 1 + + binary.BigEndian.PutUint32(uuid[0:], timeLow) + binary.BigEndian.PutUint16(uuid[4:], timeMid) + binary.BigEndian.PutUint16(uuid[6:], timeHi) + binary.BigEndian.PutUint16(uuid[8:], seq) + copy(uuid[10:], nodeID[:]) + + return uuid, nil +} diff --git a/vendor/github.com/google/uuid/version4.go b/vendor/github.com/google/uuid/version4.go new file mode 100644 index 0000000000..84af91c9f5 --- /dev/null +++ b/vendor/github.com/google/uuid/version4.go @@ -0,0 +1,38 @@ +// Copyright 2016 Google Inc. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package uuid + +import "io" + +// New creates a new random UUID or panics. New is equivalent to +// the expression +// +// uuid.Must(uuid.NewRandom()) +func New() UUID { + return Must(NewRandom()) +} + +// NewRandom returns a Random (Version 4) UUID. +// +// The strength of the UUIDs is based on the strength of the crypto/rand +// package. +// +// A note about uniqueness derived from the UUID Wikipedia entry: +// +// Randomly generated UUIDs have 122 random bits. One's annual risk of being +// hit by a meteorite is estimated to be one chance in 17 billion, that +// means the probability is about 0.00000000006 (6 × 10−11), +// equivalent to the odds of creating a few tens of trillions of UUIDs in a +// year and having one duplicate. +func NewRandom() (UUID, error) { + var uuid UUID + _, err := io.ReadFull(rander, uuid[:]) + if err != nil { + return Nil, err + } + uuid[6] = (uuid[6] & 0x0f) | 0x40 // Version 4 + uuid[8] = (uuid[8] & 0x3f) | 0x80 // Variant is 10 + return uuid, nil +} diff --git a/vendor/golang.org/x/crypto/ssh/terminal/terminal.go b/vendor/golang.org/x/crypto/ssh/terminal/terminal.go index 2f04ee5b5c..d1b4fca3a9 100644 --- a/vendor/golang.org/x/crypto/ssh/terminal/terminal.go +++ b/vendor/golang.org/x/crypto/ssh/terminal/terminal.go @@ -7,6 +7,7 @@ package terminal import ( "bytes" "io" + "runtime" "strconv" "sync" "unicode/utf8" @@ -939,6 +940,8 @@ func (s *stRingBuffer) NthPreviousEntry(n int) (value string, ok bool) { // readPasswordLine reads from reader until it finds \n or io.EOF. // The slice returned does not include the \n. // readPasswordLine also ignores any \r it finds. +// Windows uses \r as end of line. So, on Windows, readPasswordLine +// reads until it finds \r and ignores any \n it finds during processing. func readPasswordLine(reader io.Reader) ([]byte, error) { var buf [1]byte var ret []byte @@ -947,10 +950,20 @@ func readPasswordLine(reader io.Reader) ([]byte, error) { n, err := reader.Read(buf[:]) if n > 0 { switch buf[0] { + case '\b': + if len(ret) > 0 { + ret = ret[:len(ret)-1] + } case '\n': - return ret, nil + if runtime.GOOS != "windows" { + return ret, nil + } + // otherwise ignore \n case '\r': - // remove \r from passwords on Windows + if runtime.GOOS == "windows" { + return ret, nil + } + // otherwise ignore \r default: ret = append(ret, buf[0]) } diff --git a/vendor/golang.org/x/crypto/ssh/terminal/util_windows.go b/vendor/golang.org/x/crypto/ssh/terminal/util_windows.go index 5cfdf8f3f0..f614e9cb60 100644 --- a/vendor/golang.org/x/crypto/ssh/terminal/util_windows.go +++ b/vendor/golang.org/x/crypto/ssh/terminal/util_windows.go @@ -85,8 +85,8 @@ func ReadPassword(fd int) ([]byte, error) { } old := st - st &^= (windows.ENABLE_ECHO_INPUT) - st |= (windows.ENABLE_PROCESSED_INPUT | windows.ENABLE_LINE_INPUT | windows.ENABLE_PROCESSED_OUTPUT) + st &^= (windows.ENABLE_ECHO_INPUT | windows.ENABLE_LINE_INPUT) + st |= (windows.ENABLE_PROCESSED_OUTPUT | windows.ENABLE_PROCESSED_INPUT) if err := windows.SetConsoleMode(windows.Handle(fd), st); err != nil { return nil, err } diff --git a/vendor/gopkg.in/yaml.v2/.travis.yml b/vendor/gopkg.in/yaml.v2/.travis.yml index 9f556934d8..055480b9ef 100644 --- a/vendor/gopkg.in/yaml.v2/.travis.yml +++ b/vendor/gopkg.in/yaml.v2/.travis.yml @@ -1,12 +1,16 @@ language: go go: - - 1.4 - - 1.5 - - 1.6 - - 1.7 - - 1.8 - - 1.9 - - tip + - "1.4.x" + - "1.5.x" + - "1.6.x" + - "1.7.x" + - "1.8.x" + - "1.9.x" + - "1.10.x" + - "1.11.x" + - "1.12.x" + - "1.13.x" + - "tip" go_import_path: gopkg.in/yaml.v2 diff --git a/vendor/gopkg.in/yaml.v2/decode.go b/vendor/gopkg.in/yaml.v2/decode.go index 5310876555..129bc2a97d 100644 --- a/vendor/gopkg.in/yaml.v2/decode.go +++ b/vendor/gopkg.in/yaml.v2/decode.go @@ -319,10 +319,14 @@ func (d *decoder) prepare(n *node, out reflect.Value) (newout reflect.Value, unm } const ( - // 400,000 decode operations is ~500kb of dense object declarations, or ~5kb of dense object declarations with 10000% alias expansion + // 400,000 decode operations is ~500kb of dense object declarations, or + // ~5kb of dense object declarations with 10000% alias expansion alias_ratio_range_low = 400000 - // 4,000,000 decode operations is ~5MB of dense object declarations, or ~4.5MB of dense object declarations with 10% alias expansion + + // 4,000,000 decode operations is ~5MB of dense object declarations, or + // ~4.5MB of dense object declarations with 10% alias expansion alias_ratio_range_high = 4000000 + // alias_ratio_range is the range over which we scale allowed alias ratios alias_ratio_range = float64(alias_ratio_range_high - alias_ratio_range_low) ) @@ -784,8 +788,7 @@ func (d *decoder) merge(n *node, out reflect.Value) { case mappingNode: d.unmarshal(n, out) case aliasNode: - an, ok := d.doc.anchors[n.value] - if ok && an.kind != mappingNode { + if n.alias != nil && n.alias.kind != mappingNode { failWantMap() } d.unmarshal(n, out) @@ -794,8 +797,7 @@ func (d *decoder) merge(n *node, out reflect.Value) { for i := len(n.children) - 1; i >= 0; i-- { ni := n.children[i] if ni.kind == aliasNode { - an, ok := d.doc.anchors[ni.value] - if ok && an.kind != mappingNode { + if ni.alias != nil && ni.alias.kind != mappingNode { failWantMap() } } else if ni.kind != mappingNode { diff --git a/vendor/gopkg.in/yaml.v2/scannerc.go b/vendor/gopkg.in/yaml.v2/scannerc.go index 570b8ecd10..0b9bb6030a 100644 --- a/vendor/gopkg.in/yaml.v2/scannerc.go +++ b/vendor/gopkg.in/yaml.v2/scannerc.go @@ -626,31 +626,18 @@ func trace(args ...interface{}) func() { func yaml_parser_fetch_more_tokens(parser *yaml_parser_t) bool { // While we need more tokens to fetch, do it. for { - // Check if we really need to fetch more tokens. - need_more_tokens := false - - if parser.tokens_head == len(parser.tokens) { - // Queue is empty. - need_more_tokens = true - } else { - // Check if any potential simple key may occupy the head position. - if !yaml_parser_stale_simple_keys(parser) { + if parser.tokens_head != len(parser.tokens) { + // If queue is non-empty, check if any potential simple key may + // occupy the head position. + head_tok_idx, ok := parser.simple_keys_by_tok[parser.tokens_parsed] + if !ok { + break + } else if valid, ok := yaml_simple_key_is_valid(parser, &parser.simple_keys[head_tok_idx]); !ok { return false - } - - for i := range parser.simple_keys { - simple_key := &parser.simple_keys[i] - if simple_key.possible && simple_key.token_number == parser.tokens_parsed { - need_more_tokens = true - break - } + } else if !valid { + break } } - - // We are finished. - if !need_more_tokens { - break - } // Fetch the next token. if !yaml_parser_fetch_next_token(parser) { return false @@ -678,11 +665,6 @@ func yaml_parser_fetch_next_token(parser *yaml_parser_t) bool { return false } - // Remove obsolete potential simple keys. - if !yaml_parser_stale_simple_keys(parser) { - return false - } - // Check the indentation level against the current column. if !yaml_parser_unroll_indent(parser, parser.mark.column) { return false @@ -837,29 +819,30 @@ func yaml_parser_fetch_next_token(parser *yaml_parser_t) bool { "found character that cannot start any token") } -// Check the list of potential simple keys and remove the positions that -// cannot contain simple keys anymore. -func yaml_parser_stale_simple_keys(parser *yaml_parser_t) bool { - // Check for a potential simple key for each flow level. - for i := range parser.simple_keys { - simple_key := &parser.simple_keys[i] - - // The specification requires that a simple key - // - // - is limited to a single line, - // - is shorter than 1024 characters. - if simple_key.possible && (simple_key.mark.line < parser.mark.line || simple_key.mark.index+1024 < parser.mark.index) { - - // Check if the potential simple key to be removed is required. - if simple_key.required { - return yaml_parser_set_scanner_error(parser, - "while scanning a simple key", simple_key.mark, - "could not find expected ':'") - } - simple_key.possible = false +func yaml_simple_key_is_valid(parser *yaml_parser_t, simple_key *yaml_simple_key_t) (valid, ok bool) { + if !simple_key.possible { + return false, true + } + + // The 1.2 specification says: + // + // "If the ? indicator is omitted, parsing needs to see past the + // implicit key to recognize it as such. To limit the amount of + // lookahead required, the “:” indicator must appear at most 1024 + // Unicode characters beyond the start of the key. In addition, the key + // is restricted to a single line." + // + if simple_key.mark.line < parser.mark.line || simple_key.mark.index+1024 < parser.mark.index { + // Check if the potential simple key to be removed is required. + if simple_key.required { + return false, yaml_parser_set_scanner_error(parser, + "while scanning a simple key", simple_key.mark, + "could not find expected ':'") } + simple_key.possible = false + return false, true } - return true + return true, true } // Check if a simple key may start at the current position and add it if @@ -879,13 +862,14 @@ func yaml_parser_save_simple_key(parser *yaml_parser_t) bool { possible: true, required: required, token_number: parser.tokens_parsed + (len(parser.tokens) - parser.tokens_head), + mark: parser.mark, } - simple_key.mark = parser.mark if !yaml_parser_remove_simple_key(parser) { return false } parser.simple_keys[len(parser.simple_keys)-1] = simple_key + parser.simple_keys_by_tok[simple_key.token_number] = len(parser.simple_keys) - 1 } return true } @@ -900,9 +884,10 @@ func yaml_parser_remove_simple_key(parser *yaml_parser_t) bool { "while scanning a simple key", parser.simple_keys[i].mark, "could not find expected ':'") } + // Remove the key from the stack. + parser.simple_keys[i].possible = false + delete(parser.simple_keys_by_tok, parser.simple_keys[i].token_number) } - // Remove the key from the stack. - parser.simple_keys[i].possible = false return true } @@ -912,7 +897,12 @@ const max_flow_level = 10000 // Increase the flow level and resize the simple key list if needed. func yaml_parser_increase_flow_level(parser *yaml_parser_t) bool { // Reset the simple key on the next level. - parser.simple_keys = append(parser.simple_keys, yaml_simple_key_t{}) + parser.simple_keys = append(parser.simple_keys, yaml_simple_key_t{ + possible: false, + required: false, + token_number: parser.tokens_parsed + (len(parser.tokens) - parser.tokens_head), + mark: parser.mark, + }) // Increase the flow level. parser.flow_level++ @@ -928,7 +918,9 @@ func yaml_parser_increase_flow_level(parser *yaml_parser_t) bool { func yaml_parser_decrease_flow_level(parser *yaml_parser_t) bool { if parser.flow_level > 0 { parser.flow_level-- - parser.simple_keys = parser.simple_keys[:len(parser.simple_keys)-1] + last := len(parser.simple_keys) - 1 + delete(parser.simple_keys_by_tok, parser.simple_keys[last].token_number) + parser.simple_keys = parser.simple_keys[:last] } return true } @@ -1005,6 +997,8 @@ func yaml_parser_fetch_stream_start(parser *yaml_parser_t) bool { // Initialize the simple key stack. parser.simple_keys = append(parser.simple_keys, yaml_simple_key_t{}) + parser.simple_keys_by_tok = make(map[int]int) + // A simple key is allowed at the beginning of the stream. parser.simple_key_allowed = true @@ -1286,7 +1280,11 @@ func yaml_parser_fetch_value(parser *yaml_parser_t) bool { simple_key := &parser.simple_keys[len(parser.simple_keys)-1] // Have we found a simple key? - if simple_key.possible { + if valid, ok := yaml_simple_key_is_valid(parser, simple_key); !ok { + return false + + } else if valid { + // Create the KEY token and insert it into the queue. token := yaml_token_t{ typ: yaml_KEY_TOKEN, @@ -1304,6 +1302,7 @@ func yaml_parser_fetch_value(parser *yaml_parser_t) bool { // Remove the simple key. simple_key.possible = false + delete(parser.simple_keys_by_tok, simple_key.token_number) // A simple key cannot follow another simple key. parser.simple_key_allowed = false diff --git a/vendor/gopkg.in/yaml.v2/yaml.go b/vendor/gopkg.in/yaml.v2/yaml.go index de85aa4cdb..89650e293a 100644 --- a/vendor/gopkg.in/yaml.v2/yaml.go +++ b/vendor/gopkg.in/yaml.v2/yaml.go @@ -89,7 +89,7 @@ func UnmarshalStrict(in []byte, out interface{}) (err error) { return unmarshal(in, out, true) } -// A Decorder reads and decodes YAML values from an input stream. +// A Decoder reads and decodes YAML values from an input stream. type Decoder struct { strict bool parser *parser diff --git a/vendor/gopkg.in/yaml.v2/yamlh.go b/vendor/gopkg.in/yaml.v2/yamlh.go index e25cee563b..f6a9c8e34b 100644 --- a/vendor/gopkg.in/yaml.v2/yamlh.go +++ b/vendor/gopkg.in/yaml.v2/yamlh.go @@ -579,6 +579,7 @@ type yaml_parser_t struct { simple_key_allowed bool // May a simple key occur at the current position? simple_keys []yaml_simple_key_t // The stack of simple keys. + simple_keys_by_tok map[int]int // possible simple_key indexes indexed by token_number // Parser stuff diff --git a/vendor/k8s.io/client-go/discovery/discovery_client.go b/vendor/k8s.io/client-go/discovery/discovery_client.go index 61b9c4481b..5d89457cca 100644 --- a/vendor/k8s.io/client-go/discovery/discovery_client.go +++ b/vendor/k8s.io/client-go/discovery/discovery_client.go @@ -463,6 +463,13 @@ func setDiscoveryDefaults(config *restclient.Config) error { if config.Timeout == 0 { config.Timeout = defaultTimeout } + if config.Burst == 0 && config.QPS < 100 { + // discovery is expected to be bursty, increase the default burst + // to accommodate looking up resource info for many API groups. + // matches burst set by ConfigFlags#ToDiscoveryClient(). + // see https://issue.k8s.io/86149 + config.Burst = 100 + } codec := runtime.NoopEncoder{Decoder: scheme.Codecs.UniversalDecoder()} config.NegotiatedSerializer = serializer.NegotiatedSerializerWrapper(runtime.SerializerInfo{Serializer: codec}) if len(config.UserAgent) == 0 { diff --git a/vendor/k8s.io/client-go/tools/cache/reflector.go b/vendor/k8s.io/client-go/tools/cache/reflector.go index 1165c523eb..62749ed7d3 100644 --- a/vendor/k8s.io/client-go/tools/cache/reflector.go +++ b/vendor/k8s.io/client-go/tools/cache/reflector.go @@ -74,9 +74,6 @@ type Reflector struct { // observed when doing a sync with the underlying store // it is thread safe, but not synchronized with the underlying store lastSyncResourceVersion string - // isLastSyncResourceVersionGone is true if the previous list or watch request with lastSyncResourceVersion - // failed with an HTTP 410 (Gone) status code. - isLastSyncResourceVersionGone bool // lastSyncResourceVersionMutex guards read/write access to lastSyncResourceVersion lastSyncResourceVersionMutex sync.RWMutex // WatchListPageSize is the requested chunk size of initial and resync watch lists. @@ -188,7 +185,10 @@ func (r *Reflector) ListAndWatch(stopCh <-chan struct{}) error { klog.V(3).Infof("Listing and watching %v from %s", r.expectedTypeName, r.name) var resourceVersion string - options := metav1.ListOptions{ResourceVersion: r.relistResourceVersion()} + // Explicitly set "0" as resource version - it's fine for the List() + // to be served from cache and potentially be delayed relative to + // etcd contents. Reflector framework will catch up via Watch() eventually. + options := metav1.ListOptions{ResourceVersion: "0"} if err := func() error { initTrace := trace.New("Reflector ListAndWatch", trace.Field{"name", r.name}) @@ -211,17 +211,8 @@ func (r *Reflector) ListAndWatch(stopCh <-chan struct{}) error { if r.WatchListPageSize != 0 { pager.PageSize = r.WatchListPageSize } - + // Pager falls back to full list if paginated list calls fail due to an "Expired" error. list, err = pager.List(context.Background(), options) - if isExpiredError(err) { - r.setIsLastSyncResourceVersionExpired(true) - // Retry immediately if the resource version used to list is expired. - // The pager already falls back to full list if paginated list calls fail due to an "Expired" error on - // continuation pages, but the pager might not be enabled, or the full list might fail because the - // resource version it is listing at is expired, so we need to fallback to resourceVersion="" in all - // to recover and ensure the reflector makes forward progress. - list, err = pager.List(context.Background(), metav1.ListOptions{ResourceVersion: r.relistResourceVersion()}) - } close(listCh) }() select { @@ -234,7 +225,6 @@ func (r *Reflector) ListAndWatch(stopCh <-chan struct{}) error { if err != nil { return fmt.Errorf("%s: Failed to list %v: %v", r.name, r.expectedTypeName, err) } - r.setIsLastSyncResourceVersionExpired(false) // list was successful initTrace.Step("Objects listed") listMetaInterface, err := meta.ListAccessor(list) if err != nil { @@ -308,13 +298,10 @@ func (r *Reflector) ListAndWatch(stopCh <-chan struct{}) error { w, err := r.listerWatcher.Watch(options) if err != nil { - switch { - case isExpiredError(err): - r.setIsLastSyncResourceVersionExpired(true) - klog.V(4).Infof("%s: watch of %v closed with: %v", r.name, r.expectedTypeName, err) - case err == io.EOF: + switch err { + case io.EOF: // watch closed normally - case err == io.ErrUnexpectedEOF: + case io.ErrUnexpectedEOF: klog.V(1).Infof("%s: Watch for %v closed with unexpected EOF: %v", r.name, r.expectedTypeName, err) default: utilruntime.HandleError(fmt.Errorf("%s: Failed to watch %v: %v", r.name, r.expectedTypeName, err)) @@ -333,8 +320,7 @@ func (r *Reflector) ListAndWatch(stopCh <-chan struct{}) error { if err := r.watchHandler(w, &resourceVersion, resyncerrc, stopCh); err != nil { if err != errorStopRequested { switch { - case isExpiredError(err): - r.setIsLastSyncResourceVersionExpired(true) + case apierrs.IsResourceExpired(err): klog.V(4).Infof("%s: watch of %v ended with: %v", r.name, r.expectedTypeName, err) default: klog.Warningf("%s: watch of %v ended with: %v", r.name, r.expectedTypeName, err) @@ -446,42 +432,3 @@ func (r *Reflector) setLastSyncResourceVersion(v string) { defer r.lastSyncResourceVersionMutex.Unlock() r.lastSyncResourceVersion = v } - -// relistResourceVersion determines the resource version the reflector should list or relist from. -// Returns either the lastSyncResourceVersion so that this reflector will relist with a resource -// versions no older than has already been observed in relist results or watch events, or, if the last relist resulted -// in an HTTP 410 (Gone) status code, returns "" so that the relist will use the latest resource version available in -// etcd via a quorum read. -func (r *Reflector) relistResourceVersion() string { - r.lastSyncResourceVersionMutex.RLock() - defer r.lastSyncResourceVersionMutex.RUnlock() - - if r.isLastSyncResourceVersionGone { - // Since this reflector makes paginated list requests, and all paginated list requests skip the watch cache - // if the lastSyncResourceVersion is expired, we set ResourceVersion="" and list again to re-establish reflector - // to the latest available ResourceVersion, using a consistent read from etcd. - return "" - } - if r.lastSyncResourceVersion == "" { - // For performance reasons, initial list performed by reflector uses "0" as resource version to allow it to - // be served from the watch cache if it is enabled. - return "0" - } - return r.lastSyncResourceVersion -} - -// setIsLastSyncResourceVersionExpired sets if the last list or watch request with lastSyncResourceVersion returned a -// expired error: HTTP 410 (Gone) Status Code. -func (r *Reflector) setIsLastSyncResourceVersionExpired(isExpired bool) { - r.lastSyncResourceVersionMutex.Lock() - defer r.lastSyncResourceVersionMutex.Unlock() - r.isLastSyncResourceVersionGone = isExpired -} - -func isExpiredError(err error) bool { - // In Kubernetes 1.17 and earlier, the api server returns both apierrs.StatusReasonExpired and - // apierrs.StatusReasonGone for HTTP 410 (Gone) status code responses. In 1.18 the kube server is more consistent - // and always returns apierrs.StatusReasonExpired. For backward compatibility we can only remove the apierrs.IsGone - // check when we fully drop support for Kubernetes 1.17 servers from reflectors. - return apierrs.IsResourceExpired(err) || apierrs.IsGone(err) -} diff --git a/vendor/k8s.io/client-go/tools/clientcmd/api/v1/conversion.go b/vendor/k8s.io/client-go/tools/clientcmd/api/v1/conversion.go index 0d27672e3d..c38ebc0760 100644 --- a/vendor/k8s.io/client-go/tools/clientcmd/api/v1/conversion.go +++ b/vendor/k8s.io/client-go/tools/clientcmd/api/v1/conversion.go @@ -31,6 +31,9 @@ func Convert_Slice_v1_NamedCluster_To_Map_string_To_Pointer_api_Cluster(in *[]Na if err := Convert_v1_Cluster_To_api_Cluster(&curr.Cluster, newCluster, s); err != nil { return err } + if *out == nil { + *out = make(map[string]*api.Cluster) + } if (*out)[curr.Name] == nil { (*out)[curr.Name] = newCluster } else { @@ -65,6 +68,9 @@ func Convert_Slice_v1_NamedAuthInfo_To_Map_string_To_Pointer_api_AuthInfo(in *[] if err := Convert_v1_AuthInfo_To_api_AuthInfo(&curr.AuthInfo, newAuthInfo, s); err != nil { return err } + if *out == nil { + *out = make(map[string]*api.AuthInfo) + } if (*out)[curr.Name] == nil { (*out)[curr.Name] = newAuthInfo } else { @@ -99,6 +105,9 @@ func Convert_Slice_v1_NamedContext_To_Map_string_To_Pointer_api_Context(in *[]Na if err := Convert_v1_Context_To_api_Context(&curr.Context, newContext, s); err != nil { return err } + if *out == nil { + *out = make(map[string]*api.Context) + } if (*out)[curr.Name] == nil { (*out)[curr.Name] = newContext } else { @@ -133,6 +142,9 @@ func Convert_Slice_v1_NamedExtension_To_Map_string_To_runtime_Object(in *[]Named if err := runtime.Convert_runtime_RawExtension_To_runtime_Object(&curr.Extension, &newExtension, s); err != nil { return err } + if *out == nil { + *out = make(map[string]runtime.Object) + } if (*out)[curr.Name] == nil { (*out)[curr.Name] = newExtension } else { diff --git a/vendor/k8s.io/client-go/util/connrotation/connrotation.go b/vendor/k8s.io/client-go/util/connrotation/connrotation.go index 235a9e0198..f98faee47d 100644 --- a/vendor/k8s.io/client-go/util/connrotation/connrotation.go +++ b/vendor/k8s.io/client-go/util/connrotation/connrotation.go @@ -77,11 +77,6 @@ func (d *Dialer) DialContext(ctx context.Context, network, address string) (net. closable := &closableConn{Conn: conn} - // Start tracking the connection - d.mu.Lock() - d.conns[closable] = struct{}{} - d.mu.Unlock() - // When the connection is closed, remove it from the map. This will // be no-op if the connection isn't in the map, e.g. if CloseAll() // is called. @@ -91,6 +86,11 @@ func (d *Dialer) DialContext(ctx context.Context, network, address string) (net. d.mu.Unlock() } + // Start tracking the connection + d.mu.Lock() + d.conns[closable] = struct{}{} + d.mu.Unlock() + return closable, nil } diff --git a/vendor/knative.dev/eventing/pkg/apis/config/defaults.go b/vendor/knative.dev/eventing/pkg/apis/config/defaults.go index d067ad44b2..c78b42a700 100644 --- a/vendor/knative.dev/eventing/pkg/apis/config/defaults.go +++ b/vendor/knative.dev/eventing/pkg/apis/config/defaults.go @@ -70,11 +70,19 @@ func NewDefaultsConfigFromConfigMap(config *corev1.ConfigMap) (*Defaults, error) type Defaults struct { // NamespaceDefaultsConfig are the default Broker Configs for each namespace. // Namespace is the key, the value is the KReference to the config. - NamespaceDefaultsConfig map[string]*duckv1.KReference `json:"namespaceDefaults,omitempty"` + NamespaceDefaultsConfig map[string]*ClassAndKRef `json:"namespaceDefaults,omitempty"` // ClusterDefaultBrokerConfig is the default broker config for all the namespaces that // are not in NamespaceDefaultBrokerConfigs. - ClusterDefault *duckv1.KReference `json:"clusterDefault,omitempty"` + ClusterDefault *ClassAndKRef `json:"clusterDefault,omitempty"` +} + +// ClassAndKRef contains configuration for a given namespace for broker. Allows +// configuring both the Class of the Broker as well as the reference to the +// config it should use +type ClassAndKRef struct { + BrokerClass string `json:"brokerClass,omitempty"` + *duckv1.KReference `json:",inline"` } // GetBrokerConfig returns a namespace specific Broker Configuration, and if @@ -85,11 +93,28 @@ func (d *Defaults) GetBrokerConfig(ns string) (*duckv1.KReference, error) { return nil, errors.New("Defaults are nil") } value, present := d.NamespaceDefaultsConfig[ns] - if present { - return value, nil + if present && value.KReference != nil { + return value.KReference, nil } - if d.ClusterDefault != nil { - return d.ClusterDefault, nil + if d.ClusterDefault != nil && d.ClusterDefault.KReference != nil { + return d.ClusterDefault.KReference, nil } return nil, errors.New("Defaults for Broker Configurations have not been set up.") } + +// GetBrokerClass returns a namespace specific Broker Class, and if +// that doesn't exist, return a Cluster Default and if that doesn't exist +// return an error. +func (d *Defaults) GetBrokerClass(ns string) (string, error) { + if d == nil { + return "", errors.New("Defaults are nil") + } + value, present := d.NamespaceDefaultsConfig[ns] + if present && value.BrokerClass != "" { + return value.BrokerClass, nil + } + if d.ClusterDefault != nil && d.ClusterDefault.BrokerClass != "" { + return d.ClusterDefault.BrokerClass, nil + } + return "", errors.New("Defaults for Broker Configurations have not been set up.") +} diff --git a/vendor/knative.dev/eventing/pkg/apis/config/zz_generated.deepcopy.go b/vendor/knative.dev/eventing/pkg/apis/config/zz_generated.deepcopy.go index 59abf30784..bb1f1cb1a3 100644 --- a/vendor/knative.dev/eventing/pkg/apis/config/zz_generated.deepcopy.go +++ b/vendor/knative.dev/eventing/pkg/apis/config/zz_generated.deepcopy.go @@ -24,28 +24,49 @@ import ( v1 "knative.dev/pkg/apis/duck/v1" ) +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ClassAndKRef) DeepCopyInto(out *ClassAndKRef) { + *out = *in + if in.KReference != nil { + in, out := &in.KReference, &out.KReference + *out = new(v1.KReference) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClassAndKRef. +func (in *ClassAndKRef) DeepCopy() *ClassAndKRef { + if in == nil { + return nil + } + out := new(ClassAndKRef) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Defaults) DeepCopyInto(out *Defaults) { *out = *in if in.NamespaceDefaultsConfig != nil { in, out := &in.NamespaceDefaultsConfig, &out.NamespaceDefaultsConfig - *out = make(map[string]*v1.KReference, len(*in)) + *out = make(map[string]*ClassAndKRef, len(*in)) for key, val := range *in { - var outVal *v1.KReference + var outVal *ClassAndKRef if val == nil { (*out)[key] = nil } else { in, out := &val, &outVal - *out = new(v1.KReference) - **out = **in + *out = new(ClassAndKRef) + (*in).DeepCopyInto(*out) } (*out)[key] = outVal } } if in.ClusterDefault != nil { in, out := &in.ClusterDefault, &out.ClusterDefault - *out = new(v1.KReference) - **out = **in + *out = new(ClassAndKRef) + (*in).DeepCopyInto(*out) } return } diff --git a/vendor/knative.dev/eventing/pkg/apis/configs/v1alpha1/configmappropagation_types.go b/vendor/knative.dev/eventing/pkg/apis/configs/v1alpha1/configmappropagation_types.go index 7df9db3182..ae6f7d50d6 100644 --- a/vendor/knative.dev/eventing/pkg/apis/configs/v1alpha1/configmappropagation_types.go +++ b/vendor/knative.dev/eventing/pkg/apis/configs/v1alpha1/configmappropagation_types.go @@ -27,6 +27,7 @@ import ( ) // +genclient +// +genreconciler // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object // ConfigMapPropagation is used to propagate configMaps from original namespace to current namespace diff --git a/vendor/knative.dev/eventing/pkg/apis/duck/lifecycle_helper.go b/vendor/knative.dev/eventing/pkg/apis/duck/lifecycle_helper.go index c1b06b2de3..98888bbb0e 100644 --- a/vendor/knative.dev/eventing/pkg/apis/duck/lifecycle_helper.go +++ b/vendor/knative.dev/eventing/pkg/apis/duck/lifecycle_helper.go @@ -18,6 +18,7 @@ package duck import ( appsv1 "k8s.io/api/apps/v1" + corev1 "k8s.io/api/core/v1" ) // DeploymentIsAvailable determines if the provided deployment is available. Note that if it cannot @@ -31,3 +32,13 @@ func DeploymentIsAvailable(d *appsv1.DeploymentStatus, def bool) bool { } return def } + +// EndpointsAreAvailable determines if the provided Endpoints are available. +func EndpointsAreAvailable(ep *corev1.Endpoints) bool { + for _, subset := range ep.Subsets { + if len(subset.Addresses) > 0 { + return true + } + } + return false +} diff --git a/vendor/knative.dev/eventing/pkg/apis/duck/v1alpha1/subscribable_types.go b/vendor/knative.dev/eventing/pkg/apis/duck/v1alpha1/subscribable_types.go index 742fa32f13..c1817a088b 100644 --- a/vendor/knative.dev/eventing/pkg/apis/duck/v1alpha1/subscribable_types.go +++ b/vendor/knative.dev/eventing/pkg/apis/duck/v1alpha1/subscribable_types.go @@ -120,6 +120,8 @@ var ( // Verify SubscribableType resources meet duck contracts. _ duck.Populatable = (*SubscribableType)(nil) _ apis.Listable = (*SubscribableType)(nil) + + _ apis.Convertible = (*SubscribableType)(nil) ) // GetSubscribableTypeStatus method Returns the Default SubscribableStatus in this case it's SubscribableStatus diff --git a/vendor/knative.dev/eventing/pkg/apis/duck/v1alpha1/subscribable_types_conversion.go b/vendor/knative.dev/eventing/pkg/apis/duck/v1alpha1/subscribable_types_conversion.go new file mode 100644 index 0000000000..5d95f69f58 --- /dev/null +++ b/vendor/knative.dev/eventing/pkg/apis/duck/v1alpha1/subscribable_types_conversion.go @@ -0,0 +1,144 @@ +/* +Copyright 2020 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 ( + "context" + "fmt" + + "knative.dev/pkg/apis" + duckv1 "knative.dev/pkg/apis/duck/v1" + + duckv1beta1 "knative.dev/eventing/pkg/apis/duck/v1beta1" +) + +// ConvertTo implements apis.Convertible +// Converts source (from v1alpha1.SubscribableType) into v1beta1.Subscribable +func (source *SubscribableType) ConvertTo(ctx context.Context, obj apis.Convertible) error { + switch sink := obj.(type) { + case *duckv1beta1.Subscribable: + sink.ObjectMeta = source.ObjectMeta + source.Status.ConvertTo(ctx, &sink.Status) + return source.Spec.ConvertTo(ctx, &sink.Spec) + default: + return fmt.Errorf("unknown version, got: %T", sink) + } +} + +// ConvertTo helps implement apis.Convertible +func (source *SubscribableTypeSpec) ConvertTo(ctx context.Context, sink *duckv1beta1.SubscribableSpec) error { + if source.Subscribable != nil { + sink.Subscribers = make([]duckv1beta1.SubscriberSpec, len(source.Subscribable.Subscribers)) + for i, s := range source.Subscribable.Subscribers { + s.ConvertTo(ctx, &sink.Subscribers[i]) + } + } + return nil +} + +func (source *SubscriberSpec) ConvertTo(ctx context.Context, sink *duckv1beta1.SubscriberSpec) { + sink.UID = source.UID + sink.Generation = source.Generation + sink.SubscriberURI = source.SubscriberURI + sink.ReplyURI = source.ReplyURI + + if source.Delivery != nil { + sink.Delivery = source.Delivery + } else { + // If however, there's a Deprecated DeadLetterSinkURI, convert that up + // to DeliverySpec. + sink.Delivery = &duckv1beta1.DeliverySpec{ + DeadLetterSink: &duckv1.Destination{ + URI: source.DeadLetterSinkURI, + }, + } + } +} + +// ConvertTo helps implement apis.Convertible +func (source *SubscribableTypeStatus) ConvertTo(ctx context.Context, sink *duckv1beta1.SubscribableStatus) { + if source.SubscribableStatus != nil && + len(source.SubscribableStatus.Subscribers) > 0 { + sink.Subscribers = make([]duckv1beta1.SubscriberStatus, len(source.SubscribableStatus.Subscribers)) + for i, ss := range source.SubscribableStatus.Subscribers { + sink.Subscribers[i] = duckv1beta1.SubscriberStatus{ + UID: ss.UID, + ObservedGeneration: ss.ObservedGeneration, + Ready: ss.Ready, + Message: ss.Message, + } + } + } +} + +// ConvertFrom implements apis.Convertible. +// Converts obj v1beta1.Subscribable into v1alpha1.Subscribable +func (sink *SubscribableType) ConvertFrom(ctx context.Context, obj apis.Convertible) error { + switch source := obj.(type) { + case *duckv1beta1.Subscribable: + sink.ObjectMeta = source.ObjectMeta + sink.Status.ConvertFrom(ctx, source.Status) + sink.Spec.ConvertFrom(ctx, source.Spec) + return nil + default: + return fmt.Errorf("unknown version, got: %T", source) + } +} + +// ConvertFrom helps implement apis.Convertible +func (sink *SubscribableTypeSpec) ConvertFrom(ctx context.Context, source duckv1beta1.SubscribableSpec) { + if len(source.Subscribers) > 0 { + sink.Subscribable = &Subscribable{ + Subscribers: make([]SubscriberSpec, len(source.Subscribers)), + } + for i, s := range source.Subscribers { + sink.Subscribable.Subscribers[i].ConvertFrom(ctx, s) + } + } +} + +func (sink *SubscriberSpec) ConvertFrom(ctx context.Context, source duckv1beta1.SubscriberSpec) { + var deadLetterSinkURI *apis.URL + if source.Delivery != nil && source.Delivery.DeadLetterSink != nil { + deadLetterSinkURI = source.Delivery.DeadLetterSink.URI + } + sink.UID = source.UID + sink.Generation = source.Generation + sink.SubscriberURI = source.SubscriberURI + sink.ReplyURI = source.ReplyURI + sink.Delivery = source.Delivery + sink.DeadLetterSinkURI = deadLetterSinkURI + +} + +// ConvertFrom helps implement apis.Convertible +func (sink *SubscribableTypeStatus) ConvertFrom(ctx context.Context, source duckv1beta1.SubscribableStatus) error { + if len(source.Subscribers) > 0 { + sink.SubscribableStatus = &SubscribableStatus{ + Subscribers: make([]SubscriberStatus, len(source.Subscribers)), + } + for i, ss := range source.Subscribers { + sink.SubscribableStatus.Subscribers[i] = SubscriberStatus{ + UID: ss.UID, + ObservedGeneration: ss.ObservedGeneration, + Ready: ss.Ready, + Message: ss.Message, + } + } + } + return nil +} diff --git a/vendor/knative.dev/eventing/pkg/apis/duck/v1beta1/subscribable_types.go b/vendor/knative.dev/eventing/pkg/apis/duck/v1beta1/subscribable_types.go index 242901888a..e99a6be2dd 100644 --- a/vendor/knative.dev/eventing/pkg/apis/duck/v1beta1/subscribable_types.go +++ b/vendor/knative.dev/eventing/pkg/apis/duck/v1beta1/subscribable_types.go @@ -105,6 +105,8 @@ var ( // Verify SubscribableType resources meet duck contracts. _ duck.Populatable = (*Subscribable)(nil) _ apis.Listable = (*Subscribable)(nil) + + _ apis.Convertible = (*Subscribable)(nil) ) // GetFullType implements duck.Implementable diff --git a/vendor/knative.dev/eventing/pkg/apis/legacysources/v1alpha1/sinkbinding_defaults.go b/vendor/knative.dev/eventing/pkg/apis/duck/v1beta1/subscribable_types_conversion.go similarity index 54% rename from vendor/knative.dev/eventing/pkg/apis/legacysources/v1alpha1/sinkbinding_defaults.go rename to vendor/knative.dev/eventing/pkg/apis/duck/v1beta1/subscribable_types_conversion.go index fc006ec141..f25a6755ce 100644 --- a/vendor/knative.dev/eventing/pkg/apis/legacysources/v1alpha1/sinkbinding_defaults.go +++ b/vendor/knative.dev/eventing/pkg/apis/duck/v1beta1/subscribable_types_conversion.go @@ -1,5 +1,5 @@ /* -Copyright 2019 The Knative Authors +Copyright 2020 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. @@ -14,20 +14,21 @@ See the License for the specific language governing permissions and limitations under the License. */ -package v1alpha1 +package v1beta1 import ( "context" + "fmt" "knative.dev/pkg/apis" ) -// SetDefaults implements apis.Defaultable -func (fb *SinkBinding) SetDefaults(ctx context.Context) { - withNS := apis.WithinParent(ctx, fb.ObjectMeta) - fb.Spec.Sink.SetDefaults(withNS) - if fb.Spec.Subject.Namespace == "" { - // Default the subject's namespace to our namespace. - fb.Spec.Subject.Namespace = fb.Namespace - } +// ConvertTo implements apis.Convertible +func (source *Subscribable) ConvertTo(ctx context.Context, sink apis.Convertible) error { + return fmt.Errorf("v1beta1 is the highest known version, got: %T", sink) +} + +// ConvertFrom implements apis.Convertible +func (sink *Subscribable) ConvertFrom(ctx context.Context, source apis.Convertible) error { + return fmt.Errorf("v1beta1 is the highest known version, got: %T", source) } diff --git a/vendor/knative.dev/eventing/pkg/apis/eventing/defaults.go b/vendor/knative.dev/eventing/pkg/apis/eventing/defaults.go new file mode 100644 index 0000000000..d2b52e8f89 --- /dev/null +++ b/vendor/knative.dev/eventing/pkg/apis/eventing/defaults.go @@ -0,0 +1,40 @@ +/* +Copyright 2020 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 eventing + +import ( + "context" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "knative.dev/eventing/pkg/apis/config" +) + +// DefaultBrokerClassIfUnset sets default broker class annotation if unset. +func DefaultBrokerClassIfUnset(ctx context.Context, obj *metav1.ObjectMeta) { + annotations := obj.GetAnnotations() + if annotations == nil { + annotations = make(map[string]string, 1) + } + if _, present := annotations[BrokerClassKey]; !present { + cfg := config.FromContextOrDefaults(ctx) + c, err := cfg.Defaults.GetBrokerClass(obj.Namespace) + if err == nil { + annotations[BrokerClassKey] = c + obj.SetAnnotations(annotations) + } + } +} diff --git a/vendor/knative.dev/eventing/pkg/apis/eventing/register.go b/vendor/knative.dev/eventing/pkg/apis/eventing/register.go index c789e7a0d2..802e5f0216 100644 --- a/vendor/knative.dev/eventing/pkg/apis/eventing/register.go +++ b/vendor/knative.dev/eventing/pkg/apis/eventing/register.go @@ -29,10 +29,37 @@ const ( // which Controller is responsible for them. BrokerClassKey = GroupName + "/broker.class" + // ChannelBrokerClassValue is the value we use to specify the + // Broker using channels. As in Broker from this repository + // pkg/reconciler/broker + ChannelBrokerClassValue = "ChannelBasedBroker" + + // MTChannelBrokerClassValue is the value we use to specify the + // Broker using channels, but the resources (ingress,filter) run + // in the system namespace. As in Broker from this repository + // pkg/reconciler/mtbroker + MTChannelBrokerClassValue = "MTChannelBasedBroker" + // ScopeAnnotationKey is the annotation key to indicate // the scope of the component handling a given resource. // Valid values are: cluster, namespace, resource. ScopeAnnotationKey = GroupName + "/scope" + + // ScopeResource indicates that the resource + // must be handled by a dedicated component + ScopeResource = "resource" + + // ScopeNamespace indicates that the resource + // must be handled by the namespace-scoped component + ScopeNamespace = "namespace" + + // ScopeCluster indicates the resource must be + // handled by the cluster-scoped component + ScopeCluster = "cluster" + + // EventTypesAnnotationKey is the annotation key to specify + // if a Source has event types defines in its CRD. + EventTypesAnnotationKey = "registry.knative.dev/eventTypes" ) var ( diff --git a/vendor/knative.dev/eventing/pkg/apis/eventing/v1alpha1/broker_defaults.go b/vendor/knative.dev/eventing/pkg/apis/eventing/v1alpha1/broker_defaults.go index c8ccbbd6f0..53a1d1a76f 100644 --- a/vendor/knative.dev/eventing/pkg/apis/eventing/v1alpha1/broker_defaults.go +++ b/vendor/knative.dev/eventing/pkg/apis/eventing/v1alpha1/broker_defaults.go @@ -19,7 +19,8 @@ package v1alpha1 import ( "context" - "knative.dev/eventing/pkg/apis/messaging/config" + "knative.dev/eventing/pkg/apis/eventing" + messagingconfig "knative.dev/eventing/pkg/apis/messaging/config" messagingv1beta1 "knative.dev/eventing/pkg/apis/messaging/v1beta1" "knative.dev/pkg/apis" ) @@ -27,6 +28,7 @@ import ( func (b *Broker) SetDefaults(ctx context.Context) { withNS := apis.WithinParent(ctx, b.ObjectMeta) b.Spec.SetDefaults(withNS) + eventing.DefaultBrokerClassIfUnset(withNS, &b.ObjectMeta) } func (bs *BrokerSpec) SetDefaults(ctx context.Context) { @@ -34,13 +36,13 @@ func (bs *BrokerSpec) SetDefaults(ctx context.Context) { // If we haven't configured the new channelTemplate, // then set the default channel to the new channelTemplate. if bs.ChannelTemplate == nil { - cfg := config.FromContextOrDefaults(ctx) - c, err := cfg.ChannelDefaults.GetChannelConfig(apis.ParentMeta(ctx).Namespace) + channelCfg := messagingconfig.FromContextOrDefaults(ctx) + c, err := channelCfg.ChannelDefaults.GetChannelConfig(apis.ParentMeta(ctx).Namespace) if err == nil { bs.ChannelTemplate = &messagingv1beta1.ChannelTemplateSpec{ - c.TypeMeta, - c.Spec, + TypeMeta: c.TypeMeta, + Spec: c.Spec, } } } diff --git a/vendor/knative.dev/eventing/pkg/apis/eventing/v1alpha1/broker_lifecycle.go b/vendor/knative.dev/eventing/pkg/apis/eventing/v1alpha1/broker_lifecycle.go index 54e4c23d55..d99fabf886 100644 --- a/vendor/knative.dev/eventing/pkg/apis/eventing/v1alpha1/broker_lifecycle.go +++ b/vendor/knative.dev/eventing/pkg/apis/eventing/v1alpha1/broker_lifecycle.go @@ -17,9 +17,9 @@ limitations under the License. package v1alpha1 import ( - appsv1 "k8s.io/api/apps/v1" "knative.dev/pkg/apis" + corev1 "k8s.io/api/core/v1" "knative.dev/eventing/pkg/apis/duck" duckv1alpha1 "knative.dev/eventing/pkg/apis/duck/v1alpha1" ) @@ -63,13 +63,11 @@ func (bs *BrokerStatus) MarkIngressFailed(reason, format string, args ...interfa brokerCondSet.Manage(bs).MarkFalse(BrokerConditionIngress, reason, format, args...) } -func (bs *BrokerStatus) PropagateIngressDeploymentAvailability(d *appsv1.Deployment) { - if duck.DeploymentIsAvailable(&d.Status, true) { +func (bs *BrokerStatus) PropagateIngressAvailability(ep *corev1.Endpoints) { + if duck.EndpointsAreAvailable(ep) { brokerCondSet.Manage(bs).MarkTrue(BrokerConditionIngress) } else { - // I don't know how to propagate the status well, so just give the name of the Deployment - // for now. - bs.MarkIngressFailed("DeploymentUnavailable", "The Deployment '%s' is unavailable.", d.Name) + bs.MarkIngressFailed("EndpointsUnavailable", "Endpoints %q are unavailable.", ep.Name) } } @@ -91,13 +89,11 @@ func (bs *BrokerStatus) MarkFilterFailed(reason, format string, args ...interfac brokerCondSet.Manage(bs).MarkFalse(BrokerConditionFilter, reason, format, args...) } -func (bs *BrokerStatus) PropagateFilterDeploymentAvailability(d *appsv1.Deployment) { - if duck.DeploymentIsAvailable(&d.Status, true) { +func (bs *BrokerStatus) PropagateFilterAvailability(ep *corev1.Endpoints) { + if duck.EndpointsAreAvailable(ep) { brokerCondSet.Manage(bs).MarkTrue(BrokerConditionFilter) } else { - // I don't know how to propagate the status well, so just give the name of the Deployment - // for now. - bs.MarkFilterFailed("DeploymentUnavailable", "The Deployment '%s' is unavailable.", d.Name) + bs.MarkFilterFailed("EndpointsUnavailable", "Endpoints %q are unavailable.", ep.Name) } } diff --git a/vendor/knative.dev/eventing/pkg/apis/eventing/v1alpha1/broker_types.go b/vendor/knative.dev/eventing/pkg/apis/eventing/v1alpha1/broker_types.go index 155b9da3ef..f34581f967 100644 --- a/vendor/knative.dev/eventing/pkg/apis/eventing/v1alpha1/broker_types.go +++ b/vendor/knative.dev/eventing/pkg/apis/eventing/v1alpha1/broker_types.go @@ -30,7 +30,7 @@ import ( ) // +genclient -// +genreconciler +// +genreconciler:class=eventing.knative.dev/broker.class // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object // Broker collects a pool of events that are consumable using Triggers. Brokers diff --git a/vendor/knative.dev/eventing/pkg/apis/eventing/v1alpha1/eventtype_types.go b/vendor/knative.dev/eventing/pkg/apis/eventing/v1alpha1/eventtype_types.go index 0d7369906c..4bfa731690 100644 --- a/vendor/knative.dev/eventing/pkg/apis/eventing/v1alpha1/eventtype_types.go +++ b/vendor/knative.dev/eventing/pkg/apis/eventing/v1alpha1/eventtype_types.go @@ -40,6 +40,7 @@ type EventType struct { // Status represents the current state of the EventType. // This data may be out of date. // +optional + // TODO might be removed https://github.com/knative/eventing/issues/2750 Status EventTypeStatus `json:"status,omitempty"` } @@ -61,13 +62,16 @@ type EventTypeSpec struct { // Type represents the CloudEvents type. It is authoritative. Type string `json:"type"` // Source is a URI, it represents the CloudEvents source. - Source string `json:"source"` + // +optional + Source string `json:"source,omitempty"` // Schema is a URI, it represents the CloudEvents schemaurl extension attribute. // It may be a JSON schema, a protobuf schema, etc. It is optional. // +optional Schema string `json:"schema,omitempty"` + // TODO remove https://github.com/knative/eventing/issues/2750 // Broker refers to the Broker that can provide the EventType. - Broker string `json:"broker"` + // +optional + Broker string `json:"broker,omitempty"` // Description is an optional field used to describe the EventType, in any meaningful way. // +optional Description string `json:"description,omitempty"` diff --git a/vendor/knative.dev/eventing/pkg/apis/eventing/v1alpha1/eventtype_validation.go b/vendor/knative.dev/eventing/pkg/apis/eventing/v1alpha1/eventtype_validation.go index 8bc9fa6f7c..20234c693c 100644 --- a/vendor/knative.dev/eventing/pkg/apis/eventing/v1alpha1/eventtype_validation.go +++ b/vendor/knative.dev/eventing/pkg/apis/eventing/v1alpha1/eventtype_validation.go @@ -19,8 +19,6 @@ package v1alpha1 import ( "context" - "github.com/google/go-cmp/cmp/cmpopts" - "knative.dev/pkg/apis" "knative.dev/pkg/kmp" ) @@ -35,15 +33,6 @@ func (ets *EventTypeSpec) Validate(ctx context.Context) *apis.FieldError { fe := apis.ErrMissingField("type") errs = errs.Also(fe) } - if ets.Source == "" { - // TODO validate is a valid URI. - fe := apis.ErrMissingField("source") - errs = errs.Also(fe) - } - if ets.Broker == "" { - fe := apis.ErrMissingField("broker") - errs = errs.Also(fe) - } // TODO validate Schema is a valid URI. return errs } @@ -53,9 +42,8 @@ func (et *EventType) CheckImmutableFields(ctx context.Context, original *EventTy return nil } - // All but Description field immutable. - ignoreArguments := cmpopts.IgnoreFields(EventTypeSpec{}, "Description") - if diff, err := kmp.ShortDiff(original.Spec, et.Spec, ignoreArguments); err != nil { + // All fields immutable + if diff, err := kmp.ShortDiff(original.Spec, et.Spec); err != nil { return &apis.FieldError{ Message: "Failed to diff EventType", Paths: []string{"spec"}, diff --git a/vendor/knative.dev/eventing/pkg/apis/eventing/v1alpha1/test_helper.go b/vendor/knative.dev/eventing/pkg/apis/eventing/v1alpha1/test_helper.go index 3324427c1f..93ea443eb1 100644 --- a/vendor/knative.dev/eventing/pkg/apis/eventing/v1alpha1/test_helper.go +++ b/vendor/knative.dev/eventing/pkg/apis/eventing/v1alpha1/test_helper.go @@ -17,8 +17,7 @@ limitations under the License. package v1alpha1 import ( - v1 "k8s.io/api/apps/v1" - "knative.dev/eventing/pkg/apis/legacysources/v1alpha1" + corev1 "k8s.io/api/core/v1" "knative.dev/pkg/apis" pkgduckv1alpha1 "knative.dev/pkg/apis/duck/v1alpha1" @@ -69,9 +68,9 @@ func (testHelper) FalseSubscriptionStatus() *messagingv1alpha1.SubscriptionStatu func (t testHelper) ReadyBrokerStatus() *BrokerStatus { bs := &BrokerStatus{} - bs.PropagateIngressDeploymentAvailability(t.AvailableDeployment()) + bs.PropagateIngressAvailability(t.AvailableEndpoints()) bs.PropagateTriggerChannelReadiness(t.ReadyChannelStatus()) - bs.PropagateFilterDeploymentAvailability(t.AvailableDeployment()) + bs.PropagateFilterAvailability(t.AvailableEndpoints()) bs.SetAddress(&apis.URL{Scheme: "http", Host: "foo"}) return bs } @@ -100,32 +99,24 @@ func (t testHelper) ReadyTriggerStatus() *TriggerStatus { return ts } -func (testHelper) UnavailableDeployment() *v1.Deployment { - d := &v1.Deployment{} - d.Name = "unavailable" - d.Status.Conditions = []v1.DeploymentCondition{ - { - Type: v1.DeploymentAvailable, - Status: "False", - }, - } - return d -} - -func (t testHelper) AvailableDeployment() *v1.Deployment { - d := t.UnavailableDeployment() - d.Name = "available" - d.Status.Conditions = []v1.DeploymentCondition{ - { - Type: v1.DeploymentAvailable, - Status: "True", - }, - } - return d +func (t testHelper) UnavailableEndpoints() *corev1.Endpoints { + ep := &corev1.Endpoints{} + ep.Name = "unavailable" + ep.Subsets = []corev1.EndpointSubset{{ + NotReadyAddresses: []corev1.EndpointAddress{{ + IP: "127.0.0.1", + }}, + }} + return ep } -func (t testHelper) UnknownCronJobSourceStatus() *v1alpha1.CronJobSourceStatus { - cjss := &v1alpha1.CronJobSourceStatus{} - cjss.InitializeConditions() - return cjss +func (t testHelper) AvailableEndpoints() *corev1.Endpoints { + ep := &corev1.Endpoints{} + ep.Name = "available" + ep.Subsets = []corev1.EndpointSubset{{ + Addresses: []corev1.EndpointAddress{{ + IP: "127.0.0.1", + }}, + }} + return ep } diff --git a/vendor/knative.dev/eventing/pkg/apis/eventing/v1alpha1/trigger_conversion.go b/vendor/knative.dev/eventing/pkg/apis/eventing/v1alpha1/trigger_conversion.go index aa6adea0fa..bb3a7fee67 100644 --- a/vendor/knative.dev/eventing/pkg/apis/eventing/v1alpha1/trigger_conversion.go +++ b/vendor/knative.dev/eventing/pkg/apis/eventing/v1alpha1/trigger_conversion.go @@ -33,8 +33,7 @@ func (source *Trigger) ConvertTo(ctx context.Context, obj apis.Convertible) erro sink.Spec.Broker = source.Spec.Broker sink.Spec.Subscriber = source.Spec.Subscriber if source.Spec.Filter != nil { - sink.Spec.Filter = &v1beta1.TriggerFilter{ - } + sink.Spec.Filter = &v1beta1.TriggerFilter{} if source.Spec.Filter.Attributes != nil { sink.Spec.Filter = &v1beta1.TriggerFilter{ Attributes: make(v1beta1.TriggerFilterAttributes, len(*source.Spec.Filter.Attributes)), diff --git a/vendor/knative.dev/eventing/pkg/apis/eventing/v1alpha1/trigger_lifecycle.go b/vendor/knative.dev/eventing/pkg/apis/eventing/v1alpha1/trigger_lifecycle.go index aa87b211e3..cff1ab9245 100644 --- a/vendor/knative.dev/eventing/pkg/apis/eventing/v1alpha1/trigger_lifecycle.go +++ b/vendor/knative.dev/eventing/pkg/apis/eventing/v1alpha1/trigger_lifecycle.go @@ -31,7 +31,7 @@ const ( TriggerConditionBroker apis.ConditionType = "BrokerReady" - TriggerConditionSubscribed apis.ConditionType = "Subscribed" + TriggerConditionSubscribed apis.ConditionType = "SubscriptionReady" TriggerConditionDependency apis.ConditionType = "DependencyReady" @@ -154,7 +154,7 @@ func (ts *TriggerStatus) MarkDependencyUnknown(reason, messageFormat string, mes } func (ts *TriggerStatus) MarkDependencyNotConfigured() { - triggerCondSet.Manage(ts).MarkUnknown(EventTypeConditionBrokerReady, + triggerCondSet.Manage(ts).MarkUnknown(TriggerConditionDependency, "DependencyNotConfigured", "Dependency has not yet been reconciled.") } diff --git a/vendor/knative.dev/eventing/pkg/apis/eventing/v1alpha1/trigger_types.go b/vendor/knative.dev/eventing/pkg/apis/eventing/v1alpha1/trigger_types.go index 55e7ba0b86..0e7f95fd52 100644 --- a/vendor/knative.dev/eventing/pkg/apis/eventing/v1alpha1/trigger_types.go +++ b/vendor/knative.dev/eventing/pkg/apis/eventing/v1alpha1/trigger_types.go @@ -35,6 +35,7 @@ const ( ) // +genclient +// +genreconciler // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object // Trigger represents a request to have events delivered to a consumer from a diff --git a/vendor/knative.dev/eventing/pkg/apis/eventing/v1beta1/broker_defaults.go b/vendor/knative.dev/eventing/pkg/apis/eventing/v1beta1/broker_defaults.go index 217bda3ddc..ff78bd3b29 100644 --- a/vendor/knative.dev/eventing/pkg/apis/eventing/v1beta1/broker_defaults.go +++ b/vendor/knative.dev/eventing/pkg/apis/eventing/v1beta1/broker_defaults.go @@ -20,13 +20,15 @@ import ( "context" "knative.dev/eventing/pkg/apis/config" + "knative.dev/eventing/pkg/apis/eventing" "knative.dev/pkg/apis" ) func (b *Broker) SetDefaults(ctx context.Context) { - // TODO(vaikas): Set the default class annotation if not specified + // Default Spec fields. withNS := apis.WithinParent(ctx, b.ObjectMeta) b.Spec.SetDefaults(withNS) + eventing.DefaultBrokerClassIfUnset(withNS, &b.ObjectMeta) } func (bs *BrokerSpec) SetDefaults(ctx context.Context) { diff --git a/vendor/knative.dev/eventing/pkg/apis/eventing/v1beta1/eventtype_types.go b/vendor/knative.dev/eventing/pkg/apis/eventing/v1beta1/eventtype_types.go index 328f35bf3c..dbdf3f760c 100644 --- a/vendor/knative.dev/eventing/pkg/apis/eventing/v1beta1/eventtype_types.go +++ b/vendor/knative.dev/eventing/pkg/apis/eventing/v1beta1/eventtype_types.go @@ -39,6 +39,7 @@ type EventType struct { // Status represents the current state of the EventType. // This data may be out of date. // +optional + // TODO might be removed https://github.com/knative/eventing/issues/2750 Status EventTypeStatus `json:"status,omitempty"` } @@ -60,13 +61,21 @@ type EventTypeSpec struct { // Type represents the CloudEvents type. It is authoritative. Type string `json:"type"` // Source is a URI, it represents the CloudEvents source. - Source apis.URL `json:"source"` + // +optional + Source *apis.URL `json:"source,omitempty"` // Schema is a URI, it represents the CloudEvents schemaurl extension attribute. // It may be a JSON schema, a protobuf schema, etc. It is optional. // +optional Schema *apis.URL `json:"schema,omitempty"` + // SchemaData allows the CloudEvents schema to be stored directly in the + // EventType. Content is dependent on the encoding. Optional attribute. + // The contents are not validated or manipulated by the system. + // +optional + SchemaData string `json:"schemaData,omitempty"` + // TODO remove https://github.com/knative/eventing/issues/2750 // Broker refers to the Broker that can provide the EventType. - Broker string `json:"broker"` + // +optional + Broker string `json:"broker,omitempty"` // Description is an optional field used to describe the EventType, in any meaningful way. // +optional Description string `json:"description,omitempty"` diff --git a/vendor/knative.dev/eventing/pkg/apis/eventing/v1beta1/eventtype_validation.go b/vendor/knative.dev/eventing/pkg/apis/eventing/v1beta1/eventtype_validation.go index 2827d1eb15..ae5419f365 100644 --- a/vendor/knative.dev/eventing/pkg/apis/eventing/v1beta1/eventtype_validation.go +++ b/vendor/knative.dev/eventing/pkg/apis/eventing/v1beta1/eventtype_validation.go @@ -19,8 +19,6 @@ package v1beta1 import ( "context" - "github.com/google/go-cmp/cmp/cmpopts" - "knative.dev/pkg/apis" "knative.dev/pkg/kmp" ) @@ -35,16 +33,9 @@ func (ets *EventTypeSpec) Validate(ctx context.Context) *apis.FieldError { fe := apis.ErrMissingField("type") errs = errs.Also(fe) } - if ets.Source.IsEmpty() { - // TODO validate is a valid URI. - fe := apis.ErrMissingField("source") - errs = errs.Also(fe) - } - if ets.Broker == "" { - fe := apis.ErrMissingField("broker") - errs = errs.Also(fe) - } + // TODO validate Source is a valid URI. // TODO validate Schema is a valid URI. + // There is no validation of the SchemaData, it is application specific data. return errs } @@ -53,9 +44,8 @@ func (et *EventType) CheckImmutableFields(ctx context.Context, original *EventTy return nil } - // All but Description field immutable. - ignoreArguments := cmpopts.IgnoreFields(EventTypeSpec{}, "Description") - if diff, err := kmp.ShortDiff(original.Spec, et.Spec, ignoreArguments); err != nil { + // All fields are immutable. + if diff, err := kmp.ShortDiff(original.Spec, et.Spec); err != nil { return &apis.FieldError{ Message: "Failed to diff EventType", Paths: []string{"spec"}, diff --git a/vendor/knative.dev/eventing/pkg/apis/eventing/v1beta1/trigger_lifecycle.go b/vendor/knative.dev/eventing/pkg/apis/eventing/v1beta1/trigger_lifecycle.go index 31d6db5006..0e122a3748 100644 --- a/vendor/knative.dev/eventing/pkg/apis/eventing/v1beta1/trigger_lifecycle.go +++ b/vendor/knative.dev/eventing/pkg/apis/eventing/v1beta1/trigger_lifecycle.go @@ -31,7 +31,7 @@ const ( TriggerConditionBroker apis.ConditionType = "BrokerReady" - TriggerConditionSubscribed apis.ConditionType = "Subscribed" + TriggerConditionSubscribed apis.ConditionType = "SubscriptionReady" TriggerConditionDependency apis.ConditionType = "DependencyReady" diff --git a/vendor/knative.dev/eventing/pkg/apis/eventing/v1beta1/zz_generated.deepcopy.go b/vendor/knative.dev/eventing/pkg/apis/eventing/v1beta1/zz_generated.deepcopy.go index e38b3d7fb9..38bdb08340 100644 --- a/vendor/knative.dev/eventing/pkg/apis/eventing/v1beta1/zz_generated.deepcopy.go +++ b/vendor/knative.dev/eventing/pkg/apis/eventing/v1beta1/zz_generated.deepcopy.go @@ -196,7 +196,11 @@ func (in *EventTypeList) DeepCopyObject() runtime.Object { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *EventTypeSpec) DeepCopyInto(out *EventTypeSpec) { *out = *in - in.Source.DeepCopyInto(&out.Source) + if in.Source != nil { + in, out := &in.Source, &out.Source + *out = new(apis.URL) + (*in).DeepCopyInto(*out) + } if in.Schema != nil { in, out := &in.Schema, &out.Schema *out = new(apis.URL) diff --git a/vendor/knative.dev/eventing/pkg/apis/flows/v1alpha1/parallel_defaults.go b/vendor/knative.dev/eventing/pkg/apis/flows/v1alpha1/parallel_defaults.go index d4eaa9683b..5fe963ab01 100644 --- a/vendor/knative.dev/eventing/pkg/apis/flows/v1alpha1/parallel_defaults.go +++ b/vendor/knative.dev/eventing/pkg/apis/flows/v1alpha1/parallel_defaults.go @@ -32,8 +32,8 @@ func (p *Parallel) SetDefaults(ctx context.Context) { if err == nil { p.Spec.ChannelTemplate = &messagingv1beta1.ChannelTemplateSpec{ - c.TypeMeta, - c.Spec, + TypeMeta: c.TypeMeta, + Spec: c.Spec, } } } diff --git a/vendor/knative.dev/eventing/pkg/apis/flows/v1alpha1/sequence_defaults.go b/vendor/knative.dev/eventing/pkg/apis/flows/v1alpha1/sequence_defaults.go index 52e3c40be1..e7e48da1d3 100644 --- a/vendor/knative.dev/eventing/pkg/apis/flows/v1alpha1/sequence_defaults.go +++ b/vendor/knative.dev/eventing/pkg/apis/flows/v1alpha1/sequence_defaults.go @@ -32,8 +32,8 @@ func (s *Sequence) SetDefaults(ctx context.Context) { if err == nil { s.Spec.ChannelTemplate = &messagingv1beta1.ChannelTemplateSpec{ - c.TypeMeta, - c.Spec, + TypeMeta: c.TypeMeta, + Spec: c.Spec, } } } diff --git a/vendor/knative.dev/eventing/pkg/apis/flows/v1beta1/parallel_defaults.go b/vendor/knative.dev/eventing/pkg/apis/flows/v1beta1/parallel_defaults.go index c291bb0d4d..8efef07750 100644 --- a/vendor/knative.dev/eventing/pkg/apis/flows/v1beta1/parallel_defaults.go +++ b/vendor/knative.dev/eventing/pkg/apis/flows/v1beta1/parallel_defaults.go @@ -32,8 +32,8 @@ func (p *Parallel) SetDefaults(ctx context.Context) { if err == nil { p.Spec.ChannelTemplate = &messagingv1beta1.ChannelTemplateSpec{ - c.TypeMeta, - c.Spec, + TypeMeta: c.TypeMeta, + Spec: c.Spec, } } } diff --git a/vendor/knative.dev/eventing/pkg/apis/flows/v1beta1/sequence_defaults.go b/vendor/knative.dev/eventing/pkg/apis/flows/v1beta1/sequence_defaults.go index 9b55a5c51c..7c63a65b46 100644 --- a/vendor/knative.dev/eventing/pkg/apis/flows/v1beta1/sequence_defaults.go +++ b/vendor/knative.dev/eventing/pkg/apis/flows/v1beta1/sequence_defaults.go @@ -32,8 +32,8 @@ func (s *Sequence) SetDefaults(ctx context.Context) { if err == nil { s.Spec.ChannelTemplate = &messagingv1beta1.ChannelTemplateSpec{ - c.TypeMeta, - c.Spec, + TypeMeta: c.TypeMeta, + Spec: c.Spec, } } } diff --git a/vendor/knative.dev/eventing/pkg/apis/flows/v1beta1/test_helpers.go b/vendor/knative.dev/eventing/pkg/apis/flows/v1beta1/test_helpers.go index e49a52ad39..b33871177e 100644 --- a/vendor/knative.dev/eventing/pkg/apis/flows/v1beta1/test_helpers.go +++ b/vendor/knative.dev/eventing/pkg/apis/flows/v1beta1/test_helpers.go @@ -17,11 +17,9 @@ package v1beta1 import ( - "github.com/google/go-cmp/cmp/cmpopts" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" messagingv1beta1 "knative.dev/eventing/pkg/apis/messaging/v1beta1" - "knative.dev/pkg/apis" ) var ( @@ -31,8 +29,4 @@ var ( Kind: "InMemoryChannel", }, } - - ignoreAllButTypeAndStatus = cmpopts.IgnoreFields( - apis.Condition{}, - "LastTransitionTime", "Message", "Reason", "Severity") ) diff --git a/vendor/knative.dev/eventing/pkg/apis/legacysources/register.go b/vendor/knative.dev/eventing/pkg/apis/legacysources/register.go deleted file mode 100644 index 9483995420..0000000000 --- a/vendor/knative.dev/eventing/pkg/apis/legacysources/register.go +++ /dev/null @@ -1,21 +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 legacysources - -const ( - GroupName = "sources.eventing.knative.dev" -) diff --git a/vendor/knative.dev/eventing/pkg/apis/legacysources/v1alpha1/apiserver_defaults.go b/vendor/knative.dev/eventing/pkg/apis/legacysources/v1alpha1/apiserver_defaults.go deleted file mode 100644 index 18891cdb98..0000000000 --- a/vendor/knative.dev/eventing/pkg/apis/legacysources/v1alpha1/apiserver_defaults.go +++ /dev/null @@ -1,29 +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 ( - "context" -) - -func (s *ApiServerSource) SetDefaults(ctx context.Context) { - s.Spec.SetDefaults(ctx) -} - -func (ss *ApiServerSourceSpec) SetDefaults(ctx context.Context) { - // TODO anything? -} diff --git a/vendor/knative.dev/eventing/pkg/apis/legacysources/v1alpha1/apiserver_lifecycle.go b/vendor/knative.dev/eventing/pkg/apis/legacysources/v1alpha1/apiserver_lifecycle.go deleted file mode 100644 index d18d72eba9..0000000000 --- a/vendor/knative.dev/eventing/pkg/apis/legacysources/v1alpha1/apiserver_lifecycle.go +++ /dev/null @@ -1,127 +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 ( - appsv1 "k8s.io/api/apps/v1" - corev1 "k8s.io/api/core/v1" - - "knative.dev/pkg/apis" - - "knative.dev/eventing/pkg/apis/duck" -) - -const ( - // ApiServerConditionReady has status True when the ApiServerSource is ready to send events. - ApiServerConditionReady = apis.ConditionReady - - // ApiServerConditionSinkProvided has status True when the ApiServerSource has been configured with a sink target. - ApiServerConditionSinkProvided apis.ConditionType = "SinkProvided" - - // ApiServerConditionDeployed has status True when the ApiServerSource has had it's deployment created. - ApiServerConditionDeployed apis.ConditionType = "Deployed" - - // ApiServerConditionSufficientPermissions has status True when the ApiServerSource has sufficient permissions to access resources. - ApiServerConditionSufficientPermissions apis.ConditionType = "SufficientPermissions" - - // ApiServerConditionEventTypeProvided has status True when the ApiServerSource has been configured with its event types. - ApiServerConditionEventTypeProvided apis.ConditionType = "EventTypesProvided" -) - -var apiserverCondSet = apis.NewLivingConditionSet( - ApiServerConditionSinkProvided, - ApiServerConditionDeployed, - ApiServerConditionSufficientPermissions, -) - -// GetCondition returns the condition currently associated with the given type, or nil. -func (s *ApiServerSourceStatus) GetCondition(t apis.ConditionType) *apis.Condition { - return apiserverCondSet.Manage(s).GetCondition(t) -} - -// InitializeConditions sets relevant unset conditions to Unknown state. -func (s *ApiServerSourceStatus) InitializeConditions() { - apiserverCondSet.Manage(s).InitializeConditions() -} - -// MarkSink sets the condition that the source has a sink configured. -func (s *ApiServerSourceStatus) MarkSink(uri string) { - s.SinkURI = uri - if len(uri) > 0 { - apiserverCondSet.Manage(s).MarkTrue(ApiServerConditionSinkProvided) - } else { - apiserverCondSet.Manage(s).MarkFalse(ApiServerConditionSinkProvided, "SinkEmpty", "Sink has resolved to empty.%s", "") - } -} - -// MarkSinkWarnDeprecated sets the condition that the source has a sink configured and warns ref is deprecated. -func (s *ApiServerSourceStatus) MarkSinkWarnRefDeprecated(uri string) { - s.SinkURI = uri - if len(uri) > 0 { - c := apis.Condition{ - Type: ApiServerConditionSinkProvided, - Status: corev1.ConditionTrue, - Severity: apis.ConditionSeverityError, - Message: "Using deprecated object ref fields when specifying spec.sink. Update to spec.sink.ref. These will be removed in the future.", - } - apiserverCondSet.Manage(s).SetCondition(c) - } else { - apiserverCondSet.Manage(s).MarkUnknown(ApiServerConditionSinkProvided, "SinkEmpty", "Sink has resolved to empty.%s", "") - } -} - -// MarkNoSink sets the condition that the source does not have a sink configured. -func (s *ApiServerSourceStatus) MarkNoSink(reason, messageFormat string, messageA ...interface{}) { - apiserverCondSet.Manage(s).MarkFalse(ApiServerConditionSinkProvided, reason, messageFormat, messageA...) -} - -// PropagateDeploymentAvailability uses the availability of the provided Deployment to determine if -// ApiServerConditionDeployed should be marked as true or false. -func (s *ApiServerSourceStatus) PropagateDeploymentAvailability(d *appsv1.Deployment) { - if duck.DeploymentIsAvailable(&d.Status, false) { - apiserverCondSet.Manage(s).MarkTrue(ApiServerConditionDeployed) - } else { - // I don't know how to propagate the status well, so just give the name of the Deployment - // for now. - apiserverCondSet.Manage(s).MarkFalse(ApiServerConditionDeployed, "DeploymentUnavailable", "The Deployment '%s' is unavailable.", d.Name) - } -} - -// MarkEventTypes sets the condition that the source has set its event type. -func (s *ApiServerSourceStatus) MarkEventTypes() { - apiserverCondSet.Manage(s).MarkTrue(ApiServerConditionEventTypeProvided) -} - -// MarkNoEventTypes sets the condition that the source does not its event type configured. -func (s *ApiServerSourceStatus) MarkNoEventTypes(reason, messageFormat string, messageA ...interface{}) { - apiserverCondSet.Manage(s).MarkFalse(ApiServerConditionEventTypeProvided, reason, messageFormat, messageA...) -} - -// MarkSufficientPermissions sets the condition that the source has enough permissions to access the resources. -func (s *ApiServerSourceStatus) MarkSufficientPermissions() { - apiserverCondSet.Manage(s).MarkTrue(ApiServerConditionSufficientPermissions) -} - -// MarkNoSufficientPermissions sets the condition that the source does not have enough permissions to access the resources -func (s *ApiServerSourceStatus) MarkNoSufficientPermissions(reason, messageFormat string, messageA ...interface{}) { - apiserverCondSet.Manage(s).MarkFalse(ApiServerConditionSufficientPermissions, reason, messageFormat, messageA...) -} - -// IsReady returns true if the resource is ready overall. -func (s *ApiServerSourceStatus) IsReady() bool { - return apiserverCondSet.Manage(s).IsHappy() -} diff --git a/vendor/knative.dev/eventing/pkg/apis/legacysources/v1alpha1/apiserver_types.go b/vendor/knative.dev/eventing/pkg/apis/legacysources/v1alpha1/apiserver_types.go deleted file mode 100644 index 34232838db..0000000000 --- a/vendor/knative.dev/eventing/pkg/apis/legacysources/v1alpha1/apiserver_types.go +++ /dev/null @@ -1,137 +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 ( - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime/schema" - "knative.dev/pkg/apis" - duckv1 "knative.dev/pkg/apis/duck/v1" - duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" - "knative.dev/pkg/kmeta" -) - -// +genclient -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object - -// ApiServerSource is the Schema for the apiserversources API -type ApiServerSource struct { - // Deprecated allows ApiServerSource to have a deprecated message. - Deprecated - - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata,omitempty"` - - Spec ApiServerSourceSpec `json:"spec,omitempty"` - Status ApiServerSourceStatus `json:"status,omitempty"` -} - -var ( - // Check that we can create OwnerReferences to an ApiServerSource. - _ kmeta.OwnerRefable = (*ApiServerSource)(nil) - - // Check that ApiServerSource can return its spec untyped. - _ apis.HasSpec = (*ApiServerSource)(nil) -) - -const ( - // ApiServerSourceAddEventType is the ApiServerSource CloudEvent type for adds. - ApiServerSourceAddEventType = "dev.knative.apiserver.resource.add" - // ApiServerSourceUpdateEventType is the ApiServerSource CloudEvent type for updates. - ApiServerSourceUpdateEventType = "dev.knative.apiserver.resource.update" - // ApiServerSourceDeleteEventType is the ApiServerSource CloudEvent type for deletions. - ApiServerSourceDeleteEventType = "dev.knative.apiserver.resource.delete" - - // ApiServerSourceAddRefEventType is the ApiServerSource CloudEvent type for ref adds. - ApiServerSourceAddRefEventType = "dev.knative.apiserver.ref.add" - // ApiServerSourceUpdateRefEventType is the ApiServerSource CloudEvent type for ref updates. - ApiServerSourceUpdateRefEventType = "dev.knative.apiserver.ref.update" - // ApiServerSourceDeleteRefEventType is the ApiServerSource CloudEvent type for ref deletions. - ApiServerSourceDeleteRefEventType = "dev.knative.apiserver.ref.delete" -) - -// GetGroupVersionKind returns the GroupVersionKind. -func (s *ApiServerSource) GetGroupVersionKind() schema.GroupVersionKind { - return SchemeGroupVersion.WithKind("ApiServerSource") -} - -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object - -// ApiServerSourceList contains a list of ApiServerSource -type ApiServerSourceList struct { - metav1.TypeMeta `json:",inline"` - metav1.ListMeta `json:"metadata,omitempty"` - Items []ApiServerSource `json:"items"` -} - -// ApiServerSourceSpec defines the desired state of ApiServerSource -type ApiServerSourceSpec struct { - // Resources is the list of resources to watch - Resources []ApiServerResource `json:"resources"` - - // ServiceAccountName is the name of the ServiceAccount to use to run this - // source. - // +optional - ServiceAccountName string `json:"serviceAccountName,omitempty"` - - // Sink is a reference to an object that will resolve to a domain name to use as the sink. - // +optional - Sink *duckv1beta1.Destination `json:"sink,omitempty"` - - // Mode is the mode the receive adapter controller runs under: Ref or Resource. - // `Ref` sends only the reference to the resource. - // `Resource` send the full resource. - Mode string `json:"mode,omitempty"` -} - -// ApiServerSourceStatus defines the observed state of ApiServerSource -type ApiServerSourceStatus struct { - // inherits duck/v1 Status, which currently provides: - // * ObservedGeneration - the 'Generation' of the Service that was last processed by the controller. - // * Conditions - the latest available observations of a resource's current state. - duckv1.Status `json:",inline"` - - // SinkURI is the current active sink URI that has been configured for the ApiServerSource. - // +optional - SinkURI string `json:"sinkUri,omitempty"` -} - -// ApiServerResource defines the resource to watch -type ApiServerResource struct { - // API version of the resource to watch. - APIVersion string `json:"apiVersion"` - - // Kind of the resource to watch. - // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds - Kind string `json:"kind"` - - // LabelSelector restricts this source to objects with the selected labels - // More info: http://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#label-selectors - LabelSelector metav1.LabelSelector `json:"labelSelector"` - - // ControllerSelector restricts this source to objects with a controlling owner reference of the specified kind. - // Only apiVersion and kind are used. Both are optional. - ControllerSelector metav1.OwnerReference `json:"controllerSelector"` - - // If true, send an event referencing the object controlling the resource - Controller bool `json:"controller"` -} - -// GetUntypedSpec returns the spec of the ApiServerSource. -func (a *ApiServerSource) GetUntypedSpec() interface{} { - return a.Spec -} diff --git a/vendor/knative.dev/eventing/pkg/apis/legacysources/v1alpha1/apiserver_validation.go b/vendor/knative.dev/eventing/pkg/apis/legacysources/v1alpha1/apiserver_validation.go deleted file mode 100644 index 0987c19076..0000000000 --- a/vendor/knative.dev/eventing/pkg/apis/legacysources/v1alpha1/apiserver_validation.go +++ /dev/null @@ -1,56 +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 ( - "context" - - "knative.dev/pkg/apis" -) - -const ( - // RefMode produces payloads of ObjectReference - RefMode = "Ref" - // ResourceMode produces payloads of ResourceEvent - ResourceMode = "Resource" -) - -func (c *ApiServerSource) Validate(ctx context.Context) *apis.FieldError { - return c.Spec.Validate(ctx).ViaField("spec") -} - -func (cs *ApiServerSourceSpec) Validate(ctx context.Context) *apis.FieldError { - var errs *apis.FieldError - - // Validate mode, if can be empty or set as certain value - if cs.Mode != "" && cs.Mode != RefMode && cs.Mode != ResourceMode { - fe := &apis.FieldError{ - Message: "Mode is not valid", - Paths: []string{"mode"}, - } - errs = errs.Also(fe) - } - - // Validate sink - if cs.Sink == nil { - fe := apis.ErrMissingField("sink") - errs = errs.Also(fe) - } else if fe := cs.Sink.Validate(ctx); fe != nil { - errs = errs.Also(fe.ViaField("sink")) - } - return errs -} diff --git a/vendor/knative.dev/eventing/pkg/apis/legacysources/v1alpha1/containersource_lifecycle.go b/vendor/knative.dev/eventing/pkg/apis/legacysources/v1alpha1/containersource_lifecycle.go deleted file mode 100644 index efe7d7ef49..0000000000 --- a/vendor/knative.dev/eventing/pkg/apis/legacysources/v1alpha1/containersource_lifecycle.go +++ /dev/null @@ -1,109 +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 ( - corev1 "k8s.io/api/core/v1" - "knative.dev/pkg/apis" -) - -const ( - // ContainerSourceConditionReady has status True when the ContainerSource is ready to send events. - ContainerConditionReady = apis.ConditionReady - - // ContainerConditionSinkProvided has status True when the ContainerSource has been configured with a sink target. - ContainerConditionSinkProvided apis.ConditionType = "SinkProvided" - - // ContainerConditionDeployed has status True when the ContainerSource has had it's deployment created. - ContainerConditionDeployed apis.ConditionType = "Deployed" -) - -var containerCondSet = apis.NewLivingConditionSet( - ContainerConditionSinkProvided, - ContainerConditionDeployed, -) - -// GetCondition returns the condition currently associated with the given type, or nil. -func (s *ContainerSourceStatus) GetCondition(t apis.ConditionType) *apis.Condition { - return containerCondSet.Manage(s).GetCondition(t) -} - -// IsReady returns true if the resource is ready overall. -func (s *ContainerSourceStatus) IsReady() bool { - return containerCondSet.Manage(s).IsHappy() -} - -// InitializeConditions sets relevant unset conditions to Unknown state. -func (s *ContainerSourceStatus) InitializeConditions() { - containerCondSet.Manage(s).InitializeConditions() -} - -// MarkSink sets the condition that the source has a sink configured. -func (s *ContainerSourceStatus) MarkSink(uri string) { - s.SinkURI = uri - if len(uri) > 0 { - containerCondSet.Manage(s).MarkTrue(ContainerConditionSinkProvided) - } else { - containerCondSet.Manage(s).MarkFalse(ContainerConditionSinkProvided, "SinkEmpty", "Sink has resolved to empty.%s", "") - } -} - -// MarkSinkWarnDeprecated sets the condition that the source has a sink configured and warns ref is deprecated. -func (s *ContainerSourceStatus) MarkSinkWarnRefDeprecated(uri string) { - s.SinkURI = uri - if len(uri) > 0 { - c := apis.Condition{ - Type: ContainerConditionSinkProvided, - Status: corev1.ConditionTrue, - Severity: apis.ConditionSeverityError, - Message: "Using deprecated object ref fields when specifying spec.sink. Update to spec.sink.ref. These will be removed in the future.", - } - apiserverCondSet.Manage(s).SetCondition(c) - } else { - apiserverCondSet.Manage(s).MarkUnknown(ContainerConditionSinkProvided, "SinkEmpty", "Sink has resolved to empty.%s", "") - } -} - -// MarkNoSink sets the condition that the source does not have a sink configured. -func (s *ContainerSourceStatus) MarkNoSink(reason, messageFormat string, messageA ...interface{}) { - containerCondSet.Manage(s).MarkFalse(ContainerConditionSinkProvided, reason, messageFormat, messageA...) -} - -// IsDeployed returns true if the Deployed condition has status true, otherwise -// false. -func (s *ContainerSourceStatus) IsDeployed() bool { - c := containerCondSet.Manage(s).GetCondition(ContainerConditionDeployed) - if c != nil { - return c.IsTrue() - } - return false -} - -// MarkDeployed sets the condition that the source has been deployed. -func (s *ContainerSourceStatus) MarkDeployed() { - containerCondSet.Manage(s).MarkTrue(ContainerConditionDeployed) -} - -// MarkDeploying sets the condition that the source is deploying. -func (s *ContainerSourceStatus) MarkDeploying(reason, messageFormat string, messageA ...interface{}) { - containerCondSet.Manage(s).MarkUnknown(ContainerConditionDeployed, reason, messageFormat, messageA...) -} - -// MarkNotDeployed sets the condition that the source has not been deployed. -func (s *ContainerSourceStatus) MarkNotDeployed(reason, messageFormat string, messageA ...interface{}) { - containerCondSet.Manage(s).MarkFalse(ContainerConditionDeployed, reason, messageFormat, messageA...) -} diff --git a/vendor/knative.dev/eventing/pkg/apis/legacysources/v1alpha1/cron_job_defaults.go b/vendor/knative.dev/eventing/pkg/apis/legacysources/v1alpha1/cron_job_defaults.go deleted file mode 100644 index 25a58dbf19..0000000000 --- a/vendor/knative.dev/eventing/pkg/apis/legacysources/v1alpha1/cron_job_defaults.go +++ /dev/null @@ -1,29 +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 ( - "context" -) - -func (s *CronJobSource) SetDefaults(ctx context.Context) { - s.Spec.SetDefaults(ctx) -} - -func (ss *CronJobSourceSpec) SetDefaults(ctx context.Context) { - // TODO anything? -} diff --git a/vendor/knative.dev/eventing/pkg/apis/legacysources/v1alpha1/cron_job_lifecycle.go b/vendor/knative.dev/eventing/pkg/apis/legacysources/v1alpha1/cron_job_lifecycle.go deleted file mode 100644 index 319c738cc4..0000000000 --- a/vendor/knative.dev/eventing/pkg/apis/legacysources/v1alpha1/cron_job_lifecycle.go +++ /dev/null @@ -1,141 +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 ( - appsv1 "k8s.io/api/apps/v1" - corev1 "k8s.io/api/core/v1" - - "knative.dev/pkg/apis" - - "knative.dev/eventing/pkg/apis/duck" -) - -const ( - // CronJobConditionReady has status True when the CronJobSource is ready to send events. - CronJobConditionReady = apis.ConditionReady - - // CronJobConditionValidSchedule has status True when the CronJobSource has been configured with a valid schedule. - CronJobConditionValidSchedule apis.ConditionType = "ValidSchedule" - - // CronJobConditionSinkProvided has status True when the CronJobSource has been configured with a sink target. - CronJobConditionSinkProvided apis.ConditionType = "SinkProvided" - - // CronJobConditionDeployed has status True when the CronJobSource has had it's receive adapter deployment created. - CronJobConditionDeployed apis.ConditionType = "Deployed" - - // CronJobConditionEventTypeProvided has status True when the CronJobSource has been configured with its event type. - CronJobConditionEventTypeProvided apis.ConditionType = "EventTypeProvided" - - // CronJobConditionResources is True when the resources listed for the CronJobSource have been properly - // parsed and match specified syntax for resource quantities - CronJobConditionResources apis.ConditionType = "ResourcesCorrect" -) - -var cronJobSourceCondSet = apis.NewLivingConditionSet( - CronJobConditionValidSchedule, - CronJobConditionSinkProvided, - CronJobConditionDeployed) - -// GetCondition returns the condition currently associated with the given type, or nil. -func (s *CronJobSourceStatus) GetCondition(t apis.ConditionType) *apis.Condition { - return cronJobSourceCondSet.Manage(s).GetCondition(t) -} - -// IsReady returns true if the resource is ready overall. -func (s *CronJobSourceStatus) IsReady() bool { - return cronJobSourceCondSet.Manage(s).IsHappy() -} - -// InitializeConditions sets relevant unset conditions to Unknown state. -func (s *CronJobSourceStatus) InitializeConditions() { - cronJobSourceCondSet.Manage(s).InitializeConditions() -} - -// TODO: this is a bad method name, change it. -// MarkSchedule sets the condition that the source has a valid schedule configured. -func (s *CronJobSourceStatus) MarkSchedule() { - cronJobSourceCondSet.Manage(s).MarkTrue(CronJobConditionValidSchedule) -} - -// MarkInvalidSchedule sets the condition that the source does not have a valid schedule configured. -func (s *CronJobSourceStatus) MarkInvalidSchedule(reason, messageFormat string, messageA ...interface{}) { - cronJobSourceCondSet.Manage(s).MarkFalse(CronJobConditionValidSchedule, reason, messageFormat, messageA...) -} - -// MarkSink sets the condition that the source has a sink configured. -func (s *CronJobSourceStatus) MarkSink(uri string) { - s.SinkURI = uri - if len(uri) > 0 { - cronJobSourceCondSet.Manage(s).MarkTrue(CronJobConditionSinkProvided) - } else { - cronJobSourceCondSet.Manage(s).MarkFalse(CronJobConditionSinkProvided, "SinkEmpty", "Sink has resolved to empty.%s", "") - } -} - -// MarkSinkWarnDeprecated sets the condition that the source has a sink configured and warns ref is deprecated. -func (s *CronJobSourceStatus) MarkSinkWarnRefDeprecated(uri string) { - s.SinkURI = uri - if len(uri) > 0 { - c := apis.Condition{ - Type: CronJobConditionSinkProvided, - Status: corev1.ConditionTrue, - Severity: apis.ConditionSeverityError, - Message: "Using deprecated object ref fields when specifying spec.sink. Update to spec.sink.ref. These will be removed in the future.", - } - apiserverCondSet.Manage(s).SetCondition(c) - } else { - apiserverCondSet.Manage(s).MarkUnknown(CronJobConditionSinkProvided, "SinkEmpty", "Sink has resolved to empty.%s", "") - } -} - -// MarkNoSink sets the condition that the source does not have a sink configured. -func (s *CronJobSourceStatus) MarkNoSink(reason, messageFormat string, messageA ...interface{}) { - cronJobSourceCondSet.Manage(s).MarkFalse(CronJobConditionSinkProvided, reason, messageFormat, messageA...) -} - -// PropagateDeploymentAvailability uses the availability of the provided Deployment to determine if -// CronJobConditionDeployed should be marked as true or false. -func (s *CronJobSourceStatus) PropagateDeploymentAvailability(d *appsv1.Deployment) { - if duck.DeploymentIsAvailable(&d.Status, false) { - cronJobSourceCondSet.Manage(s).MarkTrue(CronJobConditionDeployed) - } else { - // I don't know how to propagate the status well, so just give the name of the Deployment - // for now. - cronJobSourceCondSet.Manage(s).MarkFalse(CronJobConditionDeployed, "DeploymentUnavailable", "The Deployment '%s' is unavailable.", d.Name) - } -} - -// MarkEventType sets the condition that the source has set its event type. -func (s *CronJobSourceStatus) MarkEventType() { - cronJobSourceCondSet.Manage(s).MarkTrue(CronJobConditionEventTypeProvided) -} - -// MarkNoEventType sets the condition that the source does not its event type configured. -func (s *CronJobSourceStatus) MarkNoEventType(reason, messageFormat string, messageA ...interface{}) { - cronJobSourceCondSet.Manage(s).MarkFalse(CronJobConditionEventTypeProvided, reason, messageFormat, messageA...) -} - -// MarkResourcesCorrect sets the condition that the source resources are properly parsable quantities -func (s *CronJobSourceStatus) MarkResourcesCorrect() { - cronJobSourceCondSet.Manage(s).MarkTrue(CronJobConditionResources) -} - -// MarkResourcesIncorrect sets the condition that the source resources are not properly parsable quantities -func (s *CronJobSourceStatus) MarkResourcesIncorrect(reason, messageFormat string, messageA ...interface{}) { - cronJobSourceCondSet.Manage(s).MarkFalse(CronJobConditionResources, reason, messageFormat, messageA...) -} diff --git a/vendor/knative.dev/eventing/pkg/apis/legacysources/v1alpha1/cron_job_types.go b/vendor/knative.dev/eventing/pkg/apis/legacysources/v1alpha1/cron_job_types.go deleted file mode 100644 index 510a145c93..0000000000 --- a/vendor/knative.dev/eventing/pkg/apis/legacysources/v1alpha1/cron_job_types.go +++ /dev/null @@ -1,135 +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" - - "knative.dev/pkg/apis" - - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/runtime/schema" - duckv1 "knative.dev/pkg/apis/duck/v1" - duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" - "knative.dev/pkg/kmeta" -) - -// +genclient -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -// +k8s:defaulter-gen=true - -// CronJobSource is the Schema for the cronjobsources API. -type CronJobSource struct { - // Deprecated allows CronJobSource to have a deprecated message. - Deprecated - - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata,omitempty"` - - Spec CronJobSourceSpec `json:"spec,omitempty"` - Status CronJobSourceStatus `json:"status,omitempty"` -} - -// TODO: Check that CronJobSource can be validated and can be defaulted. - -var ( - // Check that it is a runtime object. - _ runtime.Object = (*CronJobSource)(nil) - - // Check that we can create OwnerReferences to a CronJobSource. - _ kmeta.OwnerRefable = (*CronJobSource)(nil) - - // Check that CronJobSource can return its spec untyped. - _ apis.HasSpec = (*CronJobSource)(nil) -) - -const ( - // CronJobEventType is the CronJob CloudEvent type. - CronJobEventType = "dev.knative.cronjob.event" -) - -// CronJobEventSource returns the CronJob CloudEvent source. -func CronJobEventSource(namespace, cronJobName string) string { - return fmt.Sprintf("/apis/v1/namespaces/%s/cronjobsources/%s", namespace, cronJobName) -} - -type CronJobRequestsSpec struct { - ResourceCPU string `json:"cpu,omitempty"` - ResourceMemory string `json:"memory,omitempty"` -} - -type CronJobLimitsSpec struct { - ResourceCPU string `json:"cpu,omitempty"` - ResourceMemory string `json:"memory,omitempty"` -} - -type CronJobResourceSpec struct { - Requests CronJobRequestsSpec `json:"requests,omitempty"` - Limits CronJobLimitsSpec `json:"limits,omitempty"` -} - -// CronJobSourceSpec defines the desired state of the CronJobSource. -type CronJobSourceSpec struct { - // Schedule is the cronjob schedule. - // +required - Schedule string `json:"schedule"` - - // Data is the data posted to the target function. - Data string `json:"data,omitempty"` - - // Sink is a reference to an object that will resolve to a domain name to use as the sink. - Sink *duckv1beta1.Destination `json:"sink,omitempty"` - - // ServiceAccoutName is the name of the ServiceAccount that will be used to run the Receive - // Adapter Deployment. - ServiceAccountName string `json:"serviceAccountName,omitempty"` - - // Resource limits and Request specifications of the Receive Adapter Deployment - Resources CronJobResourceSpec `json:"resources,omitempty"` -} - -// GetGroupVersionKind returns the GroupVersionKind. -func (s *CronJobSource) GetGroupVersionKind() schema.GroupVersionKind { - return SchemeGroupVersion.WithKind("CronJobSource") -} - -// CronJobSourceStatus defines the observed state of CronJobSource. -type CronJobSourceStatus struct { - // inherits duck/v1 Status, which currently provides: - // * ObservedGeneration - the 'Generation' of the Service that was last processed by the controller. - // * Conditions - the latest available observations of a resource's current state. - duckv1.Status `json:",inline"` - - // SinkURI is the current active sink URI that has been configured for the CronJobSource. - // +optional - SinkURI string `json:"sinkUri,omitempty"` -} - -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object - -// CronJobSourceList contains a list of CronJobSources. -type CronJobSourceList struct { - metav1.TypeMeta `json:",inline"` - metav1.ListMeta `json:"metadata,omitempty"` - Items []CronJobSource `json:"items"` -} - -// GetUntypedSpec returns the spec of the CronJobSource. -func (c *CronJobSource) GetUntypedSpec() interface{} { - return c.Spec -} diff --git a/vendor/knative.dev/eventing/pkg/apis/legacysources/v1alpha1/cron_job_validation.go b/vendor/knative.dev/eventing/pkg/apis/legacysources/v1alpha1/cron_job_validation.go deleted file mode 100644 index d268f53193..0000000000 --- a/vendor/knative.dev/eventing/pkg/apis/legacysources/v1alpha1/cron_job_validation.go +++ /dev/null @@ -1,45 +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 ( - "context" - - "github.com/robfig/cron" - "knative.dev/pkg/apis" -) - -func (c *CronJobSource) Validate(ctx context.Context) *apis.FieldError { - return c.Spec.Validate(ctx).ViaField("spec") -} - -func (cs *CronJobSourceSpec) Validate(ctx context.Context) *apis.FieldError { - var errs *apis.FieldError - - if _, err := cron.ParseStandard(cs.Schedule); err != nil { - fe := apis.ErrInvalidValue(cs.Schedule, "schedule") - errs = errs.Also(fe) - } - - if cs.Sink == nil { - fe := apis.ErrMissingField("sink") - errs = errs.Also(fe) - } else if fe := cs.Sink.Validate(ctx); fe != nil { - errs = errs.Also(fe.ViaField("sink")) - } - return errs -} diff --git a/vendor/knative.dev/eventing/pkg/apis/legacysources/v1alpha1/deprecated.go b/vendor/knative.dev/eventing/pkg/apis/legacysources/v1alpha1/deprecated.go deleted file mode 100644 index 145570bb13..0000000000 --- a/vendor/knative.dev/eventing/pkg/apis/legacysources/v1alpha1/deprecated.go +++ /dev/null @@ -1,54 +0,0 @@ -/* -Copyright 2020 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 ( - "time" - - corev1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "knative.dev/pkg/apis" - duckv1 "knative.dev/pkg/apis/duck/v1" -) - -const ( - // StatusConditionTypeDeprecated is the status.conditions.type used to provide deprecation - // warnings. - StatusConditionTypeDeprecated = "Deprecated" -) - -type Deprecated struct{} - -// MarkDeprecated adds a warning condition that this object's spec is using deprecated fields -// and will stop working in the future. -func (d *Deprecated) MarkDeprecated(s *duckv1.Status, reason, msg string) { - dc := apis.Condition{ - Type: StatusConditionTypeDeprecated, - Reason: reason, - Status: corev1.ConditionTrue, - Severity: apis.ConditionSeverityWarning, - Message: msg, - LastTransitionTime: apis.VolatileTime{Inner: metav1.NewTime(time.Now())}, - } - for i, c := range s.Conditions { - if c.Type == dc.Type { - s.Conditions[i] = dc - return - } - } - s.Conditions = append(s.Conditions, dc) -} diff --git a/vendor/knative.dev/eventing/pkg/apis/legacysources/v1alpha1/doc.go b/vendor/knative.dev/eventing/pkg/apis/legacysources/v1alpha1/doc.go deleted file mode 100644 index 7d7f6738fb..0000000000 --- a/vendor/knative.dev/eventing/pkg/apis/legacysources/v1alpha1/doc.go +++ /dev/null @@ -1,20 +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 contains API Schema definitions for the sources v1alpha1 API group -// +k8s:deepcopy-gen=package -// +groupName=sources.eventing.knative.dev -package v1alpha1 diff --git a/vendor/knative.dev/eventing/pkg/apis/legacysources/v1alpha1/register.go b/vendor/knative.dev/eventing/pkg/apis/legacysources/v1alpha1/register.go deleted file mode 100644 index a1affadb40..0000000000 --- a/vendor/knative.dev/eventing/pkg/apis/legacysources/v1alpha1/register.go +++ /dev/null @@ -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 v1alpha1 - -import ( - "knative.dev/eventing/pkg/apis/legacysources" - - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/runtime/schema" -) - -// SchemeGroupVersion is group version used to register these objects -var SchemeGroupVersion = schema.GroupVersion{Group: legacysources.GroupName, Version: "v1alpha1"} - -// Kind takes an unqualified kind and returns back a Group qualified GroupKind -func Kind(kind string) schema.GroupKind { - return SchemeGroupVersion.WithKind(kind).GroupKind() -} - -// Resource takes an unqualified resource and returns a Group qualified GroupResource -func Resource(resource string) schema.GroupResource { - return SchemeGroupVersion.WithResource(resource).GroupResource() -} - -var ( - SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) - AddToScheme = SchemeBuilder.AddToScheme -) - -// Adds the list of known types to Scheme. -func addKnownTypes(scheme *runtime.Scheme) error { - scheme.AddKnownTypes(SchemeGroupVersion, - &CronJobSource{}, - &CronJobSourceList{}, - &ContainerSource{}, - &ContainerSourceList{}, - &ApiServerSource{}, - &ApiServerSourceList{}, - &SinkBinding{}, - &SinkBindingList{}, - ) - metav1.AddToGroupVersion(scheme, SchemeGroupVersion) - return nil -} diff --git a/vendor/knative.dev/eventing/pkg/apis/legacysources/v1alpha1/sinkbinding_context.go b/vendor/knative.dev/eventing/pkg/apis/legacysources/v1alpha1/sinkbinding_context.go deleted file mode 100644 index 420807fcd5..0000000000 --- a/vendor/knative.dev/eventing/pkg/apis/legacysources/v1alpha1/sinkbinding_context.go +++ /dev/null @@ -1,43 +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 ( - "context" - - "knative.dev/pkg/apis" -) - -// sinkURIKey is used as the key for associating information -// with a context.Context. -type sinkURIKey struct{} - -// WithSinkURI notes on the context for binding that the resolved SinkURI -// is the provided apis.URL. -func WithSinkURI(ctx context.Context, uri *apis.URL) context.Context { - return context.WithValue(ctx, sinkURIKey{}, uri) -} - -// GetSinkURI accesses the apis.URL for the Sink URI that has been associated -// with this context. -func GetSinkURI(ctx context.Context) *apis.URL { - value := ctx.Value(sinkURIKey{}) - if value == nil { - return nil - } - return value.(*apis.URL) -} diff --git a/vendor/knative.dev/eventing/pkg/apis/legacysources/v1alpha1/sinkbinding_lifecycle.go b/vendor/knative.dev/eventing/pkg/apis/legacysources/v1alpha1/sinkbinding_lifecycle.go deleted file mode 100644 index 283730d7a0..0000000000 --- a/vendor/knative.dev/eventing/pkg/apis/legacysources/v1alpha1/sinkbinding_lifecycle.go +++ /dev/null @@ -1,122 +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 ( - "context" - "fmt" - - corev1 "k8s.io/api/core/v1" - "k8s.io/apimachinery/pkg/runtime/schema" - "knative.dev/eventing/pkg/logging" - "knative.dev/pkg/apis" - "knative.dev/pkg/apis/duck" - duckv1 "knative.dev/pkg/apis/duck/v1" - "knative.dev/pkg/tracker" -) - -var sbCondSet = apis.NewLivingConditionSet() - -// GetGroupVersionKind returns the GroupVersionKind. -func (s *SinkBinding) GetGroupVersionKind() schema.GroupVersionKind { - return SchemeGroupVersion.WithKind("SinkBinding") -} - -// GetUntypedSpec implements apis.HasSpec -func (c *SinkBinding) GetUntypedSpec() interface{} { - return c.Spec -} - -// GetSubject implements psbinding.Bindable -func (fb *SinkBinding) GetSubject() tracker.Reference { - return fb.Spec.Subject -} - -// GetBindingStatus implements psbinding.Bindable -func (fb *SinkBinding) GetBindingStatus() duck.BindableStatus { - return &fb.Status -} - -// SetObservedGeneration implements psbinding.BindableStatus -func (fbs *SinkBindingStatus) SetObservedGeneration(gen int64) { - fbs.ObservedGeneration = gen -} - -// InitializeConditions populates the SinkBindingStatus's conditions field -// with all of its conditions configured to Unknown. -func (fbs *SinkBindingStatus) InitializeConditions() { - sbCondSet.Manage(fbs).InitializeConditions() -} - -// MarkBindingUnavailable marks the SinkBinding's Ready condition to False with -// the provided reason and message. -func (fbs *SinkBindingStatus) MarkBindingUnavailable(reason, message string) { - sbCondSet.Manage(fbs).MarkFalse(SinkBindingConditionReady, reason, message) -} - -// MarkBindingAvailable marks the SinkBinding's Ready condition to True. -func (fbs *SinkBindingStatus) MarkBindingAvailable() { - sbCondSet.Manage(fbs).MarkTrue(SinkBindingConditionReady) -} - -// Do implements psbinding.Bindable -func (fb *SinkBinding) Do(ctx context.Context, ps *duckv1.WithPod) { - fb.MarkDeprecated(&fb.Status.Status, "SinkBindingDeprecated", "sinkbindings.sources.eventing.knative.dev are deprecated and will be removed in the future. Use sinkbindings.sources.knative.dev instead.") - - // First undo so that we can just unconditionally append below. - fb.Undo(ctx, ps) - - uri := GetSinkURI(ctx) - if uri == nil { - logging.FromContext(ctx).Error(fmt.Sprintf("No sink URI associated with context for %+v", fb)) - return - } - - spec := ps.Spec.Template.Spec - for i := range spec.InitContainers { - spec.InitContainers[i].Env = append(spec.InitContainers[i].Env, corev1.EnvVar{ - Name: "K_SINK", - Value: uri.String(), - }) - } - for i := range spec.Containers { - spec.Containers[i].Env = append(spec.Containers[i].Env, corev1.EnvVar{ - Name: "K_SINK", - Value: uri.String(), - }) - } -} - -func (fb *SinkBinding) Undo(ctx context.Context, ps *duckv1.WithPod) { - spec := ps.Spec.Template.Spec - for i, c := range spec.InitContainers { - for j, ev := range c.Env { - if ev.Name == "K_SINK" { - spec.InitContainers[i].Env = append(spec.InitContainers[i].Env[:j], spec.InitContainers[i].Env[j+1:]...) - break - } - } - } - for i, c := range spec.Containers { - for j, ev := range c.Env { - if ev.Name == "K_SINK" { - spec.Containers[i].Env = append(spec.Containers[i].Env[:j], spec.Containers[i].Env[j+1:]...) - break - } - } - } -} diff --git a/vendor/knative.dev/eventing/pkg/apis/legacysources/v1alpha1/sinkbinding_types.go b/vendor/knative.dev/eventing/pkg/apis/legacysources/v1alpha1/sinkbinding_types.go deleted file mode 100644 index b9a1f0eafa..0000000000 --- a/vendor/knative.dev/eventing/pkg/apis/legacysources/v1alpha1/sinkbinding_types.go +++ /dev/null @@ -1,82 +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 ( - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "knative.dev/pkg/apis" - duckv1 "knative.dev/pkg/apis/duck/v1" - duckv1alpha1 "knative.dev/pkg/apis/duck/v1alpha1" - "knative.dev/pkg/kmeta" -) - -// +genclient -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -// +k8s:defaulter-gen=true - -// SinkBinding describes a Binding that is also a Source. -// The `sink` (from the Source duck) is resolved to a URL and -// then projected into the `subject` by augmenting the runtime -// contract of the referenced containers to have a `K_SINK` -// environment variable holding the endpoint to which to send -// cloud events. -type SinkBinding struct { - // Deprecated allows ApiServerSource to have a deprecated message. - Deprecated - - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata,omitempty"` - - Spec SinkBindingSpec `json:"spec"` - Status SinkBindingStatus `json:"status"` -} - -// Check the interfaces that SinkBinding should be implementing. -var ( - _ runtime.Object = (*SinkBinding)(nil) - _ kmeta.OwnerRefable = (*SinkBinding)(nil) - _ apis.Validatable = (*SinkBinding)(nil) - _ apis.Defaultable = (*SinkBinding)(nil) - _ apis.HasSpec = (*SinkBinding)(nil) -) - -// SinkBindingSpec holds the desired state of the SinkBinding (from the client). -type SinkBindingSpec struct { - duckv1.SourceSpec `json:",inline"` - duckv1alpha1.BindingSpec `json:",inline"` -} - -const ( - // SinkBindingConditionReady is configured to indicate whether the Binding - // has been configured for resources subject to its runtime contract. - SinkBindingConditionReady = apis.ConditionReady -) - -// SinkBindingStatus communicates the observed state of the SinkBinding (from the controller). -type SinkBindingStatus struct { - duckv1.SourceStatus `json:",inline"` -} - -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object - -// SinkBindingList contains a list of SinkBinding -type SinkBindingList struct { - metav1.TypeMeta `json:",inline"` - metav1.ListMeta `json:"metadata,omitempty"` - Items []SinkBinding `json:"items"` -} diff --git a/vendor/knative.dev/eventing/pkg/apis/legacysources/v1alpha1/sinkbinding_validation.go b/vendor/knative.dev/eventing/pkg/apis/legacysources/v1alpha1/sinkbinding_validation.go deleted file mode 100644 index e76f18abe7..0000000000 --- a/vendor/knative.dev/eventing/pkg/apis/legacysources/v1alpha1/sinkbinding_validation.go +++ /dev/null @@ -1,38 +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 ( - "context" - - "knative.dev/pkg/apis" -) - -// Validate implements apis.Validatable -func (fb *SinkBinding) Validate(ctx context.Context) *apis.FieldError { - err := fb.Spec.Validate(ctx).ViaField("spec") - if fb.Spec.Subject.Namespace != "" && fb.Namespace != fb.Spec.Subject.Namespace { - err = err.Also(apis.ErrInvalidValue(fb.Spec.Subject.Namespace, "spec.subject.namespace")) - } - return err -} - -// Validate implements apis.Validatable -func (fbs *SinkBindingSpec) Validate(ctx context.Context) *apis.FieldError { - return fbs.Subject.Validate(ctx).ViaField("subject").Also( - fbs.Sink.Validate(ctx).ViaField("sink")) -} diff --git a/vendor/knative.dev/eventing/pkg/apis/legacysources/v1alpha1/zz_generated.deepcopy.go b/vendor/knative.dev/eventing/pkg/apis/legacysources/v1alpha1/zz_generated.deepcopy.go deleted file mode 100644 index 8167839f55..0000000000 --- a/vendor/knative.dev/eventing/pkg/apis/legacysources/v1alpha1/zz_generated.deepcopy.go +++ /dev/null @@ -1,533 +0,0 @@ -// +build !ignore_autogenerated - -/* -Copyright 2020 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. -*/ - -// Code generated by deepcopy-gen. DO NOT EDIT. - -package v1alpha1 - -import ( - v1 "k8s.io/api/core/v1" - runtime "k8s.io/apimachinery/pkg/runtime" - v1beta1 "knative.dev/pkg/apis/duck/v1beta1" -) - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ApiServerResource) DeepCopyInto(out *ApiServerResource) { - *out = *in - in.LabelSelector.DeepCopyInto(&out.LabelSelector) - in.ControllerSelector.DeepCopyInto(&out.ControllerSelector) - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ApiServerResource. -func (in *ApiServerResource) DeepCopy() *ApiServerResource { - if in == nil { - return nil - } - out := new(ApiServerResource) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ApiServerSource) DeepCopyInto(out *ApiServerSource) { - *out = *in - out.Deprecated = in.Deprecated - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - in.Spec.DeepCopyInto(&out.Spec) - in.Status.DeepCopyInto(&out.Status) - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ApiServerSource. -func (in *ApiServerSource) DeepCopy() *ApiServerSource { - if in == nil { - return nil - } - out := new(ApiServerSource) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *ApiServerSource) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ApiServerSourceList) DeepCopyInto(out *ApiServerSourceList) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ListMeta.DeepCopyInto(&out.ListMeta) - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]ApiServerSource, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ApiServerSourceList. -func (in *ApiServerSourceList) DeepCopy() *ApiServerSourceList { - if in == nil { - return nil - } - out := new(ApiServerSourceList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *ApiServerSourceList) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ApiServerSourceSpec) DeepCopyInto(out *ApiServerSourceSpec) { - *out = *in - if in.Resources != nil { - in, out := &in.Resources, &out.Resources - *out = make([]ApiServerResource, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - if in.Sink != nil { - in, out := &in.Sink, &out.Sink - *out = new(v1beta1.Destination) - (*in).DeepCopyInto(*out) - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ApiServerSourceSpec. -func (in *ApiServerSourceSpec) DeepCopy() *ApiServerSourceSpec { - if in == nil { - return nil - } - out := new(ApiServerSourceSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ApiServerSourceStatus) DeepCopyInto(out *ApiServerSourceStatus) { - *out = *in - in.Status.DeepCopyInto(&out.Status) - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ApiServerSourceStatus. -func (in *ApiServerSourceStatus) DeepCopy() *ApiServerSourceStatus { - if in == nil { - return nil - } - out := new(ApiServerSourceStatus) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ContainerSource) DeepCopyInto(out *ContainerSource) { - *out = *in - out.Deprecated = in.Deprecated - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - in.Spec.DeepCopyInto(&out.Spec) - in.Status.DeepCopyInto(&out.Status) - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ContainerSource. -func (in *ContainerSource) DeepCopy() *ContainerSource { - if in == nil { - return nil - } - out := new(ContainerSource) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *ContainerSource) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ContainerSourceList) DeepCopyInto(out *ContainerSourceList) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ListMeta.DeepCopyInto(&out.ListMeta) - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]ContainerSource, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ContainerSourceList. -func (in *ContainerSourceList) DeepCopy() *ContainerSourceList { - if in == nil { - return nil - } - out := new(ContainerSourceList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *ContainerSourceList) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ContainerSourceSpec) DeepCopyInto(out *ContainerSourceSpec) { - *out = *in - if in.Template != nil { - in, out := &in.Template, &out.Template - *out = new(v1.PodTemplateSpec) - (*in).DeepCopyInto(*out) - } - if in.DeprecatedArgs != nil { - in, out := &in.DeprecatedArgs, &out.DeprecatedArgs - *out = make([]string, len(*in)) - copy(*out, *in) - } - if in.DeprecatedEnv != nil { - in, out := &in.DeprecatedEnv, &out.DeprecatedEnv - *out = make([]v1.EnvVar, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - if in.Sink != nil { - in, out := &in.Sink, &out.Sink - *out = new(v1beta1.Destination) - (*in).DeepCopyInto(*out) - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ContainerSourceSpec. -func (in *ContainerSourceSpec) DeepCopy() *ContainerSourceSpec { - if in == nil { - return nil - } - out := new(ContainerSourceSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ContainerSourceStatus) DeepCopyInto(out *ContainerSourceStatus) { - *out = *in - in.Status.DeepCopyInto(&out.Status) - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ContainerSourceStatus. -func (in *ContainerSourceStatus) DeepCopy() *ContainerSourceStatus { - if in == nil { - return nil - } - out := new(ContainerSourceStatus) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *CronJobLimitsSpec) DeepCopyInto(out *CronJobLimitsSpec) { - *out = *in - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CronJobLimitsSpec. -func (in *CronJobLimitsSpec) DeepCopy() *CronJobLimitsSpec { - if in == nil { - return nil - } - out := new(CronJobLimitsSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *CronJobRequestsSpec) DeepCopyInto(out *CronJobRequestsSpec) { - *out = *in - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CronJobRequestsSpec. -func (in *CronJobRequestsSpec) DeepCopy() *CronJobRequestsSpec { - if in == nil { - return nil - } - out := new(CronJobRequestsSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *CronJobResourceSpec) DeepCopyInto(out *CronJobResourceSpec) { - *out = *in - out.Requests = in.Requests - out.Limits = in.Limits - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CronJobResourceSpec. -func (in *CronJobResourceSpec) DeepCopy() *CronJobResourceSpec { - if in == nil { - return nil - } - out := new(CronJobResourceSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *CronJobSource) DeepCopyInto(out *CronJobSource) { - *out = *in - out.Deprecated = in.Deprecated - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - in.Spec.DeepCopyInto(&out.Spec) - in.Status.DeepCopyInto(&out.Status) - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CronJobSource. -func (in *CronJobSource) DeepCopy() *CronJobSource { - if in == nil { - return nil - } - out := new(CronJobSource) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *CronJobSource) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *CronJobSourceList) DeepCopyInto(out *CronJobSourceList) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ListMeta.DeepCopyInto(&out.ListMeta) - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]CronJobSource, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CronJobSourceList. -func (in *CronJobSourceList) DeepCopy() *CronJobSourceList { - if in == nil { - return nil - } - out := new(CronJobSourceList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *CronJobSourceList) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *CronJobSourceSpec) DeepCopyInto(out *CronJobSourceSpec) { - *out = *in - if in.Sink != nil { - in, out := &in.Sink, &out.Sink - *out = new(v1beta1.Destination) - (*in).DeepCopyInto(*out) - } - out.Resources = in.Resources - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CronJobSourceSpec. -func (in *CronJobSourceSpec) DeepCopy() *CronJobSourceSpec { - if in == nil { - return nil - } - out := new(CronJobSourceSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *CronJobSourceStatus) DeepCopyInto(out *CronJobSourceStatus) { - *out = *in - in.Status.DeepCopyInto(&out.Status) - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CronJobSourceStatus. -func (in *CronJobSourceStatus) DeepCopy() *CronJobSourceStatus { - if in == nil { - return nil - } - out := new(CronJobSourceStatus) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Deprecated) DeepCopyInto(out *Deprecated) { - *out = *in - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Deprecated. -func (in *Deprecated) DeepCopy() *Deprecated { - if in == nil { - return nil - } - out := new(Deprecated) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *SinkBinding) DeepCopyInto(out *SinkBinding) { - *out = *in - out.Deprecated = in.Deprecated - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - in.Spec.DeepCopyInto(&out.Spec) - in.Status.DeepCopyInto(&out.Status) - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SinkBinding. -func (in *SinkBinding) DeepCopy() *SinkBinding { - if in == nil { - return nil - } - out := new(SinkBinding) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *SinkBinding) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *SinkBindingList) DeepCopyInto(out *SinkBindingList) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ListMeta.DeepCopyInto(&out.ListMeta) - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]SinkBinding, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SinkBindingList. -func (in *SinkBindingList) DeepCopy() *SinkBindingList { - if in == nil { - return nil - } - out := new(SinkBindingList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *SinkBindingList) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *SinkBindingSpec) DeepCopyInto(out *SinkBindingSpec) { - *out = *in - in.SourceSpec.DeepCopyInto(&out.SourceSpec) - in.BindingSpec.DeepCopyInto(&out.BindingSpec) - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SinkBindingSpec. -func (in *SinkBindingSpec) DeepCopy() *SinkBindingSpec { - if in == nil { - return nil - } - out := new(SinkBindingSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *SinkBindingStatus) DeepCopyInto(out *SinkBindingStatus) { - *out = *in - in.SourceStatus.DeepCopyInto(&out.SourceStatus) - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SinkBindingStatus. -func (in *SinkBindingStatus) DeepCopy() *SinkBindingStatus { - if in == nil { - return nil - } - out := new(SinkBindingStatus) - in.DeepCopyInto(out) - return out -} diff --git a/vendor/knative.dev/eventing/pkg/apis/messaging/v1alpha1/channel_defaults.go b/vendor/knative.dev/eventing/pkg/apis/messaging/v1alpha1/channel_defaults.go index 389694f562..f1df81f691 100644 --- a/vendor/knative.dev/eventing/pkg/apis/messaging/v1alpha1/channel_defaults.go +++ b/vendor/knative.dev/eventing/pkg/apis/messaging/v1alpha1/channel_defaults.go @@ -30,8 +30,8 @@ func (c *Channel) SetDefaults(ctx context.Context) { defaultChannel, err := cfg.ChannelDefaults.GetChannelConfig(apis.ParentMeta(ctx).Namespace) if err == nil { c.Spec.ChannelTemplate = &v1beta1.ChannelTemplateSpec{ - defaultChannel.TypeMeta, - defaultChannel.Spec, + TypeMeta: defaultChannel.TypeMeta, + Spec: defaultChannel.Spec, } } } diff --git a/vendor/knative.dev/eventing/pkg/apis/messaging/v1alpha1/in_memory_channel_conversion.go b/vendor/knative.dev/eventing/pkg/apis/messaging/v1alpha1/in_memory_channel_conversion.go index 7434708d3a..468b84dded 100644 --- a/vendor/knative.dev/eventing/pkg/apis/messaging/v1alpha1/in_memory_channel_conversion.go +++ b/vendor/knative.dev/eventing/pkg/apis/messaging/v1alpha1/in_memory_channel_conversion.go @@ -20,13 +20,14 @@ import ( "context" "fmt" + "knative.dev/pkg/apis" + duckv1 "knative.dev/pkg/apis/duck/v1" + pkgduckv1alpha1 "knative.dev/pkg/apis/duck/v1alpha1" + duckv1alpha1 "knative.dev/eventing/pkg/apis/duck/v1alpha1" eventingduck "knative.dev/eventing/pkg/apis/duck/v1alpha1" duckv1beta1 "knative.dev/eventing/pkg/apis/duck/v1beta1" "knative.dev/eventing/pkg/apis/messaging/v1beta1" - "knative.dev/pkg/apis" - duckv1 "knative.dev/pkg/apis/duck/v1" - pkgduckv1alpha1 "knative.dev/pkg/apis/duck/v1alpha1" ) // ConvertTo implements apis.Convertible @@ -48,24 +49,7 @@ func (source *InMemoryChannelSpec) ConvertTo(ctx context.Context, sink *v1beta1. if source.Subscribable != nil { sink.Subscribers = make([]duckv1beta1.SubscriberSpec, len(source.Subscribable.Subscribers)) for i, s := range source.Subscribable.Subscribers { - sink.Subscribers[i] = duckv1beta1.SubscriberSpec{ - UID: s.UID, - Generation: s.Generation, - SubscriberURI: s.SubscriberURI, - ReplyURI: s.ReplyURI, - } - // If the source has delivery, use it. - if s.Delivery != nil { - sink.Subscribers[i].Delivery = s.Delivery - } else { - // If however, there's a Deprecated DeadLetterSinkURI, convert that up - // to DeliverySpec. - sink.Subscribers[i].Delivery = &duckv1beta1.DeliverySpec{ - DeadLetterSink: &duckv1.Destination{ - URI: s.DeadLetterSinkURI, - }, - } - } + s.ConvertTo(ctx, &sink.Subscribers[i]) } } return nil @@ -114,18 +98,7 @@ func (sink *InMemoryChannelSpec) ConvertFrom(ctx context.Context, source v1beta1 Subscribers: make([]eventingduck.SubscriberSpec, len(source.Subscribers)), } for i, s := range source.Subscribers { - var deadLetterSinkURI *apis.URL - if s.Delivery != nil && s.Delivery.DeadLetterSink != nil { - deadLetterSinkURI = s.Delivery.DeadLetterSink.URI - } - sink.Subscribable.Subscribers[i] = eventingduck.SubscriberSpec{ - UID: s.UID, - Generation: s.Generation, - SubscriberURI: s.SubscriberURI, - ReplyURI: s.ReplyURI, - Delivery: s.Delivery, - DeadLetterSinkURI: deadLetterSinkURI, - } + sink.Subscribable.Subscribers[i].ConvertFrom(ctx, s) } } } diff --git a/vendor/knative.dev/eventing/pkg/apis/messaging/v1alpha1/in_memory_channel_validation.go b/vendor/knative.dev/eventing/pkg/apis/messaging/v1alpha1/in_memory_channel_validation.go index b5200f9e93..f133d2ef25 100644 --- a/vendor/knative.dev/eventing/pkg/apis/messaging/v1alpha1/in_memory_channel_validation.go +++ b/vendor/knative.dev/eventing/pkg/apis/messaging/v1alpha1/in_memory_channel_validation.go @@ -30,7 +30,7 @@ func (imc *InMemoryChannel) Validate(ctx context.Context) *apis.FieldError { // Validate annotations if imc.Annotations != nil { if scope, ok := imc.Annotations[eventing.ScopeAnnotationKey]; ok { - if scope != "namespace" && scope != "cluster" { + if scope != eventing.ScopeNamespace && scope != eventing.ScopeCluster { iv := apis.ErrInvalidValue(scope, "") iv.Details = "expected either 'cluster' or 'namespace'" errs = errs.Also(iv.ViaFieldKey("annotations", eventing.ScopeAnnotationKey).ViaField("metadata")) diff --git a/vendor/knative.dev/eventing/pkg/apis/messaging/v1alpha1/subscription_lifecycle.go b/vendor/knative.dev/eventing/pkg/apis/messaging/v1alpha1/subscription_lifecycle.go index 0678f418e5..63a3ff7c2a 100644 --- a/vendor/knative.dev/eventing/pkg/apis/messaging/v1alpha1/subscription_lifecycle.go +++ b/vendor/knative.dev/eventing/pkg/apis/messaging/v1alpha1/subscription_lifecycle.go @@ -29,7 +29,7 @@ const ( SubscriptionConditionReady = apis.ConditionReady // SubscriptionConditionReferencesResolved has status True when all the specified references have been successfully // resolved. - SubscriptionConditionReferencesResolved apis.ConditionType = "Resolved" + SubscriptionConditionReferencesResolved apis.ConditionType = "ReferencesResolved" // SubscriptionConditionAddedToChannel has status True when controller has successfully added a // subscription to the spec.channel resource. diff --git a/vendor/knative.dev/eventing/pkg/apis/messaging/v1beta1/in_memory_channel_validation.go b/vendor/knative.dev/eventing/pkg/apis/messaging/v1beta1/in_memory_channel_validation.go index d4366419a2..7ed4dc11b7 100644 --- a/vendor/knative.dev/eventing/pkg/apis/messaging/v1beta1/in_memory_channel_validation.go +++ b/vendor/knative.dev/eventing/pkg/apis/messaging/v1beta1/in_memory_channel_validation.go @@ -31,7 +31,7 @@ func (imc *InMemoryChannel) Validate(ctx context.Context) *apis.FieldError { // Validate annotations if imc.Annotations != nil { if scope, ok := imc.Annotations[eventing.ScopeAnnotationKey]; ok { - if scope != "namespace" && scope != "cluster" { + if scope != eventing.ScopeNamespace && scope != eventing.ScopeCluster { iv := apis.ErrInvalidValue(scope, "") iv.Details = "expected either 'cluster' or 'namespace'" errs = errs.Also(iv.ViaFieldKey("annotations", eventing.ScopeAnnotationKey).ViaField("metadata")) diff --git a/vendor/knative.dev/eventing/pkg/apis/messaging/v1beta1/subscription_lifecycle.go b/vendor/knative.dev/eventing/pkg/apis/messaging/v1beta1/subscription_lifecycle.go index 0637356d21..f5e6a90df7 100644 --- a/vendor/knative.dev/eventing/pkg/apis/messaging/v1beta1/subscription_lifecycle.go +++ b/vendor/knative.dev/eventing/pkg/apis/messaging/v1beta1/subscription_lifecycle.go @@ -29,7 +29,7 @@ const ( SubscriptionConditionReady = apis.ConditionReady // SubscriptionConditionReferencesResolved has status True when all the specified references have been successfully // resolved. - SubscriptionConditionReferencesResolved apis.ConditionType = "Resolved" + SubscriptionConditionReferencesResolved apis.ConditionType = "ReferencesResolved" // SubscriptionConditionAddedToChannel has status True when controller has successfully added a // subscription to the spec.channel resource. diff --git a/vendor/knative.dev/eventing/pkg/apis/sources/register.go b/vendor/knative.dev/eventing/pkg/apis/sources/register.go index 73f43e9dc2..55b4a748b1 100644 --- a/vendor/knative.dev/eventing/pkg/apis/sources/register.go +++ b/vendor/knative.dev/eventing/pkg/apis/sources/register.go @@ -16,10 +16,22 @@ limitations under the License. package sources -import "k8s.io/apimachinery/pkg/runtime/schema" +import ( + "k8s.io/apimachinery/pkg/runtime/schema" + "knative.dev/pkg/apis/duck" +) const ( GroupName = "sources.knative.dev" + + // SourceDuckLabelKey is the label key to indicate + // whether the CRD is a Source duck type. + // Valid values: "true" or "false" + SourceDuckLabelKey = duck.GroupName + "/source" + + // SourceDuckLabelValue is the label value to indicate + // the CRD is a Source duck type. + SourceDuckLabelValue = "true" ) var ( @@ -38,4 +50,10 @@ var ( Group: GroupName, Resource: "sinkbindings", } + + // ContainerSourceResource respresents a Knative Eventing Sources ContainerSource + ContainerSourceResource = schema.GroupResource{ + Group: GroupName, + Resource: "containersources", + } ) diff --git a/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha1/apiserver_conversion.go b/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha1/apiserver_conversion.go index 62cf9227b1..970d25f312 100644 --- a/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha1/apiserver_conversion.go +++ b/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha1/apiserver_conversion.go @@ -21,12 +21,14 @@ import ( "fmt" "reflect" + "github.com/google/go-cmp/cmp" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + corev1 "k8s.io/api/core/v1" "knative.dev/eventing/pkg/apis/sources/v1alpha2" "knative.dev/pkg/apis" duckv1 "knative.dev/pkg/apis/duck/v1" duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" - "knative.dev/pkg/ptr" ) // ConvertTo implements apis.Convertible. @@ -40,12 +42,17 @@ func (source *ApiServerSource) ConvertTo(ctx context.Context, obj apis.Convertib // Spec if len(source.Spec.Resources) > 0 { - sink.Spec.Resources = make([]v1alpha2.APIVersionKind, len(source.Spec.Resources)) + sink.Spec.Resources = make([]v1alpha2.APIVersionKindSelector, len(source.Spec.Resources)) } for i, v := range source.Spec.Resources { - sink.Spec.Resources[i] = v1alpha2.APIVersionKind{ - APIVersion: ptr.String(v.APIVersion), - Kind: ptr.String(v.Kind), + sink.Spec.Resources[i] = v1alpha2.APIVersionKindSelector{ + APIVersion: v.APIVersion, + Kind: v.Kind, + } + + if !cmp.Equal(v.LabelSelector, metav1.LabelSelector{}) { + sink.Spec.Resources[i].LabelSelector = &metav1.LabelSelector{} + v.LabelSelector.DeepCopyInto(sink.Spec.Resources[i].LabelSelector) } } @@ -58,10 +65,6 @@ func (source *ApiServerSource) ConvertTo(ctx context.Context, obj apis.Convertib // Optional Spec - if source.Spec.LabelSelector != nil { - sink.Spec.LabelSelector = source.Spec.LabelSelector - } - if source.Spec.ResourceOwner != nil { sink.Spec.ResourceOwner = source.Spec.ResourceOwner } @@ -135,20 +138,15 @@ func (sink *ApiServerSource) ConvertFrom(ctx context.Context, obj apis.Convertib } for i, v := range source.Spec.Resources { sink.Spec.Resources[i] = ApiServerResource{} - if v.APIVersion != nil { - sink.Spec.Resources[i].APIVersion = *v.APIVersion - } - if v.Kind != nil { - sink.Spec.Resources[i].Kind = *v.Kind + sink.Spec.Resources[i].APIVersion = v.APIVersion + sink.Spec.Resources[i].Kind = v.Kind + if v.LabelSelector != nil { + sink.Spec.Resources[i].LabelSelector = *v.LabelSelector } } // Spec Optionals - if source.Spec.LabelSelector != nil { - sink.Spec.LabelSelector = source.Spec.LabelSelector - } - if source.Spec.ResourceOwner != nil { sink.Spec.ResourceOwner = source.Spec.ResourceOwner } diff --git a/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha1/apiserver_lifecycle.go b/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha1/apiserver_lifecycle.go index 7e3240e8af..72947aee08 100644 --- a/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha1/apiserver_lifecycle.go +++ b/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha1/apiserver_lifecycle.go @@ -37,9 +37,6 @@ const ( // ApiServerConditionSufficientPermissions has status True when the ApiServerSource has sufficient permissions to access resources. ApiServerConditionSufficientPermissions apis.ConditionType = "SufficientPermissions" - - // ApiServerConditionEventTypeProvided has status True when the ApiServerSource has been configured with its event types. - ApiServerConditionEventTypeProvided apis.ConditionType = "EventTypesProvided" ) var apiserverCondSet = apis.NewLivingConditionSet( @@ -121,16 +118,6 @@ func (s *ApiServerSourceStatus) PropagateDeploymentAvailability(d *appsv1.Deploy } } -// MarkEventTypes sets the condition that the source has set its event type. -func (s *ApiServerSourceStatus) MarkEventTypes() { - apiserverCondSet.Manage(s).MarkTrue(ApiServerConditionEventTypeProvided) -} - -// MarkNoEventTypes sets the condition that the source does not its event type configured. -func (s *ApiServerSourceStatus) MarkNoEventTypes(reason, messageFormat string, messageA ...interface{}) { - apiserverCondSet.Manage(s).MarkFalse(ApiServerConditionEventTypeProvided, reason, messageFormat, messageA...) -} - // MarkSufficientPermissions sets the condition that the source has enough permissions to access the resources. func (s *ApiServerSourceStatus) MarkSufficientPermissions() { apiserverCondSet.Manage(s).MarkTrue(ApiServerConditionSufficientPermissions) diff --git a/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha1/apiserver_types.go b/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha1/apiserver_types.go index 39b01dffbc..80440d0579 100644 --- a/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha1/apiserver_types.go +++ b/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha1/apiserver_types.go @@ -46,6 +46,16 @@ var ( _ apis.HasSpec = (*ApiServerSource)(nil) ) +// ApiServerSourceEventTypes is the list of CloudEvent types the ApiServerSource emits. +var ApiServerSourceEventTypes = []string{ + ApiServerSourceAddEventType, + ApiServerSourceDeleteEventType, + ApiServerSourceUpdateEventType, + ApiServerSourceAddRefEventType, + ApiServerSourceDeleteRefEventType, + ApiServerSourceUpdateRefEventType, +} + const ( // ApiServerSourceAddEventType is the ApiServerSource CloudEvent type for adds. ApiServerSourceAddEventType = "dev.knative.apiserver.resource.add" @@ -81,12 +91,6 @@ type ApiServerSourceSpec struct { // +optional CloudEventOverrides *duckv1.CloudEventOverrides `json:"ceOverrides,omitempty"` - // LabelSelector filters this source to objects to those resources pass the - // label selector. - // More info: http://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#label-selectors - // +optional - LabelSelector *metav1.LabelSelector `json:"selector,omitempty"` - // ResourceOwner is an additional filter to only track resources that are // owned by a specific resource type. If ResourceOwner matches Resources[n] // then Resources[n] is allowed to pass the ResourceOwner filter. @@ -122,8 +126,6 @@ type ApiServerResource struct { // LabelSelector restricts this source to objects with the selected labels // More info: http://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#label-selectors - // Deprecated: Per-resource label selectors will no longer be supported in - // v1alpha2, please use Spec.LabelSelector. LabelSelector metav1.LabelSelector `json:"labelSelector"` // ControllerSelector restricts this source to objects with a controlling owner reference of the specified kind. diff --git a/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha1/ping_conversion.go b/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha1/ping_conversion.go index 468c0d1b94..b1c7c5ae65 100644 --- a/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha1/ping_conversion.go +++ b/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha1/ping_conversion.go @@ -38,8 +38,9 @@ func (source *PingSource) ConvertTo(ctx context.Context, obj apis.Convertible) e } sink.Status = v1alpha2.PingSourceStatus{ SourceStatus: duckv1.SourceStatus{ - Status: source.Status.Status, - SinkURI: source.Status.SinkURI, + Status: source.Status.Status, + SinkURI: source.Status.SinkURI, + CloudEventAttributes: source.Status.CloudEventAttributes, }, } // Optionals @@ -71,8 +72,11 @@ func (sink *PingSource) ConvertFrom(ctx context.Context, obj apis.Convertible) e CloudEventOverrides: source.Spec.CloudEventOverrides, } sink.Status = PingSourceStatus{ - Status: source.Status.Status, - SinkURI: source.Status.SinkURI, + SourceStatus: duckv1.SourceStatus{ + Status: source.Status.Status, + SinkURI: source.Status.SinkURI, + CloudEventAttributes: source.Status.CloudEventAttributes, + }, } if reflect.DeepEqual(*sink.Spec.Sink, duckv1.Destination{}) { sink.Spec.Sink = nil diff --git a/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha1/ping_lifecycle.go b/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha1/ping_lifecycle.go index 9fb0b313b5..0258ced056 100644 --- a/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha1/ping_lifecycle.go +++ b/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha1/ping_lifecycle.go @@ -39,9 +39,6 @@ const ( // PingSourceConditionDeployed has status True when the PingSource has had it's receive adapter deployment created. PingSourceConditionDeployed apis.ConditionType = "Deployed" - // PingSourceConditionEventTypeProvided has status True when the PingSource has been configured with its event type. - PingSourceConditionEventTypeProvided apis.ConditionType = "EventTypeProvided" - // PingSourceConditionResources is True when the resources listed for the PingSource have been properly // parsed and match specified syntax for resource quantities PingSourceConditionResources apis.ConditionType = "ResourcesCorrect" @@ -131,16 +128,6 @@ func (s *PingSourceStatus) PropagateDeploymentAvailability(d *appsv1.Deployment) } } -// MarkEventType sets the condition that the source has set its event type. -func (s *PingSourceStatus) MarkEventType() { - PingSourceCondSet.Manage(s).MarkTrue(PingSourceConditionEventTypeProvided) -} - -// MarkNoEventType sets the condition that the source does not its event type configured. -func (s *PingSourceStatus) MarkNoEventType(reason, messageFormat string, messageA ...interface{}) { - PingSourceCondSet.Manage(s).MarkFalse(PingSourceConditionEventTypeProvided, reason, messageFormat, messageA...) -} - // MarkResourcesCorrect sets the condition that the source resources are properly parsable quantities func (s *PingSourceStatus) MarkResourcesCorrect() { PingSourceCondSet.Manage(s).MarkTrue(PingSourceConditionResources) diff --git a/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha1/ping_types.go b/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha1/ping_types.go index c500c305f5..578c792a83 100644 --- a/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha1/ping_types.go +++ b/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha1/ping_types.go @@ -96,14 +96,14 @@ type PingSourceSpec struct { // PingSourceStatus defines the observed state of PingSource. type PingSourceStatus struct { - // inherits duck/v1 Status, which currently provides: - // * ObservedGeneration - the 'Generation' of the Service that was last processed by the controller. - // * Conditions - the latest available observations of a resource's current state. - duckv1.Status `json:",inline"` - - // SinkURI is the current active sink URI that has been configured for the PingSource. - // +optional - SinkURI *apis.URL `json:"sinkUri,omitempty"` + // inherits duck/v1 SourceStatus, which currently provides: + // * ObservedGeneration - the 'Generation' of the Service that was last + // processed by the controller. + // * Conditions - the latest available observations of a resource's current + // state. + // * SinkURI - the current active sink URI that has been configured for the + // Source. + duckv1.SourceStatus `json:",inline"` } // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object diff --git a/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha1/ping_validation.go b/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha1/ping_validation.go index 5fbc1eeb97..40cd8b955b 100644 --- a/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha1/ping_validation.go +++ b/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha1/ping_validation.go @@ -21,10 +21,13 @@ import ( "github.com/robfig/cron" "knative.dev/pkg/apis" + + "knative.dev/eventing/pkg/apis/sources/v1alpha2" ) func (c *PingSource) Validate(ctx context.Context) *apis.FieldError { - return c.Spec.Validate(ctx).ViaField("spec") + errs := c.Spec.Validate(ctx).ViaField("spec") + return v1alpha2.ValidateAnnotations(errs, c.Annotations) } func (cs *PingSourceSpec) Validate(ctx context.Context) *apis.FieldError { diff --git a/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha1/zz_generated.deepcopy.go b/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha1/zz_generated.deepcopy.go index 30c969b98e..448fa4a859 100644 --- a/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha1/zz_generated.deepcopy.go +++ b/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha1/zz_generated.deepcopy.go @@ -21,10 +21,8 @@ limitations under the License. package v1alpha1 import ( - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" v1alpha2 "knative.dev/eventing/pkg/apis/sources/v1alpha2" - apis "knative.dev/pkg/apis" v1 "knative.dev/pkg/apis/duck/v1" v1beta1 "knative.dev/pkg/apis/duck/v1beta1" ) @@ -128,15 +126,10 @@ func (in *ApiServerSourceSpec) DeepCopyInto(out *ApiServerSourceSpec) { *out = new(v1.CloudEventOverrides) (*in).DeepCopyInto(*out) } - if in.LabelSelector != nil { - in, out := &in.LabelSelector, &out.LabelSelector - *out = new(metav1.LabelSelector) - (*in).DeepCopyInto(*out) - } if in.ResourceOwner != nil { in, out := &in.ResourceOwner, &out.ResourceOwner *out = new(v1alpha2.APIVersionKind) - (*in).DeepCopyInto(*out) + **out = **in } return } @@ -309,12 +302,7 @@ func (in *PingSourceSpec) DeepCopy() *PingSourceSpec { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *PingSourceStatus) DeepCopyInto(out *PingSourceStatus) { *out = *in - in.Status.DeepCopyInto(&out.Status) - if in.SinkURI != nil { - in, out := &in.SinkURI, &out.SinkURI - *out = new(apis.URL) - (*in).DeepCopyInto(*out) - } + in.SourceStatus.DeepCopyInto(&out.SourceStatus) return } diff --git a/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha2/apiserver_defaults.go b/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha2/apiserver_defaults.go index c9cc12d21b..11122974fb 100644 --- a/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha2/apiserver_defaults.go +++ b/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha2/apiserver_defaults.go @@ -33,6 +33,4 @@ func (ss *ApiServerSourceSpec) SetDefaults(ctx context.Context) { if ss.ServiceAccountName == "" { ss.ServiceAccountName = "default" } - - // TODO anything? } diff --git a/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha2/apiserver_types.go b/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha2/apiserver_types.go index bb411ca410..f0fa827f7f 100644 --- a/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha2/apiserver_types.go +++ b/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha2/apiserver_types.go @@ -25,6 +25,7 @@ import ( ) // +genclient +// +genreconciler // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object // +k8s:defaulter-gen=true @@ -62,6 +63,16 @@ const ( ApiServerSourceDeleteRefEventType = "dev.knative.apiserver.ref.delete" ) +// ApiServerSourceEventTypes is the list of CloudEvent types the ApiServerSource emits. +var ApiServerSourceEventTypes = []string{ + ApiServerSourceAddEventType, + ApiServerSourceDeleteEventType, + ApiServerSourceUpdateEventType, + ApiServerSourceAddRefEventType, + ApiServerSourceDeleteRefEventType, + ApiServerSourceUpdateRefEventType, +} + // ApiServerSourceSpec defines the desired state of ApiServerSource type ApiServerSourceSpec struct { // inherits duck/v1 SourceSpec, which currently provides: @@ -71,16 +82,11 @@ type ApiServerSourceSpec struct { // and modifications of the event sent to the sink. duckv1.SourceSpec `json:",inline"` - // Resource is the resource this source will track and send related - // lifecycle events from the Kubernetes ApiServer. + // Resource are the resources this source will track and send related + // lifecycle events from the Kubernetes ApiServer, with an optional label + // selector to help filter. // +required - Resources []APIVersionKind `json:"resources,omitempty"` - - // LabelSelector filters this source to objects to those resources pass the - // label selector. - // More info: http://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#label-selectors - // +optional - LabelSelector *metav1.LabelSelector `json:"selector,omitempty"` + Resources []APIVersionKindSelector `json:"resources,omitempty"` // ResourceOwner is an additional filter to only track resources that are // owned by a specific resource type. If ResourceOwner matches Resources[n] @@ -116,13 +122,27 @@ type ApiServerSourceStatus struct { // APIVersionKind is an APIVersion and Kind tuple. type APIVersionKind struct { // APIVersion - the API version of the resource to watch. - // +optional - APIVersion *string `json:"apiVersion"` + APIVersion string `json:"apiVersion"` + + // Kind of the resource to watch. + // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + Kind string `json:"kind"` +} + +// APIVersionKindSelector is an APIVersion Kind tuple with a LabelSelector. +type APIVersionKindSelector struct { + // APIVersion - the API version of the resource to watch. + APIVersion string `json:"apiVersion"` // Kind of the resource to watch. // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + Kind string `json:"kind"` + + // LabelSelector filters this source to objects to those resources pass the + // label selector. + // More info: http://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#label-selectors // +optional - Kind *string `json:"kind"` + LabelSelector *metav1.LabelSelector `json:"selector,omitempty"` } // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object diff --git a/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha2/apiserver_validation.go b/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha2/apiserver_validation.go index 0b19d438a7..9efcf2d767 100644 --- a/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha2/apiserver_validation.go +++ b/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha2/apiserver_validation.go @@ -18,6 +18,9 @@ package v1alpha2 import ( "context" + "strings" + + "k8s.io/apimachinery/pkg/runtime/schema" "knative.dev/pkg/apis" ) @@ -36,10 +39,6 @@ func (c *ApiServerSource) Validate(ctx context.Context) *apis.FieldError { func (cs *ApiServerSourceSpec) Validate(ctx context.Context) *apis.FieldError { var errs *apis.FieldError - if len(cs.Resources) == 0 { - errs = errs.Also(apis.ErrMissingField("resources")) - } - // Validate mode, if can be empty or set as certain value switch cs.EventMode { case ReferenceMode, ResourceMode: @@ -51,5 +50,28 @@ func (cs *ApiServerSourceSpec) Validate(ctx context.Context) *apis.FieldError { // Validate sink errs = errs.Also(cs.Sink.Validate(ctx).ViaField("sink")) + if len(cs.Resources) == 0 { + errs = errs.Also(apis.ErrMissingField("resources")) + } + for i, res := range cs.Resources { + _, err := schema.ParseGroupVersion(res.APIVersion) + if err != nil { + errs = errs.Also(apis.ErrInvalidValue(res.APIVersion, "apiVersion").ViaFieldIndex("resources", i)) + } + if strings.TrimSpace(res.Kind) == "" { + errs = errs.Also(apis.ErrMissingField("kind").ViaFieldIndex("resources", i)) + } + } + + if cs.ResourceOwner != nil { + _, err := schema.ParseGroupVersion(cs.ResourceOwner.APIVersion) + if err != nil { + errs = errs.Also(apis.ErrInvalidValue(cs.ResourceOwner.APIVersion, "apiVersion").ViaField("owner")) + } + if strings.TrimSpace(cs.ResourceOwner.Kind) == "" { + errs = errs.Also(apis.ErrMissingField("kind").ViaField("owner")) + } + } + return errs } diff --git a/vendor/knative.dev/eventing/pkg/apis/legacysources/v1alpha1/containersource_defaults.go b/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha2/container_defaults.go similarity index 54% rename from vendor/knative.dev/eventing/pkg/apis/legacysources/v1alpha1/containersource_defaults.go rename to vendor/knative.dev/eventing/pkg/apis/sources/v1alpha2/container_defaults.go index d9918e3897..adaadb3fb9 100644 --- a/vendor/knative.dev/eventing/pkg/apis/legacysources/v1alpha1/containersource_defaults.go +++ b/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha2/container_defaults.go @@ -1,5 +1,5 @@ /* -Copyright 2019 The Knative Authors +Copyright 2020 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. @@ -14,16 +14,29 @@ See the License for the specific language governing permissions and limitations under the License. */ -package v1alpha1 +package v1alpha2 import ( "context" + "fmt" + + corev1 "k8s.io/api/core/v1" + "knative.dev/pkg/apis" ) func (s *ContainerSource) SetDefaults(ctx context.Context) { - s.Spec.SetDefaults(ctx) + withName := apis.WithinParent(ctx, s.ObjectMeta) + s.Spec.SetDefaults(withName) } func (ss *ContainerSourceSpec) SetDefaults(ctx context.Context) { - // TODO anything? + containers := make([]corev1.Container, 0, len(ss.Template.Spec.Containers)) + for i, c := range ss.Template.Spec.Containers { + // If the Container specified has no name, then default to "_". + if c.Name == "" { + c.Name = fmt.Sprintf("%s-%d", apis.ParentMeta(ctx).Name, i) + } + containers = append(containers, c) + } + ss.Template.Spec.Containers = containers } diff --git a/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha2/container_lifecycle.go b/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha2/container_lifecycle.go new file mode 100644 index 0000000000..7cecfd380d --- /dev/null +++ b/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha2/container_lifecycle.go @@ -0,0 +1,92 @@ +/* +Copyright 2020 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 ( + appsv1 "k8s.io/api/apps/v1" + corev1 "k8s.io/api/core/v1" + "knative.dev/eventing/pkg/apis/duck" + "knative.dev/pkg/apis" +) + +const ( + // ContainerSourceConditionReady has status True when the ContainerSource is ready to send events. + ContainerSourceConditionReady = apis.ConditionReady + + // ContainerSourceConditionSinkBindingReady has status True when the ContainerSource's SinkBinding is ready. + ContainerSourceConditionSinkBindingReady apis.ConditionType = "SinkBindingReady" + + // ContainerSourceConditionReceiveAdapterReady has status True when the ContainerSource's ReceiveAdapter is ready. + ContainerSourceConditionReceiveAdapterReady apis.ConditionType = "ReceiveAdapterReady" +) + +var containerCondSet = apis.NewLivingConditionSet( + ContainerSourceConditionSinkBindingReady, + ContainerSourceConditionReceiveAdapterReady, +) + +// GetCondition returns the condition currently associated with the given type, or nil. +func (s *ContainerSourceStatus) GetCondition(t apis.ConditionType) *apis.Condition { + return containerCondSet.Manage(s).GetCondition(t) +} + +// IsReady returns true if the resource is ready overall. +func (s *ContainerSourceStatus) IsReady() bool { + return containerCondSet.Manage(s).IsHappy() +} + +// InitializeConditions sets relevant unset conditions to Unknown state. +func (s *ContainerSourceStatus) InitializeConditions() { + containerCondSet.Manage(s).InitializeConditions() +} + +// PropagateSinkBindingStatus uses the availability of the provided Deployment to determine if +// ContainerSourceConditionSinkBindingReady should be marked as true, false or unknown. +func (s *ContainerSourceStatus) PropagateSinkBindingStatus(status *SinkBindingStatus) { + // Do not copy conditions nor observedGeneration + conditions := s.Conditions + observedGeneration := s.ObservedGeneration + s.SourceStatus = status.SourceStatus + s.Conditions = conditions + s.ObservedGeneration = observedGeneration + + cond := status.GetCondition(apis.ConditionReady) + switch { + case cond == nil: + containerCondSet.Manage(s).MarkUnknown(ContainerSourceConditionSinkBindingReady, "", "") + case cond.Status == corev1.ConditionTrue: + containerCondSet.Manage(s).MarkTrue(ContainerSourceConditionSinkBindingReady) + case cond.Status == corev1.ConditionFalse: + containerCondSet.Manage(s).MarkFalse(ContainerSourceConditionSinkBindingReady, cond.Reason, cond.Message) + case cond.Status == corev1.ConditionUnknown: + containerCondSet.Manage(s).MarkUnknown(ContainerSourceConditionSinkBindingReady, cond.Reason, cond.Message) + default: + containerCondSet.Manage(s).MarkUnknown(ContainerSourceConditionSinkBindingReady, cond.Reason, cond.Message) + } +} + +// PropagateReceiveAdapterStatus uses the availability of the provided Deployment to determine if +// ContainerSourceConditionReceiveAdapterReady should be marked as true or false. +func (s *ContainerSourceStatus) PropagateReceiveAdapterStatus(d *appsv1.Deployment) { + if duck.DeploymentIsAvailable(&d.Status, false) { + containerCondSet.Manage(s).MarkTrue(ContainerSourceConditionReceiveAdapterReady) + } else { + // I don't know how to propagate the status well, so just give the name of the Deployment + // for now. + containerCondSet.Manage(s).MarkFalse(ContainerSourceConditionReceiveAdapterReady, "DeploymentUnavailable", "The Deployment '%s' is unavailable.", d.Name) + } +} diff --git a/vendor/knative.dev/eventing/pkg/apis/legacysources/v1alpha1/containersource_types.go b/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha2/container_types.go similarity index 51% rename from vendor/knative.dev/eventing/pkg/apis/legacysources/v1alpha1/containersource_types.go rename to vendor/knative.dev/eventing/pkg/apis/sources/v1alpha2/container_types.go index 1b01098404..795fdd97e1 100644 --- a/vendor/knative.dev/eventing/pkg/apis/legacysources/v1alpha1/containersource_types.go +++ b/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha2/container_types.go @@ -1,5 +1,5 @@ /* -Copyright 2019 The Knative Authors +Copyright 2020 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. @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package v1alpha1 +package v1alpha2 import ( corev1 "k8s.io/api/core/v1" @@ -23,19 +23,15 @@ import ( "k8s.io/apimachinery/pkg/runtime/schema" "knative.dev/pkg/apis" duckv1 "knative.dev/pkg/apis/duck/v1" - duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" "knative.dev/pkg/kmeta" ) // +genclient +// +genreconciler // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -// +k8s:defaulter-gen=true // ContainerSource is the Schema for the containersources API type ContainerSource struct { - // Deprecated allows ContainerSource to have a deprecated message. - Deprecated - metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` @@ -44,50 +40,24 @@ type ContainerSource struct { } var ( - _ runtime.Object = (*ContainerSource)(nil) - - // Check that we can create OwnerReferences to a ContainerSource. + _ runtime.Object = (*ContainerSource)(nil) _ kmeta.OwnerRefable = (*ContainerSource)(nil) - - // Check that ContainerSource can return its spec untyped. - _ apis.HasSpec = (*ContainerSource)(nil) + _ apis.Validatable = (*ContainerSource)(nil) + _ apis.Defaultable = (*ContainerSource)(nil) + _ apis.HasSpec = (*ContainerSource)(nil) ) // ContainerSourceSpec defines the desired state of ContainerSource type ContainerSourceSpec struct { + // inherits duck/v1 SourceSpec, which currently provides: + // * Sink - a reference to an object that will resolve to a domain name or + // a URI directly to use as the sink. + // * CloudEventOverrides - defines overrides to control the output format + // and modifications of the event sent to the sink. + duckv1.SourceSpec `json:",inline"` + // Template describes the pods that will be created - // +optional - Template *corev1.PodTemplateSpec `json:"template,omitempty"` - - // DeprecatedImage is the image to run inside of the container. - // This field is to be deprecated. Use `Template` instead. - // When `Template` is set, this field is ignored. - // +kubebuilder:validation:MinLength=1 - DeprecatedImage string `json:"image,omitempty"` - - // DeprecatedArgs are passed to the ContainerSpec as they are. - // This field is to be deprecated. Use `Template` instead. - // When `Template` is set, this field is ignored. - DeprecatedArgs []string `json:"args,omitempty"` - - // DeprecatedEnv is the list of environment variables to set in the container. - // Cannot be updated. - // This field is to be deprecated. Use `Template` instead. - // When `Template` is set, this field is ignored. - // +optional - // +patchMergeKey=name - // +patchStrategy=merge - DeprecatedEnv []corev1.EnvVar `json:"env,omitempty" patchStrategy:"merge" patchMergeKey:"name"` - - // DeprecatedServiceAccountName is the name of the ServiceAccount to use to run this - // source. - // This field is to be deprecated. Use `Template` instead. - // When `Template` is set, this field is ignored. - // +optional - DeprecatedServiceAccountName string `json:"serviceAccountName,omitempty"` - - // Sink is a reference to an object that will resolve to a domain name to use as the sink. - Sink *duckv1beta1.Destination `json:"sink,omitempty"` + Template corev1.PodTemplateSpec `json:"template"` } // GetGroupVersionKind returns the GroupVersionKind. @@ -97,14 +67,14 @@ func (s *ContainerSource) GetGroupVersionKind() schema.GroupVersionKind { // ContainerSourceStatus defines the observed state of ContainerSource type ContainerSourceStatus struct { - // inherits duck/v1 Status, which currently provides: - // * ObservedGeneration - the 'Generation' of the Service that was last processed by the controller. - // * Conditions - the latest available observations of a resource's current state. - duckv1.Status `json:",inline"` - - // SinkURI is the current active sink URI that has been configured for the ContainerSource. - // +optional - SinkURI string `json:"sinkUri,omitempty"` + // inherits duck/v1 SourceStatus, which currently provides: + // * ObservedGeneration - the 'Generation' of the Service that was last + // processed by the controller. + // * Conditions - the latest available observations of a resource's current + // state. + // * SinkURI - the current active sink URI that has been configured for the + // Source. + duckv1.SourceStatus `json:",inline"` } // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object diff --git a/vendor/knative.dev/eventing/pkg/apis/legacysources/v1alpha1/containersource_validation.go b/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha2/container_validation.go similarity index 55% rename from vendor/knative.dev/eventing/pkg/apis/legacysources/v1alpha1/containersource_validation.go rename to vendor/knative.dev/eventing/pkg/apis/sources/v1alpha2/container_validation.go index 5d4f9c6d7c..167435bfa1 100644 --- a/vendor/knative.dev/eventing/pkg/apis/legacysources/v1alpha1/containersource_validation.go +++ b/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha2/container_validation.go @@ -1,5 +1,5 @@ /* -Copyright 2019 The Knative Authors +Copyright 2020 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. @@ -14,11 +14,12 @@ See the License for the specific language governing permissions and limitations under the License. */ -package v1alpha1 +package v1alpha2 import ( "context" + corev1 "k8s.io/api/core/v1" "knative.dev/pkg/apis" ) @@ -28,11 +29,31 @@ func (c *ContainerSource) Validate(ctx context.Context) *apis.FieldError { func (cs *ContainerSourceSpec) Validate(ctx context.Context) *apis.FieldError { var errs *apis.FieldError - if cs.Sink == nil { - fe := apis.ErrMissingField("sink") - errs = errs.Also(fe) - } else if fe := cs.Sink.Validate(ctx); fe != nil { + if fe := cs.Sink.Validate(ctx); fe != nil { errs = errs.Also(fe.ViaField("sink")) } + + // Validate there is at least a container + if cs.Template.Spec.Containers == nil || len(cs.Template.Spec.Containers) == 0 { + fe := apis.ErrMissingField("containers") + errs = errs.Also(fe) + } else { + for i, c := range cs.Template.Spec.Containers { + if ce := isValidContainer(&c); ce != nil { + errs = errs.Also(ce.ViaFieldIndex("containers", i)) + } + } + } + return errs +} + +func isValidContainer(c *corev1.Container) *apis.FieldError { + var errs *apis.FieldError + if c.Name == "" { + errs = errs.Also(apis.ErrMissingField("name")) + } + if c.Image == "" { + errs = errs.Also(apis.ErrMissingField("image")) + } return errs } diff --git a/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha2/ping_types.go b/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha2/ping_types.go index 737dcad32b..bd5823ae83 100644 --- a/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha2/ping_types.go +++ b/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha2/ping_types.go @@ -26,6 +26,7 @@ import ( ) // +genclient +// +genreconciler // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object // +k8s:defaulter-gen=true diff --git a/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha2/ping_validation.go b/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha2/ping_validation.go index 589d708b55..826c5ed499 100644 --- a/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha2/ping_validation.go +++ b/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha2/ping_validation.go @@ -21,10 +21,13 @@ import ( "github.com/robfig/cron" "knative.dev/pkg/apis" + + "knative.dev/eventing/pkg/apis/eventing" ) func (c *PingSource) Validate(ctx context.Context) *apis.FieldError { - return c.Spec.Validate(ctx).ViaField("spec") + errs := c.Spec.Validate(ctx).ViaField("spec") + return ValidateAnnotations(errs, c.Annotations) } func (cs *PingSourceSpec) Validate(ctx context.Context) *apis.FieldError { @@ -40,3 +43,16 @@ func (cs *PingSourceSpec) Validate(ctx context.Context) *apis.FieldError { } return errs } + +func ValidateAnnotations(errs *apis.FieldError, annotations map[string]string) *apis.FieldError { + if annotations != nil { + if scope, ok := annotations[eventing.ScopeAnnotationKey]; ok { + if scope != eventing.ScopeResource && scope != eventing.ScopeCluster { + iv := apis.ErrInvalidValue(scope, "") + iv.Details = "expected either 'cluster' or 'resource'" + errs = errs.Also(iv.ViaFieldKey("annotations", eventing.ScopeAnnotationKey).ViaField("metadata")) + } + } + } + return errs +} diff --git a/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha2/register.go b/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha2/register.go index 9f57ddeb4a..3e19edcf66 100644 --- a/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha2/register.go +++ b/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha2/register.go @@ -45,12 +45,14 @@ var ( // Adds the list of known types to Scheme. func addKnownTypes(scheme *runtime.Scheme) error { scheme.AddKnownTypes(SchemeGroupVersion, - //&ApiServerSource{}, - //&ApiServerSourceList{}, + &ApiServerSource{}, + &ApiServerSourceList{}, &PingSource{}, &PingSourceList{}, &SinkBinding{}, &SinkBindingList{}, + &ContainerSource{}, + &ContainerSourceList{}, ) metav1.AddToGroupVersion(scheme, SchemeGroupVersion) return nil diff --git a/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha2/zz_generated.deepcopy.go b/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha2/zz_generated.deepcopy.go index eb0f9f7092..9be2e52e44 100644 --- a/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha2/zz_generated.deepcopy.go +++ b/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha2/zz_generated.deepcopy.go @@ -28,16 +28,6 @@ import ( // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *APIVersionKind) DeepCopyInto(out *APIVersionKind) { *out = *in - if in.APIVersion != nil { - in, out := &in.APIVersion, &out.APIVersion - *out = new(string) - **out = **in - } - if in.Kind != nil { - in, out := &in.Kind, &out.Kind - *out = new(string) - **out = **in - } return } @@ -51,6 +41,27 @@ func (in *APIVersionKind) DeepCopy() *APIVersionKind { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *APIVersionKindSelector) DeepCopyInto(out *APIVersionKindSelector) { + *out = *in + if in.LabelSelector != nil { + in, out := &in.LabelSelector, &out.LabelSelector + *out = new(v1.LabelSelector) + (*in).DeepCopyInto(*out) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new APIVersionKindSelector. +func (in *APIVersionKindSelector) DeepCopy() *APIVersionKindSelector { + if in == nil { + return nil + } + out := new(APIVersionKindSelector) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ApiServerSource) DeepCopyInto(out *ApiServerSource) { *out = *in @@ -118,20 +129,15 @@ func (in *ApiServerSourceSpec) DeepCopyInto(out *ApiServerSourceSpec) { in.SourceSpec.DeepCopyInto(&out.SourceSpec) if in.Resources != nil { in, out := &in.Resources, &out.Resources - *out = make([]APIVersionKind, len(*in)) + *out = make([]APIVersionKindSelector, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) } } - if in.LabelSelector != nil { - in, out := &in.LabelSelector, &out.LabelSelector - *out = new(v1.LabelSelector) - (*in).DeepCopyInto(*out) - } if in.ResourceOwner != nil { in, out := &in.ResourceOwner, &out.ResourceOwner *out = new(APIVersionKind) - (*in).DeepCopyInto(*out) + **out = **in } return } @@ -163,6 +169,102 @@ func (in *ApiServerSourceStatus) DeepCopy() *ApiServerSourceStatus { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ContainerSource) DeepCopyInto(out *ContainerSource) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ContainerSource. +func (in *ContainerSource) DeepCopy() *ContainerSource { + if in == nil { + return nil + } + out := new(ContainerSource) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ContainerSource) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ContainerSourceList) DeepCopyInto(out *ContainerSourceList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]ContainerSource, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ContainerSourceList. +func (in *ContainerSourceList) DeepCopy() *ContainerSourceList { + if in == nil { + return nil + } + out := new(ContainerSourceList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ContainerSourceList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ContainerSourceSpec) DeepCopyInto(out *ContainerSourceSpec) { + *out = *in + in.SourceSpec.DeepCopyInto(&out.SourceSpec) + in.Template.DeepCopyInto(&out.Template) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ContainerSourceSpec. +func (in *ContainerSourceSpec) DeepCopy() *ContainerSourceSpec { + if in == nil { + return nil + } + out := new(ContainerSourceSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ContainerSourceStatus) DeepCopyInto(out *ContainerSourceStatus) { + *out = *in + in.SourceStatus.DeepCopyInto(&out.SourceStatus) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ContainerSourceStatus. +func (in *ContainerSourceStatus) DeepCopy() *ContainerSourceStatus { + if in == nil { + return nil + } + out := new(ContainerSourceStatus) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *PingSource) DeepCopyInto(out *PingSource) { *out = *in diff --git a/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha1/apiserversource.go b/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha1/apiserversource.go deleted file mode 100644 index 8c30ef3c25..0000000000 --- a/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha1/apiserversource.go +++ /dev/null @@ -1,191 +0,0 @@ -/* -Copyright 2020 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. -*/ - -// Code generated by client-gen. DO NOT EDIT. - -package v1alpha1 - -import ( - "time" - - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - types "k8s.io/apimachinery/pkg/types" - watch "k8s.io/apimachinery/pkg/watch" - rest "k8s.io/client-go/rest" - v1alpha1 "knative.dev/eventing/pkg/apis/sources/v1alpha1" - scheme "knative.dev/eventing/pkg/client/clientset/versioned/scheme" -) - -// ApiServerSourcesGetter has a method to return a ApiServerSourceInterface. -// A group's client should implement this interface. -type ApiServerSourcesGetter interface { - ApiServerSources(namespace string) ApiServerSourceInterface -} - -// ApiServerSourceInterface has methods to work with ApiServerSource resources. -type ApiServerSourceInterface interface { - Create(*v1alpha1.ApiServerSource) (*v1alpha1.ApiServerSource, error) - Update(*v1alpha1.ApiServerSource) (*v1alpha1.ApiServerSource, error) - UpdateStatus(*v1alpha1.ApiServerSource) (*v1alpha1.ApiServerSource, error) - Delete(name string, options *v1.DeleteOptions) error - DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error - Get(name string, options v1.GetOptions) (*v1alpha1.ApiServerSource, error) - List(opts v1.ListOptions) (*v1alpha1.ApiServerSourceList, error) - Watch(opts v1.ListOptions) (watch.Interface, error) - Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.ApiServerSource, err error) - ApiServerSourceExpansion -} - -// apiServerSources implements ApiServerSourceInterface -type apiServerSources struct { - client rest.Interface - ns string -} - -// newApiServerSources returns a ApiServerSources -func newApiServerSources(c *SourcesV1alpha1Client, namespace string) *apiServerSources { - return &apiServerSources{ - client: c.RESTClient(), - ns: namespace, - } -} - -// Get takes name of the apiServerSource, and returns the corresponding apiServerSource object, and an error if there is any. -func (c *apiServerSources) Get(name string, options v1.GetOptions) (result *v1alpha1.ApiServerSource, err error) { - result = &v1alpha1.ApiServerSource{} - err = c.client.Get(). - Namespace(c.ns). - Resource("apiserversources"). - Name(name). - VersionedParams(&options, scheme.ParameterCodec). - Do(). - Into(result) - return -} - -// List takes label and field selectors, and returns the list of ApiServerSources that match those selectors. -func (c *apiServerSources) List(opts v1.ListOptions) (result *v1alpha1.ApiServerSourceList, err error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - result = &v1alpha1.ApiServerSourceList{} - err = c.client.Get(). - Namespace(c.ns). - Resource("apiserversources"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Do(). - Into(result) - return -} - -// Watch returns a watch.Interface that watches the requested apiServerSources. -func (c *apiServerSources) Watch(opts v1.ListOptions) (watch.Interface, error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - opts.Watch = true - return c.client.Get(). - Namespace(c.ns). - Resource("apiserversources"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Watch() -} - -// Create takes the representation of a apiServerSource and creates it. Returns the server's representation of the apiServerSource, and an error, if there is any. -func (c *apiServerSources) Create(apiServerSource *v1alpha1.ApiServerSource) (result *v1alpha1.ApiServerSource, err error) { - result = &v1alpha1.ApiServerSource{} - err = c.client.Post(). - Namespace(c.ns). - Resource("apiserversources"). - Body(apiServerSource). - Do(). - Into(result) - return -} - -// Update takes the representation of a apiServerSource and updates it. Returns the server's representation of the apiServerSource, and an error, if there is any. -func (c *apiServerSources) Update(apiServerSource *v1alpha1.ApiServerSource) (result *v1alpha1.ApiServerSource, err error) { - result = &v1alpha1.ApiServerSource{} - err = c.client.Put(). - Namespace(c.ns). - Resource("apiserversources"). - Name(apiServerSource.Name). - Body(apiServerSource). - Do(). - Into(result) - return -} - -// UpdateStatus was generated because the type contains a Status member. -// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). - -func (c *apiServerSources) UpdateStatus(apiServerSource *v1alpha1.ApiServerSource) (result *v1alpha1.ApiServerSource, err error) { - result = &v1alpha1.ApiServerSource{} - err = c.client.Put(). - Namespace(c.ns). - Resource("apiserversources"). - Name(apiServerSource.Name). - SubResource("status"). - Body(apiServerSource). - Do(). - Into(result) - return -} - -// Delete takes name of the apiServerSource and deletes it. Returns an error if one occurs. -func (c *apiServerSources) Delete(name string, options *v1.DeleteOptions) error { - return c.client.Delete(). - Namespace(c.ns). - Resource("apiserversources"). - Name(name). - Body(options). - Do(). - Error() -} - -// DeleteCollection deletes a collection of objects. -func (c *apiServerSources) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { - var timeout time.Duration - if listOptions.TimeoutSeconds != nil { - timeout = time.Duration(*listOptions.TimeoutSeconds) * time.Second - } - return c.client.Delete(). - Namespace(c.ns). - Resource("apiserversources"). - VersionedParams(&listOptions, scheme.ParameterCodec). - Timeout(timeout). - Body(options). - Do(). - Error() -} - -// Patch applies the patch and returns the patched apiServerSource. -func (c *apiServerSources) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.ApiServerSource, err error) { - result = &v1alpha1.ApiServerSource{} - err = c.client.Patch(pt). - Namespace(c.ns). - Resource("apiserversources"). - SubResource(subresources...). - Name(name). - Body(data). - Do(). - Into(result) - return -} diff --git a/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha1/doc.go b/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha1/doc.go deleted file mode 100644 index 41e872fe9a..0000000000 --- a/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha1/doc.go +++ /dev/null @@ -1,20 +0,0 @@ -/* -Copyright 2020 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. -*/ - -// Code generated by client-gen. DO NOT EDIT. - -// This package has the automatically generated typed clients. -package v1alpha1 diff --git a/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha1/fake/doc.go b/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha1/fake/doc.go deleted file mode 100644 index c7f6e65cab..0000000000 --- a/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha1/fake/doc.go +++ /dev/null @@ -1,20 +0,0 @@ -/* -Copyright 2020 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. -*/ - -// Code generated by client-gen. DO NOT EDIT. - -// Package fake has the automatically generated clients. -package fake diff --git a/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha1/fake/fake_apiserversource.go b/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha1/fake/fake_apiserversource.go deleted file mode 100644 index 8424f3b2af..0000000000 --- a/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha1/fake/fake_apiserversource.go +++ /dev/null @@ -1,140 +0,0 @@ -/* -Copyright 2020 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. -*/ - -// Code generated by client-gen. DO NOT EDIT. - -package fake - -import ( - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - labels "k8s.io/apimachinery/pkg/labels" - schema "k8s.io/apimachinery/pkg/runtime/schema" - types "k8s.io/apimachinery/pkg/types" - watch "k8s.io/apimachinery/pkg/watch" - testing "k8s.io/client-go/testing" - v1alpha1 "knative.dev/eventing/pkg/apis/sources/v1alpha1" -) - -// FakeApiServerSources implements ApiServerSourceInterface -type FakeApiServerSources struct { - Fake *FakeSourcesV1alpha1 - ns string -} - -var apiserversourcesResource = schema.GroupVersionResource{Group: "sources.knative.dev", Version: "v1alpha1", Resource: "apiserversources"} - -var apiserversourcesKind = schema.GroupVersionKind{Group: "sources.knative.dev", Version: "v1alpha1", Kind: "ApiServerSource"} - -// Get takes name of the apiServerSource, and returns the corresponding apiServerSource object, and an error if there is any. -func (c *FakeApiServerSources) Get(name string, options v1.GetOptions) (result *v1alpha1.ApiServerSource, err error) { - obj, err := c.Fake. - Invokes(testing.NewGetAction(apiserversourcesResource, c.ns, name), &v1alpha1.ApiServerSource{}) - - if obj == nil { - return nil, err - } - return obj.(*v1alpha1.ApiServerSource), err -} - -// List takes label and field selectors, and returns the list of ApiServerSources that match those selectors. -func (c *FakeApiServerSources) List(opts v1.ListOptions) (result *v1alpha1.ApiServerSourceList, err error) { - obj, err := c.Fake. - Invokes(testing.NewListAction(apiserversourcesResource, apiserversourcesKind, c.ns, opts), &v1alpha1.ApiServerSourceList{}) - - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &v1alpha1.ApiServerSourceList{ListMeta: obj.(*v1alpha1.ApiServerSourceList).ListMeta} - for _, item := range obj.(*v1alpha1.ApiServerSourceList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -// Watch returns a watch.Interface that watches the requested apiServerSources. -func (c *FakeApiServerSources) Watch(opts v1.ListOptions) (watch.Interface, error) { - return c.Fake. - InvokesWatch(testing.NewWatchAction(apiserversourcesResource, c.ns, opts)) - -} - -// Create takes the representation of a apiServerSource and creates it. Returns the server's representation of the apiServerSource, and an error, if there is any. -func (c *FakeApiServerSources) Create(apiServerSource *v1alpha1.ApiServerSource) (result *v1alpha1.ApiServerSource, err error) { - obj, err := c.Fake. - Invokes(testing.NewCreateAction(apiserversourcesResource, c.ns, apiServerSource), &v1alpha1.ApiServerSource{}) - - if obj == nil { - return nil, err - } - return obj.(*v1alpha1.ApiServerSource), err -} - -// Update takes the representation of a apiServerSource and updates it. Returns the server's representation of the apiServerSource, and an error, if there is any. -func (c *FakeApiServerSources) Update(apiServerSource *v1alpha1.ApiServerSource) (result *v1alpha1.ApiServerSource, err error) { - obj, err := c.Fake. - Invokes(testing.NewUpdateAction(apiserversourcesResource, c.ns, apiServerSource), &v1alpha1.ApiServerSource{}) - - if obj == nil { - return nil, err - } - return obj.(*v1alpha1.ApiServerSource), err -} - -// UpdateStatus was generated because the type contains a Status member. -// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). -func (c *FakeApiServerSources) UpdateStatus(apiServerSource *v1alpha1.ApiServerSource) (*v1alpha1.ApiServerSource, error) { - obj, err := c.Fake. - Invokes(testing.NewUpdateSubresourceAction(apiserversourcesResource, "status", c.ns, apiServerSource), &v1alpha1.ApiServerSource{}) - - if obj == nil { - return nil, err - } - return obj.(*v1alpha1.ApiServerSource), err -} - -// Delete takes name of the apiServerSource and deletes it. Returns an error if one occurs. -func (c *FakeApiServerSources) Delete(name string, options *v1.DeleteOptions) error { - _, err := c.Fake. - Invokes(testing.NewDeleteAction(apiserversourcesResource, c.ns, name), &v1alpha1.ApiServerSource{}) - - return err -} - -// DeleteCollection deletes a collection of objects. -func (c *FakeApiServerSources) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { - action := testing.NewDeleteCollectionAction(apiserversourcesResource, c.ns, listOptions) - - _, err := c.Fake.Invokes(action, &v1alpha1.ApiServerSourceList{}) - return err -} - -// Patch applies the patch and returns the patched apiServerSource. -func (c *FakeApiServerSources) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.ApiServerSource, err error) { - obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(apiserversourcesResource, c.ns, name, pt, data, subresources...), &v1alpha1.ApiServerSource{}) - - if obj == nil { - return nil, err - } - return obj.(*v1alpha1.ApiServerSource), err -} diff --git a/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha1/fake/fake_pingsource.go b/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha1/fake/fake_pingsource.go deleted file mode 100644 index d753a7d6be..0000000000 --- a/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha1/fake/fake_pingsource.go +++ /dev/null @@ -1,140 +0,0 @@ -/* -Copyright 2020 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. -*/ - -// Code generated by client-gen. DO NOT EDIT. - -package fake - -import ( - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - labels "k8s.io/apimachinery/pkg/labels" - schema "k8s.io/apimachinery/pkg/runtime/schema" - types "k8s.io/apimachinery/pkg/types" - watch "k8s.io/apimachinery/pkg/watch" - testing "k8s.io/client-go/testing" - v1alpha1 "knative.dev/eventing/pkg/apis/sources/v1alpha1" -) - -// FakePingSources implements PingSourceInterface -type FakePingSources struct { - Fake *FakeSourcesV1alpha1 - ns string -} - -var pingsourcesResource = schema.GroupVersionResource{Group: "sources.knative.dev", Version: "v1alpha1", Resource: "pingsources"} - -var pingsourcesKind = schema.GroupVersionKind{Group: "sources.knative.dev", Version: "v1alpha1", Kind: "PingSource"} - -// Get takes name of the pingSource, and returns the corresponding pingSource object, and an error if there is any. -func (c *FakePingSources) Get(name string, options v1.GetOptions) (result *v1alpha1.PingSource, err error) { - obj, err := c.Fake. - Invokes(testing.NewGetAction(pingsourcesResource, c.ns, name), &v1alpha1.PingSource{}) - - if obj == nil { - return nil, err - } - return obj.(*v1alpha1.PingSource), err -} - -// List takes label and field selectors, and returns the list of PingSources that match those selectors. -func (c *FakePingSources) List(opts v1.ListOptions) (result *v1alpha1.PingSourceList, err error) { - obj, err := c.Fake. - Invokes(testing.NewListAction(pingsourcesResource, pingsourcesKind, c.ns, opts), &v1alpha1.PingSourceList{}) - - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &v1alpha1.PingSourceList{ListMeta: obj.(*v1alpha1.PingSourceList).ListMeta} - for _, item := range obj.(*v1alpha1.PingSourceList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -// Watch returns a watch.Interface that watches the requested pingSources. -func (c *FakePingSources) Watch(opts v1.ListOptions) (watch.Interface, error) { - return c.Fake. - InvokesWatch(testing.NewWatchAction(pingsourcesResource, c.ns, opts)) - -} - -// Create takes the representation of a pingSource and creates it. Returns the server's representation of the pingSource, and an error, if there is any. -func (c *FakePingSources) Create(pingSource *v1alpha1.PingSource) (result *v1alpha1.PingSource, err error) { - obj, err := c.Fake. - Invokes(testing.NewCreateAction(pingsourcesResource, c.ns, pingSource), &v1alpha1.PingSource{}) - - if obj == nil { - return nil, err - } - return obj.(*v1alpha1.PingSource), err -} - -// Update takes the representation of a pingSource and updates it. Returns the server's representation of the pingSource, and an error, if there is any. -func (c *FakePingSources) Update(pingSource *v1alpha1.PingSource) (result *v1alpha1.PingSource, err error) { - obj, err := c.Fake. - Invokes(testing.NewUpdateAction(pingsourcesResource, c.ns, pingSource), &v1alpha1.PingSource{}) - - if obj == nil { - return nil, err - } - return obj.(*v1alpha1.PingSource), err -} - -// UpdateStatus was generated because the type contains a Status member. -// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). -func (c *FakePingSources) UpdateStatus(pingSource *v1alpha1.PingSource) (*v1alpha1.PingSource, error) { - obj, err := c.Fake. - Invokes(testing.NewUpdateSubresourceAction(pingsourcesResource, "status", c.ns, pingSource), &v1alpha1.PingSource{}) - - if obj == nil { - return nil, err - } - return obj.(*v1alpha1.PingSource), err -} - -// Delete takes name of the pingSource and deletes it. Returns an error if one occurs. -func (c *FakePingSources) Delete(name string, options *v1.DeleteOptions) error { - _, err := c.Fake. - Invokes(testing.NewDeleteAction(pingsourcesResource, c.ns, name), &v1alpha1.PingSource{}) - - return err -} - -// DeleteCollection deletes a collection of objects. -func (c *FakePingSources) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { - action := testing.NewDeleteCollectionAction(pingsourcesResource, c.ns, listOptions) - - _, err := c.Fake.Invokes(action, &v1alpha1.PingSourceList{}) - return err -} - -// Patch applies the patch and returns the patched pingSource. -func (c *FakePingSources) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.PingSource, err error) { - obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(pingsourcesResource, c.ns, name, pt, data, subresources...), &v1alpha1.PingSource{}) - - if obj == nil { - return nil, err - } - return obj.(*v1alpha1.PingSource), err -} diff --git a/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha1/fake/fake_sinkbinding.go b/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha1/fake/fake_sinkbinding.go deleted file mode 100644 index c9c446b0a0..0000000000 --- a/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha1/fake/fake_sinkbinding.go +++ /dev/null @@ -1,140 +0,0 @@ -/* -Copyright 2020 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. -*/ - -// Code generated by client-gen. DO NOT EDIT. - -package fake - -import ( - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - labels "k8s.io/apimachinery/pkg/labels" - schema "k8s.io/apimachinery/pkg/runtime/schema" - types "k8s.io/apimachinery/pkg/types" - watch "k8s.io/apimachinery/pkg/watch" - testing "k8s.io/client-go/testing" - v1alpha1 "knative.dev/eventing/pkg/apis/sources/v1alpha1" -) - -// FakeSinkBindings implements SinkBindingInterface -type FakeSinkBindings struct { - Fake *FakeSourcesV1alpha1 - ns string -} - -var sinkbindingsResource = schema.GroupVersionResource{Group: "sources.knative.dev", Version: "v1alpha1", Resource: "sinkbindings"} - -var sinkbindingsKind = schema.GroupVersionKind{Group: "sources.knative.dev", Version: "v1alpha1", Kind: "SinkBinding"} - -// Get takes name of the sinkBinding, and returns the corresponding sinkBinding object, and an error if there is any. -func (c *FakeSinkBindings) Get(name string, options v1.GetOptions) (result *v1alpha1.SinkBinding, err error) { - obj, err := c.Fake. - Invokes(testing.NewGetAction(sinkbindingsResource, c.ns, name), &v1alpha1.SinkBinding{}) - - if obj == nil { - return nil, err - } - return obj.(*v1alpha1.SinkBinding), err -} - -// List takes label and field selectors, and returns the list of SinkBindings that match those selectors. -func (c *FakeSinkBindings) List(opts v1.ListOptions) (result *v1alpha1.SinkBindingList, err error) { - obj, err := c.Fake. - Invokes(testing.NewListAction(sinkbindingsResource, sinkbindingsKind, c.ns, opts), &v1alpha1.SinkBindingList{}) - - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &v1alpha1.SinkBindingList{ListMeta: obj.(*v1alpha1.SinkBindingList).ListMeta} - for _, item := range obj.(*v1alpha1.SinkBindingList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -// Watch returns a watch.Interface that watches the requested sinkBindings. -func (c *FakeSinkBindings) Watch(opts v1.ListOptions) (watch.Interface, error) { - return c.Fake. - InvokesWatch(testing.NewWatchAction(sinkbindingsResource, c.ns, opts)) - -} - -// Create takes the representation of a sinkBinding and creates it. Returns the server's representation of the sinkBinding, and an error, if there is any. -func (c *FakeSinkBindings) Create(sinkBinding *v1alpha1.SinkBinding) (result *v1alpha1.SinkBinding, err error) { - obj, err := c.Fake. - Invokes(testing.NewCreateAction(sinkbindingsResource, c.ns, sinkBinding), &v1alpha1.SinkBinding{}) - - if obj == nil { - return nil, err - } - return obj.(*v1alpha1.SinkBinding), err -} - -// Update takes the representation of a sinkBinding and updates it. Returns the server's representation of the sinkBinding, and an error, if there is any. -func (c *FakeSinkBindings) Update(sinkBinding *v1alpha1.SinkBinding) (result *v1alpha1.SinkBinding, err error) { - obj, err := c.Fake. - Invokes(testing.NewUpdateAction(sinkbindingsResource, c.ns, sinkBinding), &v1alpha1.SinkBinding{}) - - if obj == nil { - return nil, err - } - return obj.(*v1alpha1.SinkBinding), err -} - -// UpdateStatus was generated because the type contains a Status member. -// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). -func (c *FakeSinkBindings) UpdateStatus(sinkBinding *v1alpha1.SinkBinding) (*v1alpha1.SinkBinding, error) { - obj, err := c.Fake. - Invokes(testing.NewUpdateSubresourceAction(sinkbindingsResource, "status", c.ns, sinkBinding), &v1alpha1.SinkBinding{}) - - if obj == nil { - return nil, err - } - return obj.(*v1alpha1.SinkBinding), err -} - -// Delete takes name of the sinkBinding and deletes it. Returns an error if one occurs. -func (c *FakeSinkBindings) Delete(name string, options *v1.DeleteOptions) error { - _, err := c.Fake. - Invokes(testing.NewDeleteAction(sinkbindingsResource, c.ns, name), &v1alpha1.SinkBinding{}) - - return err -} - -// DeleteCollection deletes a collection of objects. -func (c *FakeSinkBindings) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { - action := testing.NewDeleteCollectionAction(sinkbindingsResource, c.ns, listOptions) - - _, err := c.Fake.Invokes(action, &v1alpha1.SinkBindingList{}) - return err -} - -// Patch applies the patch and returns the patched sinkBinding. -func (c *FakeSinkBindings) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.SinkBinding, err error) { - obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(sinkbindingsResource, c.ns, name, pt, data, subresources...), &v1alpha1.SinkBinding{}) - - if obj == nil { - return nil, err - } - return obj.(*v1alpha1.SinkBinding), err -} diff --git a/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha1/fake/fake_sources_client.go b/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha1/fake/fake_sources_client.go deleted file mode 100644 index 59cd493e70..0000000000 --- a/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha1/fake/fake_sources_client.go +++ /dev/null @@ -1,48 +0,0 @@ -/* -Copyright 2020 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. -*/ - -// Code generated by client-gen. DO NOT EDIT. - -package fake - -import ( - rest "k8s.io/client-go/rest" - testing "k8s.io/client-go/testing" - v1alpha1 "knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha1" -) - -type FakeSourcesV1alpha1 struct { - *testing.Fake -} - -func (c *FakeSourcesV1alpha1) ApiServerSources(namespace string) v1alpha1.ApiServerSourceInterface { - return &FakeApiServerSources{c, namespace} -} - -func (c *FakeSourcesV1alpha1) PingSources(namespace string) v1alpha1.PingSourceInterface { - return &FakePingSources{c, namespace} -} - -func (c *FakeSourcesV1alpha1) SinkBindings(namespace string) v1alpha1.SinkBindingInterface { - return &FakeSinkBindings{c, namespace} -} - -// RESTClient returns a RESTClient that is used to communicate -// with API server by this client implementation. -func (c *FakeSourcesV1alpha1) RESTClient() rest.Interface { - var ret *rest.RESTClient - return ret -} diff --git a/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha1/generated_expansion.go b/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha1/generated_expansion.go deleted file mode 100644 index aa618931ea..0000000000 --- a/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha1/generated_expansion.go +++ /dev/null @@ -1,25 +0,0 @@ -/* -Copyright 2020 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. -*/ - -// Code generated by client-gen. DO NOT EDIT. - -package v1alpha1 - -type ApiServerSourceExpansion interface{} - -type PingSourceExpansion interface{} - -type SinkBindingExpansion interface{} diff --git a/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha1/pingsource.go b/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha1/pingsource.go deleted file mode 100644 index 89315a5119..0000000000 --- a/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha1/pingsource.go +++ /dev/null @@ -1,191 +0,0 @@ -/* -Copyright 2020 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. -*/ - -// Code generated by client-gen. DO NOT EDIT. - -package v1alpha1 - -import ( - "time" - - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - types "k8s.io/apimachinery/pkg/types" - watch "k8s.io/apimachinery/pkg/watch" - rest "k8s.io/client-go/rest" - v1alpha1 "knative.dev/eventing/pkg/apis/sources/v1alpha1" - scheme "knative.dev/eventing/pkg/client/clientset/versioned/scheme" -) - -// PingSourcesGetter has a method to return a PingSourceInterface. -// A group's client should implement this interface. -type PingSourcesGetter interface { - PingSources(namespace string) PingSourceInterface -} - -// PingSourceInterface has methods to work with PingSource resources. -type PingSourceInterface interface { - Create(*v1alpha1.PingSource) (*v1alpha1.PingSource, error) - Update(*v1alpha1.PingSource) (*v1alpha1.PingSource, error) - UpdateStatus(*v1alpha1.PingSource) (*v1alpha1.PingSource, error) - Delete(name string, options *v1.DeleteOptions) error - DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error - Get(name string, options v1.GetOptions) (*v1alpha1.PingSource, error) - List(opts v1.ListOptions) (*v1alpha1.PingSourceList, error) - Watch(opts v1.ListOptions) (watch.Interface, error) - Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.PingSource, err error) - PingSourceExpansion -} - -// pingSources implements PingSourceInterface -type pingSources struct { - client rest.Interface - ns string -} - -// newPingSources returns a PingSources -func newPingSources(c *SourcesV1alpha1Client, namespace string) *pingSources { - return &pingSources{ - client: c.RESTClient(), - ns: namespace, - } -} - -// Get takes name of the pingSource, and returns the corresponding pingSource object, and an error if there is any. -func (c *pingSources) Get(name string, options v1.GetOptions) (result *v1alpha1.PingSource, err error) { - result = &v1alpha1.PingSource{} - err = c.client.Get(). - Namespace(c.ns). - Resource("pingsources"). - Name(name). - VersionedParams(&options, scheme.ParameterCodec). - Do(). - Into(result) - return -} - -// List takes label and field selectors, and returns the list of PingSources that match those selectors. -func (c *pingSources) List(opts v1.ListOptions) (result *v1alpha1.PingSourceList, err error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - result = &v1alpha1.PingSourceList{} - err = c.client.Get(). - Namespace(c.ns). - Resource("pingsources"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Do(). - Into(result) - return -} - -// Watch returns a watch.Interface that watches the requested pingSources. -func (c *pingSources) Watch(opts v1.ListOptions) (watch.Interface, error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - opts.Watch = true - return c.client.Get(). - Namespace(c.ns). - Resource("pingsources"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Watch() -} - -// Create takes the representation of a pingSource and creates it. Returns the server's representation of the pingSource, and an error, if there is any. -func (c *pingSources) Create(pingSource *v1alpha1.PingSource) (result *v1alpha1.PingSource, err error) { - result = &v1alpha1.PingSource{} - err = c.client.Post(). - Namespace(c.ns). - Resource("pingsources"). - Body(pingSource). - Do(). - Into(result) - return -} - -// Update takes the representation of a pingSource and updates it. Returns the server's representation of the pingSource, and an error, if there is any. -func (c *pingSources) Update(pingSource *v1alpha1.PingSource) (result *v1alpha1.PingSource, err error) { - result = &v1alpha1.PingSource{} - err = c.client.Put(). - Namespace(c.ns). - Resource("pingsources"). - Name(pingSource.Name). - Body(pingSource). - Do(). - Into(result) - return -} - -// UpdateStatus was generated because the type contains a Status member. -// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). - -func (c *pingSources) UpdateStatus(pingSource *v1alpha1.PingSource) (result *v1alpha1.PingSource, err error) { - result = &v1alpha1.PingSource{} - err = c.client.Put(). - Namespace(c.ns). - Resource("pingsources"). - Name(pingSource.Name). - SubResource("status"). - Body(pingSource). - Do(). - Into(result) - return -} - -// Delete takes name of the pingSource and deletes it. Returns an error if one occurs. -func (c *pingSources) Delete(name string, options *v1.DeleteOptions) error { - return c.client.Delete(). - Namespace(c.ns). - Resource("pingsources"). - Name(name). - Body(options). - Do(). - Error() -} - -// DeleteCollection deletes a collection of objects. -func (c *pingSources) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { - var timeout time.Duration - if listOptions.TimeoutSeconds != nil { - timeout = time.Duration(*listOptions.TimeoutSeconds) * time.Second - } - return c.client.Delete(). - Namespace(c.ns). - Resource("pingsources"). - VersionedParams(&listOptions, scheme.ParameterCodec). - Timeout(timeout). - Body(options). - Do(). - Error() -} - -// Patch applies the patch and returns the patched pingSource. -func (c *pingSources) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.PingSource, err error) { - result = &v1alpha1.PingSource{} - err = c.client.Patch(pt). - Namespace(c.ns). - Resource("pingsources"). - SubResource(subresources...). - Name(name). - Body(data). - Do(). - Into(result) - return -} diff --git a/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha1/sinkbinding.go b/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha1/sinkbinding.go deleted file mode 100644 index f3654923cb..0000000000 --- a/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha1/sinkbinding.go +++ /dev/null @@ -1,191 +0,0 @@ -/* -Copyright 2020 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. -*/ - -// Code generated by client-gen. DO NOT EDIT. - -package v1alpha1 - -import ( - "time" - - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - types "k8s.io/apimachinery/pkg/types" - watch "k8s.io/apimachinery/pkg/watch" - rest "k8s.io/client-go/rest" - v1alpha1 "knative.dev/eventing/pkg/apis/sources/v1alpha1" - scheme "knative.dev/eventing/pkg/client/clientset/versioned/scheme" -) - -// SinkBindingsGetter has a method to return a SinkBindingInterface. -// A group's client should implement this interface. -type SinkBindingsGetter interface { - SinkBindings(namespace string) SinkBindingInterface -} - -// SinkBindingInterface has methods to work with SinkBinding resources. -type SinkBindingInterface interface { - Create(*v1alpha1.SinkBinding) (*v1alpha1.SinkBinding, error) - Update(*v1alpha1.SinkBinding) (*v1alpha1.SinkBinding, error) - UpdateStatus(*v1alpha1.SinkBinding) (*v1alpha1.SinkBinding, error) - Delete(name string, options *v1.DeleteOptions) error - DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error - Get(name string, options v1.GetOptions) (*v1alpha1.SinkBinding, error) - List(opts v1.ListOptions) (*v1alpha1.SinkBindingList, error) - Watch(opts v1.ListOptions) (watch.Interface, error) - Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.SinkBinding, err error) - SinkBindingExpansion -} - -// sinkBindings implements SinkBindingInterface -type sinkBindings struct { - client rest.Interface - ns string -} - -// newSinkBindings returns a SinkBindings -func newSinkBindings(c *SourcesV1alpha1Client, namespace string) *sinkBindings { - return &sinkBindings{ - client: c.RESTClient(), - ns: namespace, - } -} - -// Get takes name of the sinkBinding, and returns the corresponding sinkBinding object, and an error if there is any. -func (c *sinkBindings) Get(name string, options v1.GetOptions) (result *v1alpha1.SinkBinding, err error) { - result = &v1alpha1.SinkBinding{} - err = c.client.Get(). - Namespace(c.ns). - Resource("sinkbindings"). - Name(name). - VersionedParams(&options, scheme.ParameterCodec). - Do(). - Into(result) - return -} - -// List takes label and field selectors, and returns the list of SinkBindings that match those selectors. -func (c *sinkBindings) List(opts v1.ListOptions) (result *v1alpha1.SinkBindingList, err error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - result = &v1alpha1.SinkBindingList{} - err = c.client.Get(). - Namespace(c.ns). - Resource("sinkbindings"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Do(). - Into(result) - return -} - -// Watch returns a watch.Interface that watches the requested sinkBindings. -func (c *sinkBindings) Watch(opts v1.ListOptions) (watch.Interface, error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - opts.Watch = true - return c.client.Get(). - Namespace(c.ns). - Resource("sinkbindings"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Watch() -} - -// Create takes the representation of a sinkBinding and creates it. Returns the server's representation of the sinkBinding, and an error, if there is any. -func (c *sinkBindings) Create(sinkBinding *v1alpha1.SinkBinding) (result *v1alpha1.SinkBinding, err error) { - result = &v1alpha1.SinkBinding{} - err = c.client.Post(). - Namespace(c.ns). - Resource("sinkbindings"). - Body(sinkBinding). - Do(). - Into(result) - return -} - -// Update takes the representation of a sinkBinding and updates it. Returns the server's representation of the sinkBinding, and an error, if there is any. -func (c *sinkBindings) Update(sinkBinding *v1alpha1.SinkBinding) (result *v1alpha1.SinkBinding, err error) { - result = &v1alpha1.SinkBinding{} - err = c.client.Put(). - Namespace(c.ns). - Resource("sinkbindings"). - Name(sinkBinding.Name). - Body(sinkBinding). - Do(). - Into(result) - return -} - -// UpdateStatus was generated because the type contains a Status member. -// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). - -func (c *sinkBindings) UpdateStatus(sinkBinding *v1alpha1.SinkBinding) (result *v1alpha1.SinkBinding, err error) { - result = &v1alpha1.SinkBinding{} - err = c.client.Put(). - Namespace(c.ns). - Resource("sinkbindings"). - Name(sinkBinding.Name). - SubResource("status"). - Body(sinkBinding). - Do(). - Into(result) - return -} - -// Delete takes name of the sinkBinding and deletes it. Returns an error if one occurs. -func (c *sinkBindings) Delete(name string, options *v1.DeleteOptions) error { - return c.client.Delete(). - Namespace(c.ns). - Resource("sinkbindings"). - Name(name). - Body(options). - Do(). - Error() -} - -// DeleteCollection deletes a collection of objects. -func (c *sinkBindings) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { - var timeout time.Duration - if listOptions.TimeoutSeconds != nil { - timeout = time.Duration(*listOptions.TimeoutSeconds) * time.Second - } - return c.client.Delete(). - Namespace(c.ns). - Resource("sinkbindings"). - VersionedParams(&listOptions, scheme.ParameterCodec). - Timeout(timeout). - Body(options). - Do(). - Error() -} - -// Patch applies the patch and returns the patched sinkBinding. -func (c *sinkBindings) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.SinkBinding, err error) { - result = &v1alpha1.SinkBinding{} - err = c.client.Patch(pt). - Namespace(c.ns). - Resource("sinkbindings"). - SubResource(subresources...). - Name(name). - Body(data). - Do(). - Into(result) - return -} diff --git a/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha1/sources_client.go b/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha1/sources_client.go deleted file mode 100644 index 08031fe804..0000000000 --- a/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha1/sources_client.go +++ /dev/null @@ -1,99 +0,0 @@ -/* -Copyright 2020 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. -*/ - -// Code generated by client-gen. DO NOT EDIT. - -package v1alpha1 - -import ( - rest "k8s.io/client-go/rest" - v1alpha1 "knative.dev/eventing/pkg/apis/sources/v1alpha1" - "knative.dev/eventing/pkg/client/clientset/versioned/scheme" -) - -type SourcesV1alpha1Interface interface { - RESTClient() rest.Interface - ApiServerSourcesGetter - PingSourcesGetter - SinkBindingsGetter -} - -// SourcesV1alpha1Client is used to interact with features provided by the sources.knative.dev group. -type SourcesV1alpha1Client struct { - restClient rest.Interface -} - -func (c *SourcesV1alpha1Client) ApiServerSources(namespace string) ApiServerSourceInterface { - return newApiServerSources(c, namespace) -} - -func (c *SourcesV1alpha1Client) PingSources(namespace string) PingSourceInterface { - return newPingSources(c, namespace) -} - -func (c *SourcesV1alpha1Client) SinkBindings(namespace string) SinkBindingInterface { - return newSinkBindings(c, namespace) -} - -// NewForConfig creates a new SourcesV1alpha1Client for the given config. -func NewForConfig(c *rest.Config) (*SourcesV1alpha1Client, error) { - config := *c - if err := setConfigDefaults(&config); err != nil { - return nil, err - } - client, err := rest.RESTClientFor(&config) - if err != nil { - return nil, err - } - return &SourcesV1alpha1Client{client}, nil -} - -// NewForConfigOrDie creates a new SourcesV1alpha1Client for the given config and -// panics if there is an error in the config. -func NewForConfigOrDie(c *rest.Config) *SourcesV1alpha1Client { - client, err := NewForConfig(c) - if err != nil { - panic(err) - } - return client -} - -// New creates a new SourcesV1alpha1Client for the given RESTClient. -func New(c rest.Interface) *SourcesV1alpha1Client { - return &SourcesV1alpha1Client{c} -} - -func setConfigDefaults(config *rest.Config) error { - gv := v1alpha1.SchemeGroupVersion - config.GroupVersion = &gv - config.APIPath = "/apis" - config.NegotiatedSerializer = scheme.Codecs.WithoutConversion() - - if config.UserAgent == "" { - config.UserAgent = rest.DefaultKubernetesUserAgent() - } - - return nil -} - -// RESTClient returns a RESTClient that is used to communicate -// with API server by this client implementation. -func (c *SourcesV1alpha1Client) RESTClient() rest.Interface { - if c == nil { - return nil - } - return c.restClient -} diff --git a/vendor/knative.dev/eventing/pkg/legacyclient/clientset/versioned/typed/legacysources/v1alpha1/containersource.go b/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha2/containersource.go similarity index 79% rename from vendor/knative.dev/eventing/pkg/legacyclient/clientset/versioned/typed/legacysources/v1alpha1/containersource.go rename to vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha2/containersource.go index a06e561699..1e884bf20c 100644 --- a/vendor/knative.dev/eventing/pkg/legacyclient/clientset/versioned/typed/legacysources/v1alpha1/containersource.go +++ b/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha2/containersource.go @@ -16,7 +16,7 @@ limitations under the License. // Code generated by client-gen. DO NOT EDIT. -package v1alpha1 +package v1alpha2 import ( "time" @@ -25,8 +25,8 @@ import ( types "k8s.io/apimachinery/pkg/types" watch "k8s.io/apimachinery/pkg/watch" rest "k8s.io/client-go/rest" - v1alpha1 "knative.dev/eventing/pkg/apis/legacysources/v1alpha1" - scheme "knative.dev/eventing/pkg/legacyclient/clientset/versioned/scheme" + v1alpha2 "knative.dev/eventing/pkg/apis/sources/v1alpha2" + scheme "knative.dev/eventing/pkg/client/clientset/versioned/scheme" ) // ContainerSourcesGetter has a method to return a ContainerSourceInterface. @@ -37,15 +37,15 @@ type ContainerSourcesGetter interface { // ContainerSourceInterface has methods to work with ContainerSource resources. type ContainerSourceInterface interface { - Create(*v1alpha1.ContainerSource) (*v1alpha1.ContainerSource, error) - Update(*v1alpha1.ContainerSource) (*v1alpha1.ContainerSource, error) - UpdateStatus(*v1alpha1.ContainerSource) (*v1alpha1.ContainerSource, error) + Create(*v1alpha2.ContainerSource) (*v1alpha2.ContainerSource, error) + Update(*v1alpha2.ContainerSource) (*v1alpha2.ContainerSource, error) + UpdateStatus(*v1alpha2.ContainerSource) (*v1alpha2.ContainerSource, error) Delete(name string, options *v1.DeleteOptions) error DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error - Get(name string, options v1.GetOptions) (*v1alpha1.ContainerSource, error) - List(opts v1.ListOptions) (*v1alpha1.ContainerSourceList, error) + Get(name string, options v1.GetOptions) (*v1alpha2.ContainerSource, error) + List(opts v1.ListOptions) (*v1alpha2.ContainerSourceList, error) Watch(opts v1.ListOptions) (watch.Interface, error) - Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.ContainerSource, err error) + Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha2.ContainerSource, err error) ContainerSourceExpansion } @@ -56,7 +56,7 @@ type containerSources struct { } // newContainerSources returns a ContainerSources -func newContainerSources(c *SourcesV1alpha1Client, namespace string) *containerSources { +func newContainerSources(c *SourcesV1alpha2Client, namespace string) *containerSources { return &containerSources{ client: c.RESTClient(), ns: namespace, @@ -64,8 +64,8 @@ func newContainerSources(c *SourcesV1alpha1Client, namespace string) *containerS } // Get takes name of the containerSource, and returns the corresponding containerSource object, and an error if there is any. -func (c *containerSources) Get(name string, options v1.GetOptions) (result *v1alpha1.ContainerSource, err error) { - result = &v1alpha1.ContainerSource{} +func (c *containerSources) Get(name string, options v1.GetOptions) (result *v1alpha2.ContainerSource, err error) { + result = &v1alpha2.ContainerSource{} err = c.client.Get(). Namespace(c.ns). Resource("containersources"). @@ -77,12 +77,12 @@ func (c *containerSources) Get(name string, options v1.GetOptions) (result *v1al } // List takes label and field selectors, and returns the list of ContainerSources that match those selectors. -func (c *containerSources) List(opts v1.ListOptions) (result *v1alpha1.ContainerSourceList, err error) { +func (c *containerSources) List(opts v1.ListOptions) (result *v1alpha2.ContainerSourceList, err error) { var timeout time.Duration if opts.TimeoutSeconds != nil { timeout = time.Duration(*opts.TimeoutSeconds) * time.Second } - result = &v1alpha1.ContainerSourceList{} + result = &v1alpha2.ContainerSourceList{} err = c.client.Get(). Namespace(c.ns). Resource("containersources"). @@ -109,8 +109,8 @@ func (c *containerSources) Watch(opts v1.ListOptions) (watch.Interface, error) { } // Create takes the representation of a containerSource and creates it. Returns the server's representation of the containerSource, and an error, if there is any. -func (c *containerSources) Create(containerSource *v1alpha1.ContainerSource) (result *v1alpha1.ContainerSource, err error) { - result = &v1alpha1.ContainerSource{} +func (c *containerSources) Create(containerSource *v1alpha2.ContainerSource) (result *v1alpha2.ContainerSource, err error) { + result = &v1alpha2.ContainerSource{} err = c.client.Post(). Namespace(c.ns). Resource("containersources"). @@ -121,8 +121,8 @@ func (c *containerSources) Create(containerSource *v1alpha1.ContainerSource) (re } // Update takes the representation of a containerSource and updates it. Returns the server's representation of the containerSource, and an error, if there is any. -func (c *containerSources) Update(containerSource *v1alpha1.ContainerSource) (result *v1alpha1.ContainerSource, err error) { - result = &v1alpha1.ContainerSource{} +func (c *containerSources) Update(containerSource *v1alpha2.ContainerSource) (result *v1alpha2.ContainerSource, err error) { + result = &v1alpha2.ContainerSource{} err = c.client.Put(). Namespace(c.ns). Resource("containersources"). @@ -136,8 +136,8 @@ func (c *containerSources) Update(containerSource *v1alpha1.ContainerSource) (re // UpdateStatus was generated because the type contains a Status member. // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). -func (c *containerSources) UpdateStatus(containerSource *v1alpha1.ContainerSource) (result *v1alpha1.ContainerSource, err error) { - result = &v1alpha1.ContainerSource{} +func (c *containerSources) UpdateStatus(containerSource *v1alpha2.ContainerSource) (result *v1alpha2.ContainerSource, err error) { + result = &v1alpha2.ContainerSource{} err = c.client.Put(). Namespace(c.ns). Resource("containersources"). @@ -177,8 +177,8 @@ func (c *containerSources) DeleteCollection(options *v1.DeleteOptions, listOptio } // Patch applies the patch and returns the patched containerSource. -func (c *containerSources) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.ContainerSource, err error) { - result = &v1alpha1.ContainerSource{} +func (c *containerSources) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha2.ContainerSource, err error) { + result = &v1alpha2.ContainerSource{} err = c.client.Patch(pt). Namespace(c.ns). Resource("containersources"). diff --git a/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha2/fake/fake_containersource.go b/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha2/fake/fake_containersource.go new file mode 100644 index 0000000000..c990e643f2 --- /dev/null +++ b/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha2/fake/fake_containersource.go @@ -0,0 +1,140 @@ +/* +Copyright 2020 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. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + schema "k8s.io/apimachinery/pkg/runtime/schema" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" + v1alpha2 "knative.dev/eventing/pkg/apis/sources/v1alpha2" +) + +// FakeContainerSources implements ContainerSourceInterface +type FakeContainerSources struct { + Fake *FakeSourcesV1alpha2 + ns string +} + +var containersourcesResource = schema.GroupVersionResource{Group: "sources.knative.dev", Version: "v1alpha2", Resource: "containersources"} + +var containersourcesKind = schema.GroupVersionKind{Group: "sources.knative.dev", Version: "v1alpha2", Kind: "ContainerSource"} + +// Get takes name of the containerSource, and returns the corresponding containerSource object, and an error if there is any. +func (c *FakeContainerSources) Get(name string, options v1.GetOptions) (result *v1alpha2.ContainerSource, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(containersourcesResource, c.ns, name), &v1alpha2.ContainerSource{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha2.ContainerSource), err +} + +// List takes label and field selectors, and returns the list of ContainerSources that match those selectors. +func (c *FakeContainerSources) List(opts v1.ListOptions) (result *v1alpha2.ContainerSourceList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(containersourcesResource, containersourcesKind, c.ns, opts), &v1alpha2.ContainerSourceList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha2.ContainerSourceList{ListMeta: obj.(*v1alpha2.ContainerSourceList).ListMeta} + for _, item := range obj.(*v1alpha2.ContainerSourceList).Items { + if label.Matches(labels.Set(item.Labels)) { + list.Items = append(list.Items, item) + } + } + return list, err +} + +// Watch returns a watch.Interface that watches the requested containerSources. +func (c *FakeContainerSources) Watch(opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(containersourcesResource, c.ns, opts)) + +} + +// Create takes the representation of a containerSource and creates it. Returns the server's representation of the containerSource, and an error, if there is any. +func (c *FakeContainerSources) Create(containerSource *v1alpha2.ContainerSource) (result *v1alpha2.ContainerSource, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(containersourcesResource, c.ns, containerSource), &v1alpha2.ContainerSource{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha2.ContainerSource), err +} + +// Update takes the representation of a containerSource and updates it. Returns the server's representation of the containerSource, and an error, if there is any. +func (c *FakeContainerSources) Update(containerSource *v1alpha2.ContainerSource) (result *v1alpha2.ContainerSource, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(containersourcesResource, c.ns, containerSource), &v1alpha2.ContainerSource{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha2.ContainerSource), err +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *FakeContainerSources) UpdateStatus(containerSource *v1alpha2.ContainerSource) (*v1alpha2.ContainerSource, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(containersourcesResource, "status", c.ns, containerSource), &v1alpha2.ContainerSource{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha2.ContainerSource), err +} + +// Delete takes name of the containerSource and deletes it. Returns an error if one occurs. +func (c *FakeContainerSources) Delete(name string, options *v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(containersourcesResource, c.ns, name), &v1alpha2.ContainerSource{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeContainerSources) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(containersourcesResource, c.ns, listOptions) + + _, err := c.Fake.Invokes(action, &v1alpha2.ContainerSourceList{}) + return err +} + +// Patch applies the patch and returns the patched containerSource. +func (c *FakeContainerSources) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha2.ContainerSource, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(containersourcesResource, c.ns, name, pt, data, subresources...), &v1alpha2.ContainerSource{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha2.ContainerSource), err +} diff --git a/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha2/fake/fake_sources_client.go b/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha2/fake/fake_sources_client.go index 3459a1a0d5..fb6365ba9d 100644 --- a/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha2/fake/fake_sources_client.go +++ b/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha2/fake/fake_sources_client.go @@ -32,6 +32,10 @@ func (c *FakeSourcesV1alpha2) ApiServerSources(namespace string) v1alpha2.ApiSer return &FakeApiServerSources{c, namespace} } +func (c *FakeSourcesV1alpha2) ContainerSources(namespace string) v1alpha2.ContainerSourceInterface { + return &FakeContainerSources{c, namespace} +} + func (c *FakeSourcesV1alpha2) PingSources(namespace string) v1alpha2.PingSourceInterface { return &FakePingSources{c, namespace} } diff --git a/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha2/generated_expansion.go b/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha2/generated_expansion.go index c4f05376cf..b2816d38c5 100644 --- a/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha2/generated_expansion.go +++ b/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha2/generated_expansion.go @@ -20,6 +20,8 @@ package v1alpha2 type ApiServerSourceExpansion interface{} +type ContainerSourceExpansion interface{} + type PingSourceExpansion interface{} type SinkBindingExpansion interface{} diff --git a/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha2/sources_client.go b/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha2/sources_client.go index 1061b14e0f..e573e6dcad 100644 --- a/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha2/sources_client.go +++ b/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha2/sources_client.go @@ -27,6 +27,7 @@ import ( type SourcesV1alpha2Interface interface { RESTClient() rest.Interface ApiServerSourcesGetter + ContainerSourcesGetter PingSourcesGetter SinkBindingsGetter } @@ -40,6 +41,10 @@ func (c *SourcesV1alpha2Client) ApiServerSources(namespace string) ApiServerSour return newApiServerSources(c, namespace) } +func (c *SourcesV1alpha2Client) ContainerSources(namespace string) ContainerSourceInterface { + return newContainerSources(c, namespace) +} + func (c *SourcesV1alpha2Client) PingSources(namespace string) PingSourceInterface { return newPingSources(c, namespace) } diff --git a/vendor/knative.dev/eventing/pkg/legacyclient/clientset/versioned/scheme/doc.go b/vendor/knative.dev/eventing/pkg/legacyclient/clientset/versioned/scheme/doc.go deleted file mode 100644 index 7acc2dcf25..0000000000 --- a/vendor/knative.dev/eventing/pkg/legacyclient/clientset/versioned/scheme/doc.go +++ /dev/null @@ -1,20 +0,0 @@ -/* -Copyright 2020 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. -*/ - -// Code generated by client-gen. DO NOT EDIT. - -// This package contains the scheme of the automatically generated clientset. -package scheme diff --git a/vendor/knative.dev/eventing/pkg/legacyclient/clientset/versioned/scheme/register.go b/vendor/knative.dev/eventing/pkg/legacyclient/clientset/versioned/scheme/register.go deleted file mode 100644 index 0ddcfe7b67..0000000000 --- a/vendor/knative.dev/eventing/pkg/legacyclient/clientset/versioned/scheme/register.go +++ /dev/null @@ -1,56 +0,0 @@ -/* -Copyright 2020 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. -*/ - -// Code generated by client-gen. DO NOT EDIT. - -package scheme - -import ( - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - runtime "k8s.io/apimachinery/pkg/runtime" - schema "k8s.io/apimachinery/pkg/runtime/schema" - serializer "k8s.io/apimachinery/pkg/runtime/serializer" - utilruntime "k8s.io/apimachinery/pkg/util/runtime" - sourcesv1alpha1 "knative.dev/eventing/pkg/apis/legacysources/v1alpha1" -) - -var Scheme = runtime.NewScheme() -var Codecs = serializer.NewCodecFactory(Scheme) -var ParameterCodec = runtime.NewParameterCodec(Scheme) -var localSchemeBuilder = runtime.SchemeBuilder{ - sourcesv1alpha1.AddToScheme, -} - -// AddToScheme adds all types of this clientset into the given scheme. This allows composition -// of clientsets, like in: -// -// import ( -// "k8s.io/client-go/kubernetes" -// clientsetscheme "k8s.io/client-go/kubernetes/scheme" -// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" -// ) -// -// kclientset, _ := kubernetes.NewForConfig(c) -// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) -// -// After this, RawExtensions in Kubernetes types will serialize kube-aggregator types -// correctly. -var AddToScheme = localSchemeBuilder.AddToScheme - -func init() { - v1.AddToGroupVersion(Scheme, schema.GroupVersion{Version: "v1"}) - utilruntime.Must(AddToScheme(Scheme)) -} diff --git a/vendor/knative.dev/eventing/pkg/legacyclient/clientset/versioned/typed/legacysources/v1alpha1/apiserversource.go b/vendor/knative.dev/eventing/pkg/legacyclient/clientset/versioned/typed/legacysources/v1alpha1/apiserversource.go deleted file mode 100644 index f337d69f58..0000000000 --- a/vendor/knative.dev/eventing/pkg/legacyclient/clientset/versioned/typed/legacysources/v1alpha1/apiserversource.go +++ /dev/null @@ -1,191 +0,0 @@ -/* -Copyright 2020 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. -*/ - -// Code generated by client-gen. DO NOT EDIT. - -package v1alpha1 - -import ( - "time" - - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - types "k8s.io/apimachinery/pkg/types" - watch "k8s.io/apimachinery/pkg/watch" - rest "k8s.io/client-go/rest" - v1alpha1 "knative.dev/eventing/pkg/apis/legacysources/v1alpha1" - scheme "knative.dev/eventing/pkg/legacyclient/clientset/versioned/scheme" -) - -// ApiServerSourcesGetter has a method to return a ApiServerSourceInterface. -// A group's client should implement this interface. -type ApiServerSourcesGetter interface { - ApiServerSources(namespace string) ApiServerSourceInterface -} - -// ApiServerSourceInterface has methods to work with ApiServerSource resources. -type ApiServerSourceInterface interface { - Create(*v1alpha1.ApiServerSource) (*v1alpha1.ApiServerSource, error) - Update(*v1alpha1.ApiServerSource) (*v1alpha1.ApiServerSource, error) - UpdateStatus(*v1alpha1.ApiServerSource) (*v1alpha1.ApiServerSource, error) - Delete(name string, options *v1.DeleteOptions) error - DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error - Get(name string, options v1.GetOptions) (*v1alpha1.ApiServerSource, error) - List(opts v1.ListOptions) (*v1alpha1.ApiServerSourceList, error) - Watch(opts v1.ListOptions) (watch.Interface, error) - Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.ApiServerSource, err error) - ApiServerSourceExpansion -} - -// apiServerSources implements ApiServerSourceInterface -type apiServerSources struct { - client rest.Interface - ns string -} - -// newApiServerSources returns a ApiServerSources -func newApiServerSources(c *SourcesV1alpha1Client, namespace string) *apiServerSources { - return &apiServerSources{ - client: c.RESTClient(), - ns: namespace, - } -} - -// Get takes name of the apiServerSource, and returns the corresponding apiServerSource object, and an error if there is any. -func (c *apiServerSources) Get(name string, options v1.GetOptions) (result *v1alpha1.ApiServerSource, err error) { - result = &v1alpha1.ApiServerSource{} - err = c.client.Get(). - Namespace(c.ns). - Resource("apiserversources"). - Name(name). - VersionedParams(&options, scheme.ParameterCodec). - Do(). - Into(result) - return -} - -// List takes label and field selectors, and returns the list of ApiServerSources that match those selectors. -func (c *apiServerSources) List(opts v1.ListOptions) (result *v1alpha1.ApiServerSourceList, err error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - result = &v1alpha1.ApiServerSourceList{} - err = c.client.Get(). - Namespace(c.ns). - Resource("apiserversources"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Do(). - Into(result) - return -} - -// Watch returns a watch.Interface that watches the requested apiServerSources. -func (c *apiServerSources) Watch(opts v1.ListOptions) (watch.Interface, error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - opts.Watch = true - return c.client.Get(). - Namespace(c.ns). - Resource("apiserversources"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Watch() -} - -// Create takes the representation of a apiServerSource and creates it. Returns the server's representation of the apiServerSource, and an error, if there is any. -func (c *apiServerSources) Create(apiServerSource *v1alpha1.ApiServerSource) (result *v1alpha1.ApiServerSource, err error) { - result = &v1alpha1.ApiServerSource{} - err = c.client.Post(). - Namespace(c.ns). - Resource("apiserversources"). - Body(apiServerSource). - Do(). - Into(result) - return -} - -// Update takes the representation of a apiServerSource and updates it. Returns the server's representation of the apiServerSource, and an error, if there is any. -func (c *apiServerSources) Update(apiServerSource *v1alpha1.ApiServerSource) (result *v1alpha1.ApiServerSource, err error) { - result = &v1alpha1.ApiServerSource{} - err = c.client.Put(). - Namespace(c.ns). - Resource("apiserversources"). - Name(apiServerSource.Name). - Body(apiServerSource). - Do(). - Into(result) - return -} - -// UpdateStatus was generated because the type contains a Status member. -// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). - -func (c *apiServerSources) UpdateStatus(apiServerSource *v1alpha1.ApiServerSource) (result *v1alpha1.ApiServerSource, err error) { - result = &v1alpha1.ApiServerSource{} - err = c.client.Put(). - Namespace(c.ns). - Resource("apiserversources"). - Name(apiServerSource.Name). - SubResource("status"). - Body(apiServerSource). - Do(). - Into(result) - return -} - -// Delete takes name of the apiServerSource and deletes it. Returns an error if one occurs. -func (c *apiServerSources) Delete(name string, options *v1.DeleteOptions) error { - return c.client.Delete(). - Namespace(c.ns). - Resource("apiserversources"). - Name(name). - Body(options). - Do(). - Error() -} - -// DeleteCollection deletes a collection of objects. -func (c *apiServerSources) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { - var timeout time.Duration - if listOptions.TimeoutSeconds != nil { - timeout = time.Duration(*listOptions.TimeoutSeconds) * time.Second - } - return c.client.Delete(). - Namespace(c.ns). - Resource("apiserversources"). - VersionedParams(&listOptions, scheme.ParameterCodec). - Timeout(timeout). - Body(options). - Do(). - Error() -} - -// Patch applies the patch and returns the patched apiServerSource. -func (c *apiServerSources) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.ApiServerSource, err error) { - result = &v1alpha1.ApiServerSource{} - err = c.client.Patch(pt). - Namespace(c.ns). - Resource("apiserversources"). - SubResource(subresources...). - Name(name). - Body(data). - Do(). - Into(result) - return -} diff --git a/vendor/knative.dev/eventing/pkg/legacyclient/clientset/versioned/typed/legacysources/v1alpha1/cronjobsource.go b/vendor/knative.dev/eventing/pkg/legacyclient/clientset/versioned/typed/legacysources/v1alpha1/cronjobsource.go deleted file mode 100644 index 1d87c64b7d..0000000000 --- a/vendor/knative.dev/eventing/pkg/legacyclient/clientset/versioned/typed/legacysources/v1alpha1/cronjobsource.go +++ /dev/null @@ -1,191 +0,0 @@ -/* -Copyright 2020 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. -*/ - -// Code generated by client-gen. DO NOT EDIT. - -package v1alpha1 - -import ( - "time" - - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - types "k8s.io/apimachinery/pkg/types" - watch "k8s.io/apimachinery/pkg/watch" - rest "k8s.io/client-go/rest" - v1alpha1 "knative.dev/eventing/pkg/apis/legacysources/v1alpha1" - scheme "knative.dev/eventing/pkg/legacyclient/clientset/versioned/scheme" -) - -// CronJobSourcesGetter has a method to return a CronJobSourceInterface. -// A group's client should implement this interface. -type CronJobSourcesGetter interface { - CronJobSources(namespace string) CronJobSourceInterface -} - -// CronJobSourceInterface has methods to work with CronJobSource resources. -type CronJobSourceInterface interface { - Create(*v1alpha1.CronJobSource) (*v1alpha1.CronJobSource, error) - Update(*v1alpha1.CronJobSource) (*v1alpha1.CronJobSource, error) - UpdateStatus(*v1alpha1.CronJobSource) (*v1alpha1.CronJobSource, error) - Delete(name string, options *v1.DeleteOptions) error - DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error - Get(name string, options v1.GetOptions) (*v1alpha1.CronJobSource, error) - List(opts v1.ListOptions) (*v1alpha1.CronJobSourceList, error) - Watch(opts v1.ListOptions) (watch.Interface, error) - Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.CronJobSource, err error) - CronJobSourceExpansion -} - -// cronJobSources implements CronJobSourceInterface -type cronJobSources struct { - client rest.Interface - ns string -} - -// newCronJobSources returns a CronJobSources -func newCronJobSources(c *SourcesV1alpha1Client, namespace string) *cronJobSources { - return &cronJobSources{ - client: c.RESTClient(), - ns: namespace, - } -} - -// Get takes name of the cronJobSource, and returns the corresponding cronJobSource object, and an error if there is any. -func (c *cronJobSources) Get(name string, options v1.GetOptions) (result *v1alpha1.CronJobSource, err error) { - result = &v1alpha1.CronJobSource{} - err = c.client.Get(). - Namespace(c.ns). - Resource("cronjobsources"). - Name(name). - VersionedParams(&options, scheme.ParameterCodec). - Do(). - Into(result) - return -} - -// List takes label and field selectors, and returns the list of CronJobSources that match those selectors. -func (c *cronJobSources) List(opts v1.ListOptions) (result *v1alpha1.CronJobSourceList, err error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - result = &v1alpha1.CronJobSourceList{} - err = c.client.Get(). - Namespace(c.ns). - Resource("cronjobsources"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Do(). - Into(result) - return -} - -// Watch returns a watch.Interface that watches the requested cronJobSources. -func (c *cronJobSources) Watch(opts v1.ListOptions) (watch.Interface, error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - opts.Watch = true - return c.client.Get(). - Namespace(c.ns). - Resource("cronjobsources"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Watch() -} - -// Create takes the representation of a cronJobSource and creates it. Returns the server's representation of the cronJobSource, and an error, if there is any. -func (c *cronJobSources) Create(cronJobSource *v1alpha1.CronJobSource) (result *v1alpha1.CronJobSource, err error) { - result = &v1alpha1.CronJobSource{} - err = c.client.Post(). - Namespace(c.ns). - Resource("cronjobsources"). - Body(cronJobSource). - Do(). - Into(result) - return -} - -// Update takes the representation of a cronJobSource and updates it. Returns the server's representation of the cronJobSource, and an error, if there is any. -func (c *cronJobSources) Update(cronJobSource *v1alpha1.CronJobSource) (result *v1alpha1.CronJobSource, err error) { - result = &v1alpha1.CronJobSource{} - err = c.client.Put(). - Namespace(c.ns). - Resource("cronjobsources"). - Name(cronJobSource.Name). - Body(cronJobSource). - Do(). - Into(result) - return -} - -// UpdateStatus was generated because the type contains a Status member. -// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). - -func (c *cronJobSources) UpdateStatus(cronJobSource *v1alpha1.CronJobSource) (result *v1alpha1.CronJobSource, err error) { - result = &v1alpha1.CronJobSource{} - err = c.client.Put(). - Namespace(c.ns). - Resource("cronjobsources"). - Name(cronJobSource.Name). - SubResource("status"). - Body(cronJobSource). - Do(). - Into(result) - return -} - -// Delete takes name of the cronJobSource and deletes it. Returns an error if one occurs. -func (c *cronJobSources) Delete(name string, options *v1.DeleteOptions) error { - return c.client.Delete(). - Namespace(c.ns). - Resource("cronjobsources"). - Name(name). - Body(options). - Do(). - Error() -} - -// DeleteCollection deletes a collection of objects. -func (c *cronJobSources) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { - var timeout time.Duration - if listOptions.TimeoutSeconds != nil { - timeout = time.Duration(*listOptions.TimeoutSeconds) * time.Second - } - return c.client.Delete(). - Namespace(c.ns). - Resource("cronjobsources"). - VersionedParams(&listOptions, scheme.ParameterCodec). - Timeout(timeout). - Body(options). - Do(). - Error() -} - -// Patch applies the patch and returns the patched cronJobSource. -func (c *cronJobSources) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.CronJobSource, err error) { - result = &v1alpha1.CronJobSource{} - err = c.client.Patch(pt). - Namespace(c.ns). - Resource("cronjobsources"). - SubResource(subresources...). - Name(name). - Body(data). - Do(). - Into(result) - return -} diff --git a/vendor/knative.dev/eventing/pkg/legacyclient/clientset/versioned/typed/legacysources/v1alpha1/doc.go b/vendor/knative.dev/eventing/pkg/legacyclient/clientset/versioned/typed/legacysources/v1alpha1/doc.go deleted file mode 100644 index 41e872fe9a..0000000000 --- a/vendor/knative.dev/eventing/pkg/legacyclient/clientset/versioned/typed/legacysources/v1alpha1/doc.go +++ /dev/null @@ -1,20 +0,0 @@ -/* -Copyright 2020 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. -*/ - -// Code generated by client-gen. DO NOT EDIT. - -// This package has the automatically generated typed clients. -package v1alpha1 diff --git a/vendor/knative.dev/eventing/pkg/legacyclient/clientset/versioned/typed/legacysources/v1alpha1/generated_expansion.go b/vendor/knative.dev/eventing/pkg/legacyclient/clientset/versioned/typed/legacysources/v1alpha1/generated_expansion.go deleted file mode 100644 index 4ad31e2ba8..0000000000 --- a/vendor/knative.dev/eventing/pkg/legacyclient/clientset/versioned/typed/legacysources/v1alpha1/generated_expansion.go +++ /dev/null @@ -1,27 +0,0 @@ -/* -Copyright 2020 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. -*/ - -// Code generated by client-gen. DO NOT EDIT. - -package v1alpha1 - -type ApiServerSourceExpansion interface{} - -type ContainerSourceExpansion interface{} - -type CronJobSourceExpansion interface{} - -type SinkBindingExpansion interface{} diff --git a/vendor/knative.dev/eventing/pkg/legacyclient/clientset/versioned/typed/legacysources/v1alpha1/legacysources_client.go b/vendor/knative.dev/eventing/pkg/legacyclient/clientset/versioned/typed/legacysources/v1alpha1/legacysources_client.go deleted file mode 100644 index 922fd26ec7..0000000000 --- a/vendor/knative.dev/eventing/pkg/legacyclient/clientset/versioned/typed/legacysources/v1alpha1/legacysources_client.go +++ /dev/null @@ -1,104 +0,0 @@ -/* -Copyright 2020 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. -*/ - -// Code generated by client-gen. DO NOT EDIT. - -package v1alpha1 - -import ( - rest "k8s.io/client-go/rest" - v1alpha1 "knative.dev/eventing/pkg/apis/legacysources/v1alpha1" - "knative.dev/eventing/pkg/legacyclient/clientset/versioned/scheme" -) - -type SourcesV1alpha1Interface interface { - RESTClient() rest.Interface - ApiServerSourcesGetter - ContainerSourcesGetter - CronJobSourcesGetter - SinkBindingsGetter -} - -// SourcesV1alpha1Client is used to interact with features provided by the sources.eventing.knative.dev group. -type SourcesV1alpha1Client struct { - restClient rest.Interface -} - -func (c *SourcesV1alpha1Client) ApiServerSources(namespace string) ApiServerSourceInterface { - return newApiServerSources(c, namespace) -} - -func (c *SourcesV1alpha1Client) ContainerSources(namespace string) ContainerSourceInterface { - return newContainerSources(c, namespace) -} - -func (c *SourcesV1alpha1Client) CronJobSources(namespace string) CronJobSourceInterface { - return newCronJobSources(c, namespace) -} - -func (c *SourcesV1alpha1Client) SinkBindings(namespace string) SinkBindingInterface { - return newSinkBindings(c, namespace) -} - -// NewForConfig creates a new SourcesV1alpha1Client for the given config. -func NewForConfig(c *rest.Config) (*SourcesV1alpha1Client, error) { - config := *c - if err := setConfigDefaults(&config); err != nil { - return nil, err - } - client, err := rest.RESTClientFor(&config) - if err != nil { - return nil, err - } - return &SourcesV1alpha1Client{client}, nil -} - -// NewForConfigOrDie creates a new SourcesV1alpha1Client for the given config and -// panics if there is an error in the config. -func NewForConfigOrDie(c *rest.Config) *SourcesV1alpha1Client { - client, err := NewForConfig(c) - if err != nil { - panic(err) - } - return client -} - -// New creates a new SourcesV1alpha1Client for the given RESTClient. -func New(c rest.Interface) *SourcesV1alpha1Client { - return &SourcesV1alpha1Client{c} -} - -func setConfigDefaults(config *rest.Config) error { - gv := v1alpha1.SchemeGroupVersion - config.GroupVersion = &gv - config.APIPath = "/apis" - config.NegotiatedSerializer = scheme.Codecs.WithoutConversion() - - if config.UserAgent == "" { - config.UserAgent = rest.DefaultKubernetesUserAgent() - } - - return nil -} - -// RESTClient returns a RESTClient that is used to communicate -// with API server by this client implementation. -func (c *SourcesV1alpha1Client) RESTClient() rest.Interface { - if c == nil { - return nil - } - return c.restClient -} diff --git a/vendor/knative.dev/eventing/pkg/legacyclient/clientset/versioned/typed/legacysources/v1alpha1/sinkbinding.go b/vendor/knative.dev/eventing/pkg/legacyclient/clientset/versioned/typed/legacysources/v1alpha1/sinkbinding.go deleted file mode 100644 index 2813f32fd7..0000000000 --- a/vendor/knative.dev/eventing/pkg/legacyclient/clientset/versioned/typed/legacysources/v1alpha1/sinkbinding.go +++ /dev/null @@ -1,191 +0,0 @@ -/* -Copyright 2020 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. -*/ - -// Code generated by client-gen. DO NOT EDIT. - -package v1alpha1 - -import ( - "time" - - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - types "k8s.io/apimachinery/pkg/types" - watch "k8s.io/apimachinery/pkg/watch" - rest "k8s.io/client-go/rest" - v1alpha1 "knative.dev/eventing/pkg/apis/legacysources/v1alpha1" - scheme "knative.dev/eventing/pkg/legacyclient/clientset/versioned/scheme" -) - -// SinkBindingsGetter has a method to return a SinkBindingInterface. -// A group's client should implement this interface. -type SinkBindingsGetter interface { - SinkBindings(namespace string) SinkBindingInterface -} - -// SinkBindingInterface has methods to work with SinkBinding resources. -type SinkBindingInterface interface { - Create(*v1alpha1.SinkBinding) (*v1alpha1.SinkBinding, error) - Update(*v1alpha1.SinkBinding) (*v1alpha1.SinkBinding, error) - UpdateStatus(*v1alpha1.SinkBinding) (*v1alpha1.SinkBinding, error) - Delete(name string, options *v1.DeleteOptions) error - DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error - Get(name string, options v1.GetOptions) (*v1alpha1.SinkBinding, error) - List(opts v1.ListOptions) (*v1alpha1.SinkBindingList, error) - Watch(opts v1.ListOptions) (watch.Interface, error) - Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.SinkBinding, err error) - SinkBindingExpansion -} - -// sinkBindings implements SinkBindingInterface -type sinkBindings struct { - client rest.Interface - ns string -} - -// newSinkBindings returns a SinkBindings -func newSinkBindings(c *SourcesV1alpha1Client, namespace string) *sinkBindings { - return &sinkBindings{ - client: c.RESTClient(), - ns: namespace, - } -} - -// Get takes name of the sinkBinding, and returns the corresponding sinkBinding object, and an error if there is any. -func (c *sinkBindings) Get(name string, options v1.GetOptions) (result *v1alpha1.SinkBinding, err error) { - result = &v1alpha1.SinkBinding{} - err = c.client.Get(). - Namespace(c.ns). - Resource("sinkbindings"). - Name(name). - VersionedParams(&options, scheme.ParameterCodec). - Do(). - Into(result) - return -} - -// List takes label and field selectors, and returns the list of SinkBindings that match those selectors. -func (c *sinkBindings) List(opts v1.ListOptions) (result *v1alpha1.SinkBindingList, err error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - result = &v1alpha1.SinkBindingList{} - err = c.client.Get(). - Namespace(c.ns). - Resource("sinkbindings"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Do(). - Into(result) - return -} - -// Watch returns a watch.Interface that watches the requested sinkBindings. -func (c *sinkBindings) Watch(opts v1.ListOptions) (watch.Interface, error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - opts.Watch = true - return c.client.Get(). - Namespace(c.ns). - Resource("sinkbindings"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Watch() -} - -// Create takes the representation of a sinkBinding and creates it. Returns the server's representation of the sinkBinding, and an error, if there is any. -func (c *sinkBindings) Create(sinkBinding *v1alpha1.SinkBinding) (result *v1alpha1.SinkBinding, err error) { - result = &v1alpha1.SinkBinding{} - err = c.client.Post(). - Namespace(c.ns). - Resource("sinkbindings"). - Body(sinkBinding). - Do(). - Into(result) - return -} - -// Update takes the representation of a sinkBinding and updates it. Returns the server's representation of the sinkBinding, and an error, if there is any. -func (c *sinkBindings) Update(sinkBinding *v1alpha1.SinkBinding) (result *v1alpha1.SinkBinding, err error) { - result = &v1alpha1.SinkBinding{} - err = c.client.Put(). - Namespace(c.ns). - Resource("sinkbindings"). - Name(sinkBinding.Name). - Body(sinkBinding). - Do(). - Into(result) - return -} - -// UpdateStatus was generated because the type contains a Status member. -// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). - -func (c *sinkBindings) UpdateStatus(sinkBinding *v1alpha1.SinkBinding) (result *v1alpha1.SinkBinding, err error) { - result = &v1alpha1.SinkBinding{} - err = c.client.Put(). - Namespace(c.ns). - Resource("sinkbindings"). - Name(sinkBinding.Name). - SubResource("status"). - Body(sinkBinding). - Do(). - Into(result) - return -} - -// Delete takes name of the sinkBinding and deletes it. Returns an error if one occurs. -func (c *sinkBindings) Delete(name string, options *v1.DeleteOptions) error { - return c.client.Delete(). - Namespace(c.ns). - Resource("sinkbindings"). - Name(name). - Body(options). - Do(). - Error() -} - -// DeleteCollection deletes a collection of objects. -func (c *sinkBindings) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { - var timeout time.Duration - if listOptions.TimeoutSeconds != nil { - timeout = time.Duration(*listOptions.TimeoutSeconds) * time.Second - } - return c.client.Delete(). - Namespace(c.ns). - Resource("sinkbindings"). - VersionedParams(&listOptions, scheme.ParameterCodec). - Timeout(timeout). - Body(options). - Do(). - Error() -} - -// Patch applies the patch and returns the patched sinkBinding. -func (c *sinkBindings) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.SinkBinding, err error) { - result = &v1alpha1.SinkBinding{} - err = c.client.Patch(pt). - Namespace(c.ns). - Resource("sinkbindings"). - SubResource(subresources...). - Name(name). - Body(data). - Do(). - Into(result) - return -} diff --git a/vendor/knative.dev/pkg/logging/config.go b/vendor/knative.dev/pkg/logging/config.go index 6f59bdec24..a0fb96e275 100644 --- a/vendor/knative.dev/pkg/logging/config.go +++ b/vendor/knative.dev/pkg/logging/config.go @@ -38,7 +38,10 @@ const ( fallbackLoggerName = "fallback-logger" ) -var errEmptyLoggerConfig = errors.New("empty logger configuration") +var ( + errEmptyLoggerConfig = errors.New("empty logger configuration") + errEmptyJSONLogginString = errors.New("json logging string is empty") +) // NewLogger creates a logger with the supplied configuration. // In addition to the logger, it returns AtomicLevel that can @@ -150,17 +153,21 @@ const defaultZLC = `{ } }` +func defaultConfig() *Config { + return &Config{ + LoggingConfig: defaultZLC, + LoggingLevel: make(map[string]zapcore.Level), + } +} + // NewConfigFromMap creates a LoggingConfig from the supplied map, // expecting the given list of components. func NewConfigFromMap(data map[string]string) (*Config, error) { - lc := &Config{} + lc := defaultConfig() if zlc, ok := data[loggerConfigKey]; ok { lc.LoggingConfig = zlc - } else { - lc.LoggingConfig = defaultZLC } - lc.LoggingLevel = make(map[string]zapcore.Level) for k, v := range data { if component := strings.TrimPrefix(k, "loglevel."); component != k && component != "" { if len(v) > 0 { @@ -237,7 +244,7 @@ func ConfigMapName() string { // Returns a non-nil Config always. func JsonToLoggingConfig(jsonCfg string) (*Config, error) { if jsonCfg == "" { - return nil, errors.New("json logging string is empty") + return nil, errEmptyJSONLogginString } var configMap map[string]string @@ -248,9 +255,7 @@ func JsonToLoggingConfig(jsonCfg string) (*Config, error) { cfg, err := NewConfigFromMap(configMap) if err != nil { // Get the default config from logging package. - if cfg, err = NewConfigFromMap(nil); err != nil { - return nil, err - } + return NewConfigFromConfigMap(nil) } return cfg, nil } @@ -264,9 +269,5 @@ func LoggingConfigToJson(cfg *Config) (string, error) { jsonCfg, err := json.Marshal(map[string]string{ loggerConfigKey: cfg.LoggingConfig, }) - if err != nil { - return "", err - } - - return string(jsonCfg), nil + return string(jsonCfg), err } diff --git a/vendor/knative.dev/serving/pkg/apis/autoscaling/v1alpha1/pa_validation.go b/vendor/knative.dev/serving/pkg/apis/autoscaling/v1alpha1/pa_validation.go index 31b2bb957a..31ff3b18a4 100644 --- a/vendor/knative.dev/serving/pkg/apis/autoscaling/v1alpha1/pa_validation.go +++ b/vendor/knative.dev/serving/pkg/apis/autoscaling/v1alpha1/pa_validation.go @@ -34,7 +34,11 @@ func (pa *PodAutoscalerSpec) Validate(ctx context.Context) *apis.FieldError { if equality.Semantic.DeepEqual(pa, &PodAutoscalerSpec{}) { return apis.ErrMissingField(apis.CurrentField) } - return serving.ValidateNamespacedObjectReference(&pa.ScaleTargetRef).ViaField("scaleTargetRef").Also(serving.ValidateContainerConcurrency(&pa.ContainerConcurrency).ViaField("containerConcurrency")).Also(validateSKSFields(ctx, pa)) + return serving.ValidateNamespacedObjectReference(&pa.ScaleTargetRef). + ViaField("scaleTargetRef").Also( + serving.ValidateContainerConcurrency( + ctx, &pa.ContainerConcurrency).ViaField("containerConcurrency")).Also( + validateSKSFields(ctx, pa)) } func validateSKSFields(ctx context.Context, rs *PodAutoscalerSpec) (errs *apis.FieldError) { diff --git a/vendor/knative.dev/serving/pkg/apis/config/defaults.go b/vendor/knative.dev/serving/pkg/apis/config/defaults.go index fe1820dec3..7371e3bd3f 100644 --- a/vendor/knative.dev/serving/pkg/apis/config/defaults.go +++ b/vendor/knative.dev/serving/pkg/apis/config/defaults.go @@ -21,7 +21,9 @@ import ( "context" "fmt" "io/ioutil" + "math" "strconv" + "strings" "text/template" corev1 "k8s.io/api/core/v1" @@ -53,34 +55,45 @@ const ( DefaultMaxRevisionContainerConcurrency int64 = 1000 ) +func defaultConfig() *Defaults { + return &Defaults{ + RevisionTimeoutSeconds: DefaultRevisionTimeoutSeconds, + MaxRevisionTimeoutSeconds: DefaultMaxRevisionTimeoutSeconds, + UserContainerNameTemplate: DefaultUserContainerName, + ContainerConcurrency: DefaultContainerConcurrency, + ContainerConcurrencyMaxLimit: DefaultMaxRevisionContainerConcurrency, + } +} + // NewDefaultsConfigFromMap creates a Defaults from the supplied Map func NewDefaultsConfigFromMap(data map[string]string) (*Defaults, error) { - nc := &Defaults{} + nc := defaultConfig() + + // Process bool field. + nc.EnableMultiContainer = strings.EqualFold(data["enable-multi-container"], "true") // Process int64 fields for _, i64 := range []struct { key string field *int64 - // specified exactly when optional - defaultValue int64 }{{ - key: "revision-timeout-seconds", - field: &nc.RevisionTimeoutSeconds, - defaultValue: DefaultRevisionTimeoutSeconds, + key: "revision-timeout-seconds", + field: &nc.RevisionTimeoutSeconds, + }, { + key: "max-revision-timeout-seconds", + field: &nc.MaxRevisionTimeoutSeconds, }, { - key: "max-revision-timeout-seconds", - field: &nc.MaxRevisionTimeoutSeconds, - defaultValue: DefaultMaxRevisionTimeoutSeconds, + key: "container-concurrency", + field: &nc.ContainerConcurrency, }, { - key: "container-concurrency", - field: &nc.ContainerConcurrency, - defaultValue: DefaultContainerConcurrency, + key: "container-concurrency-max-limit", + field: &nc.ContainerConcurrencyMaxLimit, }} { - if raw, ok := data[i64.key]; !ok { - *i64.field = i64.defaultValue - } else if val, err := strconv.ParseInt(raw, 10, 64); err != nil { - return nil, err - } else { + if raw, ok := data[i64.key]; ok { + val, err := strconv.ParseInt(raw, 10, 64) + if err != nil { + return nil, err + } *i64.field = val } } @@ -88,9 +101,13 @@ func NewDefaultsConfigFromMap(data map[string]string) (*Defaults, error) { if nc.RevisionTimeoutSeconds > nc.MaxRevisionTimeoutSeconds { return nil, fmt.Errorf("revision-timeout-seconds (%d) cannot be greater than max-revision-timeout-seconds (%d)", nc.RevisionTimeoutSeconds, nc.MaxRevisionTimeoutSeconds) } - - if nc.ContainerConcurrency < 0 || nc.ContainerConcurrency > DefaultMaxRevisionContainerConcurrency { - return nil, apis.ErrOutOfBoundsValue(nc.ContainerConcurrency, 0, DefaultMaxRevisionContainerConcurrency, "containerConcurrency") + if nc.ContainerConcurrencyMaxLimit < 1 { + return nil, apis.ErrOutOfBoundsValue( + nc.ContainerConcurrencyMaxLimit, 1, math.MaxInt32, "container-concurrency-max-limit") + } + if nc.ContainerConcurrency < 0 || nc.ContainerConcurrency > nc.ContainerConcurrencyMaxLimit { + return nil, apis.ErrOutOfBoundsValue( + nc.ContainerConcurrency, 0, nc.ContainerConcurrencyMaxLimit, "container-concurrency") } // Process resource quantity fields @@ -119,9 +136,7 @@ func NewDefaultsConfigFromMap(data map[string]string) (*Defaults, error) { } } - if raw, ok := data["container-name-template"]; !ok { - nc.UserContainerNameTemplate = DefaultUserContainerName - } else { + if raw, ok := data["container-name-template"]; ok { tmpl, err := template.New("user-container").Parse(raw) if err != nil { return nil, err @@ -145,6 +160,9 @@ func NewDefaultsConfigFromConfigMap(config *corev1.ConfigMap) (*Defaults, error) // Defaults includes the default values to be populated by the webhook. type Defaults struct { + // Feature flag to enable multi container support + EnableMultiContainer bool + RevisionTimeoutSeconds int64 // This is the timeout set for cluster ingress. // RevisionTimeoutSeconds must be less than this value. @@ -154,6 +172,10 @@ type Defaults struct { ContainerConcurrency int64 + // ContainerConcurrencyMaxLimit is the maximum permitted container concurrency + // or target value in the system. + ContainerConcurrencyMaxLimit int64 + RevisionCPURequest *resource.Quantity RevisionCPULimit *resource.Quantity RevisionMemoryRequest *resource.Quantity diff --git a/vendor/knative.dev/serving/pkg/apis/networking/register.go b/vendor/knative.dev/serving/pkg/apis/networking/register.go index 268e6f996c..0e7d18804d 100644 --- a/vendor/knative.dev/serving/pkg/apis/networking/register.go +++ b/vendor/knative.dev/serving/pkg/apis/networking/register.go @@ -44,7 +44,7 @@ const ( SKSLabelKey = GroupName + "/serverlessservice" // ServiceTypeKey is the label key attached to a service specifying the type of service. - // e.g. Public, Metrics + // e.g. Public, Private. ServiceTypeKey = GroupName + "/serviceType" // OriginSecretNameLabelKey is the label key attached to the TLS secret to indicate @@ -98,10 +98,6 @@ const ( // ServiceTypePublic is the label value for externally reachable // services for user applications. ServiceTypePublic ServiceType = "Public" - // ServiceTypeMetrics is the label value for Metrics services. Such services - // are used for metric scraping. - // TODO(5900): Remove after 0.12 is cut. - ServiceTypeMetrics ServiceType = "Metrics" ) // Pseudo-constants diff --git a/vendor/knative.dev/serving/pkg/apis/networking/v1alpha1/serverlessservice_types.go b/vendor/knative.dev/serving/pkg/apis/networking/v1alpha1/serverlessservice_types.go index 3d2a64278e..9949923486 100644 --- a/vendor/knative.dev/serving/pkg/apis/networking/v1alpha1/serverlessservice_types.go +++ b/vendor/knative.dev/serving/pkg/apis/networking/v1alpha1/serverlessservice_types.go @@ -101,6 +101,11 @@ type ServerlessServiceSpec struct { // The application-layer protocol. Matches `RevisionProtocolType` set on the owning pa/revision. // serving imports networking, so just use string. ProtocolType networking.ProtocolType + + // NumActivators contains number of Activators that this revision should be + // assigned. + // O means — assign all. + NumActivators int32 `json:"numActivators,omitempty"` } // ServerlessServiceStatus describes the current state of the ServerlessService. diff --git a/vendor/knative.dev/serving/pkg/apis/networking/v1alpha1/serverlessservice_validation.go b/vendor/knative.dev/serving/pkg/apis/networking/v1alpha1/serverlessservice_validation.go index ebace729dc..0ee05b2bed 100644 --- a/vendor/knative.dev/serving/pkg/apis/networking/v1alpha1/serverlessservice_validation.go +++ b/vendor/knative.dev/serving/pkg/apis/networking/v1alpha1/serverlessservice_validation.go @@ -46,6 +46,10 @@ func (spec *ServerlessServiceSpec) Validate(ctx context.Context) *apis.FieldErro all = all.Also(apis.ErrInvalidValue(spec.Mode, "mode")) } + if spec.NumActivators < 0 { + all = all.Also(apis.ErrInvalidValue(spec.NumActivators, "numActivators")) + } + all = all.Also(serving.ValidateNamespacedObjectReference(&spec.ObjectRef).ViaField("objectRef")) return all.Also(spec.ProtocolType.Validate(ctx).ViaField("protocolType")) diff --git a/vendor/knative.dev/serving/pkg/apis/serving/k8s_validation.go b/vendor/knative.dev/serving/pkg/apis/serving/k8s_validation.go index 09be210985..8de3576138 100644 --- a/vendor/knative.dev/serving/pkg/apis/serving/k8s_validation.go +++ b/vendor/knative.dev/serving/pkg/apis/serving/k8s_validation.go @@ -17,6 +17,7 @@ limitations under the License. package serving import ( + "context" "fmt" "math" "path/filepath" @@ -29,6 +30,7 @@ import ( "k8s.io/apimachinery/pkg/util/validation" "knative.dev/pkg/apis" "knative.dev/pkg/profiling" + "knative.dev/serving/pkg/apis/config" "knative.dev/serving/pkg/apis/networking" ) @@ -236,7 +238,8 @@ func validateEnvFrom(envFromList []corev1.EnvFromSource) *apis.FieldError { return errs } -func ValidatePodSpec(ps corev1.PodSpec) *apis.FieldError { +// ValidatePodSpec validates the pod spec +func ValidatePodSpec(ctx context.Context, ps corev1.PodSpec) *apis.FieldError { // This is inlined, and so it makes for a less meaningful // error message. // if equality.Semantic.DeepEqual(ps, corev1.PodSpec{}) { @@ -257,7 +260,7 @@ func ValidatePodSpec(ps corev1.PodSpec) *apis.FieldError { errs = errs.Also(ValidateContainer(ps.Containers[0], volumes). ViaFieldIndex("containers", 0)) default: - errs = errs.Also(apis.ErrMultipleOneOf("containers")) + errs = errs.Also(validateContainers(ctx, ps.Containers, volumes)) } if ps.ServiceAccountName != "" { for range validation.IsDNS1123Subdomain(ps.ServiceAccountName) { @@ -267,7 +270,82 @@ func ValidatePodSpec(ps corev1.PodSpec) *apis.FieldError { return errs } +func validateContainers(ctx context.Context, containers []corev1.Container, volumes sets.String) *apis.FieldError { + var errs *apis.FieldError + cfg := config.FromContextOrDefaults(ctx).Defaults + if !cfg.EnableMultiContainer { + errs = errs.Also(&apis.FieldError{Message: fmt.Sprintf("enable-multi-container is off, "+ + "but found %d containers", len(containers))}) + } else { + errs = errs.Also(validateContainersPorts(containers).ViaField("containers")) + for i := range containers { + // Probes are not allowed on other than serving container, + // ref: http://bit.ly/probes-condition + if len(containers[i].Ports) == 0 { + errs = errs.Also(validateSidecarContainer(containers[i], volumes).ViaFieldIndex("containers", i)) + } else { + errs = errs.Also(ValidateContainer(containers[i], volumes).ViaFieldIndex("containers", i)) + } + } + } + return errs +} + +// validateContainersPorts validates port when specified multiple containers +func validateContainersPorts(containers []corev1.Container) *apis.FieldError { + var count int + for i := range containers { + count += len(containers[i].Ports) + } + // When no container ports are specified. + if count == 0 { + return apis.ErrMissingField("ports") + } + // More than one container sections have ports. + if count > 1 { + return apis.ErrMultipleOneOf("ports") + } + return nil +} + +// validateSidecarContainer validate fields for non serving containers +func validateSidecarContainer(container corev1.Container, volumes sets.String) *apis.FieldError { + var errs *apis.FieldError + if container.LivenessProbe != nil { + errs = errs.Also(apis.CheckDisallowedFields(*container.LivenessProbe, + *ProbeMask(&corev1.Probe{})).ViaField("livenessProbe")) + } + if container.ReadinessProbe != nil { + errs = errs.Also(apis.CheckDisallowedFields(*container.ReadinessProbe, + *ProbeMask(&corev1.Probe{})).ViaField("readinessProbe")) + } + return errs.Also(validate(container, volumes)) +} + +// ValidateContainer validate fields for serving containers func ValidateContainer(container corev1.Container, volumes sets.String) *apis.FieldError { + var errs *apis.FieldError + // Single container cannot have multiple ports + errs = errs.Also(portValidation(container.Ports).ViaField("ports")) + // Liveness Probes + errs = errs.Also(validateProbe(container.LivenessProbe).ViaField("livenessProbe")) + // Readiness Probes + errs = errs.Also(validateReadinessProbe(container.ReadinessProbe).ViaField("readinessProbe")) + return errs.Also(validate(container, volumes)) +} + +func portValidation(containerPorts []corev1.ContainerPort) *apis.FieldError { + if len(containerPorts) > 1 { + return &apis.FieldError{ + Message: "More than one container port is set", + Paths: []string{apis.CurrentField}, + Details: "Only a single port is allowed", + } + } + return nil +} + +func validate(container corev1.Container, volumes sets.String) *apis.FieldError { if equality.Semantic.DeepEqual(container, corev1.Container{}) { return apis.ErrMissingField(apis.CurrentField) } @@ -296,12 +374,8 @@ func ValidateContainer(container corev1.Container, volumes sets.String) *apis.Fi } errs = errs.Also(fe) } - // Liveness Probes - errs = errs.Also(validateProbe(container.LivenessProbe).ViaField("livenessProbe")) // Ports errs = errs.Also(validateContainerPorts(container.Ports).ViaField("ports")) - // Readiness Probes - errs = errs.Also(validateReadinessProbe(container.ReadinessProbe).ViaField("readinessProbe")) // Resources errs = errs.Also(validateResources(&container.Resources).ViaField("resources")) // SecurityContext @@ -397,14 +471,6 @@ func validateContainerPorts(ports []corev1.ContainerPort) *apis.FieldError { // user can set container port which names "user-port" to define application's port. // Queue-proxy will use it to send requests to application // if user didn't set any port, it will set default port user-port=8080. - if len(ports) > 1 { - errs = errs.Also(&apis.FieldError{ - Message: "More than one container port is set", - Paths: []string{apis.CurrentField}, - Details: "Only a single port is allowed", - }) - } - userPort := ports[0] errs = errs.Also(apis.CheckDisallowedFields(userPort, *ContainerPortMask(&userPort))) diff --git a/vendor/knative.dev/serving/pkg/apis/serving/metadata_validation.go b/vendor/knative.dev/serving/pkg/apis/serving/metadata_validation.go index df3ec6fd5d..9b396450dc 100644 --- a/vendor/knative.dev/serving/pkg/apis/serving/metadata_validation.go +++ b/vendor/knative.dev/serving/pkg/apis/serving/metadata_validation.go @@ -91,11 +91,12 @@ func ValidateTimeoutSeconds(ctx context.Context, timeoutSeconds int64) *apis.Fie // ValidateContainerConcurrency function validates the ContainerConcurrency field // TODO(#5007): Move this to autoscaling. -func ValidateContainerConcurrency(containerConcurrency *int64) *apis.FieldError { +func ValidateContainerConcurrency(ctx context.Context, containerConcurrency *int64) *apis.FieldError { if containerConcurrency != nil { - if *containerConcurrency < 0 || *containerConcurrency > config.DefaultMaxRevisionContainerConcurrency { + cfg := config.FromContextOrDefaults(ctx).Defaults + if *containerConcurrency < 0 || *containerConcurrency > cfg.ContainerConcurrencyMaxLimit { return apis.ErrOutOfBoundsValue( - *containerConcurrency, 0, config.DefaultMaxRevisionContainerConcurrency, apis.CurrentField) + *containerConcurrency, 0, cfg.ContainerConcurrencyMaxLimit, apis.CurrentField) } } return nil diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1/revision_defaults.go b/vendor/knative.dev/serving/pkg/apis/serving/v1/revision_defaults.go index 01df5b6262..0849af3742 100644 --- a/vendor/knative.dev/serving/pkg/apis/serving/v1/revision_defaults.go +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1/revision_defaults.go @@ -19,8 +19,11 @@ package v1 import ( "context" + "github.com/google/uuid" + corev1 "k8s.io/api/core/v1" "knative.dev/pkg/apis" + "knative.dev/pkg/kmeta" "knative.dev/pkg/ptr" "knative.dev/serving/pkg/apis/config" ) @@ -51,52 +54,70 @@ func (rs *RevisionSpec) SetDefaults(ctx context.Context) { for idx := range rs.PodSpec.Containers { if rs.PodSpec.Containers[idx].Name == "" { - rs.PodSpec.Containers[idx].Name = cfg.Defaults.UserContainerName(ctx) - } - - if rs.PodSpec.Containers[idx].Resources.Requests == nil { - rs.PodSpec.Containers[idx].Resources.Requests = corev1.ResourceList{} - } - if _, ok := rs.PodSpec.Containers[idx].Resources.Requests[corev1.ResourceCPU]; !ok { - if rsrc := cfg.Defaults.RevisionCPURequest; rsrc != nil { - rs.PodSpec.Containers[idx].Resources.Requests[corev1.ResourceCPU] = *rsrc - } - } - if _, ok := rs.PodSpec.Containers[idx].Resources.Requests[corev1.ResourceMemory]; !ok { - if rsrc := cfg.Defaults.RevisionMemoryRequest; rsrc != nil { - rs.PodSpec.Containers[idx].Resources.Requests[corev1.ResourceMemory] = *rsrc + if len(rs.PodSpec.Containers) > 1 { + rs.PodSpec.Containers[idx].Name = kmeta.ChildName(cfg.Defaults.UserContainerName(ctx), "-"+uuid.New().String()) + } else { + rs.PodSpec.Containers[idx].Name = cfg.Defaults.UserContainerName(ctx) } } - if rs.PodSpec.Containers[idx].Resources.Limits == nil { - rs.PodSpec.Containers[idx].Resources.Limits = corev1.ResourceList{} - } - if _, ok := rs.PodSpec.Containers[idx].Resources.Limits[corev1.ResourceCPU]; !ok { - if rsrc := cfg.Defaults.RevisionCPULimit; rsrc != nil { - rs.PodSpec.Containers[idx].Resources.Limits[corev1.ResourceCPU] = *rsrc - } + rs.applyDefault(&rs.PodSpec.Containers[idx], cfg) + } +} + +func (rs *RevisionSpec) applyDefault(container *corev1.Container, cfg *config.Config) { + if container.Resources.Requests == nil { + container.Resources.Requests = corev1.ResourceList{} + } + if _, ok := container.Resources.Requests[corev1.ResourceCPU]; !ok { + if rc := cfg.Defaults.RevisionCPURequest; rc != nil { + container.Resources.Requests[corev1.ResourceCPU] = *rc } - if _, ok := rs.PodSpec.Containers[idx].Resources.Limits[corev1.ResourceMemory]; !ok { - if rsrc := cfg.Defaults.RevisionMemoryLimit; rsrc != nil { - rs.PodSpec.Containers[idx].Resources.Limits[corev1.ResourceMemory] = *rsrc - } + } + if _, ok := container.Resources.Requests[corev1.ResourceMemory]; !ok { + if rm := cfg.Defaults.RevisionMemoryRequest; rm != nil { + container.Resources.Requests[corev1.ResourceMemory] = *rm } - if rs.PodSpec.Containers[idx].ReadinessProbe == nil { - rs.PodSpec.Containers[idx].ReadinessProbe = &corev1.Probe{} + } + + if container.Resources.Limits == nil { + container.Resources.Limits = corev1.ResourceList{} + } + if _, ok := container.Resources.Limits[corev1.ResourceCPU]; !ok { + if rc := cfg.Defaults.RevisionCPULimit; rc != nil { + container.Resources.Limits[corev1.ResourceCPU] = *rc } - if rs.PodSpec.Containers[idx].ReadinessProbe.TCPSocket == nil && - rs.PodSpec.Containers[idx].ReadinessProbe.HTTPGet == nil && - rs.PodSpec.Containers[idx].ReadinessProbe.Exec == nil { - rs.PodSpec.Containers[idx].ReadinessProbe.TCPSocket = &corev1.TCPSocketAction{} + } + if _, ok := container.Resources.Limits[corev1.ResourceMemory]; !ok { + if rm := cfg.Defaults.RevisionMemoryLimit; rm != nil { + container.Resources.Limits[corev1.ResourceMemory] = *rm } + } - if rs.PodSpec.Containers[idx].ReadinessProbe.SuccessThreshold == 0 { - rs.PodSpec.Containers[idx].ReadinessProbe.SuccessThreshold = 1 - } + // If there are multiple containers then default probes will be applied to the container where user specified PORT + // default probes will not be applied for non serving containers + if len(rs.PodSpec.Containers) == 1 || len(container.Ports) != 0 { + rs.applyProbes(container) + } - vms := rs.PodSpec.Containers[idx].VolumeMounts - for i := range vms { - vms[i].ReadOnly = true - } + vms := container.VolumeMounts + for i := range vms { + vms[i].ReadOnly = true } } + +func (*RevisionSpec) applyProbes(container *corev1.Container) { + if container.ReadinessProbe == nil { + container.ReadinessProbe = &corev1.Probe{} + } + if container.ReadinessProbe.TCPSocket == nil && + container.ReadinessProbe.HTTPGet == nil && + container.ReadinessProbe.Exec == nil { + container.ReadinessProbe.TCPSocket = &corev1.TCPSocketAction{} + } + + if container.ReadinessProbe.SuccessThreshold == 0 { + container.ReadinessProbe.SuccessThreshold = 1 + } + +} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1/revision_validation.go b/vendor/knative.dev/serving/pkg/apis/serving/v1/revision_validation.go index d83b3760cb..fd426b7ea2 100644 --- a/vendor/knative.dev/serving/pkg/apis/serving/v1/revision_validation.go +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1/revision_validation.go @@ -96,14 +96,14 @@ func (current *RevisionTemplateSpec) VerifyNameChange(ctx context.Context, og Re // Validate implements apis.Validatable func (rs *RevisionSpec) Validate(ctx context.Context) *apis.FieldError { - errs := serving.ValidatePodSpec(rs.PodSpec) + errs := serving.ValidatePodSpec(ctx, rs.PodSpec) if rs.TimeoutSeconds != nil { errs = errs.Also(serving.ValidateTimeoutSeconds(ctx, *rs.TimeoutSeconds)) } if rs.ContainerConcurrency != nil { - errs = errs.Also(serving.ValidateContainerConcurrency(rs.ContainerConcurrency).ViaField("containerConcurrency")) + errs = errs.Also(serving.ValidateContainerConcurrency(ctx, rs.ContainerConcurrency).ViaField("containerConcurrency")) } return errs diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/revision_conversion.go b/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/revision_conversion.go index c6314d33f4..e54ebfeeaa 100644 --- a/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/revision_conversion.go +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/revision_conversion.go @@ -62,10 +62,8 @@ func (source *RevisionSpec) ConvertTo(ctx context.Context, sink *v1.RevisionSpec Volumes: source.Volumes, ImagePullSecrets: source.ImagePullSecrets, } - case len(source.Containers) == 1: + case len(source.Containers) != 0: sink.PodSpec = source.PodSpec - case len(source.Containers) > 1: - return apis.ErrMultipleOneOf("containers") default: return apis.ErrMissingOneOf("container", "containers") } diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/revision_lifecycle.go b/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/revision_lifecycle.go index 7c333281e4..53907424b4 100644 --- a/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/revision_lifecycle.go +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/revision_lifecycle.go @@ -79,7 +79,7 @@ func (rs *RevisionSpec) GetContainer() *corev1.Container { if len(rs.Containers) > 0 { return &rs.Containers[0] } - // Should be unreachable post-validation, but here to ease testing. + // Should be unreachable post-validation, but is here to ease testing. return &corev1.Container{} } diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/revision_validation.go b/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/revision_validation.go index 713c56770b..1f3b2edf93 100644 --- a/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/revision_validation.go +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/revision_validation.go @@ -126,7 +126,7 @@ func (rs *RevisionSpec) Validate(ctx context.Context) *apis.FieldError { errs = errs.Also(err) } else { if rs.ContainerConcurrency != nil { - errs = errs.Also(serving.ValidateContainerConcurrency(rs.ContainerConcurrency).ViaField("containerConcurrency")) + errs = errs.Also(serving.ValidateContainerConcurrency(ctx, rs.ContainerConcurrency).ViaField("containerConcurrency")) } } diff --git a/vendor/knative.dev/serving/pkg/autoscaler/config/config.go b/vendor/knative.dev/serving/pkg/autoscaler/config/config.go index b51e0e8eb0..1263c6aaef 100644 --- a/vendor/knative.dev/serving/pkg/autoscaler/config/config.go +++ b/vendor/knative.dev/serving/pkg/autoscaler/config/config.go @@ -62,6 +62,11 @@ type Config struct { // NB: most of our computations are in floats, so this is float to avoid casting. TargetBurstCapacity float64 + // ActivatorCapacity is the number of the concurrent requests an activator + // task can accept. This is used in activator subsetting algorithm, to determine + // the number of activators per revision. + ActivatorCapacity float64 + // General autoscaler algorithm configuration. MaxScaleUpRate float64 MaxScaleDownRate float64 @@ -75,31 +80,46 @@ type Config struct { PodAutoscalerClass string } +func defaultConfig() *Config { + return &Config{ + EnableScaleToZero: true, + EnableGracefulScaledown: false, + ContainerConcurrencyTargetFraction: defaultTargetUtilization, + ContainerConcurrencyTargetDefault: 100, + // TODO(#1956): Tune target usage based on empirical data. + TargetUtilization: defaultTargetUtilization, + RPSTargetDefault: 200, + MaxScaleUpRate: 1000, + MaxScaleDownRate: 2, + TargetBurstCapacity: 200, + PanicWindowPercentage: 10, + ActivatorCapacity: 100, + PanicThresholdPercentage: 200, + StableWindow: 60 * time.Second, + ScaleToZeroGracePeriod: 30 * time.Second, + TickInterval: 2 * time.Second, + PodAutoscalerClass: autoscaling.KPA, + } +} + // NewConfigFromMap creates a Config from the supplied map func NewConfigFromMap(data map[string]string) (*Config, error) { - lc := &Config{ - TargetUtilization: defaultTargetUtilization, - } + lc := defaultConfig() // Process bool fields. for _, b := range []struct { - key string - field *bool - defaultValue bool + key string + field *bool }{ { - key: "enable-scale-to-zero", - field: &lc.EnableScaleToZero, - defaultValue: true, + key: "enable-scale-to-zero", + field: &lc.EnableScaleToZero, }, { - key: "enable-graceful-scaledown", - field: &lc.EnableGracefulScaledown, - defaultValue: false, + key: "enable-graceful-scaledown", + field: &lc.EnableGracefulScaledown, }} { - if raw, ok := data[b.key]; !ok { - *b.field = b.defaultValue - } else { + if raw, ok := data[b.key]; ok { *b.field = strings.EqualFold(raw, "true") } } @@ -108,47 +128,39 @@ func NewConfigFromMap(data map[string]string) (*Config, error) { for _, f64 := range []struct { key string field *float64 - // specified exactly when optional - defaultValue float64 }{{ - key: "max-scale-up-rate", - field: &lc.MaxScaleUpRate, - defaultValue: 1000.0, + key: "max-scale-up-rate", + field: &lc.MaxScaleUpRate, }, { - key: "max-scale-down-rate", - field: &lc.MaxScaleDownRate, - defaultValue: 2.0, + key: "max-scale-down-rate", + field: &lc.MaxScaleDownRate, }, { key: "container-concurrency-target-percentage", field: &lc.ContainerConcurrencyTargetFraction, - // TODO(#1956): Tune target usage based on empirical data. - defaultValue: defaultTargetUtilization, }, { - key: "container-concurrency-target-default", - field: &lc.ContainerConcurrencyTargetDefault, - defaultValue: 100.0, + key: "container-concurrency-target-default", + field: &lc.ContainerConcurrencyTargetDefault, + }, { + key: "requests-per-second-target-default", + field: &lc.RPSTargetDefault, }, { - key: "requests-per-second-target-default", - field: &lc.RPSTargetDefault, - defaultValue: 200.0, + key: "target-burst-capacity", + field: &lc.TargetBurstCapacity, }, { - key: "target-burst-capacity", - field: &lc.TargetBurstCapacity, - defaultValue: 200, + key: "panic-window-percentage", + field: &lc.PanicWindowPercentage, }, { - key: "panic-window-percentage", - field: &lc.PanicWindowPercentage, - defaultValue: 10.0, + key: "activator-capacity", + field: &lc.ActivatorCapacity, }, { - key: "panic-threshold-percentage", - field: &lc.PanicThresholdPercentage, - defaultValue: 200.0, + key: "panic-threshold-percentage", + field: &lc.PanicThresholdPercentage, }} { - if raw, ok := data[f64.key]; !ok { - *f64.field = f64.defaultValue - } else if val, err := strconv.ParseFloat(raw, 64); err != nil { - return nil, err - } else { + if raw, ok := data[f64.key]; ok { + val, err := strconv.ParseFloat(raw, 64) + if err != nil { + return nil, err + } *f64.field = val } } @@ -163,32 +175,27 @@ func NewConfigFromMap(data map[string]string) (*Config, error) { // Process Duration fields for _, dur := range []struct { - key string - field *time.Duration - defaultValue time.Duration + key string + field *time.Duration }{{ - key: "stable-window", - field: &lc.StableWindow, - defaultValue: 60 * time.Second, + key: "stable-window", + field: &lc.StableWindow, }, { - key: "scale-to-zero-grace-period", - field: &lc.ScaleToZeroGracePeriod, - defaultValue: 30 * time.Second, + key: "scale-to-zero-grace-period", + field: &lc.ScaleToZeroGracePeriod, }, { - key: "tick-interval", - field: &lc.TickInterval, - defaultValue: 2 * time.Second, + key: "tick-interval", + field: &lc.TickInterval, }} { - if raw, ok := data[dur.key]; !ok { - *dur.field = dur.defaultValue - } else if val, err := time.ParseDuration(raw); err != nil { - return nil, err - } else { + if raw, ok := data[dur.key]; ok { + val, err := time.ParseDuration(raw) + if err != nil { + return nil, err + } *dur.field = val } } - lc.PodAutoscalerClass = autoscaling.KPA if pac, ok := data["pod-autoscaler-class"]; ok { lc.PodAutoscalerClass = pac } @@ -216,6 +223,10 @@ func validate(lc *Config) (*Config, error) { return nil, fmt.Errorf("requests-per-second-target-default must be at least %v, got %v", autoscaling.TargetMin, lc.RPSTargetDefault) } + if lc.ActivatorCapacity < 1 { + return nil, fmt.Errorf("activator-capacity = %v, must be at least 1", lc.ActivatorCapacity) + } + if lc.MaxScaleUpRate <= 1.0 { return nil, fmt.Errorf("max-scale-up-rate = %v, must be greater than 1.0", lc.MaxScaleUpRate) } diff --git a/vendor/modules.txt b/vendor/modules.txt index 0678f4c67d..4f54fc0b63 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -43,10 +43,12 @@ github.com/google/go-cmp/cmp/internal/diff github.com/google/go-cmp/cmp/internal/flags github.com/google/go-cmp/cmp/internal/function github.com/google/go-cmp/cmp/internal/value -# github.com/google/go-containerregistry v0.0.0-20200304201134-fcc8ea80e26f +# github.com/google/go-containerregistry v0.0.0-20200413145205-82d30a103c0a github.com/google/go-containerregistry/pkg/name # github.com/google/gofuzz v1.0.0 github.com/google/gofuzz +# github.com/google/uuid v1.1.1 +github.com/google/uuid # github.com/googleapis/gnostic v0.2.2 github.com/googleapis/gnostic/OpenAPIv2 github.com/googleapis/gnostic/compiler @@ -127,7 +129,7 @@ go.uber.org/zap/internal/bufferpool go.uber.org/zap/internal/color go.uber.org/zap/internal/exit go.uber.org/zap/zapcore -# golang.org/x/crypto v0.0.0-20191206172530-e9b2fee46413 +# golang.org/x/crypto v0.0.0-20200220183623-bac4c82f6975 golang.org/x/crypto/ssh/terminal # golang.org/x/net v0.0.0-20191004110552-13f9640d40b9 golang.org/x/net/context @@ -174,7 +176,7 @@ google.golang.org/appengine/internal/urlfetch google.golang.org/appengine/urlfetch # gopkg.in/inf.v0 v0.9.1 gopkg.in/inf.v0 -# gopkg.in/yaml.v2 v2.2.4 +# gopkg.in/yaml.v2 v2.2.8 gopkg.in/yaml.v2 # gotest.tools v2.2.0+incompatible gotest.tools/assert @@ -182,7 +184,7 @@ gotest.tools/assert/cmp gotest.tools/internal/difflib gotest.tools/internal/format gotest.tools/internal/source -# k8s.io/api v0.17.0 +# k8s.io/api v0.17.4 k8s.io/api/admissionregistration/v1 k8s.io/api/admissionregistration/v1beta1 k8s.io/api/apps/v1 @@ -223,7 +225,7 @@ k8s.io/api/settings/v1alpha1 k8s.io/api/storage/v1 k8s.io/api/storage/v1alpha1 k8s.io/api/storage/v1beta1 -# k8s.io/apimachinery v0.17.0 +# k8s.io/apimachinery v0.17.4 k8s.io/apimachinery/pkg/api/apitesting/fuzzer k8s.io/apimachinery/pkg/api/equality k8s.io/apimachinery/pkg/api/errors @@ -285,7 +287,7 @@ k8s.io/cli-runtime/pkg/kustomize/k8sdeps/transformer/patch k8s.io/cli-runtime/pkg/kustomize/k8sdeps/validator k8s.io/cli-runtime/pkg/printers k8s.io/cli-runtime/pkg/resource -# k8s.io/client-go v0.17.0 +# k8s.io/client-go v0.17.4 k8s.io/client-go/discovery k8s.io/client-go/discovery/cached/disk k8s.io/client-go/dynamic @@ -463,7 +465,7 @@ k8s.io/kube-openapi/pkg/util/proto k8s.io/utils/buffer k8s.io/utils/integer k8s.io/utils/trace -# knative.dev/eventing v0.13.6 +# knative.dev/eventing v0.14.0 knative.dev/eventing/pkg/apis/config knative.dev/eventing/pkg/apis/configs knative.dev/eventing/pkg/apis/configs/v1alpha1 @@ -476,8 +478,6 @@ knative.dev/eventing/pkg/apis/eventing/v1beta1 knative.dev/eventing/pkg/apis/flows knative.dev/eventing/pkg/apis/flows/v1alpha1 knative.dev/eventing/pkg/apis/flows/v1beta1 -knative.dev/eventing/pkg/apis/legacysources -knative.dev/eventing/pkg/apis/legacysources/v1alpha1 knative.dev/eventing/pkg/apis/messaging knative.dev/eventing/pkg/apis/messaging/config knative.dev/eventing/pkg/apis/messaging/v1alpha1 @@ -488,14 +488,10 @@ knative.dev/eventing/pkg/apis/sources/v1alpha2 knative.dev/eventing/pkg/client/clientset/versioned/scheme knative.dev/eventing/pkg/client/clientset/versioned/typed/eventing/v1alpha1 knative.dev/eventing/pkg/client/clientset/versioned/typed/eventing/v1alpha1/fake -knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha1 -knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha1/fake knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha2 knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha2/fake -knative.dev/eventing/pkg/legacyclient/clientset/versioned/scheme -knative.dev/eventing/pkg/legacyclient/clientset/versioned/typed/legacysources/v1alpha1 knative.dev/eventing/pkg/logging -# knative.dev/pkg v0.0.0-20200409225505-9147309d5366 +# knative.dev/pkg v0.0.0-20200414233146-0eed424fa4ee knative.dev/pkg/apis knative.dev/pkg/apis/duck knative.dev/pkg/apis/duck/v1 @@ -511,7 +507,7 @@ knative.dev/pkg/logging/logkey knative.dev/pkg/profiling knative.dev/pkg/ptr knative.dev/pkg/tracker -# knative.dev/serving v0.13.2 +# knative.dev/serving v0.14.0 knative.dev/serving/pkg/apis/autoscaling knative.dev/serving/pkg/apis/autoscaling/v1alpha1 knative.dev/serving/pkg/apis/config @@ -525,7 +521,7 @@ knative.dev/serving/pkg/autoscaler/config knative.dev/serving/pkg/client/clientset/versioned/scheme knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1 knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1/fake -# knative.dev/test-infra v0.0.0-20200409221904-5e04d955cdb9 +# knative.dev/test-infra v0.0.0-20200413202711-9cf64fb1b912 knative.dev/test-infra/scripts # sigs.k8s.io/kustomize v2.0.3+incompatible sigs.k8s.io/kustomize/pkg/commands/build