Merge pull request #45115 from deads2k/tpr-07-types

Automatic merge from submit-queue (batch tested with PRs 45272, 45115)

initial types for TPRs

This pull starts creating the types described by https://github.com/kubernetes/community/blob/master/contributors/design-proposals/thirdpartyresources.md .  In the initial pull different names were suggested.  I've started this pull with `CustomResource.apiextensions.k8s.io`.

The structure begins as a separate API server to facilitate rapid prototyping and experimentation, but the end result will be added to the end of the `kube-apiserver` chain as described in https://github.com/kubernetes/community/blob/master/sig-api-machinery/api-extensions-position-statement.md .

Because it is separate to start (not included in any default server), I don't think we need a perfect name, but I'd like to be close.

@kubernetes/sig-api-machinery-misc @enisoc @smarterclayton @erictune
This commit is contained in:
Kubernetes Submit Queue
2017-05-03 05:36:59 -07:00
committed by GitHub
109 changed files with 5302 additions and 1 deletions

View File

@@ -397,6 +397,17 @@ staging/src/k8s.io/kube-aggregator/pkg/client/informers/internalversion/apiregis
staging/src/k8s.io/kube-aggregator/pkg/client/listers/apiregistration/internalversion
staging/src/k8s.io/kube-aggregator/pkg/client/listers/apiregistration/v1alpha1
staging/src/k8s.io/kube-aggregator/pkg/controllers
staging/src/k8s.io/kube-apiextensions-server
staging/src/k8s.io/kube-apiextensions-server/pkg/apis/apiextensions/install
staging/src/k8s.io/kube-apiextensions-server/pkg/apis/apiextensions/validation
staging/src/k8s.io/kube-apiextensions-server/pkg/client/informers/externalversions
staging/src/k8s.io/kube-apiextensions-server/pkg/client/informers/externalversions/apiextensions
staging/src/k8s.io/kube-apiextensions-server/pkg/client/informers/externalversions/apiextensions/v1alpha1
staging/src/k8s.io/kube-apiextensions-server/pkg/client/informers/internalversion
staging/src/k8s.io/kube-apiextensions-server/pkg/client/informers/internalversion/apiextensions
staging/src/k8s.io/kube-apiextensions-server/pkg/client/informers/internalversion/apiextensions/internalversion
staging/src/k8s.io/kube-apiextensions-server/pkg/client/listers/apiextensions/internalversion
staging/src/k8s.io/kube-apiextensions-server/pkg/client/listers/apiextensions/v1alpha1
staging/src/k8s.io/metrics/pkg/apis/custom_metrics/install
staging/src/k8s.io/metrics/pkg/apis/metrics/install
staging/src/k8s.io/sample-apiserver

View File

@@ -50,6 +50,9 @@ pushd "${KUBE_ROOT}" > /dev/null
if [ ! -e "vendor/k8s.io/kube-aggregator" ]; then
ln -s ../../staging/src/k8s.io/kube-aggregator vendor/k8s.io/kube-aggregator
fi
if [ ! -e "vendor/k8s.io/kube-apiextensions-server" ]; then
ln -s ../../staging/src/k8s.io/kube-apiextensions-server vendor/k8s.io/kube-apiextensions-server
fi
if [ ! -e "vendor/k8s.io/sample-apiserver" ]; then
ln -s ../../staging/src/k8s.io/sample-apiserver vendor/k8s.io/sample-apiserver
fi

View File

@@ -30,6 +30,7 @@ kube::golang::server_targets() {
cmd/kubeadm
cmd/hyperkube
vendor/k8s.io/kube-aggregator
vendor/k8s.io/kube-apiextensions-server
plugin/cmd/kube-scheduler
)
echo "${targets[@]}"

View File

@@ -39,7 +39,7 @@ function kfind() {
# include the "special" vendor directories which are actually part
# of the Kubernetes source tree - generators will use these for
# including certain core API concepts.
find -H . ./vendor/k8s.io/apimachinery ./vendor/k8s.io/apiserver ./vendor/k8s.io/kube-aggregator ./vendor/k8s.io/sample-apiserver ./vendor/k8s.io/metrics \
find -H . ./vendor/k8s.io/apimachinery ./vendor/k8s.io/apiserver ./vendor/k8s.io/kube-aggregator ./vendor/k8s.io/kube-apiextensions-server ./vendor/k8s.io/metrics ./vendor/k8s.io/sample-apiserver \
\( \
-not \( \
\( \

View File

@@ -72,6 +72,9 @@ kube::test::find_dirs() {
find ./staging/src/k8s.io/kube-aggregator -name '*_test.go' \
-name '*_test.go' -print0 | xargs -0n1 dirname | sed 's|^\./staging/src/|./vendor/|' | LC_ALL=C sort -u
find ./staging/src/k8s.io/kube-apiextensions-server -name '*_test.go' \
-name '*_test.go' -print0 | xargs -0n1 dirname | sed 's|^\./staging/src/|./vendor/|' | LC_ALL=C sort -u
find ./staging/src/k8s.io/sample-apiserver -name '*_test.go' \
-name '*_test.go' -print0 | xargs -0n1 dirname | sed 's|^\./staging/src/|./vendor/|' | LC_ALL=C sort -u
)

View File

@@ -103,3 +103,4 @@ ${informergen} \
# call generation on sub-project for now
vendor/k8s.io/kube-aggregator/hack/update-codegen.sh
vendor/k8s.io/sample-apiserver/hack/update-codegen.sh
vendor/k8s.io/kube-apiextensions-server/hack/update-codegen.sh

View File

@@ -26,6 +26,7 @@ kube::golang::setup_env
# call verify on sub-project for now
vendor/k8s.io/kube-aggregator/hack/verify-codegen.sh
vendor/k8s.io/sample-apiserver/hack/verify-codegen.sh
vendor/k8s.io/kube-apiextensions-server/hack/verify-codegen.sh
"${KUBE_ROOT}/hack/update-codegen.sh" --verify-only

View File

@@ -0,0 +1,26 @@
package(default_visibility = ["//visibility:public"])
licenses(["notice"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_binary",
"go_library",
)
go_binary(
name = "kube-apiextensions-server",
library = ":go_default_library",
tags = ["automanaged"],
)
go_library(
name = "go_default_library",
srcs = ["main.go"],
tags = ["automanaged"],
deps = [
"//vendor/k8s.io/apimachinery/pkg/util/wait:go_default_library",
"//vendor/k8s.io/apiserver/pkg/util/logs:go_default_library",
"//vendor/k8s.io/kube-apiextensions-server/pkg/cmd/server:go_default_library",
],
)

View File

@@ -0,0 +1,394 @@
{
"ImportPath": "k8s.io/kube-apiextensions-server",
"GoVersion": "go1.8",
"GodepVersion": "v79",
"Packages": [
"./..."
],
"Deps": [
{
"ImportPath": "bitbucket.org/ww/goautoneg",
"Rev": "75cd24fc2f2c2a2088577d12123ddee5f54e0675"
},
{
"ImportPath": "github.com/PuerkitoBio/purell",
"Rev": "8a290539e2e8629dbc4e6bad948158f790ec31f4"
},
{
"ImportPath": "github.com/PuerkitoBio/urlesc",
"Rev": "5bd2802263f21d8788851d5305584c82a5c75d7e"
},
{
"ImportPath": "github.com/beorn7/perks/quantile",
"Rev": "3ac7bf7a47d159a033b107610db8a1b6575507a4"
},
{
"ImportPath": "github.com/coreos/etcd/auth/authpb",
"Rev": "20490caaf0dcd96bb4a95e40625559def8ef5b04"
},
{
"ImportPath": "github.com/coreos/etcd/client",
"Rev": "20490caaf0dcd96bb4a95e40625559def8ef5b04"
},
{
"ImportPath": "github.com/coreos/etcd/clientv3",
"Rev": "20490caaf0dcd96bb4a95e40625559def8ef5b04"
},
{
"ImportPath": "github.com/coreos/etcd/etcdserver/api/v3rpc/rpctypes",
"Rev": "20490caaf0dcd96bb4a95e40625559def8ef5b04"
},
{
"ImportPath": "github.com/coreos/etcd/etcdserver/etcdserverpb",
"Rev": "20490caaf0dcd96bb4a95e40625559def8ef5b04"
},
{
"ImportPath": "github.com/coreos/etcd/mvcc/mvccpb",
"Rev": "20490caaf0dcd96bb4a95e40625559def8ef5b04"
},
{
"ImportPath": "github.com/coreos/etcd/pkg/fileutil",
"Rev": "20490caaf0dcd96bb4a95e40625559def8ef5b04"
},
{
"ImportPath": "github.com/coreos/etcd/pkg/pathutil",
"Rev": "20490caaf0dcd96bb4a95e40625559def8ef5b04"
},
{
"ImportPath": "github.com/coreos/etcd/pkg/tlsutil",
"Rev": "20490caaf0dcd96bb4a95e40625559def8ef5b04"
},
{
"ImportPath": "github.com/coreos/etcd/pkg/transport",
"Rev": "20490caaf0dcd96bb4a95e40625559def8ef5b04"
},
{
"ImportPath": "github.com/coreos/etcd/pkg/types",
"Rev": "20490caaf0dcd96bb4a95e40625559def8ef5b04"
},
{
"ImportPath": "github.com/coreos/go-systemd/daemon",
"Rev": "48702e0da86bd25e76cfef347e2adeb434a0d0a6"
},
{
"ImportPath": "github.com/coreos/go-systemd/journal",
"Rev": "48702e0da86bd25e76cfef347e2adeb434a0d0a6"
},
{
"ImportPath": "github.com/coreos/pkg/capnslog",
"Rev": "fa29b1d70f0beaddd4c7021607cc3c3be8ce94b8"
},
{
"ImportPath": "github.com/davecgh/go-spew/spew",
"Rev": "5215b55f46b2b919f50a1df0eaa5886afe4e3b3d"
},
{
"ImportPath": "github.com/docker/distribution/digest",
"Rev": "cd27f179f2c10c5d300e6d09025b538c475b0d51"
},
{
"ImportPath": "github.com/docker/distribution/reference",
"Rev": "cd27f179f2c10c5d300e6d09025b538c475b0d51"
},
{
"ImportPath": "github.com/elazarl/go-bindata-assetfs",
"Rev": "3dcc96556217539f50599357fb481ac0dc7439b9"
},
{
"ImportPath": "github.com/emicklei/go-restful",
"Rev": "09691a3b6378b740595c1002f40c34dd5f218a22"
},
{
"ImportPath": "github.com/emicklei/go-restful/log",
"Rev": "09691a3b6378b740595c1002f40c34dd5f218a22"
},
{
"ImportPath": "github.com/emicklei/go-restful/swagger",
"Rev": "09691a3b6378b740595c1002f40c34dd5f218a22"
},
{
"ImportPath": "github.com/evanphx/json-patch",
"Rev": "ba18e35c5c1b36ef6334cad706eb681153d2d379"
},
{
"ImportPath": "github.com/ghodss/yaml",
"Rev": "73d445a93680fa1a78ae23a5839bad48f32ba1ee"
},
{
"ImportPath": "github.com/go-openapi/analysis",
"Rev": "b44dc874b601d9e4e2f6e19140e794ba24bead3b"
},
{
"ImportPath": "github.com/go-openapi/jsonpointer",
"Rev": "46af16f9f7b149af66e5d1bd010e3574dc06de98"
},
{
"ImportPath": "github.com/go-openapi/jsonreference",
"Rev": "13c6e3589ad90f49bd3e3bbe2c2cb3d7a4142272"
},
{
"ImportPath": "github.com/go-openapi/loads",
"Rev": "18441dfa706d924a39a030ee2c3b1d8d81917b38"
},
{
"ImportPath": "github.com/go-openapi/spec",
"Rev": "6aced65f8501fe1217321abf0749d354824ba2ff"
},
{
"ImportPath": "github.com/go-openapi/swag",
"Rev": "1d0bd113de87027671077d3c71eb3ac5d7dbba72"
},
{
"ImportPath": "github.com/gogo/protobuf/proto",
"Rev": "c0656edd0d9eab7c66d1eb0c568f9039345796f7"
},
{
"ImportPath": "github.com/gogo/protobuf/sortkeys",
"Rev": "c0656edd0d9eab7c66d1eb0c568f9039345796f7"
},
{
"ImportPath": "github.com/golang/glog",
"Rev": "44145f04b68cf362d9c4df2182967c2275eaefed"
},
{
"ImportPath": "github.com/golang/groupcache/lru",
"Rev": "02826c3e79038b59d737d3b1c0a1d937f71a4433"
},
{
"ImportPath": "github.com/golang/protobuf/jsonpb",
"Rev": "4bd1920723d7b7c925de087aa32e2187708897f7"
},
{
"ImportPath": "github.com/golang/protobuf/proto",
"Rev": "4bd1920723d7b7c925de087aa32e2187708897f7"
},
{
"ImportPath": "github.com/google/gofuzz",
"Rev": "44d81051d367757e1c7c6a5a86423ece9afcf63c"
},
{
"ImportPath": "github.com/grpc-ecosystem/go-grpc-prometheus",
"Rev": "2500245aa6110c562d17020fb31a2c133d737799"
},
{
"ImportPath": "github.com/grpc-ecosystem/grpc-gateway/runtime",
"Rev": "84398b94e188ee336f307779b57b3aa91af7063c"
},
{
"ImportPath": "github.com/grpc-ecosystem/grpc-gateway/runtime/internal",
"Rev": "84398b94e188ee336f307779b57b3aa91af7063c"
},
{
"ImportPath": "github.com/grpc-ecosystem/grpc-gateway/utilities",
"Rev": "84398b94e188ee336f307779b57b3aa91af7063c"
},
{
"ImportPath": "github.com/howeyc/gopass",
"Rev": "3ca23474a7c7203e0a0a070fd33508f6efdb9b3d"
},
{
"ImportPath": "github.com/imdario/mergo",
"Rev": "6633656539c1639d9d78127b7d47c622b5d7b6dc"
},
{
"ImportPath": "github.com/inconshreveable/mousetrap",
"Rev": "76626ae9c91c4f2a10f34cad8ce83ea42c93bb75"
},
{
"ImportPath": "github.com/juju/ratelimit",
"Rev": "77ed1c8a01217656d2080ad51981f6e99adaa177"
},
{
"ImportPath": "github.com/mailru/easyjson/buffer",
"Rev": "d5b7844b561a7bc640052f1b935f7b800330d7e0"
},
{
"ImportPath": "github.com/mailru/easyjson/jlexer",
"Rev": "d5b7844b561a7bc640052f1b935f7b800330d7e0"
},
{
"ImportPath": "github.com/mailru/easyjson/jwriter",
"Rev": "d5b7844b561a7bc640052f1b935f7b800330d7e0"
},
{
"ImportPath": "github.com/matttproud/golang_protobuf_extensions/pbutil",
"Rev": "fc2b8d3a73c4867e51861bbdd5ae3c1f0869dd6a"
},
{
"ImportPath": "github.com/pborman/uuid",
"Rev": "ca53cad383cad2479bbba7f7a1a05797ec1386e4"
},
{
"ImportPath": "github.com/pkg/errors",
"Rev": "a22138067af1c4942683050411a841ade67fe1eb"
},
{
"ImportPath": "github.com/prometheus/client_golang/prometheus",
"Rev": "e51041b3fa41cece0dca035740ba6411905be473"
},
{
"ImportPath": "github.com/prometheus/client_model/go",
"Rev": "fa8ad6fec33561be4280a8f0514318c79d7f6cb6"
},
{
"ImportPath": "github.com/prometheus/common/expfmt",
"Rev": "ffe929a3f4c4faeaa10f2b9535c2b1be3ad15650"
},
{
"ImportPath": "github.com/prometheus/common/model",
"Rev": "ffe929a3f4c4faeaa10f2b9535c2b1be3ad15650"
},
{
"ImportPath": "github.com/prometheus/procfs",
"Rev": "454a56f35412459b5e684fd5ec0f9211b94f002a"
},
{
"ImportPath": "github.com/spf13/cobra",
"Rev": "f62e98d28ab7ad31d707ba837a966378465c7b57"
},
{
"ImportPath": "github.com/spf13/pflag",
"Rev": "9ff6c6923cfffbcd502984b8e0c80539a94968b7"
},
{
"ImportPath": "github.com/ugorji/go/codec",
"Rev": "ded73eae5db7e7a0ef6f55aace87a2873c5d2b74"
},
{
"ImportPath": "golang.org/x/crypto/ssh/terminal",
"Rev": "d172538b2cfce0c13cee31e647d0367aa8cd2486"
},
{
"ImportPath": "golang.org/x/net/context",
"Rev": "f2499483f923065a842d38eb4c7f1927e6fc6e6d"
},
{
"ImportPath": "golang.org/x/net/html",
"Rev": "f2499483f923065a842d38eb4c7f1927e6fc6e6d"
},
{
"ImportPath": "golang.org/x/net/html/atom",
"Rev": "f2499483f923065a842d38eb4c7f1927e6fc6e6d"
},
{
"ImportPath": "golang.org/x/net/http2",
"Rev": "f2499483f923065a842d38eb4c7f1927e6fc6e6d"
},
{
"ImportPath": "golang.org/x/net/http2/hpack",
"Rev": "f2499483f923065a842d38eb4c7f1927e6fc6e6d"
},
{
"ImportPath": "golang.org/x/net/idna",
"Rev": "f2499483f923065a842d38eb4c7f1927e6fc6e6d"
},
{
"ImportPath": "golang.org/x/net/internal/timeseries",
"Rev": "f2499483f923065a842d38eb4c7f1927e6fc6e6d"
},
{
"ImportPath": "golang.org/x/net/lex/httplex",
"Rev": "f2499483f923065a842d38eb4c7f1927e6fc6e6d"
},
{
"ImportPath": "golang.org/x/net/trace",
"Rev": "f2499483f923065a842d38eb4c7f1927e6fc6e6d"
},
{
"ImportPath": "golang.org/x/net/websocket",
"Rev": "f2499483f923065a842d38eb4c7f1927e6fc6e6d"
},
{
"ImportPath": "golang.org/x/sys/unix",
"Rev": "8f0908ab3b2457e2e15403d3697c9ef5cb4b57a9"
},
{
"ImportPath": "golang.org/x/text/cases",
"Rev": "2910a502d2bf9e43193af9d68ca516529614eed3"
},
{
"ImportPath": "golang.org/x/text/internal/tag",
"Rev": "2910a502d2bf9e43193af9d68ca516529614eed3"
},
{
"ImportPath": "golang.org/x/text/language",
"Rev": "2910a502d2bf9e43193af9d68ca516529614eed3"
},
{
"ImportPath": "golang.org/x/text/runes",
"Rev": "2910a502d2bf9e43193af9d68ca516529614eed3"
},
{
"ImportPath": "golang.org/x/text/secure/bidirule",
"Rev": "2910a502d2bf9e43193af9d68ca516529614eed3"
},
{
"ImportPath": "golang.org/x/text/secure/precis",
"Rev": "2910a502d2bf9e43193af9d68ca516529614eed3"
},
{
"ImportPath": "golang.org/x/text/transform",
"Rev": "2910a502d2bf9e43193af9d68ca516529614eed3"
},
{
"ImportPath": "golang.org/x/text/unicode/bidi",
"Rev": "2910a502d2bf9e43193af9d68ca516529614eed3"
},
{
"ImportPath": "golang.org/x/text/unicode/norm",
"Rev": "2910a502d2bf9e43193af9d68ca516529614eed3"
},
{
"ImportPath": "golang.org/x/text/width",
"Rev": "2910a502d2bf9e43193af9d68ca516529614eed3"
},
{
"ImportPath": "google.golang.org/grpc",
"Rev": "777daa17ff9b5daef1cfdf915088a2ada3332bf0"
},
{
"ImportPath": "google.golang.org/grpc/codes",
"Rev": "777daa17ff9b5daef1cfdf915088a2ada3332bf0"
},
{
"ImportPath": "google.golang.org/grpc/credentials",
"Rev": "777daa17ff9b5daef1cfdf915088a2ada3332bf0"
},
{
"ImportPath": "google.golang.org/grpc/grpclog",
"Rev": "777daa17ff9b5daef1cfdf915088a2ada3332bf0"
},
{
"ImportPath": "google.golang.org/grpc/internal",
"Rev": "777daa17ff9b5daef1cfdf915088a2ada3332bf0"
},
{
"ImportPath": "google.golang.org/grpc/metadata",
"Rev": "777daa17ff9b5daef1cfdf915088a2ada3332bf0"
},
{
"ImportPath": "google.golang.org/grpc/naming",
"Rev": "777daa17ff9b5daef1cfdf915088a2ada3332bf0"
},
{
"ImportPath": "google.golang.org/grpc/peer",
"Rev": "777daa17ff9b5daef1cfdf915088a2ada3332bf0"
},
{
"ImportPath": "google.golang.org/grpc/transport",
"Rev": "777daa17ff9b5daef1cfdf915088a2ada3332bf0"
},
{
"ImportPath": "gopkg.in/inf.v0",
"Rev": "3887ee99ecf07df5b447e9b00d9c0b2adaa9f3e4"
},
{
"ImportPath": "gopkg.in/natefinch/lumberjack.v2",
"Rev": "20b71e5b60d756d3d2f80def009790325acc2b23"
},
{
"ImportPath": "gopkg.in/yaml.v2",
"Rev": "53feefa2559fb8dfa8d81baad31be332c97d6c77"
}
]
}

View File

@@ -0,0 +1,12 @@
apiVersion: apiextensions.k8s.io/v1alpha1
kind: CustomResource
metadata:
name: noxus.mygroup.example.com
spec:
group: mygroup.example.com
version: v1alpha1
names:
name: noxus
singular: noxu
kind: Noxu
listKind: NoxuList

View File

@@ -0,0 +1,12 @@
apiVersion: apiregistration.k8s.io/v1alpha1
kind: APIService
metadata:
name: v1alpha1.apiextensions.k8s.io
spec:
insecureSkipTLSVerify: true
group: apiextensions.k8s.io
priority: 100
service:
name: api
namespace: kube-apiextensions
version: v1alpha1

View File

@@ -0,0 +1,13 @@
apiVersion: rbac.authorization.k8s.io/v1alpha1
kind: ClusterRoleBinding
metadata:
name: apiextensions:system:auth-delegator
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: system:auth-delegator
subjects:
- apiVersion: v1
kind: ServiceAccount
name: apiserver
namespace: kube-apiextensions

View File

@@ -0,0 +1,14 @@
apiVersion: rbac.authorization.k8s.io/v1alpha1
kind: RoleBinding
metadata:
name: apiextensions-auth-reader
namespace: kube-system
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: extension-apiserver-authentication-reader
subjects:
- apiVersion: v1
kind: ServiceAccount
name: apiserver
namespace: kube-apiextensions

View File

@@ -0,0 +1,26 @@
apiVersion: v1
kind: ReplicationController
metadata:
name: apiextensions-server
namespace: kube-apiextensions
labels:
apiserver: "true"
spec:
replicas: 1
selector:
apiserver: "true"
template:
metadata:
labels:
apiserver: "true"
spec:
serviceAccountName: apiserver
containers:
- name: apiextensions-server
image: kube-apiextensions-server:latest
imagePullPolicy: Never
args:
- "--etcd-servers=http://localhost:2379"
- "--audit-log-path=-"
- name: etcd
image: quay.io/coreos/etcd:v3.0.17

View File

@@ -0,0 +1,5 @@
kind: ServiceAccount
apiVersion: v1
metadata:
name: apiserver
namespace: kube-apiextensions

View File

@@ -0,0 +1,12 @@
apiVersion: v1
kind: Service
metadata:
name: api
namespace: kube-apiextensions
spec:
ports:
- port: 443
protocol: TCP
targetPort: 443
selector:
apiserver: "true"

View File

@@ -0,0 +1,17 @@
# Copyright 2017 The Kubernetes 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.
FROM fedora
ADD kube-apiextensions-server /
ENTRYPOINT ["/kube-apiextensions-server"]

View File

@@ -0,0 +1,30 @@
#!/bin/bash
# Copyright 2017 The Kubernetes 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.
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/../../../../..
source "${KUBE_ROOT}/hack/lib/util.sh"
# Register function to be called on EXIT to remove generated binary.
function cleanup {
rm "${KUBE_ROOT}/vendor/k8s.io/kube-apiextensions-server/artifacts/simple-image/kube-apiextensions-server"
}
trap cleanup EXIT
pushd "${KUBE_ROOT}/vendor/k8s.io/kube-apiextensions-server"
cp -v ../../../../_output/local/bin/linux/amd64/kube-apiextensions-server ./artifacts/simple-image/kube-apiextensions-server
docker build -t kube-apiextensions-server:latest ./artifacts/simple-image
popd

View File

@@ -0,0 +1,79 @@
#!/bin/bash
# Copyright 2017 The Kubernetes 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.
set -o errexit
set -o nounset
set -o pipefail
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/../../../../..
APIFEDERATOR_ROOT=$(dirname "${BASH_SOURCE}")/..
source "${KUBE_ROOT}/hack/lib/init.sh"
if LANG=C sed --help 2>&1 | grep -q GNU; then
SED="sed"
elif which gsed &>/dev/null; then
SED="gsed"
else
echo "Failed to find GNU sed as sed or gsed. If you are on Mac: brew install gnu-sed." >&2
exit 1
fi
# Register function to be called on EXIT to remove generated binary.
function cleanup {
rm -f "${CLIENTGEN:-}"
rm -f "${listergen:-}"
rm -f "${informergen:-}"
}
trap cleanup EXIT
echo "Building client-gen"
CLIENTGEN="${PWD}/client-gen-binary"
go build -o "${CLIENTGEN}" ./cmd/libs/go2idl/client-gen
PREFIX=k8s.io/kube-apiextensions-server/pkg/apis
INPUT_BASE="--input-base ${PREFIX}"
INPUT_APIS=(
apiextensions/
apiextensions/v1alpha1
)
INPUT="--input ${INPUT_APIS[@]}"
CLIENTSET_PATH="--clientset-path k8s.io/kube-apiextensions-server/pkg/client/clientset"
${CLIENTGEN} ${INPUT_BASE} ${INPUT} ${CLIENTSET_PATH} --output-base ${KUBE_ROOT}/vendor
${CLIENTGEN} --clientset-name="clientset" ${INPUT_BASE} --input apiextensions/v1alpha1 ${CLIENTSET_PATH} --output-base ${KUBE_ROOT}/vendor
echo "Building lister-gen"
listergen="${PWD}/lister-gen"
go build -o "${listergen}" ./cmd/libs/go2idl/lister-gen
LISTER_INPUT="--input-dirs k8s.io/kube-apiextensions-server/pkg/apis/apiextensions --input-dirs k8s.io/kube-apiextensions-server/pkg/apis/apiextensions/v1alpha1"
LISTER_PATH="--output-package k8s.io/kube-apiextensions-server/pkg/client/listers"
${listergen} ${LISTER_INPUT} ${LISTER_PATH} --output-base ${KUBE_ROOT}/vendor
echo "Building informer-gen"
informergen="${PWD}/informer-gen"
go build -o "${informergen}" ./cmd/libs/go2idl/informer-gen
${informergen} \
--output-base ${KUBE_ROOT}/vendor \
--input-dirs k8s.io/kube-apiextensions-server/pkg/apis/apiextensions --input-dirs k8s.io/kube-apiextensions-server/pkg/apis/apiextensions/v1alpha1 \
--versioned-clientset-package k8s.io/kube-apiextensions-server/pkg/client/clientset/clientset \
--internal-clientset-package k8s.io/kube-apiextensions-server/pkg/client/clientset/internalclientset \
--listers-package k8s.io/kube-apiextensions-server/pkg/client/listers \
--output-package k8s.io/kube-apiextensions-server/pkg/client/informers
"$@"

View File

@@ -0,0 +1,50 @@
#!/bin/bash
# Copyright 2017 The Kubernetes 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.
set -o errexit
set -o nounset
set -o pipefail
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/../../../../..
APIFEDERATOR_ROOT=$(dirname "${BASH_SOURCE}")/..
source "${KUBE_ROOT}/hack/lib/init.sh"
DIFFROOT="${APIFEDERATOR_ROOT}/pkg"
TMP_DIFFROOT="${APIFEDERATOR_ROOT}/_tmp/pkg"
_tmp="${APIFEDERATOR_ROOT}/_tmp"
cleanup() {
rm -rf "${_tmp}"
}
trap "cleanup" EXIT SIGINT
cleanup
mkdir -p "${TMP_DIFFROOT}"
cp -a "${DIFFROOT}"/* "${TMP_DIFFROOT}"
"${APIFEDERATOR_ROOT}/hack/update-codegen.sh"
echo "diffing ${DIFFROOT} against freshly generated codegen"
ret=0
diff -Naupr "${DIFFROOT}" "${TMP_DIFFROOT}" || ret=$?
cp -a "${TMP_DIFFROOT}"/* "${DIFFROOT}"
if [[ $ret -eq 0 ]]
then
echo "${DIFFROOT} up to date."
else
echo "${DIFFROOT} is out of date. Please run hack/update-codegen.sh"
exit 1
fi

View File

@@ -0,0 +1,42 @@
/*
Copyright 2017 The Kubernetes 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 main
import (
"flag"
"os"
"runtime"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/apiserver/pkg/util/logs"
"k8s.io/kube-apiextensions-server/pkg/cmd/server"
)
func main() {
logs.InitLogs()
defer logs.FlushLogs()
if len(os.Getenv("GOMAXPROCS")) == 0 {
runtime.GOMAXPROCS(runtime.NumCPU())
}
cmd := server.NewCommandStartCustomResourcesServer(os.Stdout, os.Stderr, wait.NeverStop)
cmd.Flags().AddGoFlagSet(flag.CommandLine)
if err := cmd.Execute(); err != nil {
panic(err)
}
}

View File

@@ -0,0 +1,25 @@
package(default_visibility = ["//visibility:public"])
licenses(["notice"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = [
"doc.go",
"register.go",
"types.go",
"zz_generated.deepcopy.go",
],
tags = ["automanaged"],
deps = [
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/conversion:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
],
)

View File

@@ -0,0 +1,21 @@
/*
Copyright 2017 The Kubernetes 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.
*/
// +k8s:deepcopy-gen=package,register
// Package apiextensions is the internal version of the API.
// +groupName=apiextensions.k8s.io
package apiextensions // import "k8s.io/apiextension-server/pkg/apis/apiextensions"

View File

@@ -0,0 +1,32 @@
package(default_visibility = ["//visibility:public"])
licenses(["notice"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
"go_test",
)
go_test(
name = "go_default_test",
srcs = ["install_test.go"],
library = ":go_default_library",
tags = ["automanaged"],
deps = ["//vendor/k8s.io/apimachinery/pkg/api/testing:go_default_library"],
)
go_library(
name = "go_default_library",
srcs = ["install.go"],
tags = ["automanaged"],
deps = [
"//vendor/k8s.io/apimachinery/pkg/apimachinery/announced:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apimachinery/registered:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/sets:go_default_library",
"//vendor/k8s.io/client-go/pkg/api:go_default_library",
"//vendor/k8s.io/kube-apiextensions-server/pkg/apis/apiextensions:go_default_library",
"//vendor/k8s.io/kube-apiextensions-server/pkg/apis/apiextensions/v1alpha1:go_default_library",
],
)

View File

@@ -0,0 +1,49 @@
/*
Copyright 2017 The Kubernetes 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 install
import (
"k8s.io/apimachinery/pkg/apimachinery/announced"
"k8s.io/apimachinery/pkg/apimachinery/registered"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/client-go/pkg/api"
"k8s.io/kube-apiextensions-server/pkg/apis/apiextensions"
"k8s.io/kube-apiextensions-server/pkg/apis/apiextensions/v1alpha1"
)
func init() {
Install(api.GroupFactoryRegistry, api.Registry, api.Scheme)
}
// Install registers the API group and adds types to a scheme
func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *registered.APIRegistrationManager, scheme *runtime.Scheme) {
if err := announced.NewGroupMetaFactory(
&announced.GroupMetaFactoryArgs{
GroupName: apiextensions.GroupName,
RootScopedKinds: sets.NewString("CustomResource"),
VersionPreferenceOrder: []string{v1alpha1.SchemeGroupVersion.Version},
ImportPrefix: "k8s.io/kube-apiextensions-server/pkg/apis/apiextension",
AddInternalObjectsToScheme: apiextensions.AddToScheme,
},
announced.VersionToSchemeFunc{
v1alpha1.SchemeGroupVersion.Version: v1alpha1.AddToScheme,
},
).Announce(groupFactoryRegistry).RegisterAndEnable(registry, scheme); err != nil {
panic(err)
}
}

View File

@@ -0,0 +1,27 @@
/*
Copyright 2017 The Kubernetes 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 install
import (
"testing"
apitesting "k8s.io/apimachinery/pkg/api/testing"
)
func TestRoundTripTypes(t *testing.T) {
apitesting.RoundTripTestForAPIGroup(t, Install, nil)
}

View File

@@ -0,0 +1,51 @@
/*
Copyright 2017 The Kubernetes 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 apiextensions
import (
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
)
const GroupName = "apiextensions.k8s.io"
// SchemeGroupVersion is group version used to register these objects
var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: runtime.APIVersionInternal}
// 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 back 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 api.Scheme.
func addKnownTypes(scheme *runtime.Scheme) error {
scheme.AddKnownTypes(SchemeGroupVersion,
&CustomResource{},
&CustomResourceList{},
)
return nil
}

View File

@@ -0,0 +1,129 @@
/*
Copyright 2017 The Kubernetes 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 apiextensions
import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
// CustomResourceSpec describes how a user wants their resource to appear
type CustomResourceSpec struct {
// Group is the group this resource belongs in
Group string
// Version is the version this resource belongs in
Version string
// Names are the names used to describe this custom resource
Names CustomResourceNames
// Scope indicates whether this resource is cluster or namespace scoped. Default is namespaced
Scope ResourceScope
}
// CustomResourceNames indicates the names to serve this CustomResource
type CustomResourceNames struct {
// Plural is the plural name of the resource to serve. It must match the name of the TPR-registration
// too: plural.group and it must be all lowercase.
Plural string
// Singular is the singular name of the resource. It must be all lowercase Defaults to lowercased <kind>
Singular string
// ShortNames are short names for the resource. It must be all lowercase.
ShortNames []string
// Kind is the serialized kind of the resource. It is normally CamelCase and singular.
Kind string
// ListKind is the serialized kind of the list for this resource. Defaults to <kind>List.
ListKind string
}
// ResourceScope is an enum defining the different scopes availabe to a custom resource
type ResourceScope string
const (
ClusterScoped ResourceScope = "Cluster"
NamespaceScoped ResourceScope = "Namespaced"
)
type ConditionStatus string
// These are valid condition statuses. "ConditionTrue" means a resource is in the condition.
// "ConditionFalse" means a resource is not in the condition. "ConditionUnknown" means kubernetes
// can't decide if a resource is in the condition or not. In the future, we could add other
// intermediate conditions, e.g. ConditionDegraded.
const (
ConditionTrue ConditionStatus = "True"
ConditionFalse ConditionStatus = "False"
ConditionUnknown ConditionStatus = "Unknown"
)
// CustomResourceConditionType is a valid value for CustomResourceCondition.Type
type CustomResourceConditionType string
const (
// NameConflict means the names chosen for this CustomResource conflict with others in the group.
NameConflict CustomResourceConditionType = "NameConflict"
// Terminating means that the CustomResource has been deleted and is cleaning up.
Terminating CustomResourceConditionType = "Terminating"
)
// CustomResourceCondition contains details for the current condition of this pod.
type CustomResourceCondition struct {
// Type is the type of the condition.
Type CustomResourceConditionType
// Status is the status of the condition.
// Can be True, False, Unknown.
Status ConditionStatus
// Last time the condition transitioned from one status to another.
// +optional
LastTransitionTime metav1.Time
// Unique, one-word, CamelCase reason for the condition's last transition.
// +optional
Reason string
// Human-readable message indicating details about last transition.
// +optional
Message string
}
// CustomResourceStatus indicates the state of the CustomResource
type CustomResourceStatus struct {
// Conditions indicate state for particular aspects of a CustomResource
Conditions []CustomResourceCondition
// AcceptedNames are the names that are actually being used to serve discovery
// They may be different than the names in spec.
AcceptedNames CustomResourceNames
}
// +genclient=true
// +nonNamespaced=true
// CustomResource represents a resource that should be exposed on the API server. Its name MUST be in the format
// <.spec.name>.<.spec.group>.
type CustomResource struct {
metav1.TypeMeta
metav1.ObjectMeta
// Spec describes how the user wants the resources to appear
Spec CustomResourceSpec
// Status indicates the actual state of the CustomResource
Status CustomResourceStatus
}
// CustomResourceList is a list of CustomResource objects.
type CustomResourceList struct {
metav1.TypeMeta
metav1.ListMeta
// Items individual CustomResources
Items []CustomResource
}

View File

@@ -0,0 +1,27 @@
package(default_visibility = ["//visibility:public"])
licenses(["notice"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = [
"doc.go",
"register.go",
"types.go",
"zz_generated.conversion.go",
"zz_generated.deepcopy.go",
],
tags = ["automanaged"],
deps = [
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/conversion:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
"//vendor/k8s.io/kube-apiextensions-server/pkg/apis/apiextensions:go_default_library",
],
)

View File

@@ -0,0 +1,22 @@
/*
Copyright 2017 The Kubernetes 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.
*/
// +k8s:deepcopy-gen=package,register
// +k8s:conversion-gen=k8s.io/kubernetes/vendor/k8s.io/kube-apiextensions-server/pkg/apis/apiextensions
// Package v1alpha1 is the v1alpha1 version of the API.
// +groupName=apiextensions.k8s.io
package v1alpha1 // import "k8s.io/apiextension-server/pkg/apis/apiextensions/v1alpha1"

View File

@@ -0,0 +1,53 @@
/*
Copyright 2017 The Kubernetes 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"
"k8s.io/apimachinery/pkg/runtime/schema"
)
const GroupName = "apiextensions.k8s.io"
// SchemeGroupVersion is group version used to register these objects
var SchemeGroupVersion = schema.GroupVersion{Group: 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 back 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 api.Scheme.
func addKnownTypes(scheme *runtime.Scheme) error {
scheme.AddKnownTypes(SchemeGroupVersion,
&CustomResource{},
&CustomResourceList{},
)
metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
return nil
}

View File

@@ -0,0 +1,129 @@
/*
Copyright 2017 The Kubernetes 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"
// CustomResourceSpec describes how a user wants their resource to appear
type CustomResourceSpec struct {
// Group is the group this resource belongs in
Group string `json:"group" protobuf:"bytes,1,opt,name=group"`
// Version is the version this resource belongs in
Version string `json:"version" protobuf:"bytes,2,opt,name=version"`
// Names are the names used to describe this custom resource
Names CustomResourceNames `json:"names" protobuf:"bytes,3,opt,name=names"`
// Scope indicates whether this resource is cluster or namespace scoped. Default is namespaced
Scope ResourceScope `json:"scope" protobuf:"bytes,4,opt,name=scope,casttype=ResourceScope"`
}
// CustomResourceNames indicates the names to serve this CustomResource
type CustomResourceNames struct {
// Plural is the plural name of the resource to serve. It must match the name of the TPR-registration
// too: plural.group and it must be all lowercase.
Plural string `json:"plural" protobuf:"bytes,1,opt,name=plural"`
// Singular is the singular name of the resource. It must be all lowercase Defaults to lowercased <kind>
Singular string `json:"singular,omitempty" protobuf:"bytes,2,opt,name=singular"`
// ShortNames are short names for the resource. It must be all lowercase.
ShortNames []string `json:"shortNames,omitempty" protobuf:"bytes,3,opt,name=shortNames"`
// Kind is the serialized kind of the resource. It is normally CamelCase and singular.
Kind string `json:"kind" protobuf:"bytes,4,opt,name=kind"`
// ListKind is the serialized kind of the list for this resource. Defaults to <kind>List.
ListKind string `json:"listKind,omitempty" protobuf:"bytes,5,opt,name=listKind"`
}
// ResourceScope is an enum defining the different scopes availabe to a custom resource
type ResourceScope string
const (
ClusterScoped ResourceScope = "Cluster"
NamespaceScoped ResourceScope = "Namespaced"
)
type ConditionStatus string
// These are valid condition statuses. "ConditionTrue" means a resource is in the condition.
// "ConditionFalse" means a resource is not in the condition. "ConditionUnknown" means kubernetes
// can't decide if a resource is in the condition or not. In the future, we could add other
// intermediate conditions, e.g. ConditionDegraded.
const (
ConditionTrue ConditionStatus = "True"
ConditionFalse ConditionStatus = "False"
ConditionUnknown ConditionStatus = "Unknown"
)
// CustomResourceConditionType is a valid value for CustomResourceCondition.Type
type CustomResourceConditionType string
const (
// NameConflict means the names chosen for this CustomResource conflict with others in the group.
NameConflict CustomResourceConditionType = "NameConflict"
// Terminating means that the CustomResource has been deleted and is cleaning up.
Terminating CustomResourceConditionType = "Terminating"
)
// CustomResourceCondition contains details for the current condition of this pod.
type CustomResourceCondition struct {
// Type is the type of the condition.
Type CustomResourceConditionType `json:"type" protobuf:"bytes,1,opt,name=type,casttype=CustomResourceConditionType"`
// Status is the status of the condition.
// Can be True, False, Unknown.
Status ConditionStatus `json:"status" protobuf:"bytes,2,opt,name=status,casttype=ConditionStatus"`
// Last time the condition transitioned from one status to another.
// +optional
LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty" protobuf:"bytes,3,opt,name=lastTransitionTime"`
// Unique, one-word, CamelCase reason for the condition's last transition.
// +optional
Reason string `json:"reason,omitempty" protobuf:"bytes,4,opt,name=reason"`
// Human-readable message indicating details about last transition.
// +optional
Message string `json:"message,omitempty" protobuf:"bytes,5,opt,name=message"`
}
// CustomResourceStatus indicates the state of the CustomResource
type CustomResourceStatus struct {
// Conditions indicate state for particular aspects of a CustomResource
Conditions []CustomResourceCondition `json:"conditions" protobuf:"bytes,1,opt,name=conditions"`
// AcceptedNames are the names that are actually being used to serve discovery
// They may be different than the names in spec.
AcceptedNames CustomResourceNames `json:"acceptedNames" protobuf:"bytes,2,opt,name=acceptedNames"`
}
// +genclient=true
// +nonNamespaced=true
// CustomResource represents a resource that should be exposed on the API server. Its name MUST be in the format
// <.spec.name>.<.spec.group>.
type CustomResource struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
// Spec describes how the user wants the resources to appear
Spec CustomResourceSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"`
// Status indicates the actual state of the CustomResource
Status CustomResourceStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"`
}
// CustomResourceList is a list of CustomResource objects.
type CustomResourceList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
// Items individual CustomResources
Items []CustomResource `json:"items" protobuf:"bytes,2,rep,name=items"`
}

View File

@@ -0,0 +1,225 @@
// +build !ignore_autogenerated
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// This file was autogenerated by conversion-gen. Do not edit it manually!
package v1alpha1
import (
conversion "k8s.io/apimachinery/pkg/conversion"
runtime "k8s.io/apimachinery/pkg/runtime"
apiextensions "k8s.io/kube-apiextensions-server/pkg/apis/apiextensions"
unsafe "unsafe"
)
func init() {
SchemeBuilder.Register(RegisterConversions)
}
// RegisterConversions adds conversion functions to the given scheme.
// Public to allow building arbitrary schemes.
func RegisterConversions(scheme *runtime.Scheme) error {
return scheme.AddGeneratedConversionFuncs(
Convert_v1alpha1_CustomResource_To_apiextensions_CustomResource,
Convert_apiextensions_CustomResource_To_v1alpha1_CustomResource,
Convert_v1alpha1_CustomResourceCondition_To_apiextensions_CustomResourceCondition,
Convert_apiextensions_CustomResourceCondition_To_v1alpha1_CustomResourceCondition,
Convert_v1alpha1_CustomResourceList_To_apiextensions_CustomResourceList,
Convert_apiextensions_CustomResourceList_To_v1alpha1_CustomResourceList,
Convert_v1alpha1_CustomResourceNames_To_apiextensions_CustomResourceNames,
Convert_apiextensions_CustomResourceNames_To_v1alpha1_CustomResourceNames,
Convert_v1alpha1_CustomResourceSpec_To_apiextensions_CustomResourceSpec,
Convert_apiextensions_CustomResourceSpec_To_v1alpha1_CustomResourceSpec,
Convert_v1alpha1_CustomResourceStatus_To_apiextensions_CustomResourceStatus,
Convert_apiextensions_CustomResourceStatus_To_v1alpha1_CustomResourceStatus,
)
}
func autoConvert_v1alpha1_CustomResource_To_apiextensions_CustomResource(in *CustomResource, out *apiextensions.CustomResource, s conversion.Scope) error {
out.ObjectMeta = in.ObjectMeta
if err := Convert_v1alpha1_CustomResourceSpec_To_apiextensions_CustomResourceSpec(&in.Spec, &out.Spec, s); err != nil {
return err
}
if err := Convert_v1alpha1_CustomResourceStatus_To_apiextensions_CustomResourceStatus(&in.Status, &out.Status, s); err != nil {
return err
}
return nil
}
// Convert_v1alpha1_CustomResource_To_apiextensions_CustomResource is an autogenerated conversion function.
func Convert_v1alpha1_CustomResource_To_apiextensions_CustomResource(in *CustomResource, out *apiextensions.CustomResource, s conversion.Scope) error {
return autoConvert_v1alpha1_CustomResource_To_apiextensions_CustomResource(in, out, s)
}
func autoConvert_apiextensions_CustomResource_To_v1alpha1_CustomResource(in *apiextensions.CustomResource, out *CustomResource, s conversion.Scope) error {
out.ObjectMeta = in.ObjectMeta
if err := Convert_apiextensions_CustomResourceSpec_To_v1alpha1_CustomResourceSpec(&in.Spec, &out.Spec, s); err != nil {
return err
}
if err := Convert_apiextensions_CustomResourceStatus_To_v1alpha1_CustomResourceStatus(&in.Status, &out.Status, s); err != nil {
return err
}
return nil
}
// Convert_apiextensions_CustomResource_To_v1alpha1_CustomResource is an autogenerated conversion function.
func Convert_apiextensions_CustomResource_To_v1alpha1_CustomResource(in *apiextensions.CustomResource, out *CustomResource, s conversion.Scope) error {
return autoConvert_apiextensions_CustomResource_To_v1alpha1_CustomResource(in, out, s)
}
func autoConvert_v1alpha1_CustomResourceCondition_To_apiextensions_CustomResourceCondition(in *CustomResourceCondition, out *apiextensions.CustomResourceCondition, s conversion.Scope) error {
out.Type = apiextensions.CustomResourceConditionType(in.Type)
out.Status = apiextensions.ConditionStatus(in.Status)
out.LastTransitionTime = in.LastTransitionTime
out.Reason = in.Reason
out.Message = in.Message
return nil
}
// Convert_v1alpha1_CustomResourceCondition_To_apiextensions_CustomResourceCondition is an autogenerated conversion function.
func Convert_v1alpha1_CustomResourceCondition_To_apiextensions_CustomResourceCondition(in *CustomResourceCondition, out *apiextensions.CustomResourceCondition, s conversion.Scope) error {
return autoConvert_v1alpha1_CustomResourceCondition_To_apiextensions_CustomResourceCondition(in, out, s)
}
func autoConvert_apiextensions_CustomResourceCondition_To_v1alpha1_CustomResourceCondition(in *apiextensions.CustomResourceCondition, out *CustomResourceCondition, s conversion.Scope) error {
out.Type = CustomResourceConditionType(in.Type)
out.Status = ConditionStatus(in.Status)
out.LastTransitionTime = in.LastTransitionTime
out.Reason = in.Reason
out.Message = in.Message
return nil
}
// Convert_apiextensions_CustomResourceCondition_To_v1alpha1_CustomResourceCondition is an autogenerated conversion function.
func Convert_apiextensions_CustomResourceCondition_To_v1alpha1_CustomResourceCondition(in *apiextensions.CustomResourceCondition, out *CustomResourceCondition, s conversion.Scope) error {
return autoConvert_apiextensions_CustomResourceCondition_To_v1alpha1_CustomResourceCondition(in, out, s)
}
func autoConvert_v1alpha1_CustomResourceList_To_apiextensions_CustomResourceList(in *CustomResourceList, out *apiextensions.CustomResourceList, s conversion.Scope) error {
out.ListMeta = in.ListMeta
out.Items = *(*[]apiextensions.CustomResource)(unsafe.Pointer(&in.Items))
return nil
}
// Convert_v1alpha1_CustomResourceList_To_apiextensions_CustomResourceList is an autogenerated conversion function.
func Convert_v1alpha1_CustomResourceList_To_apiextensions_CustomResourceList(in *CustomResourceList, out *apiextensions.CustomResourceList, s conversion.Scope) error {
return autoConvert_v1alpha1_CustomResourceList_To_apiextensions_CustomResourceList(in, out, s)
}
func autoConvert_apiextensions_CustomResourceList_To_v1alpha1_CustomResourceList(in *apiextensions.CustomResourceList, out *CustomResourceList, s conversion.Scope) error {
out.ListMeta = in.ListMeta
if in.Items == nil {
out.Items = make([]CustomResource, 0)
} else {
out.Items = *(*[]CustomResource)(unsafe.Pointer(&in.Items))
}
return nil
}
// Convert_apiextensions_CustomResourceList_To_v1alpha1_CustomResourceList is an autogenerated conversion function.
func Convert_apiextensions_CustomResourceList_To_v1alpha1_CustomResourceList(in *apiextensions.CustomResourceList, out *CustomResourceList, s conversion.Scope) error {
return autoConvert_apiextensions_CustomResourceList_To_v1alpha1_CustomResourceList(in, out, s)
}
func autoConvert_v1alpha1_CustomResourceNames_To_apiextensions_CustomResourceNames(in *CustomResourceNames, out *apiextensions.CustomResourceNames, s conversion.Scope) error {
out.Plural = in.Plural
out.Singular = in.Singular
out.ShortNames = *(*[]string)(unsafe.Pointer(&in.ShortNames))
out.Kind = in.Kind
out.ListKind = in.ListKind
return nil
}
// Convert_v1alpha1_CustomResourceNames_To_apiextensions_CustomResourceNames is an autogenerated conversion function.
func Convert_v1alpha1_CustomResourceNames_To_apiextensions_CustomResourceNames(in *CustomResourceNames, out *apiextensions.CustomResourceNames, s conversion.Scope) error {
return autoConvert_v1alpha1_CustomResourceNames_To_apiextensions_CustomResourceNames(in, out, s)
}
func autoConvert_apiextensions_CustomResourceNames_To_v1alpha1_CustomResourceNames(in *apiextensions.CustomResourceNames, out *CustomResourceNames, s conversion.Scope) error {
out.Plural = in.Plural
out.Singular = in.Singular
out.ShortNames = *(*[]string)(unsafe.Pointer(&in.ShortNames))
out.Kind = in.Kind
out.ListKind = in.ListKind
return nil
}
// Convert_apiextensions_CustomResourceNames_To_v1alpha1_CustomResourceNames is an autogenerated conversion function.
func Convert_apiextensions_CustomResourceNames_To_v1alpha1_CustomResourceNames(in *apiextensions.CustomResourceNames, out *CustomResourceNames, s conversion.Scope) error {
return autoConvert_apiextensions_CustomResourceNames_To_v1alpha1_CustomResourceNames(in, out, s)
}
func autoConvert_v1alpha1_CustomResourceSpec_To_apiextensions_CustomResourceSpec(in *CustomResourceSpec, out *apiextensions.CustomResourceSpec, s conversion.Scope) error {
out.Group = in.Group
out.Version = in.Version
if err := Convert_v1alpha1_CustomResourceNames_To_apiextensions_CustomResourceNames(&in.Names, &out.Names, s); err != nil {
return err
}
out.Scope = apiextensions.ResourceScope(in.Scope)
return nil
}
// Convert_v1alpha1_CustomResourceSpec_To_apiextensions_CustomResourceSpec is an autogenerated conversion function.
func Convert_v1alpha1_CustomResourceSpec_To_apiextensions_CustomResourceSpec(in *CustomResourceSpec, out *apiextensions.CustomResourceSpec, s conversion.Scope) error {
return autoConvert_v1alpha1_CustomResourceSpec_To_apiextensions_CustomResourceSpec(in, out, s)
}
func autoConvert_apiextensions_CustomResourceSpec_To_v1alpha1_CustomResourceSpec(in *apiextensions.CustomResourceSpec, out *CustomResourceSpec, s conversion.Scope) error {
out.Group = in.Group
out.Version = in.Version
if err := Convert_apiextensions_CustomResourceNames_To_v1alpha1_CustomResourceNames(&in.Names, &out.Names, s); err != nil {
return err
}
out.Scope = ResourceScope(in.Scope)
return nil
}
// Convert_apiextensions_CustomResourceSpec_To_v1alpha1_CustomResourceSpec is an autogenerated conversion function.
func Convert_apiextensions_CustomResourceSpec_To_v1alpha1_CustomResourceSpec(in *apiextensions.CustomResourceSpec, out *CustomResourceSpec, s conversion.Scope) error {
return autoConvert_apiextensions_CustomResourceSpec_To_v1alpha1_CustomResourceSpec(in, out, s)
}
func autoConvert_v1alpha1_CustomResourceStatus_To_apiextensions_CustomResourceStatus(in *CustomResourceStatus, out *apiextensions.CustomResourceStatus, s conversion.Scope) error {
out.Conditions = *(*[]apiextensions.CustomResourceCondition)(unsafe.Pointer(&in.Conditions))
if err := Convert_v1alpha1_CustomResourceNames_To_apiextensions_CustomResourceNames(&in.AcceptedNames, &out.AcceptedNames, s); err != nil {
return err
}
return nil
}
// Convert_v1alpha1_CustomResourceStatus_To_apiextensions_CustomResourceStatus is an autogenerated conversion function.
func Convert_v1alpha1_CustomResourceStatus_To_apiextensions_CustomResourceStatus(in *CustomResourceStatus, out *apiextensions.CustomResourceStatus, s conversion.Scope) error {
return autoConvert_v1alpha1_CustomResourceStatus_To_apiextensions_CustomResourceStatus(in, out, s)
}
func autoConvert_apiextensions_CustomResourceStatus_To_v1alpha1_CustomResourceStatus(in *apiextensions.CustomResourceStatus, out *CustomResourceStatus, s conversion.Scope) error {
if in.Conditions == nil {
out.Conditions = make([]CustomResourceCondition, 0)
} else {
out.Conditions = *(*[]CustomResourceCondition)(unsafe.Pointer(&in.Conditions))
}
if err := Convert_apiextensions_CustomResourceNames_To_v1alpha1_CustomResourceNames(&in.AcceptedNames, &out.AcceptedNames, s); err != nil {
return err
}
return nil
}
// Convert_apiextensions_CustomResourceStatus_To_v1alpha1_CustomResourceStatus is an autogenerated conversion function.
func Convert_apiextensions_CustomResourceStatus_To_v1alpha1_CustomResourceStatus(in *apiextensions.CustomResourceStatus, out *CustomResourceStatus, s conversion.Scope) error {
return autoConvert_apiextensions_CustomResourceStatus_To_v1alpha1_CustomResourceStatus(in, out, s)
}

View File

@@ -0,0 +1,152 @@
// +build !ignore_autogenerated
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// This file was autogenerated by deepcopy-gen. Do not edit it manually!
package v1alpha1
import (
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
conversion "k8s.io/apimachinery/pkg/conversion"
runtime "k8s.io/apimachinery/pkg/runtime"
reflect "reflect"
)
func init() {
SchemeBuilder.Register(RegisterDeepCopies)
}
// RegisterDeepCopies adds deep-copy functions to the given scheme. Public
// to allow building arbitrary schemes.
func RegisterDeepCopies(scheme *runtime.Scheme) error {
return scheme.AddGeneratedDeepCopyFuncs(
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_v1alpha1_CustomResource, InType: reflect.TypeOf(&CustomResource{})},
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_v1alpha1_CustomResourceCondition, InType: reflect.TypeOf(&CustomResourceCondition{})},
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_v1alpha1_CustomResourceList, InType: reflect.TypeOf(&CustomResourceList{})},
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_v1alpha1_CustomResourceNames, InType: reflect.TypeOf(&CustomResourceNames{})},
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_v1alpha1_CustomResourceSpec, InType: reflect.TypeOf(&CustomResourceSpec{})},
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_v1alpha1_CustomResourceStatus, InType: reflect.TypeOf(&CustomResourceStatus{})},
)
}
func DeepCopy_v1alpha1_CustomResource(in interface{}, out interface{}, c *conversion.Cloner) error {
{
in := in.(*CustomResource)
out := out.(*CustomResource)
*out = *in
if newVal, err := c.DeepCopy(&in.ObjectMeta); err != nil {
return err
} else {
out.ObjectMeta = *newVal.(*v1.ObjectMeta)
}
if newVal, err := c.DeepCopy(&in.Spec); err != nil {
return err
} else {
out.Spec = *newVal.(*CustomResourceSpec)
}
if newVal, err := c.DeepCopy(&in.Status); err != nil {
return err
} else {
out.Status = *newVal.(*CustomResourceStatus)
}
return nil
}
}
func DeepCopy_v1alpha1_CustomResourceCondition(in interface{}, out interface{}, c *conversion.Cloner) error {
{
in := in.(*CustomResourceCondition)
out := out.(*CustomResourceCondition)
*out = *in
out.LastTransitionTime = in.LastTransitionTime.DeepCopy()
return nil
}
}
func DeepCopy_v1alpha1_CustomResourceList(in interface{}, out interface{}, c *conversion.Cloner) error {
{
in := in.(*CustomResourceList)
out := out.(*CustomResourceList)
*out = *in
if in.Items != nil {
in, out := &in.Items, &out.Items
*out = make([]CustomResource, len(*in))
for i := range *in {
if newVal, err := c.DeepCopy(&(*in)[i]); err != nil {
return err
} else {
(*out)[i] = *newVal.(*CustomResource)
}
}
}
return nil
}
}
func DeepCopy_v1alpha1_CustomResourceNames(in interface{}, out interface{}, c *conversion.Cloner) error {
{
in := in.(*CustomResourceNames)
out := out.(*CustomResourceNames)
*out = *in
if in.ShortNames != nil {
in, out := &in.ShortNames, &out.ShortNames
*out = make([]string, len(*in))
copy(*out, *in)
}
return nil
}
}
func DeepCopy_v1alpha1_CustomResourceSpec(in interface{}, out interface{}, c *conversion.Cloner) error {
{
in := in.(*CustomResourceSpec)
out := out.(*CustomResourceSpec)
*out = *in
if newVal, err := c.DeepCopy(&in.Names); err != nil {
return err
} else {
out.Names = *newVal.(*CustomResourceNames)
}
return nil
}
}
func DeepCopy_v1alpha1_CustomResourceStatus(in interface{}, out interface{}, c *conversion.Cloner) error {
{
in := in.(*CustomResourceStatus)
out := out.(*CustomResourceStatus)
*out = *in
if in.Conditions != nil {
in, out := &in.Conditions, &out.Conditions
*out = make([]CustomResourceCondition, len(*in))
for i := range *in {
if newVal, err := c.DeepCopy(&(*in)[i]); err != nil {
return err
} else {
(*out)[i] = *newVal.(*CustomResourceCondition)
}
}
}
if newVal, err := c.DeepCopy(&in.AcceptedNames); err != nil {
return err
} else {
out.AcceptedNames = *newVal.(*CustomResourceNames)
}
return nil
}
}

View File

@@ -0,0 +1,14 @@
package(default_visibility = ["//visibility:public"])
licenses(["notice"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = ["validation.go"],
tags = ["automanaged"],
)

View File

@@ -0,0 +1,17 @@
/*
Copyright 2017 The Kubernetes 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 validation

View File

@@ -0,0 +1,152 @@
// +build !ignore_autogenerated
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// This file was autogenerated by deepcopy-gen. Do not edit it manually!
package apiextensions
import (
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
conversion "k8s.io/apimachinery/pkg/conversion"
runtime "k8s.io/apimachinery/pkg/runtime"
reflect "reflect"
)
func init() {
SchemeBuilder.Register(RegisterDeepCopies)
}
// RegisterDeepCopies adds deep-copy functions to the given scheme. Public
// to allow building arbitrary schemes.
func RegisterDeepCopies(scheme *runtime.Scheme) error {
return scheme.AddGeneratedDeepCopyFuncs(
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_apiextensions_CustomResource, InType: reflect.TypeOf(&CustomResource{})},
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_apiextensions_CustomResourceCondition, InType: reflect.TypeOf(&CustomResourceCondition{})},
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_apiextensions_CustomResourceList, InType: reflect.TypeOf(&CustomResourceList{})},
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_apiextensions_CustomResourceNames, InType: reflect.TypeOf(&CustomResourceNames{})},
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_apiextensions_CustomResourceSpec, InType: reflect.TypeOf(&CustomResourceSpec{})},
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_apiextensions_CustomResourceStatus, InType: reflect.TypeOf(&CustomResourceStatus{})},
)
}
func DeepCopy_apiextensions_CustomResource(in interface{}, out interface{}, c *conversion.Cloner) error {
{
in := in.(*CustomResource)
out := out.(*CustomResource)
*out = *in
if newVal, err := c.DeepCopy(&in.ObjectMeta); err != nil {
return err
} else {
out.ObjectMeta = *newVal.(*v1.ObjectMeta)
}
if newVal, err := c.DeepCopy(&in.Spec); err != nil {
return err
} else {
out.Spec = *newVal.(*CustomResourceSpec)
}
if newVal, err := c.DeepCopy(&in.Status); err != nil {
return err
} else {
out.Status = *newVal.(*CustomResourceStatus)
}
return nil
}
}
func DeepCopy_apiextensions_CustomResourceCondition(in interface{}, out interface{}, c *conversion.Cloner) error {
{
in := in.(*CustomResourceCondition)
out := out.(*CustomResourceCondition)
*out = *in
out.LastTransitionTime = in.LastTransitionTime.DeepCopy()
return nil
}
}
func DeepCopy_apiextensions_CustomResourceList(in interface{}, out interface{}, c *conversion.Cloner) error {
{
in := in.(*CustomResourceList)
out := out.(*CustomResourceList)
*out = *in
if in.Items != nil {
in, out := &in.Items, &out.Items
*out = make([]CustomResource, len(*in))
for i := range *in {
if newVal, err := c.DeepCopy(&(*in)[i]); err != nil {
return err
} else {
(*out)[i] = *newVal.(*CustomResource)
}
}
}
return nil
}
}
func DeepCopy_apiextensions_CustomResourceNames(in interface{}, out interface{}, c *conversion.Cloner) error {
{
in := in.(*CustomResourceNames)
out := out.(*CustomResourceNames)
*out = *in
if in.ShortNames != nil {
in, out := &in.ShortNames, &out.ShortNames
*out = make([]string, len(*in))
copy(*out, *in)
}
return nil
}
}
func DeepCopy_apiextensions_CustomResourceSpec(in interface{}, out interface{}, c *conversion.Cloner) error {
{
in := in.(*CustomResourceSpec)
out := out.(*CustomResourceSpec)
*out = *in
if newVal, err := c.DeepCopy(&in.Names); err != nil {
return err
} else {
out.Names = *newVal.(*CustomResourceNames)
}
return nil
}
}
func DeepCopy_apiextensions_CustomResourceStatus(in interface{}, out interface{}, c *conversion.Cloner) error {
{
in := in.(*CustomResourceStatus)
out := out.(*CustomResourceStatus)
*out = *in
if in.Conditions != nil {
in, out := &in.Conditions, &out.Conditions
*out = make([]CustomResourceCondition, len(*in))
for i := range *in {
if newVal, err := c.DeepCopy(&(*in)[i]); err != nil {
return err
} else {
(*out)[i] = *newVal.(*CustomResourceCondition)
}
}
}
if newVal, err := c.DeepCopy(&in.AcceptedNames); err != nil {
return err
} else {
out.AcceptedNames = *newVal.(*CustomResourceNames)
}
return nil
}
}

View File

@@ -0,0 +1,33 @@
package(default_visibility = ["//visibility:public"])
licenses(["notice"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = ["apiserver.go"],
tags = ["automanaged"],
deps = [
"//vendor/k8s.io/apimachinery/pkg/apimachinery/announced:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apimachinery/registered:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime/serializer:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/version:go_default_library",
"//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library",
"//vendor/k8s.io/apiserver/pkg/server:go_default_library",
"//vendor/k8s.io/kube-apiextensions-server/pkg/apis/apiextensions:go_default_library",
"//vendor/k8s.io/kube-apiextensions-server/pkg/apis/apiextensions/install:go_default_library",
"//vendor/k8s.io/kube-apiextensions-server/pkg/apis/apiextensions/v1alpha1:go_default_library",
"//vendor/k8s.io/kube-apiextensions-server/pkg/client/clientset/clientset:go_default_library",
"//vendor/k8s.io/kube-apiextensions-server/pkg/client/clientset/internalclientset:go_default_library",
"//vendor/k8s.io/kube-apiextensions-server/pkg/client/informers/externalversions:go_default_library",
"//vendor/k8s.io/kube-apiextensions-server/pkg/client/informers/internalversion:go_default_library",
"//vendor/k8s.io/kube-apiextensions-server/pkg/registry/customresource:go_default_library",
],
)

View File

@@ -0,0 +1,116 @@
/*
Copyright 2017 The Kubernetes 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 apiserver
import (
"k8s.io/apimachinery/pkg/apimachinery/announced"
"k8s.io/apimachinery/pkg/apimachinery/registered"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/runtime/serializer"
"k8s.io/apimachinery/pkg/version"
"k8s.io/apiserver/pkg/registry/rest"
genericapiserver "k8s.io/apiserver/pkg/server"
"k8s.io/kube-apiextensions-server/pkg/apis/apiextensions"
"k8s.io/kube-apiextensions-server/pkg/apis/apiextensions/install"
"k8s.io/kube-apiextensions-server/pkg/apis/apiextensions/v1alpha1"
"k8s.io/kube-apiextensions-server/pkg/registry/customresource"
// make sure the generated client works
_ "k8s.io/kube-apiextensions-server/pkg/client/clientset/clientset"
_ "k8s.io/kube-apiextensions-server/pkg/client/clientset/internalclientset"
_ "k8s.io/kube-apiextensions-server/pkg/client/informers/externalversions"
_ "k8s.io/kube-apiextensions-server/pkg/client/informers/internalversion"
)
var (
groupFactoryRegistry = make(announced.APIGroupFactoryRegistry)
registry = registered.NewOrDie("")
Scheme = runtime.NewScheme()
Codecs = serializer.NewCodecFactory(Scheme)
)
func init() {
install.Install(groupFactoryRegistry, registry, Scheme)
// we need to add the options to empty v1
metav1.AddToGroupVersion(Scheme, schema.GroupVersion{Group: "", Version: "v1"})
unversioned := schema.GroupVersion{Group: "", Version: "v1"}
Scheme.AddUnversionedTypes(unversioned,
&metav1.Status{},
&metav1.APIVersions{},
&metav1.APIGroupList{},
&metav1.APIGroup{},
&metav1.APIResourceList{},
)
}
type Config struct {
GenericConfig *genericapiserver.Config
}
type CustomResources struct {
GenericAPIServer *genericapiserver.GenericAPIServer
}
type completedConfig struct {
*Config
}
// Complete fills in any fields not set that are required to have valid data. It's mutating the receiver.
func (c *Config) Complete() completedConfig {
c.GenericConfig.Complete()
c.GenericConfig.Version = &version.Info{
Major: "0",
Minor: "1",
}
return completedConfig{c}
}
// SkipComplete provides a way to construct a server instance without config completion.
func (c *Config) SkipComplete() completedConfig {
return completedConfig{c}
}
// New returns a new instance of CustomResources from the given config.
func (c completedConfig) New() (*CustomResources, error) {
genericServer, err := c.Config.GenericConfig.SkipComplete().New() // completion is done in Complete, no need for a second time
if err != nil {
return nil, err
}
s := &CustomResources{
GenericAPIServer: genericServer,
}
apiGroupInfo := genericapiserver.NewDefaultAPIGroupInfo(apiextensions.GroupName, registry, Scheme, metav1.ParameterCodec, Codecs)
apiGroupInfo.GroupMeta.GroupVersion = v1alpha1.SchemeGroupVersion
v1alpha1storage := map[string]rest.Storage{}
v1alpha1storage["customresources"] = customresource.NewREST(Scheme, c.GenericConfig.RESTOptionsGetter)
apiGroupInfo.VersionedResourcesStorageMap["v1alpha1"] = v1alpha1storage
if err := s.GenericAPIServer.InstallAPIGroup(&apiGroupInfo); err != nil {
return nil, err
}
return s, nil
}

View File

@@ -0,0 +1,24 @@
package(default_visibility = ["//visibility:public"])
licenses(["notice"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = [
"clientset.go",
"doc.go",
],
tags = ["automanaged"],
deps = [
"//vendor/github.com/golang/glog:go_default_library",
"//vendor/k8s.io/client-go/discovery:go_default_library",
"//vendor/k8s.io/client-go/rest:go_default_library",
"//vendor/k8s.io/client-go/util/flowcontrol:go_default_library",
"//vendor/k8s.io/kube-apiextensions-server/pkg/client/clientset/clientset/typed/apiextensions/v1alpha1:go_default_library",
],
)

View File

@@ -0,0 +1,104 @@
/*
Copyright 2017 The Kubernetes 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 clientset
import (
glog "github.com/golang/glog"
discovery "k8s.io/client-go/discovery"
rest "k8s.io/client-go/rest"
flowcontrol "k8s.io/client-go/util/flowcontrol"
apiextensionsv1alpha1 "k8s.io/kube-apiextensions-server/pkg/client/clientset/clientset/typed/apiextensions/v1alpha1"
)
type Interface interface {
Discovery() discovery.DiscoveryInterface
ApiextensionsV1alpha1() apiextensionsv1alpha1.ApiextensionsV1alpha1Interface
// Deprecated: please explicitly pick a version if possible.
Apiextensions() apiextensionsv1alpha1.ApiextensionsV1alpha1Interface
}
// Clientset contains the clients for groups. Each group has exactly one
// version included in a Clientset.
type Clientset struct {
*discovery.DiscoveryClient
*apiextensionsv1alpha1.ApiextensionsV1alpha1Client
}
// ApiextensionsV1alpha1 retrieves the ApiextensionsV1alpha1Client
func (c *Clientset) ApiextensionsV1alpha1() apiextensionsv1alpha1.ApiextensionsV1alpha1Interface {
if c == nil {
return nil
}
return c.ApiextensionsV1alpha1Client
}
// Deprecated: Apiextensions retrieves the default version of ApiextensionsClient.
// Please explicitly pick a version.
func (c *Clientset) Apiextensions() apiextensionsv1alpha1.ApiextensionsV1alpha1Interface {
if c == nil {
return nil
}
return c.ApiextensionsV1alpha1Client
}
// Discovery retrieves the DiscoveryClient
func (c *Clientset) Discovery() discovery.DiscoveryInterface {
if c == nil {
return nil
}
return c.DiscoveryClient
}
// NewForConfig creates a new Clientset for the given config.
func NewForConfig(c *rest.Config) (*Clientset, error) {
configShallowCopy := *c
if configShallowCopy.RateLimiter == nil && configShallowCopy.QPS > 0 {
configShallowCopy.RateLimiter = flowcontrol.NewTokenBucketRateLimiter(configShallowCopy.QPS, configShallowCopy.Burst)
}
var cs Clientset
var err error
cs.ApiextensionsV1alpha1Client, err = apiextensionsv1alpha1.NewForConfig(&configShallowCopy)
if err != nil {
return nil, err
}
cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfig(&configShallowCopy)
if err != nil {
glog.Errorf("failed to create the DiscoveryClient: %v", err)
return nil, err
}
return &cs, nil
}
// NewForConfigOrDie creates a new Clientset for the given config and
// panics if there is an error in the config.
func NewForConfigOrDie(c *rest.Config) *Clientset {
var cs Clientset
cs.ApiextensionsV1alpha1Client = apiextensionsv1alpha1.NewForConfigOrDie(c)
cs.DiscoveryClient = discovery.NewDiscoveryClientForConfigOrDie(c)
return &cs
}
// New creates a new Clientset for the given RESTClient.
func New(c rest.Interface) *Clientset {
var cs Clientset
cs.ApiextensionsV1alpha1Client = apiextensionsv1alpha1.New(c)
cs.DiscoveryClient = discovery.NewDiscoveryClient(c)
return &cs
}

View File

@@ -0,0 +1,20 @@
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// This package is generated by client-gen with custom arguments.
// This package has the automatically generated clientset.
package clientset

View File

@@ -0,0 +1,34 @@
package(default_visibility = ["//visibility:public"])
licenses(["notice"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = [
"clientset_generated.go",
"doc.go",
"register.go",
],
tags = ["automanaged"],
deps = [
"//vendor/k8s.io/apimachinery/pkg/apimachinery/announced:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apimachinery/registered:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime/serializer:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/watch:go_default_library",
"//vendor/k8s.io/client-go/discovery:go_default_library",
"//vendor/k8s.io/client-go/discovery/fake:go_default_library",
"//vendor/k8s.io/client-go/testing:go_default_library",
"//vendor/k8s.io/kube-apiextensions-server/pkg/apis/apiextensions/install:go_default_library",
"//vendor/k8s.io/kube-apiextensions-server/pkg/client/clientset/clientset:go_default_library",
"//vendor/k8s.io/kube-apiextensions-server/pkg/client/clientset/clientset/typed/apiextensions/v1alpha1:go_default_library",
"//vendor/k8s.io/kube-apiextensions-server/pkg/client/clientset/clientset/typed/apiextensions/v1alpha1/fake:go_default_library",
],
)

View File

@@ -0,0 +1,71 @@
/*
Copyright 2017 The Kubernetes 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 fake
import (
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/watch"
"k8s.io/client-go/discovery"
fakediscovery "k8s.io/client-go/discovery/fake"
"k8s.io/client-go/testing"
clientset "k8s.io/kube-apiextensions-server/pkg/client/clientset/clientset"
apiextensionsv1alpha1 "k8s.io/kube-apiextensions-server/pkg/client/clientset/clientset/typed/apiextensions/v1alpha1"
fakeapiextensionsv1alpha1 "k8s.io/kube-apiextensions-server/pkg/client/clientset/clientset/typed/apiextensions/v1alpha1/fake"
)
// NewSimpleClientset returns a clientset that will respond with the provided objects.
// It's backed by a very simple object tracker that processes creates, updates and deletions as-is,
// without applying any validations and/or defaults. It shouldn't be considered a replacement
// for a real clientset and is mostly useful in simple unit tests.
func NewSimpleClientset(objects ...runtime.Object) *Clientset {
o := testing.NewObjectTracker(registry, scheme, codecs.UniversalDecoder())
for _, obj := range objects {
if err := o.Add(obj); err != nil {
panic(err)
}
}
fakePtr := testing.Fake{}
fakePtr.AddReactor("*", "*", testing.ObjectReaction(o, registry.RESTMapper()))
fakePtr.AddWatchReactor("*", testing.DefaultWatchReactor(watch.NewFake(), nil))
return &Clientset{fakePtr}
}
// Clientset implements clientset.Interface. Meant to be embedded into a
// struct to get a default implementation. This makes faking out just the method
// you want to test easier.
type Clientset struct {
testing.Fake
}
func (c *Clientset) Discovery() discovery.DiscoveryInterface {
return &fakediscovery.FakeDiscovery{Fake: &c.Fake}
}
var _ clientset.Interface = &Clientset{}
// ApiextensionsV1alpha1 retrieves the ApiextensionsV1alpha1Client
func (c *Clientset) ApiextensionsV1alpha1() apiextensionsv1alpha1.ApiextensionsV1alpha1Interface {
return &fakeapiextensionsv1alpha1.FakeApiextensionsV1alpha1{Fake: &c.Fake}
}
// Apiextensions retrieves the ApiextensionsV1alpha1Client
func (c *Clientset) Apiextensions() apiextensionsv1alpha1.ApiextensionsV1alpha1Interface {
return &fakeapiextensionsv1alpha1.FakeApiextensionsV1alpha1{Fake: &c.Fake}
}

View File

@@ -0,0 +1,20 @@
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// This package is generated by client-gen with custom arguments.
// This package has the automatically generated fake clientset.
package fake

View File

@@ -0,0 +1,46 @@
/*
Copyright 2017 The Kubernetes 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 fake
import (
announced "k8s.io/apimachinery/pkg/apimachinery/announced"
registered "k8s.io/apimachinery/pkg/apimachinery/registered"
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"
apiextensions "k8s.io/kube-apiextensions-server/pkg/apis/apiextensions/install"
os "os"
)
var scheme = runtime.NewScheme()
var codecs = serializer.NewCodecFactory(scheme)
var parameterCodec = runtime.NewParameterCodec(scheme)
var registry = registered.NewOrDie(os.Getenv("KUBE_API_VERSIONS"))
var groupFactoryRegistry = make(announced.APIGroupFactoryRegistry)
func init() {
v1.AddToGroupVersion(scheme, schema.GroupVersion{Version: "v1"})
Install(groupFactoryRegistry, registry, scheme)
}
// Install registers the API group and adds types to a scheme
func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *registered.APIRegistrationManager, scheme *runtime.Scheme) {
apiextensions.Install(groupFactoryRegistry, registry, scheme)
}

View File

@@ -0,0 +1,24 @@
package(default_visibility = ["//visibility:public"])
licenses(["notice"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = [
"doc.go",
"register.go",
],
tags = ["automanaged"],
deps = [
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime/serializer:go_default_library",
"//vendor/k8s.io/kube-apiextensions-server/pkg/apis/apiextensions/v1alpha1:go_default_library",
],
)

View File

@@ -0,0 +1,20 @@
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// This package is generated by client-gen with custom arguments.
// This package contains the scheme of the automatically generated clientset.
package scheme

View File

@@ -0,0 +1,53 @@
/*
Copyright 2017 The Kubernetes 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 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"
apiextensionsv1alpha1 "k8s.io/kube-apiextensions-server/pkg/apis/apiextensions/v1alpha1"
)
var Scheme = runtime.NewScheme()
var Codecs = serializer.NewCodecFactory(Scheme)
var ParameterCodec = runtime.NewParameterCodec(Scheme)
func init() {
v1.AddToGroupVersion(Scheme, schema.GroupVersion{Version: "v1"})
AddToScheme(Scheme)
}
// 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/kuberentes/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.
func AddToScheme(scheme *runtime.Scheme) {
apiextensionsv1alpha1.AddToScheme(scheme)
}

View File

@@ -0,0 +1,28 @@
package(default_visibility = ["//visibility:public"])
licenses(["notice"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = [
"apiextensions_client.go",
"customresource.go",
"doc.go",
"generated_expansion.go",
],
tags = ["automanaged"],
deps = [
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime/serializer:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/types:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/watch:go_default_library",
"//vendor/k8s.io/client-go/rest:go_default_library",
"//vendor/k8s.io/kube-apiextensions-server/pkg/apis/apiextensions/v1alpha1:go_default_library",
"//vendor/k8s.io/kube-apiextensions-server/pkg/client/clientset/clientset/scheme:go_default_library",
],
)

View File

@@ -0,0 +1,88 @@
/*
Copyright 2017 The Kubernetes 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 (
serializer "k8s.io/apimachinery/pkg/runtime/serializer"
rest "k8s.io/client-go/rest"
v1alpha1 "k8s.io/kube-apiextensions-server/pkg/apis/apiextensions/v1alpha1"
"k8s.io/kube-apiextensions-server/pkg/client/clientset/clientset/scheme"
)
type ApiextensionsV1alpha1Interface interface {
RESTClient() rest.Interface
CustomResourcesGetter
}
// ApiextensionsV1alpha1Client is used to interact with features provided by the apiextensions.k8s.io group.
type ApiextensionsV1alpha1Client struct {
restClient rest.Interface
}
func (c *ApiextensionsV1alpha1Client) CustomResources() CustomResourceInterface {
return newCustomResources(c)
}
// NewForConfig creates a new ApiextensionsV1alpha1Client for the given config.
func NewForConfig(c *rest.Config) (*ApiextensionsV1alpha1Client, error) {
config := *c
if err := setConfigDefaults(&config); err != nil {
return nil, err
}
client, err := rest.RESTClientFor(&config)
if err != nil {
return nil, err
}
return &ApiextensionsV1alpha1Client{client}, nil
}
// NewForConfigOrDie creates a new ApiextensionsV1alpha1Client for the given config and
// panics if there is an error in the config.
func NewForConfigOrDie(c *rest.Config) *ApiextensionsV1alpha1Client {
client, err := NewForConfig(c)
if err != nil {
panic(err)
}
return client
}
// New creates a new ApiextensionsV1alpha1Client for the given RESTClient.
func New(c rest.Interface) *ApiextensionsV1alpha1Client {
return &ApiextensionsV1alpha1Client{c}
}
func setConfigDefaults(config *rest.Config) error {
gv := v1alpha1.SchemeGroupVersion
config.GroupVersion = &gv
config.APIPath = "/apis"
config.NegotiatedSerializer = serializer.DirectCodecFactory{CodecFactory: scheme.Codecs}
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 *ApiextensionsV1alpha1Client) RESTClient() rest.Interface {
if c == nil {
return nil
}
return c.restClient
}

View File

@@ -0,0 +1,161 @@
/*
Copyright 2017 The Kubernetes 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 (
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 "k8s.io/kube-apiextensions-server/pkg/apis/apiextensions/v1alpha1"
scheme "k8s.io/kube-apiextensions-server/pkg/client/clientset/clientset/scheme"
)
// CustomResourcesGetter has a method to return a CustomResourceInterface.
// A group's client should implement this interface.
type CustomResourcesGetter interface {
CustomResources() CustomResourceInterface
}
// CustomResourceInterface has methods to work with CustomResource resources.
type CustomResourceInterface interface {
Create(*v1alpha1.CustomResource) (*v1alpha1.CustomResource, error)
Update(*v1alpha1.CustomResource) (*v1alpha1.CustomResource, error)
UpdateStatus(*v1alpha1.CustomResource) (*v1alpha1.CustomResource, error)
Delete(name string, options *v1.DeleteOptions) error
DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error
Get(name string, options v1.GetOptions) (*v1alpha1.CustomResource, error)
List(opts v1.ListOptions) (*v1alpha1.CustomResourceList, error)
Watch(opts v1.ListOptions) (watch.Interface, error)
Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.CustomResource, err error)
CustomResourceExpansion
}
// customResources implements CustomResourceInterface
type customResources struct {
client rest.Interface
}
// newCustomResources returns a CustomResources
func newCustomResources(c *ApiextensionsV1alpha1Client) *customResources {
return &customResources{
client: c.RESTClient(),
}
}
// Create takes the representation of a customResource and creates it. Returns the server's representation of the customResource, and an error, if there is any.
func (c *customResources) Create(customResource *v1alpha1.CustomResource) (result *v1alpha1.CustomResource, err error) {
result = &v1alpha1.CustomResource{}
err = c.client.Post().
Resource("customresources").
Body(customResource).
Do().
Into(result)
return
}
// Update takes the representation of a customResource and updates it. Returns the server's representation of the customResource, and an error, if there is any.
func (c *customResources) Update(customResource *v1alpha1.CustomResource) (result *v1alpha1.CustomResource, err error) {
result = &v1alpha1.CustomResource{}
err = c.client.Put().
Resource("customresources").
Name(customResource.Name).
Body(customResource).
Do().
Into(result)
return
}
// UpdateStatus was generated because the type contains a Status member.
// Add a +genclientstatus=false comment above the type to avoid generating UpdateStatus().
func (c *customResources) UpdateStatus(customResource *v1alpha1.CustomResource) (result *v1alpha1.CustomResource, err error) {
result = &v1alpha1.CustomResource{}
err = c.client.Put().
Resource("customresources").
Name(customResource.Name).
SubResource("status").
Body(customResource).
Do().
Into(result)
return
}
// Delete takes name of the customResource and deletes it. Returns an error if one occurs.
func (c *customResources) Delete(name string, options *v1.DeleteOptions) error {
return c.client.Delete().
Resource("customresources").
Name(name).
Body(options).
Do().
Error()
}
// DeleteCollection deletes a collection of objects.
func (c *customResources) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error {
return c.client.Delete().
Resource("customresources").
VersionedParams(&listOptions, scheme.ParameterCodec).
Body(options).
Do().
Error()
}
// Get takes name of the customResource, and returns the corresponding customResource object, and an error if there is any.
func (c *customResources) Get(name string, options v1.GetOptions) (result *v1alpha1.CustomResource, err error) {
result = &v1alpha1.CustomResource{}
err = c.client.Get().
Resource("customresources").
Name(name).
VersionedParams(&options, scheme.ParameterCodec).
Do().
Into(result)
return
}
// List takes label and field selectors, and returns the list of CustomResources that match those selectors.
func (c *customResources) List(opts v1.ListOptions) (result *v1alpha1.CustomResourceList, err error) {
result = &v1alpha1.CustomResourceList{}
err = c.client.Get().
Resource("customresources").
VersionedParams(&opts, scheme.ParameterCodec).
Do().
Into(result)
return
}
// Watch returns a watch.Interface that watches the requested customResources.
func (c *customResources) Watch(opts v1.ListOptions) (watch.Interface, error) {
opts.Watch = true
return c.client.Get().
Resource("customresources").
VersionedParams(&opts, scheme.ParameterCodec).
Watch()
}
// Patch applies the patch and returns the patched customResource.
func (c *customResources) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.CustomResource, err error) {
result = &v1alpha1.CustomResource{}
err = c.client.Patch(pt).
Resource("customresources").
SubResource(subresources...).
Name(name).
Body(data).
Do().
Into(result)
return
}

View File

@@ -0,0 +1,20 @@
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// This package is generated by client-gen with custom arguments.
// This package has the automatically generated typed clients.
package v1alpha1

View File

@@ -0,0 +1,29 @@
package(default_visibility = ["//visibility:public"])
licenses(["notice"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = [
"doc.go",
"fake_apiextensions_client.go",
"fake_customresource.go",
],
tags = ["automanaged"],
deps = [
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/labels:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/types:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/watch:go_default_library",
"//vendor/k8s.io/client-go/rest:go_default_library",
"//vendor/k8s.io/client-go/testing:go_default_library",
"//vendor/k8s.io/kube-apiextensions-server/pkg/apis/apiextensions/v1alpha1:go_default_library",
"//vendor/k8s.io/kube-apiextensions-server/pkg/client/clientset/clientset/typed/apiextensions/v1alpha1:go_default_library",
],
)

View File

@@ -0,0 +1,20 @@
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// This package is generated by client-gen with custom arguments.
// Package fake has the automatically generated clients.
package fake

View File

@@ -0,0 +1,38 @@
/*
Copyright 2017 The Kubernetes 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 fake
import (
rest "k8s.io/client-go/rest"
testing "k8s.io/client-go/testing"
v1alpha1 "k8s.io/kube-apiextensions-server/pkg/client/clientset/clientset/typed/apiextensions/v1alpha1"
)
type FakeApiextensionsV1alpha1 struct {
*testing.Fake
}
func (c *FakeApiextensionsV1alpha1) CustomResources() v1alpha1.CustomResourceInterface {
return &FakeCustomResources{c}
}
// RESTClient returns a RESTClient that is used to communicate
// with API server by this client implementation.
func (c *FakeApiextensionsV1alpha1) RESTClient() rest.Interface {
var ret *rest.RESTClient
return ret
}

View File

@@ -0,0 +1,119 @@
/*
Copyright 2017 The Kubernetes 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 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 "k8s.io/kube-apiextensions-server/pkg/apis/apiextensions/v1alpha1"
)
// FakeCustomResources implements CustomResourceInterface
type FakeCustomResources struct {
Fake *FakeApiextensionsV1alpha1
}
var customresourcesResource = schema.GroupVersionResource{Group: "apiextensions.k8s.io", Version: "v1alpha1", Resource: "customresources"}
func (c *FakeCustomResources) Create(customResource *v1alpha1.CustomResource) (result *v1alpha1.CustomResource, err error) {
obj, err := c.Fake.
Invokes(testing.NewRootCreateAction(customresourcesResource, customResource), &v1alpha1.CustomResource{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha1.CustomResource), err
}
func (c *FakeCustomResources) Update(customResource *v1alpha1.CustomResource) (result *v1alpha1.CustomResource, err error) {
obj, err := c.Fake.
Invokes(testing.NewRootUpdateAction(customresourcesResource, customResource), &v1alpha1.CustomResource{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha1.CustomResource), err
}
func (c *FakeCustomResources) UpdateStatus(customResource *v1alpha1.CustomResource) (*v1alpha1.CustomResource, error) {
obj, err := c.Fake.
Invokes(testing.NewRootUpdateSubresourceAction(customresourcesResource, "status", customResource), &v1alpha1.CustomResource{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha1.CustomResource), err
}
func (c *FakeCustomResources) Delete(name string, options *v1.DeleteOptions) error {
_, err := c.Fake.
Invokes(testing.NewRootDeleteAction(customresourcesResource, name), &v1alpha1.CustomResource{})
return err
}
func (c *FakeCustomResources) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error {
action := testing.NewRootDeleteCollectionAction(customresourcesResource, listOptions)
_, err := c.Fake.Invokes(action, &v1alpha1.CustomResourceList{})
return err
}
func (c *FakeCustomResources) Get(name string, options v1.GetOptions) (result *v1alpha1.CustomResource, err error) {
obj, err := c.Fake.
Invokes(testing.NewRootGetAction(customresourcesResource, name), &v1alpha1.CustomResource{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha1.CustomResource), err
}
func (c *FakeCustomResources) List(opts v1.ListOptions) (result *v1alpha1.CustomResourceList, err error) {
obj, err := c.Fake.
Invokes(testing.NewRootListAction(customresourcesResource, opts), &v1alpha1.CustomResourceList{})
if obj == nil {
return nil, err
}
label, _, _ := testing.ExtractFromListOptions(opts)
if label == nil {
label = labels.Everything()
}
list := &v1alpha1.CustomResourceList{}
for _, item := range obj.(*v1alpha1.CustomResourceList).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 customResources.
func (c *FakeCustomResources) Watch(opts v1.ListOptions) (watch.Interface, error) {
return c.Fake.
InvokesWatch(testing.NewRootWatchAction(customresourcesResource, opts))
}
// Patch applies the patch and returns the patched customResource.
func (c *FakeCustomResources) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.CustomResource, err error) {
obj, err := c.Fake.
Invokes(testing.NewRootPatchSubresourceAction(customresourcesResource, name, data, subresources...), &v1alpha1.CustomResource{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha1.CustomResource), err
}

View File

@@ -0,0 +1,19 @@
/*
Copyright 2017 The Kubernetes 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
type CustomResourceExpansion interface{}

View File

@@ -0,0 +1,24 @@
package(default_visibility = ["//visibility:public"])
licenses(["notice"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = [
"clientset.go",
"doc.go",
],
tags = ["automanaged"],
deps = [
"//vendor/github.com/golang/glog:go_default_library",
"//vendor/k8s.io/client-go/discovery:go_default_library",
"//vendor/k8s.io/client-go/rest:go_default_library",
"//vendor/k8s.io/client-go/util/flowcontrol:go_default_library",
"//vendor/k8s.io/kube-apiextensions-server/pkg/client/clientset/internalclientset/typed/apiextensions/internalversion:go_default_library",
],
)

View File

@@ -0,0 +1,93 @@
/*
Copyright 2017 The Kubernetes 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 internalclientset
import (
glog "github.com/golang/glog"
discovery "k8s.io/client-go/discovery"
rest "k8s.io/client-go/rest"
flowcontrol "k8s.io/client-go/util/flowcontrol"
apiextensionsinternalversion "k8s.io/kube-apiextensions-server/pkg/client/clientset/internalclientset/typed/apiextensions/internalversion"
)
type Interface interface {
Discovery() discovery.DiscoveryInterface
Apiextensions() apiextensionsinternalversion.ApiextensionsInterface
}
// Clientset contains the clients for groups. Each group has exactly one
// version included in a Clientset.
type Clientset struct {
*discovery.DiscoveryClient
*apiextensionsinternalversion.ApiextensionsClient
}
// Apiextensions retrieves the ApiextensionsClient
func (c *Clientset) Apiextensions() apiextensionsinternalversion.ApiextensionsInterface {
if c == nil {
return nil
}
return c.ApiextensionsClient
}
// Discovery retrieves the DiscoveryClient
func (c *Clientset) Discovery() discovery.DiscoveryInterface {
if c == nil {
return nil
}
return c.DiscoveryClient
}
// NewForConfig creates a new Clientset for the given config.
func NewForConfig(c *rest.Config) (*Clientset, error) {
configShallowCopy := *c
if configShallowCopy.RateLimiter == nil && configShallowCopy.QPS > 0 {
configShallowCopy.RateLimiter = flowcontrol.NewTokenBucketRateLimiter(configShallowCopy.QPS, configShallowCopy.Burst)
}
var cs Clientset
var err error
cs.ApiextensionsClient, err = apiextensionsinternalversion.NewForConfig(&configShallowCopy)
if err != nil {
return nil, err
}
cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfig(&configShallowCopy)
if err != nil {
glog.Errorf("failed to create the DiscoveryClient: %v", err)
return nil, err
}
return &cs, nil
}
// NewForConfigOrDie creates a new Clientset for the given config and
// panics if there is an error in the config.
func NewForConfigOrDie(c *rest.Config) *Clientset {
var cs Clientset
cs.ApiextensionsClient = apiextensionsinternalversion.NewForConfigOrDie(c)
cs.DiscoveryClient = discovery.NewDiscoveryClientForConfigOrDie(c)
return &cs
}
// New creates a new Clientset for the given RESTClient.
func New(c rest.Interface) *Clientset {
var cs Clientset
cs.ApiextensionsClient = apiextensionsinternalversion.New(c)
cs.DiscoveryClient = discovery.NewDiscoveryClient(c)
return &cs
}

View File

@@ -0,0 +1,20 @@
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// This package is generated by client-gen with custom arguments.
// This package has the automatically generated clientset.
package internalclientset

View File

@@ -0,0 +1,34 @@
package(default_visibility = ["//visibility:public"])
licenses(["notice"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = [
"clientset_generated.go",
"doc.go",
"register.go",
],
tags = ["automanaged"],
deps = [
"//vendor/k8s.io/apimachinery/pkg/apimachinery/announced:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apimachinery/registered:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime/serializer:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/watch:go_default_library",
"//vendor/k8s.io/client-go/discovery:go_default_library",
"//vendor/k8s.io/client-go/discovery/fake:go_default_library",
"//vendor/k8s.io/client-go/testing:go_default_library",
"//vendor/k8s.io/kube-apiextensions-server/pkg/apis/apiextensions/install:go_default_library",
"//vendor/k8s.io/kube-apiextensions-server/pkg/client/clientset/internalclientset:go_default_library",
"//vendor/k8s.io/kube-apiextensions-server/pkg/client/clientset/internalclientset/typed/apiextensions/internalversion:go_default_library",
"//vendor/k8s.io/kube-apiextensions-server/pkg/client/clientset/internalclientset/typed/apiextensions/internalversion/fake:go_default_library",
],
)

View File

@@ -0,0 +1,66 @@
/*
Copyright 2017 The Kubernetes 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 fake
import (
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/watch"
"k8s.io/client-go/discovery"
fakediscovery "k8s.io/client-go/discovery/fake"
"k8s.io/client-go/testing"
clientset "k8s.io/kube-apiextensions-server/pkg/client/clientset/internalclientset"
apiextensionsinternalversion "k8s.io/kube-apiextensions-server/pkg/client/clientset/internalclientset/typed/apiextensions/internalversion"
fakeapiextensionsinternalversion "k8s.io/kube-apiextensions-server/pkg/client/clientset/internalclientset/typed/apiextensions/internalversion/fake"
)
// NewSimpleClientset returns a clientset that will respond with the provided objects.
// It's backed by a very simple object tracker that processes creates, updates and deletions as-is,
// without applying any validations and/or defaults. It shouldn't be considered a replacement
// for a real clientset and is mostly useful in simple unit tests.
func NewSimpleClientset(objects ...runtime.Object) *Clientset {
o := testing.NewObjectTracker(registry, scheme, codecs.UniversalDecoder())
for _, obj := range objects {
if err := o.Add(obj); err != nil {
panic(err)
}
}
fakePtr := testing.Fake{}
fakePtr.AddReactor("*", "*", testing.ObjectReaction(o, registry.RESTMapper()))
fakePtr.AddWatchReactor("*", testing.DefaultWatchReactor(watch.NewFake(), nil))
return &Clientset{fakePtr}
}
// Clientset implements clientset.Interface. Meant to be embedded into a
// struct to get a default implementation. This makes faking out just the method
// you want to test easier.
type Clientset struct {
testing.Fake
}
func (c *Clientset) Discovery() discovery.DiscoveryInterface {
return &fakediscovery.FakeDiscovery{Fake: &c.Fake}
}
var _ clientset.Interface = &Clientset{}
// Apiextensions retrieves the ApiextensionsClient
func (c *Clientset) Apiextensions() apiextensionsinternalversion.ApiextensionsInterface {
return &fakeapiextensionsinternalversion.FakeApiextensions{Fake: &c.Fake}
}

View File

@@ -0,0 +1,20 @@
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// This package is generated by client-gen with custom arguments.
// This package has the automatically generated fake clientset.
package fake

View File

@@ -0,0 +1,46 @@
/*
Copyright 2017 The Kubernetes 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 fake
import (
announced "k8s.io/apimachinery/pkg/apimachinery/announced"
registered "k8s.io/apimachinery/pkg/apimachinery/registered"
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"
apiextensions "k8s.io/kube-apiextensions-server/pkg/apis/apiextensions/install"
os "os"
)
var scheme = runtime.NewScheme()
var codecs = serializer.NewCodecFactory(scheme)
var parameterCodec = runtime.NewParameterCodec(scheme)
var registry = registered.NewOrDie(os.Getenv("KUBE_API_VERSIONS"))
var groupFactoryRegistry = make(announced.APIGroupFactoryRegistry)
func init() {
v1.AddToGroupVersion(scheme, schema.GroupVersion{Version: "v1"})
Install(groupFactoryRegistry, registry, scheme)
}
// Install registers the API group and adds types to a scheme
func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *registered.APIRegistrationManager, scheme *runtime.Scheme) {
apiextensions.Install(groupFactoryRegistry, registry, scheme)
}

View File

@@ -0,0 +1,26 @@
package(default_visibility = ["//visibility:public"])
licenses(["notice"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = [
"doc.go",
"register.go",
],
tags = ["automanaged"],
deps = [
"//vendor/k8s.io/apimachinery/pkg/apimachinery/announced:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apimachinery/registered:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime/serializer:go_default_library",
"//vendor/k8s.io/kube-apiextensions-server/pkg/apis/apiextensions/install:go_default_library",
],
)

View File

@@ -0,0 +1,20 @@
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// This package is generated by client-gen with custom arguments.
// This package contains the scheme of the automatically generated clientset.
package scheme

View File

@@ -0,0 +1,46 @@
/*
Copyright 2017 The Kubernetes 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 scheme
import (
announced "k8s.io/apimachinery/pkg/apimachinery/announced"
registered "k8s.io/apimachinery/pkg/apimachinery/registered"
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"
apiextensions "k8s.io/kube-apiextensions-server/pkg/apis/apiextensions/install"
os "os"
)
var Scheme = runtime.NewScheme()
var Codecs = serializer.NewCodecFactory(Scheme)
var ParameterCodec = runtime.NewParameterCodec(Scheme)
var Registry = registered.NewOrDie(os.Getenv("KUBE_API_VERSIONS"))
var GroupFactoryRegistry = make(announced.APIGroupFactoryRegistry)
func init() {
v1.AddToGroupVersion(Scheme, schema.GroupVersion{Version: "v1"})
Install(GroupFactoryRegistry, Registry, Scheme)
}
// Install registers the API group and adds types to a scheme
func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *registered.APIRegistrationManager, scheme *runtime.Scheme) {
apiextensions.Install(groupFactoryRegistry, registry, scheme)
}

View File

@@ -0,0 +1,27 @@
package(default_visibility = ["//visibility:public"])
licenses(["notice"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = [
"apiextensions_client.go",
"customresource.go",
"doc.go",
"generated_expansion.go",
],
tags = ["automanaged"],
deps = [
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/types:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/watch:go_default_library",
"//vendor/k8s.io/client-go/rest:go_default_library",
"//vendor/k8s.io/kube-apiextensions-server/pkg/apis/apiextensions:go_default_library",
"//vendor/k8s.io/kube-apiextensions-server/pkg/client/clientset/internalclientset/scheme:go_default_library",
],
)

View File

@@ -0,0 +1,99 @@
/*
Copyright 2017 The Kubernetes 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 internalversion
import (
rest "k8s.io/client-go/rest"
"k8s.io/kube-apiextensions-server/pkg/client/clientset/internalclientset/scheme"
)
type ApiextensionsInterface interface {
RESTClient() rest.Interface
CustomResourcesGetter
}
// ApiextensionsClient is used to interact with features provided by the apiextensions.k8s.io group.
type ApiextensionsClient struct {
restClient rest.Interface
}
func (c *ApiextensionsClient) CustomResources() CustomResourceInterface {
return newCustomResources(c)
}
// NewForConfig creates a new ApiextensionsClient for the given config.
func NewForConfig(c *rest.Config) (*ApiextensionsClient, error) {
config := *c
if err := setConfigDefaults(&config); err != nil {
return nil, err
}
client, err := rest.RESTClientFor(&config)
if err != nil {
return nil, err
}
return &ApiextensionsClient{client}, nil
}
// NewForConfigOrDie creates a new ApiextensionsClient for the given config and
// panics if there is an error in the config.
func NewForConfigOrDie(c *rest.Config) *ApiextensionsClient {
client, err := NewForConfig(c)
if err != nil {
panic(err)
}
return client
}
// New creates a new ApiextensionsClient for the given RESTClient.
func New(c rest.Interface) *ApiextensionsClient {
return &ApiextensionsClient{c}
}
func setConfigDefaults(config *rest.Config) error {
g, err := scheme.Registry.Group("apiextensions.k8s.io")
if err != nil {
return err
}
config.APIPath = "/apis"
if config.UserAgent == "" {
config.UserAgent = rest.DefaultKubernetesUserAgent()
}
if config.GroupVersion == nil || config.GroupVersion.Group != g.GroupVersion.Group {
gv := g.GroupVersion
config.GroupVersion = &gv
}
config.NegotiatedSerializer = scheme.Codecs
if config.QPS == 0 {
config.QPS = 5
}
if config.Burst == 0 {
config.Burst = 10
}
return nil
}
// RESTClient returns a RESTClient that is used to communicate
// with API server by this client implementation.
func (c *ApiextensionsClient) RESTClient() rest.Interface {
if c == nil {
return nil
}
return c.restClient
}

View File

@@ -0,0 +1,161 @@
/*
Copyright 2017 The Kubernetes 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 internalversion
import (
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"
apiextensions "k8s.io/kube-apiextensions-server/pkg/apis/apiextensions"
scheme "k8s.io/kube-apiextensions-server/pkg/client/clientset/internalclientset/scheme"
)
// CustomResourcesGetter has a method to return a CustomResourceInterface.
// A group's client should implement this interface.
type CustomResourcesGetter interface {
CustomResources() CustomResourceInterface
}
// CustomResourceInterface has methods to work with CustomResource resources.
type CustomResourceInterface interface {
Create(*apiextensions.CustomResource) (*apiextensions.CustomResource, error)
Update(*apiextensions.CustomResource) (*apiextensions.CustomResource, error)
UpdateStatus(*apiextensions.CustomResource) (*apiextensions.CustomResource, error)
Delete(name string, options *v1.DeleteOptions) error
DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error
Get(name string, options v1.GetOptions) (*apiextensions.CustomResource, error)
List(opts v1.ListOptions) (*apiextensions.CustomResourceList, error)
Watch(opts v1.ListOptions) (watch.Interface, error)
Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *apiextensions.CustomResource, err error)
CustomResourceExpansion
}
// customResources implements CustomResourceInterface
type customResources struct {
client rest.Interface
}
// newCustomResources returns a CustomResources
func newCustomResources(c *ApiextensionsClient) *customResources {
return &customResources{
client: c.RESTClient(),
}
}
// Create takes the representation of a customResource and creates it. Returns the server's representation of the customResource, and an error, if there is any.
func (c *customResources) Create(customResource *apiextensions.CustomResource) (result *apiextensions.CustomResource, err error) {
result = &apiextensions.CustomResource{}
err = c.client.Post().
Resource("customresources").
Body(customResource).
Do().
Into(result)
return
}
// Update takes the representation of a customResource and updates it. Returns the server's representation of the customResource, and an error, if there is any.
func (c *customResources) Update(customResource *apiextensions.CustomResource) (result *apiextensions.CustomResource, err error) {
result = &apiextensions.CustomResource{}
err = c.client.Put().
Resource("customresources").
Name(customResource.Name).
Body(customResource).
Do().
Into(result)
return
}
// UpdateStatus was generated because the type contains a Status member.
// Add a +genclientstatus=false comment above the type to avoid generating UpdateStatus().
func (c *customResources) UpdateStatus(customResource *apiextensions.CustomResource) (result *apiextensions.CustomResource, err error) {
result = &apiextensions.CustomResource{}
err = c.client.Put().
Resource("customresources").
Name(customResource.Name).
SubResource("status").
Body(customResource).
Do().
Into(result)
return
}
// Delete takes name of the customResource and deletes it. Returns an error if one occurs.
func (c *customResources) Delete(name string, options *v1.DeleteOptions) error {
return c.client.Delete().
Resource("customresources").
Name(name).
Body(options).
Do().
Error()
}
// DeleteCollection deletes a collection of objects.
func (c *customResources) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error {
return c.client.Delete().
Resource("customresources").
VersionedParams(&listOptions, scheme.ParameterCodec).
Body(options).
Do().
Error()
}
// Get takes name of the customResource, and returns the corresponding customResource object, and an error if there is any.
func (c *customResources) Get(name string, options v1.GetOptions) (result *apiextensions.CustomResource, err error) {
result = &apiextensions.CustomResource{}
err = c.client.Get().
Resource("customresources").
Name(name).
VersionedParams(&options, scheme.ParameterCodec).
Do().
Into(result)
return
}
// List takes label and field selectors, and returns the list of CustomResources that match those selectors.
func (c *customResources) List(opts v1.ListOptions) (result *apiextensions.CustomResourceList, err error) {
result = &apiextensions.CustomResourceList{}
err = c.client.Get().
Resource("customresources").
VersionedParams(&opts, scheme.ParameterCodec).
Do().
Into(result)
return
}
// Watch returns a watch.Interface that watches the requested customResources.
func (c *customResources) Watch(opts v1.ListOptions) (watch.Interface, error) {
opts.Watch = true
return c.client.Get().
Resource("customresources").
VersionedParams(&opts, scheme.ParameterCodec).
Watch()
}
// Patch applies the patch and returns the patched customResource.
func (c *customResources) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *apiextensions.CustomResource, err error) {
result = &apiextensions.CustomResource{}
err = c.client.Patch(pt).
Resource("customresources").
SubResource(subresources...).
Name(name).
Body(data).
Do().
Into(result)
return
}

View File

@@ -0,0 +1,20 @@
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// This package is generated by client-gen with custom arguments.
// This package has the automatically generated typed clients.
package internalversion

View File

@@ -0,0 +1,29 @@
package(default_visibility = ["//visibility:public"])
licenses(["notice"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = [
"doc.go",
"fake_apiextensions_client.go",
"fake_customresource.go",
],
tags = ["automanaged"],
deps = [
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/labels:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/types:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/watch:go_default_library",
"//vendor/k8s.io/client-go/rest:go_default_library",
"//vendor/k8s.io/client-go/testing:go_default_library",
"//vendor/k8s.io/kube-apiextensions-server/pkg/apis/apiextensions:go_default_library",
"//vendor/k8s.io/kube-apiextensions-server/pkg/client/clientset/internalclientset/typed/apiextensions/internalversion:go_default_library",
],
)

View File

@@ -0,0 +1,20 @@
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// This package is generated by client-gen with custom arguments.
// Package fake has the automatically generated clients.
package fake

View File

@@ -0,0 +1,38 @@
/*
Copyright 2017 The Kubernetes 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 fake
import (
rest "k8s.io/client-go/rest"
testing "k8s.io/client-go/testing"
internalversion "k8s.io/kube-apiextensions-server/pkg/client/clientset/internalclientset/typed/apiextensions/internalversion"
)
type FakeApiextensions struct {
*testing.Fake
}
func (c *FakeApiextensions) CustomResources() internalversion.CustomResourceInterface {
return &FakeCustomResources{c}
}
// RESTClient returns a RESTClient that is used to communicate
// with API server by this client implementation.
func (c *FakeApiextensions) RESTClient() rest.Interface {
var ret *rest.RESTClient
return ret
}

View File

@@ -0,0 +1,119 @@
/*
Copyright 2017 The Kubernetes 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 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"
apiextensions "k8s.io/kube-apiextensions-server/pkg/apis/apiextensions"
)
// FakeCustomResources implements CustomResourceInterface
type FakeCustomResources struct {
Fake *FakeApiextensions
}
var customresourcesResource = schema.GroupVersionResource{Group: "apiextensions.k8s.io", Version: "", Resource: "customresources"}
func (c *FakeCustomResources) Create(customResource *apiextensions.CustomResource) (result *apiextensions.CustomResource, err error) {
obj, err := c.Fake.
Invokes(testing.NewRootCreateAction(customresourcesResource, customResource), &apiextensions.CustomResource{})
if obj == nil {
return nil, err
}
return obj.(*apiextensions.CustomResource), err
}
func (c *FakeCustomResources) Update(customResource *apiextensions.CustomResource) (result *apiextensions.CustomResource, err error) {
obj, err := c.Fake.
Invokes(testing.NewRootUpdateAction(customresourcesResource, customResource), &apiextensions.CustomResource{})
if obj == nil {
return nil, err
}
return obj.(*apiextensions.CustomResource), err
}
func (c *FakeCustomResources) UpdateStatus(customResource *apiextensions.CustomResource) (*apiextensions.CustomResource, error) {
obj, err := c.Fake.
Invokes(testing.NewRootUpdateSubresourceAction(customresourcesResource, "status", customResource), &apiextensions.CustomResource{})
if obj == nil {
return nil, err
}
return obj.(*apiextensions.CustomResource), err
}
func (c *FakeCustomResources) Delete(name string, options *v1.DeleteOptions) error {
_, err := c.Fake.
Invokes(testing.NewRootDeleteAction(customresourcesResource, name), &apiextensions.CustomResource{})
return err
}
func (c *FakeCustomResources) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error {
action := testing.NewRootDeleteCollectionAction(customresourcesResource, listOptions)
_, err := c.Fake.Invokes(action, &apiextensions.CustomResourceList{})
return err
}
func (c *FakeCustomResources) Get(name string, options v1.GetOptions) (result *apiextensions.CustomResource, err error) {
obj, err := c.Fake.
Invokes(testing.NewRootGetAction(customresourcesResource, name), &apiextensions.CustomResource{})
if obj == nil {
return nil, err
}
return obj.(*apiextensions.CustomResource), err
}
func (c *FakeCustomResources) List(opts v1.ListOptions) (result *apiextensions.CustomResourceList, err error) {
obj, err := c.Fake.
Invokes(testing.NewRootListAction(customresourcesResource, opts), &apiextensions.CustomResourceList{})
if obj == nil {
return nil, err
}
label, _, _ := testing.ExtractFromListOptions(opts)
if label == nil {
label = labels.Everything()
}
list := &apiextensions.CustomResourceList{}
for _, item := range obj.(*apiextensions.CustomResourceList).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 customResources.
func (c *FakeCustomResources) Watch(opts v1.ListOptions) (watch.Interface, error) {
return c.Fake.
InvokesWatch(testing.NewRootWatchAction(customresourcesResource, opts))
}
// Patch applies the patch and returns the patched customResource.
func (c *FakeCustomResources) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *apiextensions.CustomResource, err error) {
obj, err := c.Fake.
Invokes(testing.NewRootPatchSubresourceAction(customresourcesResource, name, data, subresources...), &apiextensions.CustomResource{})
if obj == nil {
return nil, err
}
return obj.(*apiextensions.CustomResource), err
}

View File

@@ -0,0 +1,19 @@
/*
Copyright 2017 The Kubernetes 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 internalversion
type CustomResourceExpansion interface{}

View File

@@ -0,0 +1,26 @@
package(default_visibility = ["//visibility:public"])
licenses(["notice"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = [
"factory.go",
"generic.go",
],
tags = ["automanaged"],
deps = [
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
"//vendor/k8s.io/client-go/tools/cache:go_default_library",
"//vendor/k8s.io/kube-apiextensions-server/pkg/apis/apiextensions/v1alpha1:go_default_library",
"//vendor/k8s.io/kube-apiextensions-server/pkg/client/clientset/clientset:go_default_library",
"//vendor/k8s.io/kube-apiextensions-server/pkg/client/informers/externalversions/apiextensions:go_default_library",
"//vendor/k8s.io/kube-apiextensions-server/pkg/client/informers/externalversions/internalinterfaces:go_default_library",
],
)

View File

@@ -0,0 +1,18 @@
package(default_visibility = ["//visibility:public"])
licenses(["notice"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = ["interface.go"],
tags = ["automanaged"],
deps = [
"//vendor/k8s.io/kube-apiextensions-server/pkg/client/informers/externalversions/apiextensions/v1alpha1:go_default_library",
"//vendor/k8s.io/kube-apiextensions-server/pkg/client/informers/externalversions/internalinterfaces:go_default_library",
],
)

View File

@@ -0,0 +1,44 @@
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// This file was automatically generated by informer-gen
package apiextensions
import (
v1alpha1 "k8s.io/kube-apiextensions-server/pkg/client/informers/externalversions/apiextensions/v1alpha1"
internalinterfaces "k8s.io/kube-apiextensions-server/pkg/client/informers/externalversions/internalinterfaces"
)
// Interface provides access to each of this group's versions.
type Interface interface {
// V1alpha1 provides access to shared informers for resources in V1alpha1.
V1alpha1() v1alpha1.Interface
}
type group struct {
internalinterfaces.SharedInformerFactory
}
// New returns a new Interface.
func New(f internalinterfaces.SharedInformerFactory) Interface {
return &group{f}
}
// V1alpha1 returns a new v1alpha1.Interface.
func (g *group) V1alpha1() v1alpha1.Interface {
return v1alpha1.New(g.SharedInformerFactory)
}

View File

@@ -0,0 +1,27 @@
package(default_visibility = ["//visibility:public"])
licenses(["notice"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = [
"customresource.go",
"interface.go",
],
tags = ["automanaged"],
deps = [
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/watch:go_default_library",
"//vendor/k8s.io/client-go/tools/cache:go_default_library",
"//vendor/k8s.io/kube-apiextensions-server/pkg/apis/apiextensions/v1alpha1:go_default_library",
"//vendor/k8s.io/kube-apiextensions-server/pkg/client/clientset/clientset:go_default_library",
"//vendor/k8s.io/kube-apiextensions-server/pkg/client/informers/externalversions/internalinterfaces:go_default_library",
"//vendor/k8s.io/kube-apiextensions-server/pkg/client/listers/apiextensions/v1alpha1:go_default_library",
],
)

View File

@@ -0,0 +1,68 @@
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// This file was automatically generated by informer-gen
package v1alpha1
import (
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
runtime "k8s.io/apimachinery/pkg/runtime"
watch "k8s.io/apimachinery/pkg/watch"
cache "k8s.io/client-go/tools/cache"
apiextensions_v1alpha1 "k8s.io/kube-apiextensions-server/pkg/apis/apiextensions/v1alpha1"
clientset "k8s.io/kube-apiextensions-server/pkg/client/clientset/clientset"
internalinterfaces "k8s.io/kube-apiextensions-server/pkg/client/informers/externalversions/internalinterfaces"
v1alpha1 "k8s.io/kube-apiextensions-server/pkg/client/listers/apiextensions/v1alpha1"
time "time"
)
// CustomResourceInformer provides access to a shared informer and lister for
// CustomResources.
type CustomResourceInformer interface {
Informer() cache.SharedIndexInformer
Lister() v1alpha1.CustomResourceLister
}
type customResourceInformer struct {
factory internalinterfaces.SharedInformerFactory
}
func newCustomResourceInformer(client clientset.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
sharedIndexInformer := cache.NewSharedIndexInformer(
&cache.ListWatch{
ListFunc: func(options v1.ListOptions) (runtime.Object, error) {
return client.ApiextensionsV1alpha1().CustomResources().List(options)
},
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
return client.ApiextensionsV1alpha1().CustomResources().Watch(options)
},
},
&apiextensions_v1alpha1.CustomResource{},
resyncPeriod,
cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc},
)
return sharedIndexInformer
}
func (f *customResourceInformer) Informer() cache.SharedIndexInformer {
return f.factory.InformerFor(&apiextensions_v1alpha1.CustomResource{}, newCustomResourceInformer)
}
func (f *customResourceInformer) Lister() v1alpha1.CustomResourceLister {
return v1alpha1.NewCustomResourceLister(f.Informer().GetIndexer())
}

View File

@@ -0,0 +1,43 @@
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// This file was automatically generated by informer-gen
package v1alpha1
import (
internalinterfaces "k8s.io/kube-apiextensions-server/pkg/client/informers/externalversions/internalinterfaces"
)
// Interface provides access to all the informers in this group version.
type Interface interface {
// CustomResources returns a CustomResourceInformer.
CustomResources() CustomResourceInformer
}
type version struct {
internalinterfaces.SharedInformerFactory
}
// New returns a new Interface.
func New(f internalinterfaces.SharedInformerFactory) Interface {
return &version{f}
}
// CustomResources returns a CustomResourceInformer.
func (v *version) CustomResources() CustomResourceInformer {
return &customResourceInformer{factory: v.SharedInformerFactory}
}

View File

@@ -0,0 +1,95 @@
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// This file was automatically generated by informer-gen
package externalversions
import (
runtime "k8s.io/apimachinery/pkg/runtime"
schema "k8s.io/apimachinery/pkg/runtime/schema"
cache "k8s.io/client-go/tools/cache"
clientset "k8s.io/kube-apiextensions-server/pkg/client/clientset/clientset"
apiextensions "k8s.io/kube-apiextensions-server/pkg/client/informers/externalversions/apiextensions"
internalinterfaces "k8s.io/kube-apiextensions-server/pkg/client/informers/externalversions/internalinterfaces"
reflect "reflect"
sync "sync"
time "time"
)
type sharedInformerFactory struct {
client clientset.Interface
lock sync.Mutex
defaultResync time.Duration
informers map[reflect.Type]cache.SharedIndexInformer
// startedInformers is used for tracking which informers have been started.
// This allows Start() to be called multiple times safely.
startedInformers map[reflect.Type]bool
}
// NewSharedInformerFactory constructs a new instance of sharedInformerFactory
func NewSharedInformerFactory(client clientset.Interface, defaultResync time.Duration) SharedInformerFactory {
return &sharedInformerFactory{
client: client,
defaultResync: defaultResync,
informers: make(map[reflect.Type]cache.SharedIndexInformer),
startedInformers: make(map[reflect.Type]bool),
}
}
// Start initializes all requested informers.
func (f *sharedInformerFactory) Start(stopCh <-chan struct{}) {
f.lock.Lock()
defer f.lock.Unlock()
for informerType, informer := range f.informers {
if !f.startedInformers[informerType] {
go informer.Run(stopCh)
f.startedInformers[informerType] = true
}
}
}
// InternalInformerFor returns the SharedIndexInformer for obj using an internal
// client.
func (f *sharedInformerFactory) InformerFor(obj runtime.Object, newFunc internalinterfaces.NewInformerFunc) cache.SharedIndexInformer {
f.lock.Lock()
defer f.lock.Unlock()
informerType := reflect.TypeOf(obj)
informer, exists := f.informers[informerType]
if exists {
return informer
}
informer = newFunc(f.client, f.defaultResync)
f.informers[informerType] = informer
return informer
}
// SharedInformerFactory provides shared informers for resources in all known
// API group versions.
type SharedInformerFactory interface {
internalinterfaces.SharedInformerFactory
ForResource(resource schema.GroupVersionResource) (GenericInformer, error)
Apiextensions() apiextensions.Interface
}
func (f *sharedInformerFactory) Apiextensions() apiextensions.Interface {
return apiextensions.New(f)
}

View File

@@ -0,0 +1,61 @@
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// This file was automatically generated by informer-gen
package externalversions
import (
"fmt"
schema "k8s.io/apimachinery/pkg/runtime/schema"
cache "k8s.io/client-go/tools/cache"
v1alpha1 "k8s.io/kube-apiextensions-server/pkg/apis/apiextensions/v1alpha1"
)
// GenericInformer is type of SharedIndexInformer which will locate and delegate to other
// sharedInformers based on type
type GenericInformer interface {
Informer() cache.SharedIndexInformer
Lister() cache.GenericLister
}
type genericInformer struct {
informer cache.SharedIndexInformer
resource schema.GroupResource
}
// Informer returns the SharedIndexInformer.
func (f *genericInformer) Informer() cache.SharedIndexInformer {
return f.informer
}
// Lister returns the GenericLister.
func (f *genericInformer) Lister() cache.GenericLister {
return cache.NewGenericLister(f.Informer().GetIndexer(), f.resource)
}
// ForResource gives generic access to a shared informer of the matching type
// TODO extend this to unknown resources with a client pool
func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource) (GenericInformer, error) {
switch resource {
// Group=Apiextensions, Version=V1alpha1
case v1alpha1.SchemeGroupVersion.WithResource("customresources"):
return &genericInformer{resource: resource.GroupResource(), informer: f.Apiextensions().V1alpha1().CustomResources().Informer()}, nil
}
return nil, fmt.Errorf("no informer found for %v", resource)
}

View File

@@ -0,0 +1,19 @@
package(default_visibility = ["//visibility:public"])
licenses(["notice"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = ["factory_interfaces.go"],
tags = ["automanaged"],
deps = [
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/client-go/tools/cache:go_default_library",
"//vendor/k8s.io/kube-apiextensions-server/pkg/client/clientset/clientset:go_default_library",
],
)

View File

@@ -0,0 +1,34 @@
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// This file was automatically generated by informer-gen
package internalinterfaces
import (
runtime "k8s.io/apimachinery/pkg/runtime"
cache "k8s.io/client-go/tools/cache"
clientset "k8s.io/kube-apiextensions-server/pkg/client/clientset/clientset"
time "time"
)
type NewInformerFunc func(clientset.Interface, time.Duration) cache.SharedIndexInformer
// SharedInformerFactory a small interface to allow for adding an informer without an import cycle
type SharedInformerFactory interface {
Start(stopCh <-chan struct{})
InformerFor(obj runtime.Object, newFunc NewInformerFunc) cache.SharedIndexInformer
}

View File

@@ -0,0 +1,26 @@
package(default_visibility = ["//visibility:public"])
licenses(["notice"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = [
"factory.go",
"generic.go",
],
tags = ["automanaged"],
deps = [
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
"//vendor/k8s.io/client-go/tools/cache:go_default_library",
"//vendor/k8s.io/kube-apiextensions-server/pkg/apis/apiextensions:go_default_library",
"//vendor/k8s.io/kube-apiextensions-server/pkg/client/clientset/internalclientset:go_default_library",
"//vendor/k8s.io/kube-apiextensions-server/pkg/client/informers/internalversion/apiextensions:go_default_library",
"//vendor/k8s.io/kube-apiextensions-server/pkg/client/informers/internalversion/internalinterfaces:go_default_library",
],
)

View File

@@ -0,0 +1,18 @@
package(default_visibility = ["//visibility:public"])
licenses(["notice"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = ["interface.go"],
tags = ["automanaged"],
deps = [
"//vendor/k8s.io/kube-apiextensions-server/pkg/client/informers/internalversion/apiextensions/internalversion:go_default_library",
"//vendor/k8s.io/kube-apiextensions-server/pkg/client/informers/internalversion/internalinterfaces:go_default_library",
],
)

View File

@@ -0,0 +1,44 @@
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// This file was automatically generated by informer-gen
package apiextensions
import (
internalversion "k8s.io/kube-apiextensions-server/pkg/client/informers/internalversion/apiextensions/internalversion"
internalinterfaces "k8s.io/kube-apiextensions-server/pkg/client/informers/internalversion/internalinterfaces"
)
// Interface provides access to each of this group's versions.
type Interface interface {
// InternalVersion provides access to shared informers for resources in InternalVersion.
InternalVersion() internalversion.Interface
}
type group struct {
internalinterfaces.SharedInformerFactory
}
// New returns a new Interface.
func New(f internalinterfaces.SharedInformerFactory) Interface {
return &group{f}
}
// InternalVersion returns a new internalversion.Interface.
func (g *group) InternalVersion() internalversion.Interface {
return internalversion.New(g.SharedInformerFactory)
}

View File

@@ -0,0 +1,27 @@
package(default_visibility = ["//visibility:public"])
licenses(["notice"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = [
"customresource.go",
"interface.go",
],
tags = ["automanaged"],
deps = [
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/watch:go_default_library",
"//vendor/k8s.io/client-go/tools/cache:go_default_library",
"//vendor/k8s.io/kube-apiextensions-server/pkg/apis/apiextensions:go_default_library",
"//vendor/k8s.io/kube-apiextensions-server/pkg/client/clientset/internalclientset:go_default_library",
"//vendor/k8s.io/kube-apiextensions-server/pkg/client/informers/internalversion/internalinterfaces:go_default_library",
"//vendor/k8s.io/kube-apiextensions-server/pkg/client/listers/apiextensions/internalversion:go_default_library",
],
)

View File

@@ -0,0 +1,68 @@
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// This file was automatically generated by informer-gen
package internalversion
import (
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
runtime "k8s.io/apimachinery/pkg/runtime"
watch "k8s.io/apimachinery/pkg/watch"
cache "k8s.io/client-go/tools/cache"
apiextensions "k8s.io/kube-apiextensions-server/pkg/apis/apiextensions"
internalclientset "k8s.io/kube-apiextensions-server/pkg/client/clientset/internalclientset"
internalinterfaces "k8s.io/kube-apiextensions-server/pkg/client/informers/internalversion/internalinterfaces"
internalversion "k8s.io/kube-apiextensions-server/pkg/client/listers/apiextensions/internalversion"
time "time"
)
// CustomResourceInformer provides access to a shared informer and lister for
// CustomResources.
type CustomResourceInformer interface {
Informer() cache.SharedIndexInformer
Lister() internalversion.CustomResourceLister
}
type customResourceInformer struct {
factory internalinterfaces.SharedInformerFactory
}
func newCustomResourceInformer(client internalclientset.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
sharedIndexInformer := cache.NewSharedIndexInformer(
&cache.ListWatch{
ListFunc: func(options v1.ListOptions) (runtime.Object, error) {
return client.Apiextensions().CustomResources().List(options)
},
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
return client.Apiextensions().CustomResources().Watch(options)
},
},
&apiextensions.CustomResource{},
resyncPeriod,
cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc},
)
return sharedIndexInformer
}
func (f *customResourceInformer) Informer() cache.SharedIndexInformer {
return f.factory.InformerFor(&apiextensions.CustomResource{}, newCustomResourceInformer)
}
func (f *customResourceInformer) Lister() internalversion.CustomResourceLister {
return internalversion.NewCustomResourceLister(f.Informer().GetIndexer())
}

View File

@@ -0,0 +1,43 @@
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// This file was automatically generated by informer-gen
package internalversion
import (
internalinterfaces "k8s.io/kube-apiextensions-server/pkg/client/informers/internalversion/internalinterfaces"
)
// Interface provides access to all the informers in this group version.
type Interface interface {
// CustomResources returns a CustomResourceInformer.
CustomResources() CustomResourceInformer
}
type version struct {
internalinterfaces.SharedInformerFactory
}
// New returns a new Interface.
func New(f internalinterfaces.SharedInformerFactory) Interface {
return &version{f}
}
// CustomResources returns a CustomResourceInformer.
func (v *version) CustomResources() CustomResourceInformer {
return &customResourceInformer{factory: v.SharedInformerFactory}
}

View File

@@ -0,0 +1,95 @@
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// This file was automatically generated by informer-gen
package internalversion
import (
runtime "k8s.io/apimachinery/pkg/runtime"
schema "k8s.io/apimachinery/pkg/runtime/schema"
cache "k8s.io/client-go/tools/cache"
internalclientset "k8s.io/kube-apiextensions-server/pkg/client/clientset/internalclientset"
apiextensions "k8s.io/kube-apiextensions-server/pkg/client/informers/internalversion/apiextensions"
internalinterfaces "k8s.io/kube-apiextensions-server/pkg/client/informers/internalversion/internalinterfaces"
reflect "reflect"
sync "sync"
time "time"
)
type sharedInformerFactory struct {
client internalclientset.Interface
lock sync.Mutex
defaultResync time.Duration
informers map[reflect.Type]cache.SharedIndexInformer
// startedInformers is used for tracking which informers have been started.
// This allows Start() to be called multiple times safely.
startedInformers map[reflect.Type]bool
}
// NewSharedInformerFactory constructs a new instance of sharedInformerFactory
func NewSharedInformerFactory(client internalclientset.Interface, defaultResync time.Duration) SharedInformerFactory {
return &sharedInformerFactory{
client: client,
defaultResync: defaultResync,
informers: make(map[reflect.Type]cache.SharedIndexInformer),
startedInformers: make(map[reflect.Type]bool),
}
}
// Start initializes all requested informers.
func (f *sharedInformerFactory) Start(stopCh <-chan struct{}) {
f.lock.Lock()
defer f.lock.Unlock()
for informerType, informer := range f.informers {
if !f.startedInformers[informerType] {
go informer.Run(stopCh)
f.startedInformers[informerType] = true
}
}
}
// InternalInformerFor returns the SharedIndexInformer for obj using an internal
// client.
func (f *sharedInformerFactory) InformerFor(obj runtime.Object, newFunc internalinterfaces.NewInformerFunc) cache.SharedIndexInformer {
f.lock.Lock()
defer f.lock.Unlock()
informerType := reflect.TypeOf(obj)
informer, exists := f.informers[informerType]
if exists {
return informer
}
informer = newFunc(f.client, f.defaultResync)
f.informers[informerType] = informer
return informer
}
// SharedInformerFactory provides shared informers for resources in all known
// API group versions.
type SharedInformerFactory interface {
internalinterfaces.SharedInformerFactory
ForResource(resource schema.GroupVersionResource) (GenericInformer, error)
Apiextensions() apiextensions.Interface
}
func (f *sharedInformerFactory) Apiextensions() apiextensions.Interface {
return apiextensions.New(f)
}

View File

@@ -0,0 +1,61 @@
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// This file was automatically generated by informer-gen
package internalversion
import (
"fmt"
schema "k8s.io/apimachinery/pkg/runtime/schema"
cache "k8s.io/client-go/tools/cache"
apiextensions "k8s.io/kube-apiextensions-server/pkg/apis/apiextensions"
)
// GenericInformer is type of SharedIndexInformer which will locate and delegate to other
// sharedInformers based on type
type GenericInformer interface {
Informer() cache.SharedIndexInformer
Lister() cache.GenericLister
}
type genericInformer struct {
informer cache.SharedIndexInformer
resource schema.GroupResource
}
// Informer returns the SharedIndexInformer.
func (f *genericInformer) Informer() cache.SharedIndexInformer {
return f.informer
}
// Lister returns the GenericLister.
func (f *genericInformer) Lister() cache.GenericLister {
return cache.NewGenericLister(f.Informer().GetIndexer(), f.resource)
}
// ForResource gives generic access to a shared informer of the matching type
// TODO extend this to unknown resources with a client pool
func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource) (GenericInformer, error) {
switch resource {
// Group=Apiextensions, Version=InternalVersion
case apiextensions.SchemeGroupVersion.WithResource("customresources"):
return &genericInformer{resource: resource.GroupResource(), informer: f.Apiextensions().InternalVersion().CustomResources().Informer()}, nil
}
return nil, fmt.Errorf("no informer found for %v", resource)
}

View File

@@ -0,0 +1,19 @@
package(default_visibility = ["//visibility:public"])
licenses(["notice"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = ["factory_interfaces.go"],
tags = ["automanaged"],
deps = [
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/client-go/tools/cache:go_default_library",
"//vendor/k8s.io/kube-apiextensions-server/pkg/client/clientset/internalclientset:go_default_library",
],
)

View File

@@ -0,0 +1,34 @@
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// This file was automatically generated by informer-gen
package internalinterfaces
import (
runtime "k8s.io/apimachinery/pkg/runtime"
cache "k8s.io/client-go/tools/cache"
internalclientset "k8s.io/kube-apiextensions-server/pkg/client/clientset/internalclientset"
time "time"
)
type NewInformerFunc func(internalclientset.Interface, time.Duration) cache.SharedIndexInformer
// SharedInformerFactory a small interface to allow for adding an informer without an import cycle
type SharedInformerFactory interface {
Start(stopCh <-chan struct{})
InformerFor(obj runtime.Object, newFunc NewInformerFunc) cache.SharedIndexInformer
}

View File

@@ -0,0 +1,24 @@
package(default_visibility = ["//visibility:public"])
licenses(["notice"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = [
"customresource.go",
"expansion_generated.go",
],
tags = ["automanaged"],
deps = [
"//vendor/k8s.io/apimachinery/pkg/api/errors:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/labels:go_default_library",
"//vendor/k8s.io/client-go/tools/cache:go_default_library",
"//vendor/k8s.io/kube-apiextensions-server/pkg/apis/apiextensions:go_default_library",
],
)

View File

@@ -0,0 +1,67 @@
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// This file was automatically generated by lister-gen
package internalversion
import (
"k8s.io/apimachinery/pkg/api/errors"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/client-go/tools/cache"
apiextensions "k8s.io/kube-apiextensions-server/pkg/apis/apiextensions"
)
// CustomResourceLister helps list CustomResources.
type CustomResourceLister interface {
// List lists all CustomResources in the indexer.
List(selector labels.Selector) (ret []*apiextensions.CustomResource, err error)
// Get retrieves the CustomResource from the index for a given name.
Get(name string) (*apiextensions.CustomResource, error)
CustomResourceListerExpansion
}
// customResourceLister implements the CustomResourceLister interface.
type customResourceLister struct {
indexer cache.Indexer
}
// NewCustomResourceLister returns a new CustomResourceLister.
func NewCustomResourceLister(indexer cache.Indexer) CustomResourceLister {
return &customResourceLister{indexer: indexer}
}
// List lists all CustomResources in the indexer.
func (s *customResourceLister) List(selector labels.Selector) (ret []*apiextensions.CustomResource, err error) {
err = cache.ListAll(s.indexer, selector, func(m interface{}) {
ret = append(ret, m.(*apiextensions.CustomResource))
})
return ret, err
}
// Get retrieves the CustomResource from the index for a given name.
func (s *customResourceLister) Get(name string) (*apiextensions.CustomResource, error) {
key := &apiextensions.CustomResource{ObjectMeta: v1.ObjectMeta{Name: name}}
obj, exists, err := s.indexer.Get(key)
if err != nil {
return nil, err
}
if !exists {
return nil, errors.NewNotFound(apiextensions.Resource("customresource"), name)
}
return obj.(*apiextensions.CustomResource), nil
}

View File

@@ -0,0 +1,23 @@
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// This file was automatically generated by lister-gen
package internalversion
// CustomResourceListerExpansion allows custom methods to be added to
// CustomResourceLister.
type CustomResourceListerExpansion interface{}

Some files were not shown because too many files have changed in this diff Show More