mirror of
https://github.com/kubernetes/client-go.git
synced 2026-05-15 11:43:33 +00:00
Compare commits
305 Commits
release-3.
...
v4.0.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d92e8497f7 | ||
|
|
91e3f9312a | ||
|
|
1f9a49df2c | ||
|
|
ec392585e9 | ||
|
|
d9588c19ff | ||
|
|
d1fa9c161c | ||
|
|
0caf586a65 | ||
|
|
16b0436fa2 | ||
|
|
9508caae84 | ||
|
|
25bffd9c45 | ||
|
|
df46f7f13b | ||
|
|
684c9f06e8 | ||
|
|
e356aa2e77 | ||
|
|
d8822e0597 | ||
|
|
e83269bc2b | ||
|
|
382c391988 | ||
|
|
eddc268ce3 | ||
|
|
63a56d7439 | ||
|
|
cc44961f93 | ||
|
|
1cd03f0805 | ||
|
|
51bf18f5e6 | ||
|
|
46003734b1 | ||
|
|
56e6e0e8fd | ||
|
|
4030b37262 | ||
|
|
1c32168167 | ||
|
|
cc9ad31a2a | ||
|
|
b131aa47b5 | ||
|
|
83b93de35a | ||
|
|
6620bd1af9 | ||
|
|
ecd7406c9f | ||
|
|
2c59aca317 | ||
|
|
b3357e1e10 | ||
|
|
dbc1e28158 | ||
|
|
d54b530cba | ||
|
|
c1b6a1c0a4 | ||
|
|
7e76c26781 | ||
|
|
5c999e1aec | ||
|
|
70922d408f | ||
|
|
5adaf62880 | ||
|
|
6df6f2148a | ||
|
|
2163038fbf | ||
|
|
36b51953e6 | ||
|
|
d184230daa | ||
|
|
c2459566d6 | ||
|
|
e12b58626c | ||
|
|
fabe644bb3 | ||
|
|
1741b65fcb | ||
|
|
794d95e91e | ||
|
|
83b4b27326 | ||
|
|
5990d225d9 | ||
|
|
d44b3079ca | ||
|
|
92eadecb13 | ||
|
|
5c16341058 | ||
|
|
bbe6158ef3 | ||
|
|
4f99d16391 | ||
|
|
99b01357a0 | ||
|
|
5f9a335584 | ||
|
|
a8d18952cb | ||
|
|
1f501c6ac0 | ||
|
|
25e58688a7 | ||
|
|
52247e9130 | ||
|
|
b1f01ecf00 | ||
|
|
157df17111 | ||
|
|
1db1ab7b11 | ||
|
|
bf9b15475a | ||
|
|
62a5cd0975 | ||
|
|
38cb1a951d | ||
|
|
d9ea62815a | ||
|
|
a23ebdbf48 | ||
|
|
27aa69fcc8 | ||
|
|
aad51bc86d | ||
|
|
b113bd5b26 | ||
|
|
11c69ac127 | ||
|
|
8787fb55e2 | ||
|
|
8db6be287c | ||
|
|
375eed416f | ||
|
|
c39a8b699d | ||
|
|
5ae2719295 | ||
|
|
44b2cb7282 | ||
|
|
d3d2ebe2d3 | ||
|
|
e65054aaa9 | ||
|
|
5ccf401176 | ||
|
|
cad616fd7b | ||
|
|
10e9ca1449 | ||
|
|
b1f4aacc70 | ||
|
|
7bef0aa41b | ||
|
|
0c8efe21e2 | ||
|
|
6bfadd9f8f | ||
|
|
2e44fe3560 | ||
|
|
48409ad603 | ||
|
|
18c8914690 | ||
|
|
ed614f066a | ||
|
|
dc0c592386 | ||
|
|
0d7af62b83 | ||
|
|
1309db5ec6 | ||
|
|
a5e25d7218 | ||
|
|
87c960d69b | ||
|
|
8debebccfb | ||
|
|
309d9ec71a | ||
|
|
e06018a166 | ||
|
|
e15298083c | ||
|
|
8efad6dbf0 | ||
|
|
6e8ae30f39 | ||
|
|
d12329fb4d | ||
|
|
07c4fcb4df | ||
|
|
6b1566ccaa | ||
|
|
450baa5d60 | ||
|
|
34de549141 | ||
|
|
074f58b23a | ||
|
|
25835dfc1e | ||
|
|
d84ceacdd1 | ||
|
|
09165439d7 | ||
|
|
dd465010d3 | ||
|
|
c6a3373021 | ||
|
|
1f73522a95 | ||
|
|
b59661b22c | ||
|
|
2255f22758 | ||
|
|
4e6534081b | ||
|
|
45154911ef | ||
|
|
1788286020 | ||
|
|
16495c6a8f | ||
|
|
59a623b7ba | ||
|
|
6a84e825d9 | ||
|
|
b904f78ea0 | ||
|
|
3a86c93348 | ||
|
|
24b46cb91b | ||
|
|
8aceb98010 | ||
|
|
5eab562d64 | ||
|
|
cf4d5c32f3 | ||
|
|
cf4cea8c3f | ||
|
|
3290c558e2 | ||
|
|
0aaf615b8c | ||
|
|
a53d10f5ad | ||
|
|
2ea6418cfa | ||
|
|
c5bdf38534 | ||
|
|
299a25eb5a | ||
|
|
7ed1861317 | ||
|
|
9e7cf8d7ca | ||
|
|
28760732a9 | ||
|
|
dffa083760 | ||
|
|
20e59c60f8 | ||
|
|
29b5bff0fa | ||
|
|
fdfa162aed | ||
|
|
8a36291845 | ||
|
|
a546461dcc | ||
|
|
f851632ada | ||
|
|
fe9ac9f9c0 | ||
|
|
1bf81ae841 | ||
|
|
f3b79c3323 | ||
|
|
3c049628f8 | ||
|
|
7ee9bbd10c | ||
|
|
f1648c6391 | ||
|
|
1b8c2a3e22 | ||
|
|
29ea990f7c | ||
|
|
6434e2e4bb | ||
|
|
5a21aa58a2 | ||
|
|
bdefb3c11a | ||
|
|
a46cb79cf4 | ||
|
|
e833e172a0 | ||
|
|
d112596ad6 | ||
|
|
02b7d62fd4 | ||
|
|
1120d7fc8d | ||
|
|
8d49905c48 | ||
|
|
bb2e182124 | ||
|
|
650f6b4f1d | ||
|
|
958f3df6a4 | ||
|
|
dad27d745a | ||
|
|
ca719949f1 | ||
|
|
1f311d1b79 | ||
|
|
22eca115bd | ||
|
|
e71930600e | ||
|
|
d2e281defd | ||
|
|
69da22a50f | ||
|
|
6db1a83402 | ||
|
|
85c50f4ccb | ||
|
|
ede4e68eb7 | ||
|
|
89e9cea531 | ||
|
|
0389c75147 | ||
|
|
8e696697e7 | ||
|
|
64e947de2f | ||
|
|
f0ab6b85bd | ||
|
|
ad97d39b91 | ||
|
|
b3c3c3d1fe | ||
|
|
7b1f9a193b | ||
|
|
f1cb94b672 | ||
|
|
bc6311c19c | ||
|
|
7ba6be5949 | ||
|
|
db4645fe45 | ||
|
|
ee36746f42 | ||
|
|
750abd4711 | ||
|
|
e7b07ed0c1 | ||
|
|
9ccb531510 | ||
|
|
54b86aca52 | ||
|
|
d4d5232db6 | ||
|
|
1a014f4539 | ||
|
|
153fd0bab2 | ||
|
|
384737846d | ||
|
|
cf012f20d0 | ||
|
|
670b68600e | ||
|
|
313ec0555a | ||
|
|
c6d944a2de | ||
|
|
3fa06e848c | ||
|
|
6bc1999690 | ||
|
|
6cd603a009 | ||
|
|
97a8b3b040 | ||
|
|
c192350f2c | ||
|
|
dee664a95b | ||
|
|
71cbfce9d8 | ||
|
|
818c53c780 | ||
|
|
51e9e663fd | ||
|
|
837527a2a0 | ||
|
|
70c13e394d | ||
|
|
d3789e9779 | ||
|
|
21a475eefb | ||
|
|
714e60e890 | ||
|
|
e2c503b420 | ||
|
|
1aa489224e | ||
|
|
7972aac9f3 | ||
|
|
a4c9f96ebf | ||
|
|
a8293e2363 | ||
|
|
3e24501bb6 | ||
|
|
1baf68dddb | ||
|
|
f64a115c80 | ||
|
|
e57428f505 | ||
|
|
4c84996bc2 | ||
|
|
69f0a81e21 | ||
|
|
65b634c822 | ||
|
|
354468e551 | ||
|
|
ad53524c7c | ||
|
|
b128bee2cc | ||
|
|
5188c3e3d4 | ||
|
|
2876fbe4ad | ||
|
|
3113f909d8 | ||
|
|
f215249656 | ||
|
|
4f4d9e78f5 | ||
|
|
dd45794e15 | ||
|
|
633aab4bea | ||
|
|
bb2e2ad83c | ||
|
|
4b15a8b136 | ||
|
|
9a45999fa0 | ||
|
|
a1a3cacf90 | ||
|
|
3cbc5ba655 | ||
|
|
76c209704f | ||
|
|
5b1ad11ba7 | ||
|
|
449f25e669 | ||
|
|
8a68cfcf75 | ||
|
|
268171e690 | ||
|
|
bc86c35183 | ||
|
|
fcf5e39983 | ||
|
|
d2a94be401 | ||
|
|
57fb61ca9c | ||
|
|
5b0e11b577 | ||
|
|
faba476f26 | ||
|
|
b4836ee03e | ||
|
|
184fe30384 | ||
|
|
bcb754b775 | ||
|
|
656cf48fd6 | ||
|
|
0865289f28 | ||
|
|
5cca8d5380 | ||
|
|
d7af91d796 | ||
|
|
4a3ab2f5be | ||
|
|
e4963c97a8 | ||
|
|
5d5193044b | ||
|
|
bd7878428d | ||
|
|
035f98d6c6 | ||
|
|
634770b327 | ||
|
|
f503ec43c7 | ||
|
|
1953732e1e | ||
|
|
0ec10d4351 | ||
|
|
875418b286 | ||
|
|
b71dbc873e | ||
|
|
f065b8d2f7 | ||
|
|
f256b244db | ||
|
|
8459297e5e | ||
|
|
74bee732dd | ||
|
|
dcd132623d | ||
|
|
623dbc3dc4 | ||
|
|
d89514765b | ||
|
|
1f9cd88972 | ||
|
|
7f5f33cf4b | ||
|
|
dabf37f5df | ||
|
|
e4d1dd445d | ||
|
|
4e221f82e2 | ||
|
|
6919445563 | ||
|
|
e65642b619 | ||
|
|
bcb98146bb | ||
|
|
e8ae1e5c8e | ||
|
|
388446dfe7 | ||
|
|
8c2f08eadb | ||
|
|
16f41facbc | ||
|
|
1b8a363f59 | ||
|
|
20aa040788 | ||
|
|
63e44d4493 | ||
|
|
4c84db01ca | ||
|
|
8462402abd | ||
|
|
f15453e5cd | ||
|
|
999c0d5c20 | ||
|
|
9be38b2aa2 | ||
|
|
45bc41463a | ||
|
|
09ffb13d76 | ||
|
|
98caa049f9 | ||
|
|
6be328a96b | ||
|
|
45e7f68a04 | ||
|
|
200ba6b1ab | ||
|
|
399b27ce31 |
@@ -3,6 +3,6 @@ language: go
|
||||
go_import_path: k8s.io/client-go
|
||||
|
||||
go:
|
||||
- 1.7.4
|
||||
- 1.8.1
|
||||
|
||||
script: go build ./...
|
||||
|
||||
20
CHANGELOG.md
20
CHANGELOG.md
@@ -3,8 +3,22 @@ TODO: This document was neglected and is currently not complete. Working on
|
||||
fixing this.
|
||||
|
||||
# HEAD (changes that will go into the next release)
|
||||
* Added dependency on k8s.io/apimachinery
|
||||
* Added generated listers and informers
|
||||
|
||||
# v3.0.0-beta.0
|
||||
|
||||
* Added dependency on k8s.io/apimachinery. The impacts include changing import path of API objects like `ListOptions` from `k8s.io/client-go/pkg/api/v1` to `k8s.io/apimachinery/pkg/apis/meta/v1`.
|
||||
* Added generated listers (listers/) and informers (informers/)
|
||||
* Kubernetes API changes:
|
||||
* Added client support for:
|
||||
* authentication/v1
|
||||
* authorization/v1
|
||||
* autoscaling/v2alpha1
|
||||
* rbac/v1beta1
|
||||
* settings/v1alpha1
|
||||
* storage/v1
|
||||
* Changed client support for:
|
||||
* certificates from v1alpha1 to v1beta1
|
||||
* policy from v1alpha1 to v1beta1
|
||||
* CHANGED: pass typed options to dynamic client (https://github.com/kubernetes/kubernetes/pull/41887)
|
||||
|
||||
# v2.0.0
|
||||
@@ -18,7 +32,7 @@ fixing this.
|
||||
in separate branches.
|
||||
* Clientset supported multiple versions per API group
|
||||
* Added ThirdPartyResources example
|
||||
* API changes
|
||||
* Kubernetes API changes
|
||||
* Apps API group graduated to v1beta1
|
||||
* Policy API group graduated to v1beta1
|
||||
* Added support for batch/v2alpha1/cronjob
|
||||
|
||||
257
Godeps/Godeps.json
generated
257
Godeps/Godeps.json
generated
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"ImportPath": "k8s.io/client-go",
|
||||
"GoVersion": "go1.7",
|
||||
"GoVersion": "go1.8",
|
||||
"GodepVersion": "v79",
|
||||
"Packages": [
|
||||
"./..."
|
||||
@@ -16,6 +16,26 @@
|
||||
"Comment": "v0.1.0-115-g3b1ae45",
|
||||
"Rev": "3b1ae45394a234c385be014e9a488f2bb6eef821"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/Azure/go-autorest/autorest",
|
||||
"Comment": "v8.0.0",
|
||||
"Rev": "58f6f26e200fa5dfb40c9cd1c83f3e2c860d779d"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/Azure/go-autorest/autorest/adal",
|
||||
"Comment": "v8.0.0",
|
||||
"Rev": "58f6f26e200fa5dfb40c9cd1c83f3e2c860d779d"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/Azure/go-autorest/autorest/azure",
|
||||
"Comment": "v8.0.0",
|
||||
"Rev": "58f6f26e200fa5dfb40c9cd1c83f3e2c860d779d"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/Azure/go-autorest/autorest/date",
|
||||
"Comment": "v8.0.0",
|
||||
"Rev": "58f6f26e200fa5dfb40c9cd1c83f3e2c860d779d"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/PuerkitoBio/purell",
|
||||
"Comment": "v1.0.0",
|
||||
@@ -64,6 +84,11 @@
|
||||
"ImportPath": "github.com/davecgh/go-spew/spew",
|
||||
"Rev": "5215b55f46b2b919f50a1df0eaa5886afe4e3b3d"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/dgrijalva/jwt-go",
|
||||
"Comment": "v3.0.0-4-g01aeca5",
|
||||
"Rev": "01aeca54ebda6e0fbfafd0a524d234159c05ec20"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/docker/distribution/digest",
|
||||
"Comment": "v2.4.0-rc.1-38-gcd27f17",
|
||||
@@ -74,25 +99,37 @@
|
||||
"Comment": "v2.4.0-rc.1-38-gcd27f17",
|
||||
"Rev": "cd27f179f2c10c5d300e6d09025b538c475b0d51"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/docker/spdystream",
|
||||
"Rev": "449fdfce4d962303d702fec724ef0ad181c92528"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/docker/spdystream/spdy",
|
||||
"Rev": "449fdfce4d962303d702fec724ef0ad181c92528"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/emicklei/go-restful",
|
||||
"Comment": "v1.2-96-g09691a3",
|
||||
"Rev": "09691a3b6378b740595c1002f40c34dd5f218a22"
|
||||
"Comment": "2.2.0-4-gff4f55a",
|
||||
"Rev": "ff4f55a206334ef123e4f79bbf348980da81ca46"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/emicklei/go-restful-swagger12",
|
||||
"Comment": "1.0.1",
|
||||
"Rev": "dcef7f55730566d41eae5db10e7d6981829720f6"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/emicklei/go-restful/log",
|
||||
"Comment": "v1.2-96-g09691a3",
|
||||
"Rev": "09691a3b6378b740595c1002f40c34dd5f218a22"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/emicklei/go-restful/swagger",
|
||||
"Comment": "v1.2-96-g09691a3",
|
||||
"Rev": "09691a3b6378b740595c1002f40c34dd5f218a22"
|
||||
"Comment": "2.2.0-4-gff4f55a",
|
||||
"Rev": "ff4f55a206334ef123e4f79bbf348980da81ca46"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/ghodss/yaml",
|
||||
"Rev": "73d445a93680fa1a78ae23a5839bad48f32ba1ee"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/go-openapi/analysis",
|
||||
"Rev": "b44dc874b601d9e4e2f6e19140e794ba24bead3b"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/go-openapi/jsonpointer",
|
||||
"Rev": "46af16f9f7b149af66e5d1bd010e3574dc06de98"
|
||||
@@ -101,6 +138,10 @@
|
||||
"ImportPath": "github.com/go-openapi/jsonreference",
|
||||
"Rev": "13c6e3589ad90f49bd3e3bbe2c2cb3d7a4142272"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/go-openapi/loads",
|
||||
"Rev": "18441dfa706d924a39a030ee2c3b1d8d81917b38"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/go-openapi/spec",
|
||||
"Rev": "6aced65f8501fe1217321abf0749d354824ba2ff"
|
||||
@@ -111,13 +152,13 @@
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/gogo/protobuf/proto",
|
||||
"Comment": "v0.2-33-ge18d7aa",
|
||||
"Rev": "e18d7aa8f8c624c915db340349aad4c49b10d173"
|
||||
"Comment": "v0.4-3-gc0656ed",
|
||||
"Rev": "c0656edd0d9eab7c66d1eb0c568f9039345796f7"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/gogo/protobuf/sortkeys",
|
||||
"Comment": "v0.2-33-ge18d7aa",
|
||||
"Rev": "e18d7aa8f8c624c915db340349aad4c49b10d173"
|
||||
"Comment": "v0.4-3-gc0656ed",
|
||||
"Rev": "c0656edd0d9eab7c66d1eb0c568f9039345796f7"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/golang/glog",
|
||||
@@ -129,15 +170,23 @@
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/golang/protobuf/proto",
|
||||
"Rev": "8616e8ee5e20a1704615e6c8d7afcdac06087a67"
|
||||
"Rev": "4bd1920723d7b7c925de087aa32e2187708897f7"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/google/gofuzz",
|
||||
"Rev": "44d81051d367757e1c7c6a5a86423ece9afcf63c"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/hashicorp/golang-lru",
|
||||
"Rev": "a0d98a5f288019575c6d1f4bb1573fef2d1fcdc4"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/hashicorp/golang-lru/simplelru",
|
||||
"Rev": "a0d98a5f288019575c6d1f4bb1573fef2d1fcdc4"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/howeyc/gopass",
|
||||
"Rev": "3ca23474a7c7203e0a0a070fd33508f6efdb9b3d"
|
||||
"Rev": "bf9dde6d0d2c004a008c27aaee91170c786f6db8"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/imdario/mergo",
|
||||
@@ -150,7 +199,7 @@
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/juju/ratelimit",
|
||||
"Rev": "77ed1c8a01217656d2080ad51981f6e99adaa177"
|
||||
"Rev": "5b9ff866471762aa2ab2dced63c9fb6f53921342"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/mailru/easyjson/buffer",
|
||||
@@ -187,47 +236,47 @@
|
||||
},
|
||||
{
|
||||
"ImportPath": "golang.org/x/net/context",
|
||||
"Rev": "e90d6d0afc4c315a0d87a568ae68577cc15149a0"
|
||||
"Rev": "f2499483f923065a842d38eb4c7f1927e6fc6e6d"
|
||||
},
|
||||
{
|
||||
"ImportPath": "golang.org/x/net/context/ctxhttp",
|
||||
"Rev": "e90d6d0afc4c315a0d87a568ae68577cc15149a0"
|
||||
"Rev": "f2499483f923065a842d38eb4c7f1927e6fc6e6d"
|
||||
},
|
||||
{
|
||||
"ImportPath": "golang.org/x/net/http2",
|
||||
"Rev": "e90d6d0afc4c315a0d87a568ae68577cc15149a0"
|
||||
"Rev": "f2499483f923065a842d38eb4c7f1927e6fc6e6d"
|
||||
},
|
||||
{
|
||||
"ImportPath": "golang.org/x/net/http2/hpack",
|
||||
"Rev": "e90d6d0afc4c315a0d87a568ae68577cc15149a0"
|
||||
"Rev": "f2499483f923065a842d38eb4c7f1927e6fc6e6d"
|
||||
},
|
||||
{
|
||||
"ImportPath": "golang.org/x/net/idna",
|
||||
"Rev": "e90d6d0afc4c315a0d87a568ae68577cc15149a0"
|
||||
"Rev": "f2499483f923065a842d38eb4c7f1927e6fc6e6d"
|
||||
},
|
||||
{
|
||||
"ImportPath": "golang.org/x/net/lex/httplex",
|
||||
"Rev": "e90d6d0afc4c315a0d87a568ae68577cc15149a0"
|
||||
"Rev": "f2499483f923065a842d38eb4c7f1927e6fc6e6d"
|
||||
},
|
||||
{
|
||||
"ImportPath": "golang.org/x/oauth2",
|
||||
"Rev": "3c3a985cb79f52a3190fbc056984415ca6763d01"
|
||||
"Rev": "a6bd8cefa1811bd24b86f8902872e4e8225f74c4"
|
||||
},
|
||||
{
|
||||
"ImportPath": "golang.org/x/oauth2/google",
|
||||
"Rev": "3c3a985cb79f52a3190fbc056984415ca6763d01"
|
||||
"Rev": "a6bd8cefa1811bd24b86f8902872e4e8225f74c4"
|
||||
},
|
||||
{
|
||||
"ImportPath": "golang.org/x/oauth2/internal",
|
||||
"Rev": "3c3a985cb79f52a3190fbc056984415ca6763d01"
|
||||
"Rev": "a6bd8cefa1811bd24b86f8902872e4e8225f74c4"
|
||||
},
|
||||
{
|
||||
"ImportPath": "golang.org/x/oauth2/jws",
|
||||
"Rev": "3c3a985cb79f52a3190fbc056984415ca6763d01"
|
||||
"Rev": "a6bd8cefa1811bd24b86f8902872e4e8225f74c4"
|
||||
},
|
||||
{
|
||||
"ImportPath": "golang.org/x/oauth2/jwt",
|
||||
"Rev": "3c3a985cb79f52a3190fbc056984415ca6763d01"
|
||||
"Rev": "a6bd8cefa1811bd24b86f8902872e4e8225f74c4"
|
||||
},
|
||||
{
|
||||
"ImportPath": "golang.org/x/sys/unix",
|
||||
@@ -273,38 +322,6 @@
|
||||
"ImportPath": "golang.org/x/text/width",
|
||||
"Rev": "2910a502d2bf9e43193af9d68ca516529614eed3"
|
||||
},
|
||||
{
|
||||
"ImportPath": "google.golang.org/appengine",
|
||||
"Rev": "4f7eeb5305a4ba1966344836ba4af9996b7b4e05"
|
||||
},
|
||||
{
|
||||
"ImportPath": "google.golang.org/appengine/internal",
|
||||
"Rev": "4f7eeb5305a4ba1966344836ba4af9996b7b4e05"
|
||||
},
|
||||
{
|
||||
"ImportPath": "google.golang.org/appengine/internal/app_identity",
|
||||
"Rev": "4f7eeb5305a4ba1966344836ba4af9996b7b4e05"
|
||||
},
|
||||
{
|
||||
"ImportPath": "google.golang.org/appengine/internal/base",
|
||||
"Rev": "4f7eeb5305a4ba1966344836ba4af9996b7b4e05"
|
||||
},
|
||||
{
|
||||
"ImportPath": "google.golang.org/appengine/internal/datastore",
|
||||
"Rev": "4f7eeb5305a4ba1966344836ba4af9996b7b4e05"
|
||||
},
|
||||
{
|
||||
"ImportPath": "google.golang.org/appengine/internal/log",
|
||||
"Rev": "4f7eeb5305a4ba1966344836ba4af9996b7b4e05"
|
||||
},
|
||||
{
|
||||
"ImportPath": "google.golang.org/appengine/internal/modules",
|
||||
"Rev": "4f7eeb5305a4ba1966344836ba4af9996b7b4e05"
|
||||
},
|
||||
{
|
||||
"ImportPath": "google.golang.org/appengine/internal/remote_api",
|
||||
"Rev": "4f7eeb5305a4ba1966344836ba4af9996b7b4e05"
|
||||
},
|
||||
{
|
||||
"ImportPath": "gopkg.in/inf.v0",
|
||||
"Comment": "v0.9.0",
|
||||
@@ -316,179 +333,211 @@
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/api/equality",
|
||||
"Rev": "c1c4a7fe832857c75cc1d79c8e40d71d5da15fc6"
|
||||
"Rev": "1fd2e63a9a370677308a42f24fd40c86438afddf"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/api/errors",
|
||||
"Rev": "c1c4a7fe832857c75cc1d79c8e40d71d5da15fc6"
|
||||
"Rev": "1fd2e63a9a370677308a42f24fd40c86438afddf"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/api/meta",
|
||||
"Rev": "c1c4a7fe832857c75cc1d79c8e40d71d5da15fc6"
|
||||
"Rev": "1fd2e63a9a370677308a42f24fd40c86438afddf"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/api/resource",
|
||||
"Rev": "c1c4a7fe832857c75cc1d79c8e40d71d5da15fc6"
|
||||
"Rev": "1fd2e63a9a370677308a42f24fd40c86438afddf"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/api/testing",
|
||||
"Rev": "1fd2e63a9a370677308a42f24fd40c86438afddf"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/apimachinery",
|
||||
"Rev": "c1c4a7fe832857c75cc1d79c8e40d71d5da15fc6"
|
||||
"Rev": "1fd2e63a9a370677308a42f24fd40c86438afddf"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/apimachinery/announced",
|
||||
"Rev": "c1c4a7fe832857c75cc1d79c8e40d71d5da15fc6"
|
||||
"Rev": "1fd2e63a9a370677308a42f24fd40c86438afddf"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/apimachinery/registered",
|
||||
"Rev": "c1c4a7fe832857c75cc1d79c8e40d71d5da15fc6"
|
||||
"Rev": "1fd2e63a9a370677308a42f24fd40c86438afddf"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1",
|
||||
"Rev": "c1c4a7fe832857c75cc1d79c8e40d71d5da15fc6"
|
||||
"Rev": "1fd2e63a9a370677308a42f24fd40c86438afddf"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured",
|
||||
"Rev": "c1c4a7fe832857c75cc1d79c8e40d71d5da15fc6"
|
||||
"Rev": "1fd2e63a9a370677308a42f24fd40c86438afddf"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1alpha1",
|
||||
"Rev": "1fd2e63a9a370677308a42f24fd40c86438afddf"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/conversion",
|
||||
"Rev": "c1c4a7fe832857c75cc1d79c8e40d71d5da15fc6"
|
||||
"Rev": "1fd2e63a9a370677308a42f24fd40c86438afddf"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/conversion/queryparams",
|
||||
"Rev": "c1c4a7fe832857c75cc1d79c8e40d71d5da15fc6"
|
||||
"Rev": "1fd2e63a9a370677308a42f24fd40c86438afddf"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/conversion/unstructured",
|
||||
"Rev": "1fd2e63a9a370677308a42f24fd40c86438afddf"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/fields",
|
||||
"Rev": "c1c4a7fe832857c75cc1d79c8e40d71d5da15fc6"
|
||||
"Rev": "1fd2e63a9a370677308a42f24fd40c86438afddf"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/labels",
|
||||
"Rev": "c1c4a7fe832857c75cc1d79c8e40d71d5da15fc6"
|
||||
"Rev": "1fd2e63a9a370677308a42f24fd40c86438afddf"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/openapi",
|
||||
"Rev": "c1c4a7fe832857c75cc1d79c8e40d71d5da15fc6"
|
||||
"Rev": "1fd2e63a9a370677308a42f24fd40c86438afddf"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/runtime",
|
||||
"Rev": "c1c4a7fe832857c75cc1d79c8e40d71d5da15fc6"
|
||||
"Rev": "1fd2e63a9a370677308a42f24fd40c86438afddf"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/runtime/schema",
|
||||
"Rev": "c1c4a7fe832857c75cc1d79c8e40d71d5da15fc6"
|
||||
"Rev": "1fd2e63a9a370677308a42f24fd40c86438afddf"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer",
|
||||
"Rev": "c1c4a7fe832857c75cc1d79c8e40d71d5da15fc6"
|
||||
"Rev": "1fd2e63a9a370677308a42f24fd40c86438afddf"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/json",
|
||||
"Rev": "c1c4a7fe832857c75cc1d79c8e40d71d5da15fc6"
|
||||
"Rev": "1fd2e63a9a370677308a42f24fd40c86438afddf"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/protobuf",
|
||||
"Rev": "c1c4a7fe832857c75cc1d79c8e40d71d5da15fc6"
|
||||
"Rev": "1fd2e63a9a370677308a42f24fd40c86438afddf"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/recognizer",
|
||||
"Rev": "c1c4a7fe832857c75cc1d79c8e40d71d5da15fc6"
|
||||
"Rev": "1fd2e63a9a370677308a42f24fd40c86438afddf"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/streaming",
|
||||
"Rev": "c1c4a7fe832857c75cc1d79c8e40d71d5da15fc6"
|
||||
"Rev": "1fd2e63a9a370677308a42f24fd40c86438afddf"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/versioning",
|
||||
"Rev": "c1c4a7fe832857c75cc1d79c8e40d71d5da15fc6"
|
||||
"Rev": "1fd2e63a9a370677308a42f24fd40c86438afddf"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/selection",
|
||||
"Rev": "c1c4a7fe832857c75cc1d79c8e40d71d5da15fc6"
|
||||
"Rev": "1fd2e63a9a370677308a42f24fd40c86438afddf"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/types",
|
||||
"Rev": "c1c4a7fe832857c75cc1d79c8e40d71d5da15fc6"
|
||||
"Rev": "1fd2e63a9a370677308a42f24fd40c86438afddf"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/util/cache",
|
||||
"Rev": "1fd2e63a9a370677308a42f24fd40c86438afddf"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/util/clock",
|
||||
"Rev": "1fd2e63a9a370677308a42f24fd40c86438afddf"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/util/diff",
|
||||
"Rev": "c1c4a7fe832857c75cc1d79c8e40d71d5da15fc6"
|
||||
"Rev": "1fd2e63a9a370677308a42f24fd40c86438afddf"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/util/errors",
|
||||
"Rev": "c1c4a7fe832857c75cc1d79c8e40d71d5da15fc6"
|
||||
"Rev": "1fd2e63a9a370677308a42f24fd40c86438afddf"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/util/framer",
|
||||
"Rev": "c1c4a7fe832857c75cc1d79c8e40d71d5da15fc6"
|
||||
"Rev": "1fd2e63a9a370677308a42f24fd40c86438afddf"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/util/httpstream",
|
||||
"Rev": "c1c4a7fe832857c75cc1d79c8e40d71d5da15fc6"
|
||||
"Rev": "1fd2e63a9a370677308a42f24fd40c86438afddf"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/util/httpstream/spdy",
|
||||
"Rev": "1fd2e63a9a370677308a42f24fd40c86438afddf"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/util/intstr",
|
||||
"Rev": "c1c4a7fe832857c75cc1d79c8e40d71d5da15fc6"
|
||||
"Rev": "1fd2e63a9a370677308a42f24fd40c86438afddf"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/util/json",
|
||||
"Rev": "c1c4a7fe832857c75cc1d79c8e40d71d5da15fc6"
|
||||
"Rev": "1fd2e63a9a370677308a42f24fd40c86438afddf"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/util/mergepatch",
|
||||
"Rev": "c1c4a7fe832857c75cc1d79c8e40d71d5da15fc6"
|
||||
"Rev": "1fd2e63a9a370677308a42f24fd40c86438afddf"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/util/net",
|
||||
"Rev": "c1c4a7fe832857c75cc1d79c8e40d71d5da15fc6"
|
||||
"Rev": "1fd2e63a9a370677308a42f24fd40c86438afddf"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/util/rand",
|
||||
"Rev": "c1c4a7fe832857c75cc1d79c8e40d71d5da15fc6"
|
||||
"Rev": "1fd2e63a9a370677308a42f24fd40c86438afddf"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/util/remotecommand",
|
||||
"Rev": "1fd2e63a9a370677308a42f24fd40c86438afddf"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/util/runtime",
|
||||
"Rev": "c1c4a7fe832857c75cc1d79c8e40d71d5da15fc6"
|
||||
"Rev": "1fd2e63a9a370677308a42f24fd40c86438afddf"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/util/sets",
|
||||
"Rev": "c1c4a7fe832857c75cc1d79c8e40d71d5da15fc6"
|
||||
"Rev": "1fd2e63a9a370677308a42f24fd40c86438afddf"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/util/strategicpatch",
|
||||
"Rev": "c1c4a7fe832857c75cc1d79c8e40d71d5da15fc6"
|
||||
"Rev": "1fd2e63a9a370677308a42f24fd40c86438afddf"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/util/validation",
|
||||
"Rev": "c1c4a7fe832857c75cc1d79c8e40d71d5da15fc6"
|
||||
"Rev": "1fd2e63a9a370677308a42f24fd40c86438afddf"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/util/validation/field",
|
||||
"Rev": "c1c4a7fe832857c75cc1d79c8e40d71d5da15fc6"
|
||||
"Rev": "1fd2e63a9a370677308a42f24fd40c86438afddf"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/util/wait",
|
||||
"Rev": "c1c4a7fe832857c75cc1d79c8e40d71d5da15fc6"
|
||||
"Rev": "1fd2e63a9a370677308a42f24fd40c86438afddf"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/util/yaml",
|
||||
"Rev": "c1c4a7fe832857c75cc1d79c8e40d71d5da15fc6"
|
||||
"Rev": "1fd2e63a9a370677308a42f24fd40c86438afddf"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/version",
|
||||
"Rev": "c1c4a7fe832857c75cc1d79c8e40d71d5da15fc6"
|
||||
"Rev": "1fd2e63a9a370677308a42f24fd40c86438afddf"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/watch",
|
||||
"Rev": "c1c4a7fe832857c75cc1d79c8e40d71d5da15fc6"
|
||||
"Rev": "1fd2e63a9a370677308a42f24fd40c86438afddf"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/third_party/forked/golang/json",
|
||||
"Rev": "c1c4a7fe832857c75cc1d79c8e40d71d5da15fc6"
|
||||
"Rev": "1fd2e63a9a370677308a42f24fd40c86438afddf"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/third_party/forked/golang/netutil",
|
||||
"Rev": "1fd2e63a9a370677308a42f24fd40c86438afddf"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/third_party/forked/golang/reflect",
|
||||
"Rev": "c1c4a7fe832857c75cc1d79c8e40d71d5da15fc6"
|
||||
"Rev": "1fd2e63a9a370677308a42f24fd40c86438afddf"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
103
INSTALL.md
103
INSTALL.md
@@ -2,10 +2,33 @@
|
||||
|
||||
## For the casual user
|
||||
|
||||
Currently, there is no super easy way to use client-go. Hopefully this will
|
||||
change soon. Simply running `go get k8s.io/client-go/...` will leave you with a
|
||||
library that can't practically be used. It is important to synchronize your
|
||||
dependencies with the ones that are required by the library.
|
||||
If you want to write a simple script, don't care about a reproducible client
|
||||
library install, don't mind getting head (which may be less stable than a
|
||||
particular release), then simply:
|
||||
|
||||
```sh
|
||||
$ go get k8s.io/client-go/...
|
||||
```
|
||||
|
||||
This will install `k8s.io/client-go` in your `$GOPATH`. `k8s.io/client-go`
|
||||
includes most of its own dependencies in its `k8s.io/client-go/vendor` path,
|
||||
except for `k8s.io/apimachinery` and `glog`. `go get` will recursively download
|
||||
these excluded repos to your `$GOPATH`, if they don't already exist. If
|
||||
`k8s.io/apimachinery` preexisted in `$GOPATH`, you also need to:
|
||||
|
||||
```sh
|
||||
$ go get -u k8s.io/apimachinery/...
|
||||
```
|
||||
|
||||
because the head of client-go is only guaranteed to work with the head of
|
||||
apimachinery.
|
||||
|
||||
We excluded `k8s.io/apimachinery` and `glog` from `k8s.io/client-go/vendor` to
|
||||
prevent `go get` users from hitting issues like
|
||||
[#19](https://github.com/kubernetes/client-go/issues/19) and
|
||||
[#83](https://github.com/kubernetes/client-go/issues/83). If your project share
|
||||
other dependencies with client-go, and you hit issues similar to #19 or #83,
|
||||
then you'll need to look down at the next section.
|
||||
|
||||
Note: the official go policy is that libraries should not vendor their
|
||||
dependencies. This is unworkable for us, since our dependencies change and HEAD
|
||||
@@ -26,42 +49,6 @@ Reasons why you might need to use a dependency management system:
|
||||
There are three tools you could in theory use for this. Instructions
|
||||
for each follows.
|
||||
|
||||
### Dep
|
||||
|
||||
[dep](https://github.com/golang/dep) is an up-and-coming dependency management tool,
|
||||
which has the goal of being accepted as part of the standard go toolchain. Its
|
||||
status is currently alpha. However, it comes the closest to working easily out
|
||||
of the box.
|
||||
|
||||
```sh
|
||||
$ go get github.com/golang/dep
|
||||
$ go install github.com/golang/dep/cmd/dep
|
||||
|
||||
# Make sure you have a go file in your directory which imports k8s.io/client-go
|
||||
# first--I suggest copying one of the examples.
|
||||
$ dep init
|
||||
$ dep ensure k8s.io/client-go@^2.0.0
|
||||
```
|
||||
|
||||
Then you can try one of the
|
||||
[examples](https://github.com/kubernetes/client-go/tree/v2.0.0/examples/) from
|
||||
the 2.0.0 release.
|
||||
|
||||
This will set up a `vendor` directory in your current directory, add `k8s.io/client-go`
|
||||
to it, and flatten all of `k8s.io/client-go`'s dependencies into that vendor directory,
|
||||
so that your code and `client-go` will both get the same copy of each
|
||||
dependency.
|
||||
|
||||
After installing like this, you could either use dep for your other
|
||||
dependencies, or copy everything in the `vendor` directory into your
|
||||
`$GOPATH/src` directory and proceed as if you had done a fancy `go get` that
|
||||
flattened dependencies sanely.
|
||||
|
||||
One thing to note about dep is that it will omit dependencies that aren't
|
||||
actually used, and some dependencies of `client-go` are used only if you import
|
||||
one of the plugins (for example, the auth plugins). So you may need to run `dep
|
||||
ensure` again if you start importing a plugin that you weren't using before.
|
||||
|
||||
### Godep
|
||||
|
||||
[godep](https://github.com/tools/godep) is an older dependency management tool, which is
|
||||
@@ -155,3 +142,39 @@ After modifying, run `glide up -v` again to re-populate your /vendor directory.
|
||||
|
||||
Optionally, Glide users can also use [`glide-vc`](https://github.com/sgotti/glide-vc)
|
||||
after running `glide up -v` to remove unused files from /vendor.
|
||||
|
||||
### Dep
|
||||
|
||||
[dep](https://github.com/golang/dep) is an up-and-coming dependency management tool,
|
||||
which has the goal of being accepted as part of the standard go toolchain. Its
|
||||
status is currently alpha. However, it comes the closest to working easily out
|
||||
of the box.
|
||||
|
||||
```sh
|
||||
$ go get github.com/golang/dep
|
||||
$ go install github.com/golang/dep/cmd/dep
|
||||
|
||||
# Make sure you have a go file in your directory which imports a package of
|
||||
# k8s.io/client-go first--I suggest copying one of the examples.
|
||||
$ dep init
|
||||
$ dep ensure k8s.io/client-go@^2.0.0
|
||||
```
|
||||
|
||||
Then you can try one of the
|
||||
[examples](https://github.com/kubernetes/client-go/tree/v2.0.0/examples/) from
|
||||
the 2.0.0 release.
|
||||
|
||||
This will set up a `vendor` directory in your current directory, add `k8s.io/client-go`
|
||||
to it, and flatten all of `k8s.io/client-go`'s dependencies into that vendor directory,
|
||||
so that your code and `client-go` will both get the same copy of each
|
||||
dependency.
|
||||
|
||||
After installing like this, you could either use dep for your other
|
||||
dependencies, or copy everything in the `vendor` directory into your
|
||||
`$GOPATH/src` directory and proceed as if you had done a fancy `go get` that
|
||||
flattened dependencies sanely.
|
||||
|
||||
One thing to note about dep is that it will omit dependencies that aren't
|
||||
actually used, and some dependencies of `client-go` are used only if you import
|
||||
one of the plugins (for example, the auth plugins). So you may need to run `dep
|
||||
ensure` again if you start importing a plugin that you weren't using before.
|
||||
|
||||
1
OWNERS
1
OWNERS
@@ -4,6 +4,7 @@ approvers:
|
||||
- krousey
|
||||
- lavalamp
|
||||
- smarterclayton
|
||||
- sttts
|
||||
reviewers:
|
||||
- thockin
|
||||
- lavalamp
|
||||
|
||||
29
README.md
29
README.md
@@ -6,6 +6,9 @@ We currently recommend using the v2.0.0 tag. See [INSTALL.md](/INSTALL.md) for
|
||||
detailed installation instructions. `go get k8s.io/client-go/...` works, but
|
||||
will give you head and doesn't handle the dependencies well.
|
||||
|
||||
[](https://travis-ci.org/kubernetes/client-go)
|
||||
[](https://godoc.org/k8s.io/client-go)
|
||||
|
||||
## Table of Contents
|
||||
|
||||
- [What's included](#whats-included)
|
||||
@@ -77,20 +80,21 @@ We will backport bugfixes--but not new features--into older versions of
|
||||
|
||||
#### Compatibility matrix
|
||||
|
||||
| | Kubernetes 1.3 | Kubernetes 1.4 | Kubernetes 1.5 | Kubernetes 1.6 (not released yet) |
|
||||
|----------------|----------------|----------------|----------------|----------------|
|
||||
| client-go 1.4 | + | ✓ | - | - |
|
||||
| client-go 1.5 | + | + | - | - |
|
||||
| client-go 2.0 | + | + | ✓ | - |
|
||||
| client-go HEAD | + | + | + | ✓ |
|
||||
| | Kubernetes 1.3 | Kubernetes 1.4 | Kubernetes 1.5 | Kubernetes 1.6 |
|
||||
|---------------------|----------------|----------------|----------------|----------------|
|
||||
| client-go 1.4 | + | ✓ | - | - |
|
||||
| client-go 1.5 | + | + | - | - |
|
||||
| client-go 2.0 | + | + | ✓ | - |
|
||||
| client-go 3.0 beta | + | + | + | ✓ |
|
||||
| client-go HEAD | + | + | + | + |
|
||||
|
||||
Key:
|
||||
|
||||
* ✓ Exactly the same features / API objects in both client-go and the Kubernetes
|
||||
* `✓` Exactly the same features / API objects in both client-go and the Kubernetes
|
||||
version.
|
||||
* + client-go has features or api objects that may not be present in the
|
||||
* `+` client-go has features or api objects that may not be present in the
|
||||
Kubernetes cluster, but everything they have in common will work.
|
||||
* - The Kubernetes cluster has features the client-go library can't use
|
||||
* `-` The Kubernetes cluster has features the client-go library can't use
|
||||
(additional API objects, etc).
|
||||
|
||||
See the [CHANGELOG](./CHANGELOG.md) for a detailed description of changes
|
||||
@@ -101,13 +105,14 @@ between client-go versions.
|
||||
| client-go 1.4 | Kubernetes main repo, 1.4 branch | = - |
|
||||
| client-go 1.5 | Kubernetes main repo, 1.5 branch | = - |
|
||||
| client-go 2.0 | Kubernetes main repo, 1.5 branch | ✓ |
|
||||
| client-go 3.0 | Kubernetes main repo, 1.6 branch | ✓ |
|
||||
| client-go HEAD | Kubernetes main repo, master branch | ✓ |
|
||||
|
||||
Key:
|
||||
|
||||
* ✓ Changes in main Kubernetes repo are actively published to client-go by a bot
|
||||
* = Maintenance is manual, only severe security bugs will be patched.
|
||||
* - Deprecated; please upgrade.
|
||||
* `✓` Changes in main Kubernetes repo are actively published to client-go by a bot
|
||||
* `=` Maintenance is manual, only severe security bugs will be patched.
|
||||
* `-` Deprecated; please upgrade.
|
||||
|
||||
#### Deprecation policy
|
||||
|
||||
|
||||
63
discovery/BUILD
Normal file
63
discovery/BUILD
Normal file
@@ -0,0 +1,63 @@
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
licenses(["notice"])
|
||||
|
||||
load(
|
||||
"@io_bazel_rules_go//go:def.bzl",
|
||||
"go_library",
|
||||
"go_test",
|
||||
)
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = [
|
||||
"discovery_client.go",
|
||||
"helper.go",
|
||||
"restmapper.go",
|
||||
"unstructured.go",
|
||||
],
|
||||
tags = ["automanaged"],
|
||||
deps = [
|
||||
"//vendor/github.com/emicklei/go-restful-swagger12:go_default_library",
|
||||
"//vendor/github.com/go-openapi/loads:go_default_library",
|
||||
"//vendor/github.com/go-openapi/spec:go_default_library",
|
||||
"//vendor/github.com/golang/glog:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/api/errors:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/api/meta: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/util/sets:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/version:go_default_library",
|
||||
"//vendor/k8s.io/client-go/kubernetes/scheme:go_default_library",
|
||||
"//vendor/k8s.io/client-go/pkg/api/v1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/rest:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
go_test(
|
||||
name = "go_default_xtest",
|
||||
srcs = [
|
||||
"discovery_client_test.go",
|
||||
"helper_blackbox_test.go",
|
||||
"restmapper_test.go",
|
||||
],
|
||||
tags = ["automanaged"],
|
||||
deps = [
|
||||
"//vendor/github.com/emicklei/go-restful-swagger12:go_default_library",
|
||||
"//vendor/github.com/go-openapi/spec:go_default_library",
|
||||
"//vendor/github.com/stretchr/testify/assert:go_default_library",
|
||||
"//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/runtime:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/util/sets:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/version:go_default_library",
|
||||
"//vendor/k8s.io/client-go/discovery:go_default_library",
|
||||
"//vendor/k8s.io/client-go/kubernetes/scheme:go_default_library",
|
||||
"//vendor/k8s.io/client-go/pkg/api/v1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/rest:go_default_library",
|
||||
"//vendor/k8s.io/client-go/rest/fake:go_default_library",
|
||||
],
|
||||
)
|
||||
@@ -23,15 +23,17 @@ import (
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"github.com/emicklei/go-restful/swagger"
|
||||
"github.com/emicklei/go-restful-swagger12"
|
||||
|
||||
"github.com/go-openapi/loads"
|
||||
"github.com/go-openapi/spec"
|
||||
"k8s.io/apimachinery/pkg/api/errors"
|
||||
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/client-go/pkg/api"
|
||||
"k8s.io/client-go/kubernetes/scheme"
|
||||
"k8s.io/client-go/pkg/api/v1"
|
||||
restclient "k8s.io/client-go/rest"
|
||||
)
|
||||
@@ -47,6 +49,7 @@ type DiscoveryInterface interface {
|
||||
ServerResourcesInterface
|
||||
ServerVersionInterface
|
||||
SwaggerSchemaInterface
|
||||
OpenAPISchemaInterface
|
||||
}
|
||||
|
||||
// CachedDiscoveryInterface is a DiscoveryInterface with cache invalidation and freshness.
|
||||
@@ -91,6 +94,12 @@ type SwaggerSchemaInterface interface {
|
||||
SwaggerSchema(version schema.GroupVersion) (*swagger.ApiDeclaration, error)
|
||||
}
|
||||
|
||||
// OpenAPISchemaInterface has a method to retrieve the open API schema.
|
||||
type OpenAPISchemaInterface interface {
|
||||
// OpenAPISchema retrieves and parses the swagger API schema the server supports.
|
||||
OpenAPISchema() (*spec.Swagger, error)
|
||||
}
|
||||
|
||||
// DiscoveryClient implements the functions that discover server-supported API groups,
|
||||
// versions and resources.
|
||||
type DiscoveryClient struct {
|
||||
@@ -332,6 +341,7 @@ func (d *DiscoveryClient) ServerVersion() (*version.Info, error) {
|
||||
}
|
||||
|
||||
// SwaggerSchema retrieves and parses the swagger API schema the server supports.
|
||||
// TODO: Replace usages with Open API. Tracked in https://github.com/kubernetes/kubernetes/issues/44589
|
||||
func (d *DiscoveryClient) SwaggerSchema(version schema.GroupVersion) (*swagger.ApiDeclaration, error) {
|
||||
if version.Empty() {
|
||||
return nil, fmt.Errorf("groupVersion cannot be empty")
|
||||
@@ -365,6 +375,21 @@ func (d *DiscoveryClient) SwaggerSchema(version schema.GroupVersion) (*swagger.A
|
||||
return &schema, nil
|
||||
}
|
||||
|
||||
// OpenAPISchema fetches the open api schema using a rest client and parses the json.
|
||||
// Warning: this is very expensive (~1.2s)
|
||||
func (d *DiscoveryClient) OpenAPISchema() (*spec.Swagger, error) {
|
||||
data, err := d.restClient.Get().AbsPath("/swagger.json").Do().Raw()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
msg := json.RawMessage(data)
|
||||
doc, err := loads.Analyzed(msg, "")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return doc.Spec(), err
|
||||
}
|
||||
|
||||
// withRetries retries the given recovery function in case the groups supported by the server change after ServerGroup() returns.
|
||||
func withRetries(maxRetries int, f func(failEarly bool) ([]*metav1.APIResourceList, error)) ([]*metav1.APIResourceList, error) {
|
||||
var result []*metav1.APIResourceList
|
||||
@@ -385,7 +410,7 @@ func withRetries(maxRetries int, f func(failEarly bool) ([]*metav1.APIResourceLi
|
||||
func setDiscoveryDefaults(config *restclient.Config) error {
|
||||
config.APIPath = ""
|
||||
config.GroupVersion = nil
|
||||
codec := runtime.NoopEncoder{Decoder: api.Codecs.UniversalDecoder()}
|
||||
codec := runtime.NoopEncoder{Decoder: scheme.Codecs.UniversalDecoder()}
|
||||
config.NegotiatedSerializer = serializer.NegotiatedSerializerWrapper(runtime.SerializerInfo{Serializer: codec})
|
||||
if len(config.UserAgent) == 0 {
|
||||
config.UserAgent = restclient.DefaultKubernetesUserAgent()
|
||||
|
||||
@@ -18,13 +18,15 @@ package discovery_test
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/emicklei/go-restful/swagger"
|
||||
"github.com/emicklei/go-restful-swagger12"
|
||||
|
||||
"github.com/go-openapi/spec"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"k8s.io/apimachinery/pkg/util/sets"
|
||||
@@ -325,6 +327,81 @@ func TestGetSwaggerSchemaFail(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
var returnedOpenAPI = spec.Swagger{
|
||||
SwaggerProps: spec.SwaggerProps{
|
||||
Definitions: spec.Definitions{
|
||||
"fake.type.1": spec.Schema{
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Properties: map[string]spec.Schema{
|
||||
"count": {
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Type: []string{"integer"},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"fake.type.2": spec.Schema{
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Properties: map[string]spec.Schema{
|
||||
"count": {
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Type: []string{"array"},
|
||||
Items: &spec.SchemaOrArray{
|
||||
Schema: &spec.Schema{
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Type: []string{"string"},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
func openapiSchemaFakeServer() (*httptest.Server, error) {
|
||||
var sErr error
|
||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
|
||||
if req.URL.Path != "/swagger.json" {
|
||||
sErr = fmt.Errorf("Unexpected url %v", req.URL)
|
||||
}
|
||||
if req.Method != "GET" {
|
||||
sErr = fmt.Errorf("Unexpected method %v", req.Method)
|
||||
}
|
||||
|
||||
output, err := json.Marshal(returnedOpenAPI)
|
||||
if err != nil {
|
||||
sErr = err
|
||||
return
|
||||
}
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
w.Write(output)
|
||||
}))
|
||||
return server, sErr
|
||||
}
|
||||
|
||||
func TestGetOpenAPISchema(t *testing.T) {
|
||||
server, err := openapiSchemaFakeServer()
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error starting fake server: %v", err)
|
||||
}
|
||||
defer server.Close()
|
||||
|
||||
client := NewDiscoveryClientForConfigOrDie(&restclient.Config{Host: server.URL})
|
||||
got, err := client.OpenAPISchema()
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error getting openapi: %v", err)
|
||||
}
|
||||
if e, a := returnedOpenAPI, *got; !reflect.DeepEqual(e, a) {
|
||||
t.Errorf("expected %v, got %v", e, a)
|
||||
}
|
||||
}
|
||||
|
||||
func TestServerPreferredResources(t *testing.T) {
|
||||
stable := metav1.APIResourceList{
|
||||
GroupVersion: "v1",
|
||||
@@ -617,8 +694,8 @@ func TestServerPreferredNamespacedResources(t *testing.T) {
|
||||
w.Write(output)
|
||||
},
|
||||
expected: map[schema.GroupVersionResource]struct{}{
|
||||
schema.GroupVersionResource{Group: "", Version: "v1", Resource: "pods"}: {},
|
||||
schema.GroupVersionResource{Group: "", Version: "v1", Resource: "services"}: {},
|
||||
{Group: "", Version: "v1", Resource: "pods"}: {},
|
||||
{Group: "", Version: "v1", Resource: "services"}: {},
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -660,8 +737,8 @@ func TestServerPreferredNamespacedResources(t *testing.T) {
|
||||
w.Write(output)
|
||||
},
|
||||
expected: map[schema.GroupVersionResource]struct{}{
|
||||
schema.GroupVersionResource{Group: "batch", Version: "v1", Resource: "jobs"}: {},
|
||||
schema.GroupVersionResource{Group: "batch", Version: "v2alpha1", Resource: "cronjobs"}: {},
|
||||
{Group: "batch", Version: "v1", Resource: "jobs"}: {},
|
||||
{Group: "batch", Version: "v2alpha1", Resource: "cronjobs"}: {},
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -703,8 +780,8 @@ func TestServerPreferredNamespacedResources(t *testing.T) {
|
||||
w.Write(output)
|
||||
},
|
||||
expected: map[schema.GroupVersionResource]struct{}{
|
||||
schema.GroupVersionResource{Group: "batch", Version: "v2alpha1", Resource: "jobs"}: {},
|
||||
schema.GroupVersionResource{Group: "batch", Version: "v2alpha1", Resource: "cronjobs"}: {},
|
||||
{Group: "batch", Version: "v2alpha1", Resource: "jobs"}: {},
|
||||
{Group: "batch", Version: "v2alpha1", Resource: "cronjobs"}: {},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
25
discovery/fake/BUILD
Normal file
25
discovery/fake/BUILD
Normal 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 = ["discovery.go"],
|
||||
tags = ["automanaged"],
|
||||
deps = [
|
||||
"//vendor/github.com/emicklei/go-restful-swagger12:go_default_library",
|
||||
"//vendor/github.com/go-openapi/spec:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/version:go_default_library",
|
||||
"//vendor/k8s.io/client-go/pkg/api/v1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/pkg/version:go_default_library",
|
||||
"//vendor/k8s.io/client-go/rest:go_default_library",
|
||||
"//vendor/k8s.io/client-go/testing:go_default_library",
|
||||
],
|
||||
)
|
||||
@@ -19,8 +19,9 @@ package fake
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/emicklei/go-restful/swagger"
|
||||
"github.com/emicklei/go-restful-swagger12"
|
||||
|
||||
"github.com/go-openapi/spec"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"k8s.io/apimachinery/pkg/version"
|
||||
@@ -92,6 +93,8 @@ func (c *FakeDiscovery) SwaggerSchema(version schema.GroupVersion) (*swagger.Api
|
||||
return &swagger.ApiDeclaration{}, nil
|
||||
}
|
||||
|
||||
func (c *FakeDiscovery) OpenAPISchema() (*spec.Swagger, error) { return &spec.Swagger{}, nil }
|
||||
|
||||
func (c *FakeDiscovery) RESTClient() restclient.Interface {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -41,25 +41,13 @@ func MatchesServerVersion(clientVersion apimachineryversion.Info, client Discove
|
||||
return nil
|
||||
}
|
||||
|
||||
// NegotiateVersion queries the server's supported api versions to find
|
||||
// a version that both client and server support.
|
||||
// - If no version is provided, try registered client versions in order of
|
||||
// preference.
|
||||
// - If version is provided and the server does not support it,
|
||||
// return an error.
|
||||
// TODO negotiation should be reserved for cases where we need a version for a given group. In those cases, it should return an ordered list of
|
||||
// server preferences. From that list, a separate function can match from an ordered list of client versions.
|
||||
// This is not what the function has ever done before, but it makes more logical sense.
|
||||
func NegotiateVersion(client DiscoveryInterface, requiredGV *schema.GroupVersion, clientRegisteredGVs []schema.GroupVersion) (*schema.GroupVersion, error) {
|
||||
clientVersions := sets.String{}
|
||||
for _, gv := range clientRegisteredGVs {
|
||||
clientVersions.Insert(gv.String())
|
||||
}
|
||||
// ServerSupportsVersion returns an error if the server doesn't have the required version
|
||||
func ServerSupportsVersion(client DiscoveryInterface, requiredGV schema.GroupVersion) error {
|
||||
groups, err := client.ServerGroups()
|
||||
if err != nil {
|
||||
// This is almost always a connection error, and higher level code should treat this as a generic error,
|
||||
// not a negotiation specific error.
|
||||
return nil, err
|
||||
return err
|
||||
}
|
||||
versions := metav1.ExtractGroupVersions(groups)
|
||||
serverVersions := sets.String{}
|
||||
@@ -67,46 +55,17 @@ func NegotiateVersion(client DiscoveryInterface, requiredGV *schema.GroupVersion
|
||||
serverVersions.Insert(v)
|
||||
}
|
||||
|
||||
// If version explicitly requested verify that both client and server support it.
|
||||
// If server does not support warn, but try to negotiate a lower version.
|
||||
if requiredGV != nil {
|
||||
if !clientVersions.Has(requiredGV.String()) {
|
||||
return nil, fmt.Errorf("client does not support API version %q; client supported API versions: %v", requiredGV, clientVersions)
|
||||
|
||||
}
|
||||
// If the server supports no versions, then we should just use the preferredGV
|
||||
// This can happen because discovery fails due to 403 Forbidden errors
|
||||
if len(serverVersions) == 0 {
|
||||
return requiredGV, nil
|
||||
}
|
||||
if serverVersions.Has(requiredGV.String()) {
|
||||
return requiredGV, nil
|
||||
}
|
||||
// If we are using an explicit config version the server does not support, fail.
|
||||
return nil, fmt.Errorf("server does not support API version %q", requiredGV)
|
||||
if serverVersions.Has(requiredGV.String()) {
|
||||
return nil
|
||||
}
|
||||
|
||||
for _, clientGV := range clientRegisteredGVs {
|
||||
if serverVersions.Has(clientGV.String()) {
|
||||
// Version was not explicitly requested in command config (--api-version).
|
||||
// Ok to fall back to a supported version with a warning.
|
||||
// TODO: caesarxuchao: enable the warning message when we have
|
||||
// proper fix. Please refer to issue #14895.
|
||||
// if len(version) != 0 {
|
||||
// glog.Warningf("Server does not support API version '%s'. Falling back to '%s'.", version, clientVersion)
|
||||
// }
|
||||
t := clientGV
|
||||
return &t, nil
|
||||
}
|
||||
// If the server supports no versions, then we should pretend it has the version because of old servers.
|
||||
// This can happen because discovery fails due to 403 Forbidden errors
|
||||
if len(serverVersions) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
// if we have no server versions and we have no required version, choose the first clientRegisteredVersion
|
||||
if len(serverVersions) == 0 && len(clientRegisteredGVs) > 0 {
|
||||
return &clientRegisteredGVs[0], nil
|
||||
}
|
||||
|
||||
// fall back to an empty GroupVersion. Most client commands no longer respect a GroupVersion anyway
|
||||
return &schema.GroupVersion{}, nil
|
||||
return fmt.Errorf("server does not support API version %q", requiredGV)
|
||||
}
|
||||
|
||||
// GroupVersionResources converts APIResourceLists to the GroupVersionResources.
|
||||
|
||||
@@ -32,11 +32,10 @@ import (
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"k8s.io/apimachinery/pkg/util/sets"
|
||||
"k8s.io/client-go/discovery"
|
||||
"k8s.io/client-go/pkg/api"
|
||||
"k8s.io/client-go/kubernetes/scheme"
|
||||
"k8s.io/client-go/pkg/api/v1"
|
||||
restclient "k8s.io/client-go/rest"
|
||||
"k8s.io/client-go/rest/fake"
|
||||
|
||||
_ "k8s.io/client-go/pkg/api/install"
|
||||
)
|
||||
|
||||
func objBody(object interface{}) io.ReadCloser {
|
||||
@@ -47,87 +46,45 @@ func objBody(object interface{}) io.ReadCloser {
|
||||
return ioutil.NopCloser(bytes.NewReader([]byte(output)))
|
||||
}
|
||||
|
||||
func TestNegotiateVersion(t *testing.T) {
|
||||
func TestServerSupportsVersion(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
requiredVersion *schema.GroupVersion
|
||||
expectedVersion *schema.GroupVersion
|
||||
requiredVersion schema.GroupVersion
|
||||
serverVersions []string
|
||||
clientVersions []schema.GroupVersion
|
||||
expectErr func(err error) bool
|
||||
sendErr error
|
||||
statusCode int
|
||||
}{
|
||||
{
|
||||
name: "server supports client default",
|
||||
serverVersions: []string{"version1", api.Registry.GroupOrDie(api.GroupName).GroupVersion.String()},
|
||||
clientVersions: []schema.GroupVersion{{Version: "version1"}, api.Registry.GroupOrDie(api.GroupName).GroupVersion},
|
||||
expectedVersion: &schema.GroupVersion{Version: "version1"},
|
||||
statusCode: http.StatusOK,
|
||||
},
|
||||
{
|
||||
name: "server falls back to client supported",
|
||||
serverVersions: []string{"version1"},
|
||||
clientVersions: []schema.GroupVersion{{Version: "version1"}, api.Registry.GroupOrDie(api.GroupName).GroupVersion},
|
||||
expectedVersion: &schema.GroupVersion{Version: "version1"},
|
||||
statusCode: http.StatusOK,
|
||||
},
|
||||
{
|
||||
name: "explicit version supported",
|
||||
requiredVersion: &schema.GroupVersion{Version: "v1"},
|
||||
serverVersions: []string{"/version1", api.Registry.GroupOrDie(api.GroupName).GroupVersion.String()},
|
||||
clientVersions: []schema.GroupVersion{{Version: "version1"}, api.Registry.GroupOrDie(api.GroupName).GroupVersion},
|
||||
expectedVersion: &schema.GroupVersion{Version: "v1"},
|
||||
requiredVersion: schema.GroupVersion{Version: "v1"},
|
||||
serverVersions: []string{"/version1", v1.SchemeGroupVersion.String()},
|
||||
statusCode: http.StatusOK,
|
||||
},
|
||||
{
|
||||
name: "explicit version not supported on server",
|
||||
requiredVersion: &schema.GroupVersion{Version: "v1"},
|
||||
requiredVersion: schema.GroupVersion{Version: "v1"},
|
||||
serverVersions: []string{"version1"},
|
||||
clientVersions: []schema.GroupVersion{{Version: "version1"}, api.Registry.GroupOrDie(api.GroupName).GroupVersion},
|
||||
expectErr: func(err error) bool { return strings.Contains(err.Error(), `server does not support API version "v1"`) },
|
||||
statusCode: http.StatusOK,
|
||||
},
|
||||
{
|
||||
name: "explicit version not supported on client",
|
||||
requiredVersion: &schema.GroupVersion{Version: "v1"},
|
||||
serverVersions: []string{"v1"},
|
||||
clientVersions: []schema.GroupVersion{{Version: "version1"}},
|
||||
expectErr: func(err error) bool { return strings.Contains(err.Error(), `client does not support API version "v1"`) },
|
||||
statusCode: http.StatusOK,
|
||||
},
|
||||
{
|
||||
name: "connection refused error",
|
||||
serverVersions: []string{"version1"},
|
||||
clientVersions: []schema.GroupVersion{{Version: "version1"}, api.Registry.GroupOrDie(api.GroupName).GroupVersion},
|
||||
sendErr: errors.New("connection refused"),
|
||||
expectErr: func(err error) bool { return strings.Contains(err.Error(), "connection refused") },
|
||||
statusCode: http.StatusOK,
|
||||
},
|
||||
{
|
||||
name: "discovery fails due to 403 Forbidden errors and thus serverVersions is empty, use default GroupVersion",
|
||||
clientVersions: []schema.GroupVersion{{Version: "version1"}, api.Registry.GroupOrDie(api.GroupName).GroupVersion},
|
||||
expectedVersion: &schema.GroupVersion{Version: "version1"},
|
||||
statusCode: http.StatusForbidden,
|
||||
},
|
||||
{
|
||||
name: "discovery fails due to 404 Not Found errors and thus serverVersions is empty, use requested GroupVersion",
|
||||
requiredVersion: &schema.GroupVersion{Version: "version1"},
|
||||
clientVersions: []schema.GroupVersion{{Version: "version1"}, api.Registry.GroupOrDie(api.GroupName).GroupVersion},
|
||||
expectedVersion: &schema.GroupVersion{Version: "version1"},
|
||||
requiredVersion: schema.GroupVersion{Version: "version1"},
|
||||
statusCode: http.StatusNotFound,
|
||||
},
|
||||
{
|
||||
name: "discovery fails due to 403 Forbidden errors and thus serverVersions is empty, fallback to empty GroupVersion",
|
||||
expectedVersion: &schema.GroupVersion{},
|
||||
statusCode: http.StatusForbidden,
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
fakeClient := &fake.RESTClient{
|
||||
APIRegistry: api.Registry,
|
||||
NegotiatedSerializer: api.Codecs,
|
||||
NegotiatedSerializer: scheme.Codecs,
|
||||
Resp: &http.Response{
|
||||
StatusCode: test.statusCode,
|
||||
Body: objBody(&uapi.APIVersions{Versions: test.serverVersions}),
|
||||
@@ -143,7 +100,7 @@ func TestNegotiateVersion(t *testing.T) {
|
||||
}
|
||||
c := discovery.NewDiscoveryClientForConfigOrDie(&restclient.Config{})
|
||||
c.RESTClient().(*restclient.RESTClient).Client = fakeClient.Client
|
||||
response, err := discovery.NegotiateVersion(c, test.requiredVersion, test.clientVersions)
|
||||
err := discovery.ServerSupportsVersion(c, test.requiredVersion)
|
||||
if err == nil && test.expectErr != nil {
|
||||
t.Errorf("expected error, got nil for [%s].", test.name)
|
||||
}
|
||||
@@ -153,9 +110,6 @@ func TestNegotiateVersion(t *testing.T) {
|
||||
}
|
||||
continue
|
||||
}
|
||||
if *response != *test.expectedVersion {
|
||||
t.Errorf("%s: expected version %s, got %s.", test.name, test.expectedVersion, response)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@ import (
|
||||
"fmt"
|
||||
"sync"
|
||||
|
||||
"k8s.io/apimachinery/pkg/api/errors"
|
||||
"k8s.io/apimachinery/pkg/api/meta"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
@@ -127,10 +126,9 @@ func GetAPIGroupResources(cl DiscoveryInterface) ([]*APIGroupResources, error) {
|
||||
for _, version := range group.Versions {
|
||||
resources, err := cl.ServerResourcesForGroupVersion(version.GroupVersion)
|
||||
if err != nil {
|
||||
if errors.IsNotFound(err) {
|
||||
continue // ignore as this can race with deletion of 3rd party APIs
|
||||
}
|
||||
return nil, err
|
||||
// continue as best we can
|
||||
// TODO track the errors and update callers to handle partial errors.
|
||||
continue
|
||||
}
|
||||
groupResources.VersionedResources[version.Version] = resources.APIResources
|
||||
}
|
||||
@@ -279,20 +277,6 @@ func (d *DeferredDiscoveryRESTMapper) RESTMappings(gk schema.GroupKind, versions
|
||||
return
|
||||
}
|
||||
|
||||
// AliasesForResource returns whether a resource has an alias or not.
|
||||
func (d *DeferredDiscoveryRESTMapper) AliasesForResource(resource string) (as []string, ok bool) {
|
||||
del, err := d.getDelegate()
|
||||
if err != nil {
|
||||
return nil, false
|
||||
}
|
||||
as, ok = del.AliasesForResource(resource)
|
||||
if len(as) == 0 && !d.cl.Fresh() {
|
||||
d.Reset()
|
||||
as, ok = d.AliasesForResource(resource)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// ResourceSingularizer converts a resource name from plural to
|
||||
// singular (e.g., from pods to pod).
|
||||
func (d *DeferredDiscoveryRESTMapper) ResourceSingularizer(resource string) (singular string, err error) {
|
||||
|
||||
@@ -25,11 +25,11 @@ import (
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"k8s.io/apimachinery/pkg/version"
|
||||
. "k8s.io/client-go/discovery"
|
||||
"k8s.io/client-go/pkg/api"
|
||||
restclient "k8s.io/client-go/rest"
|
||||
"k8s.io/client-go/rest/fake"
|
||||
|
||||
"github.com/emicklei/go-restful/swagger"
|
||||
"github.com/emicklei/go-restful-swagger12"
|
||||
"github.com/go-openapi/spec"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
@@ -208,7 +208,7 @@ func TestDeferredDiscoveryRESTMapper_CacheMiss(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
||||
cdc := fakeCachedDiscoveryInterface{fresh: false}
|
||||
m := NewDeferredDiscoveryRESTMapper(&cdc, api.Registry.InterfacesFor)
|
||||
m := NewDeferredDiscoveryRESTMapper(&cdc, nil)
|
||||
assert.False(cdc.fresh, "should NOT be fresh after instantiation")
|
||||
assert.Zero(cdc.invalidateCalls, "should not have called Invalidate()")
|
||||
|
||||
@@ -347,3 +347,7 @@ func (c *fakeCachedDiscoveryInterface) ServerVersion() (*version.Info, error) {
|
||||
func (c *fakeCachedDiscoveryInterface) SwaggerSchema(version schema.GroupVersion) (*swagger.ApiDeclaration, error) {
|
||||
return &swagger.ApiDeclaration{}, nil
|
||||
}
|
||||
|
||||
func (c *fakeCachedDiscoveryInterface) OpenAPISchema() (*spec.Swagger, error) {
|
||||
return &spec.Swagger{}, nil
|
||||
}
|
||||
|
||||
55
dynamic/BUILD
Normal file
55
dynamic/BUILD
Normal file
@@ -0,0 +1,55 @@
|
||||
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 = [
|
||||
"client_test.go",
|
||||
"dynamic_util_test.go",
|
||||
],
|
||||
library = ":go_default_library",
|
||||
tags = ["automanaged"],
|
||||
deps = [
|
||||
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1/unstructured: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/streaming: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/rest/watch:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = [
|
||||
"client.go",
|
||||
"client_pool.go",
|
||||
"dynamic_util.go",
|
||||
],
|
||||
tags = ["automanaged"],
|
||||
deps = [
|
||||
"//vendor/k8s.io/apimachinery/pkg/api/meta:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1/unstructured:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/conversion/queryparams: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/types:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/watch:go_default_library",
|
||||
"//vendor/k8s.io/client-go/kubernetes/scheme:go_default_library",
|
||||
"//vendor/k8s.io/client-go/pkg/api/v1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/rest:go_default_library",
|
||||
"//vendor/k8s.io/client-go/util/flowcontrol:go_default_library",
|
||||
],
|
||||
)
|
||||
@@ -34,7 +34,7 @@ import (
|
||||
"k8s.io/apimachinery/pkg/runtime/serializer"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
"k8s.io/apimachinery/pkg/watch"
|
||||
"k8s.io/client-go/pkg/api"
|
||||
"k8s.io/client-go/kubernetes/scheme"
|
||||
"k8s.io/client-go/pkg/api/v1"
|
||||
restclient "k8s.io/client-go/rest"
|
||||
"k8s.io/client-go/util/flowcontrol"
|
||||
@@ -126,11 +126,16 @@ func (rc *ResourceClient) List(opts metav1.ListOptions) (runtime.Object, error)
|
||||
}
|
||||
|
||||
// Get gets the resource with the specified name.
|
||||
func (rc *ResourceClient) Get(name string) (*unstructured.Unstructured, error) {
|
||||
func (rc *ResourceClient) Get(name string, opts metav1.GetOptions) (*unstructured.Unstructured, error) {
|
||||
parameterEncoder := rc.parameterCodec
|
||||
if parameterEncoder == nil {
|
||||
parameterEncoder = defaultParameterEncoder
|
||||
}
|
||||
result := new(unstructured.Unstructured)
|
||||
err := rc.cl.Get().
|
||||
NamespaceIfScoped(rc.ns, rc.resource.Namespaced).
|
||||
Resource(rc.resource.Name).
|
||||
VersionedParams(&opts, parameterEncoder).
|
||||
Name(name).
|
||||
Do().
|
||||
Into(result)
|
||||
@@ -245,9 +250,9 @@ func (dynamicCodec) Encode(obj runtime.Object, w io.Writer) error {
|
||||
// ContentConfig returns a restclient.ContentConfig for dynamic types.
|
||||
func ContentConfig() restclient.ContentConfig {
|
||||
var jsonInfo runtime.SerializerInfo
|
||||
// TODO: api.Codecs here should become "pkg/apis/server/scheme" which is the minimal core you need
|
||||
// TODO: scheme.Codecs here should become "pkg/apis/server/scheme" which is the minimal core you need
|
||||
// to talk to a kubernetes server
|
||||
for _, info := range api.Codecs.SupportedMediaTypes() {
|
||||
for _, info := range scheme.Codecs.SupportedMediaTypes() {
|
||||
if info.MediaType == runtime.ContentTypeJSON {
|
||||
jsonInfo = info
|
||||
break
|
||||
@@ -280,10 +285,10 @@ var defaultParameterEncoder runtime.ParameterCodec = parameterCodec{}
|
||||
type versionedParameterEncoderWithV1Fallback struct{}
|
||||
|
||||
func (versionedParameterEncoderWithV1Fallback) EncodeParameters(obj runtime.Object, to schema.GroupVersion) (url.Values, error) {
|
||||
ret, err := api.ParameterCodec.EncodeParameters(obj, to)
|
||||
ret, err := scheme.ParameterCodec.EncodeParameters(obj, to)
|
||||
if err != nil && runtime.IsNotRegisteredError(err) {
|
||||
// fallback to v1
|
||||
return api.ParameterCodec.EncodeParameters(obj, v1.SchemeGroupVersion)
|
||||
return scheme.ParameterCodec.EncodeParameters(obj, v1.SchemeGroupVersion)
|
||||
}
|
||||
return ret, err
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@ import (
|
||||
|
||||
"k8s.io/apimachinery/pkg/api/meta"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"k8s.io/client-go/pkg/api"
|
||||
restclient "k8s.io/client-go/rest"
|
||||
)
|
||||
|
||||
@@ -73,9 +72,9 @@ func NewClientPool(config *restclient.Config, mapper meta.RESTMapper, apiPathRes
|
||||
|
||||
// Instantiates a new dynamic client pool with the given config.
|
||||
func NewDynamicClientPool(cfg *restclient.Config) ClientPool {
|
||||
// TODO: should use a dynamic RESTMapper built from the discovery results.
|
||||
restMapper := api.Registry.RESTMapper()
|
||||
return NewClientPool(cfg, restMapper, LegacyAPIPathResolverFunc)
|
||||
// restMapper is not needed when using LegacyAPIPathResolverFunc
|
||||
emptyMapper := meta.MultiRESTMapper{}
|
||||
return NewClientPool(cfg, emptyMapper, LegacyAPIPathResolverFunc)
|
||||
}
|
||||
|
||||
// ClientForGroupVersionResource uses the provided RESTMapper to identify the appropriate resource. Resource may
|
||||
|
||||
@@ -90,9 +90,9 @@ func TestList(t *testing.T) {
|
||||
"apiVersion": "vTest",
|
||||
"kind": "rTestList",
|
||||
},
|
||||
Items: []*unstructured.Unstructured{
|
||||
getObject("vTest", "rTest", "item1"),
|
||||
getObject("vTest", "rTest", "item2"),
|
||||
Items: []unstructured.Unstructured{
|
||||
*getObject("vTest", "rTest", "item1"),
|
||||
*getObject("vTest", "rTest", "item2"),
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -108,9 +108,9 @@ func TestList(t *testing.T) {
|
||||
"apiVersion": "vTest",
|
||||
"kind": "rTestList",
|
||||
},
|
||||
Items: []*unstructured.Unstructured{
|
||||
getObject("vTest", "rTest", "item1"),
|
||||
getObject("vTest", "rTest", "item2"),
|
||||
Items: []unstructured.Unstructured{
|
||||
*getObject("vTest", "rTest", "item1"),
|
||||
*getObject("vTest", "rTest", "item2"),
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -191,7 +191,7 @@ func TestGet(t *testing.T) {
|
||||
}
|
||||
defer srv.Close()
|
||||
|
||||
got, err := cl.Resource(resource, tc.namespace).Get(tc.name)
|
||||
got, err := cl.Resource(resource, tc.namespace).Get(tc.name, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error when getting %q: %v", tc.name, err)
|
||||
continue
|
||||
@@ -556,3 +556,11 @@ func TestPatch(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestVersionedParameterEncoderWithV1Fallback(t *testing.T) {
|
||||
enc := VersionedParameterEncoderWithV1Fallback
|
||||
_, err := enc.EncodeParameters(&metav1.ListOptions{}, schema.GroupVersion{Group: "foo.bar.com", Version: "v4"})
|
||||
if err != nil {
|
||||
t.Errorf("Unexpected error: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
31
examples/README.md
Normal file
31
examples/README.md
Normal file
@@ -0,0 +1,31 @@
|
||||
# client-go Examples
|
||||
|
||||
This directory contains examples that cover various use cases and functionality
|
||||
for client-go.
|
||||
|
||||
### Configuration
|
||||
|
||||
- [**Authenticate in cluster**](./in-cluster-client-configuration): Configure a
|
||||
client while running inside the Kubernetes cluster.
|
||||
- [**Authenticate out of cluster**](./out-of-cluster-client-configuration):
|
||||
Configure a client to access a Kubernetes cluster from outside.
|
||||
|
||||
### Basics
|
||||
|
||||
- [**Managing resources with API**](./create-update-delete-deployment): Create,
|
||||
get, update, delete a Deployment resource.
|
||||
|
||||
### Advanced Concepts
|
||||
|
||||
- [**Work queues**](./workqueue): Create a hotloop-free controller with the
|
||||
rate-limited workqueue and the [informer framework][informer].
|
||||
- [**Third-party resources (deprecated)**](./third-party-resources-deprecated):
|
||||
Register a third-party resource type with the API, create/update/query this third-party
|
||||
type, and write a controller that drives the cluster state based on the changes to
|
||||
the third-party resources.
|
||||
- [**Custom Resource Definition (successor of TPR)**](https://git.k8s.io/apiextensions-apiserver/examples/client-go):
|
||||
Register a custom resource type with the API, create/update/query this custom
|
||||
type, and write a controller that drives the cluster state based on the changes to
|
||||
the custom resources.
|
||||
|
||||
[informer]: https://godoc.org/k8s.io/client-go/tools/cache#NewInformer
|
||||
29
examples/create-update-delete-deployment/BUILD
Normal file
29
examples/create-update-delete-deployment/BUILD
Normal file
@@ -0,0 +1,29 @@
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
licenses(["notice"])
|
||||
|
||||
load(
|
||||
"@io_bazel_rules_go//go:def.bzl",
|
||||
"go_binary",
|
||||
"go_library",
|
||||
)
|
||||
|
||||
go_binary(
|
||||
name = "create-update-delete-deployment",
|
||||
library = ":go_default_library",
|
||||
tags = ["automanaged"],
|
||||
)
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["main.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/client-go/kubernetes:go_default_library",
|
||||
"//vendor/k8s.io/client-go/pkg/api/v1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/pkg/apis/apps/v1beta1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/tools/clientcmd:go_default_library",
|
||||
],
|
||||
)
|
||||
81
examples/create-update-delete-deployment/README.md
Normal file
81
examples/create-update-delete-deployment/README.md
Normal file
@@ -0,0 +1,81 @@
|
||||
# Create, Update & Delete Deployment
|
||||
|
||||
This example program demonstrates the fundamental operations for managing on
|
||||
[Deployment][1] resources, such as `Create`, `List`, `Update` and `Delete`.
|
||||
|
||||
You can adopt the source code from this example to write programs that manage
|
||||
other types of resources through the Kubernetes API.
|
||||
|
||||
## Running this example
|
||||
|
||||
Make sure you have a Kubernetes cluster and `kubectl` is configured:
|
||||
|
||||
kubectl get nodes
|
||||
|
||||
Compile this example on your workstation:
|
||||
|
||||
```
|
||||
cd create-update-delete-deployment
|
||||
go build -o ./app
|
||||
```
|
||||
|
||||
Now, run this application on your workstation with your local kubeconfig file:
|
||||
|
||||
```
|
||||
./app -kubeconfig=$HOME/.kube/config
|
||||
```
|
||||
|
||||
Running this command will execute the following operations on your cluster:
|
||||
|
||||
1. **Create Deployment:** This will create a 2 replica Deployment. Verify with
|
||||
`kubectl get pods`.
|
||||
2. **Update Deployment:** This will update the Deployment resource created in
|
||||
previous step to set the replica count to 1 and add annotations. You are
|
||||
encouraged to inspect the retry loop that handles conflicts. Verify the new
|
||||
replica count and `foo=bar` annotation with `kubectl describe deployment
|
||||
demo`.
|
||||
3. **List Deployments:** This will retrieve Deployments in the `default`
|
||||
namespace and print their names and replica counts.
|
||||
4. **Delete Deployment:** This will delete the Deployment object and its
|
||||
dependent ReplicaSet resource. Verify with `kubectl get deployments`.
|
||||
|
||||
Each step is separated by an interactive prompt. You must hit the
|
||||
<kbd>Return</kbd> key to proceeed to the next step. You can use these prompts as
|
||||
a break to take time to run `kubectl` and inspect the result of the operations
|
||||
executed.
|
||||
|
||||
You should see an output like the following:
|
||||
|
||||
```
|
||||
Creating deployment...
|
||||
Created deployment "demo-deployment".
|
||||
-> Press Return key to continue.
|
||||
|
||||
Updating deployment...
|
||||
Updated deployment...
|
||||
-> Press Return key to continue.
|
||||
|
||||
Listing deployments in namespace "default":
|
||||
* demo-deployment (1 replicas)
|
||||
-> Press Return key to continue.
|
||||
|
||||
Deleting deployment...
|
||||
Deleted deployment.
|
||||
```
|
||||
|
||||
## Cleanup
|
||||
|
||||
Successfully running this program will clean the created artifacts. If you
|
||||
terminate the program without completing, you can clean up the created
|
||||
deployment with:
|
||||
|
||||
kubectl delete deploy demo-deployment
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
If you are getting the following error, make sure Kubernetes version of your
|
||||
cluster is v1.6 or above in `kubectl version`:
|
||||
|
||||
panic: the server could not find the requested resource
|
||||
|
||||
[1]: https://kubernetes.io/docs/user-guide/deployments/
|
||||
165
examples/create-update-delete-deployment/main.go
Normal file
165
examples/create-update-delete-deployment/main.go
Normal file
@@ -0,0 +1,165 @@
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
|
||||
// Note: the example only works with the code within the same release/branch.
|
||||
package main
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"k8s.io/apimachinery/pkg/api/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/client-go/kubernetes"
|
||||
apiv1 "k8s.io/client-go/pkg/api/v1"
|
||||
appsv1beta1 "k8s.io/client-go/pkg/apis/apps/v1beta1"
|
||||
"k8s.io/client-go/tools/clientcmd"
|
||||
// Uncomment the following line to load the gcp plugin (only required to authenticate against GKE clusters).
|
||||
// _ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
|
||||
)
|
||||
|
||||
func main() {
|
||||
kubeconfig := flag.String("kubeconfig", "", "absolute path to the kubeconfig file")
|
||||
flag.Parse()
|
||||
if *kubeconfig == "" {
|
||||
panic("-kubeconfig not specified")
|
||||
}
|
||||
config, err := clientcmd.BuildConfigFromFlags("", *kubeconfig)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
clientset, err := kubernetes.NewForConfig(config)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
deploymentsClient := clientset.AppsV1beta1().Deployments(apiv1.NamespaceDefault)
|
||||
|
||||
deployment := &appsv1beta1.Deployment{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "demo-deployment",
|
||||
},
|
||||
Spec: appsv1beta1.DeploymentSpec{
|
||||
Replicas: int32Ptr(2),
|
||||
Template: apiv1.PodTemplateSpec{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Labels: map[string]string{
|
||||
"app": "demo",
|
||||
},
|
||||
},
|
||||
Spec: apiv1.PodSpec{
|
||||
Containers: []apiv1.Container{
|
||||
{
|
||||
Name: "web",
|
||||
Image: "nginx:1.13",
|
||||
Ports: []apiv1.ContainerPort{
|
||||
{
|
||||
Name: "http",
|
||||
Protocol: apiv1.ProtocolTCP,
|
||||
ContainerPort: 80,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
// Create Deployment
|
||||
fmt.Println("Creating deployment...")
|
||||
result, err := deploymentsClient.Create(deployment)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
fmt.Printf("Created deployment %q.\n", result.GetObjectMeta().GetName())
|
||||
|
||||
// Update Deployment
|
||||
prompt()
|
||||
fmt.Println("Updating deployment...")
|
||||
// You have two options to Update() this Deployment:
|
||||
//
|
||||
// 1. Modify the "deployment" variable and call: Update(deployment).
|
||||
// This works like the "kubectl replace" command and it overwrites/loses changes
|
||||
// made by other clients between you Create() and Update() the object.
|
||||
// 2. Modify the "result" returned by Create()/Get() and retry Update(result) until
|
||||
// you no longer get a conflict error. This way, you can preserve changes made
|
||||
// by other clients between Create() and Update(). This is implemented below:
|
||||
|
||||
for {
|
||||
result.Spec.Replicas = int32Ptr(1) // reduce replica count
|
||||
result.Spec.Template.Annotations = map[string]string{ // add annotations
|
||||
"foo": "bar",
|
||||
}
|
||||
|
||||
if _, err := deploymentsClient.Update(result); errors.IsConflict(err) {
|
||||
// Deployment is modified in the meanwhile, query the latest version
|
||||
// and modify the retrieved object.
|
||||
fmt.Println("encountered conflict, retrying")
|
||||
result, err = deploymentsClient.Get("demo-deployment", metav1.GetOptions{})
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("Get failed: %+v", err))
|
||||
}
|
||||
} else if err != nil {
|
||||
panic(err)
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
||||
// TODO: You should sleep here with an exponential backoff to avoid
|
||||
// exhausting the apiserver, and add a limit/timeout on the retries to
|
||||
// avoid getting stuck in this loop indefintiely.
|
||||
}
|
||||
fmt.Println("Updated deployment...")
|
||||
|
||||
// List Deployments
|
||||
prompt()
|
||||
fmt.Printf("Listing deployments in namespace %q:\n", apiv1.NamespaceDefault)
|
||||
list, err := deploymentsClient.List(metav1.ListOptions{})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
for _, d := range list.Items {
|
||||
fmt.Printf(" * %s (%d replicas)\n", d.Name, *d.Spec.Replicas)
|
||||
}
|
||||
|
||||
// Delete Deployment
|
||||
prompt()
|
||||
fmt.Println("Deleting deployment...")
|
||||
deletePolicy := metav1.DeletePropagationForeground
|
||||
if err := deploymentsClient.Delete("demo-deployment", &metav1.DeleteOptions{
|
||||
PropagationPolicy: &deletePolicy,
|
||||
}); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
fmt.Println("Deleted deployment.")
|
||||
}
|
||||
|
||||
func prompt() {
|
||||
fmt.Printf("-> Press Return key to continue.")
|
||||
scanner := bufio.NewScanner(os.Stdin)
|
||||
for scanner.Scan() {
|
||||
break
|
||||
}
|
||||
if err := scanner.Err(); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
fmt.Println()
|
||||
}
|
||||
|
||||
func int32Ptr(i int32) *int32 { return &i }
|
||||
27
examples/in-cluster-client-configuration/BUILD
Normal file
27
examples/in-cluster-client-configuration/BUILD
Normal file
@@ -0,0 +1,27 @@
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
licenses(["notice"])
|
||||
|
||||
load(
|
||||
"@io_bazel_rules_go//go:def.bzl",
|
||||
"go_binary",
|
||||
"go_library",
|
||||
)
|
||||
|
||||
go_binary(
|
||||
name = "in-cluster-client-configuration",
|
||||
library = ":go_default_library",
|
||||
tags = ["automanaged"],
|
||||
)
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["main.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/client-go/kubernetes:go_default_library",
|
||||
"//vendor/k8s.io/client-go/rest:go_default_library",
|
||||
],
|
||||
)
|
||||
17
examples/in-cluster-client-configuration/Dockerfile
Normal file
17
examples/in-cluster-client-configuration/Dockerfile
Normal 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 debian
|
||||
COPY ./app /app
|
||||
ENTRYPOINT /app
|
||||
50
examples/in-cluster-client-configuration/README.md
Normal file
50
examples/in-cluster-client-configuration/README.md
Normal file
@@ -0,0 +1,50 @@
|
||||
# Authenticating inside the cluster
|
||||
|
||||
This example shows you how to configure a client with client-go to authenticate
|
||||
to the Kubernetes API from an application running inside the Kubernetes cluster.
|
||||
|
||||
client-go uses the [Service Account token][sa] mounted inside the Pod at the
|
||||
`/var/run/secrets/kubernetes.io/serviceaccount` path when the
|
||||
`rest.InClusterConfig()` is used.
|
||||
|
||||
## Running this example
|
||||
|
||||
First compile the application for Linux:
|
||||
|
||||
cd in-cluster-client-configuration
|
||||
GOOS=linux go build -o ./app .
|
||||
|
||||
Then package it to a docker image using the provided Dockerfile to run it on
|
||||
Kubernetes.
|
||||
|
||||
If you are running a [Minikube][mk] cluster, you can build this image directly
|
||||
on the Docker engine of the Minikube node without pushing it to a registry. To
|
||||
build the image on Minikube:
|
||||
|
||||
eval $(minikube docker-env)
|
||||
docker build -t in-cluster .
|
||||
|
||||
If you are not using Minikube, you should build this image and push it to a registry
|
||||
that your Kubernetes cluster can pull from.
|
||||
|
||||
Then, run the image in a Pod with a single instance Deployment:
|
||||
|
||||
$ kubectl run --rm -i demo --image=in-cluster --image-pull-policy=Never
|
||||
|
||||
There are 4 pods in the cluster
|
||||
There are 4 pods in the cluster
|
||||
There are 4 pods in the cluster
|
||||
...
|
||||
|
||||
The example now runs on Kubernetes API and successfully queries the number of
|
||||
pods in the cluster every 10 seconds.
|
||||
|
||||
### Clean up
|
||||
|
||||
To stop this example and clean up the pod, press <kbd>Ctrl</kbd>+<kbd>C</kbd> on
|
||||
the `kubectl run` command and then run:
|
||||
|
||||
kubectl delete deployment demo
|
||||
|
||||
[sa]: https://kubernetes.io/docs/admin/authentication/#service-account-tokens
|
||||
[mk]: https://kubernetes.io/docs/getting-started-guides/minikube/
|
||||
@@ -21,6 +21,7 @@ import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"k8s.io/apimachinery/pkg/api/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/client-go/kubernetes"
|
||||
"k8s.io/client-go/rest"
|
||||
@@ -43,6 +44,21 @@ func main() {
|
||||
panic(err.Error())
|
||||
}
|
||||
fmt.Printf("There are %d pods in the cluster\n", len(pods.Items))
|
||||
|
||||
// Examples for error handling:
|
||||
// - Use helper functions like e.g. errors.IsNotFound()
|
||||
// - And/or cast to StatusError and use its properties like e.g. ErrStatus.Message
|
||||
_, err = clientset.CoreV1().Pods("default").Get("example-xxxxx", metav1.GetOptions{})
|
||||
if errors.IsNotFound(err) {
|
||||
fmt.Printf("Pod not found\n")
|
||||
} else if statusError, isStatus := err.(*errors.StatusError); isStatus {
|
||||
fmt.Printf("Error getting pod %v\n", statusError.ErrStatus.Message)
|
||||
} else if err != nil {
|
||||
panic(err.Error())
|
||||
} else {
|
||||
fmt.Printf("Found pod\n")
|
||||
}
|
||||
|
||||
time.Sleep(10 * time.Second)
|
||||
}
|
||||
}
|
||||
27
examples/out-of-cluster-client-configuration/BUILD
Normal file
27
examples/out-of-cluster-client-configuration/BUILD
Normal file
@@ -0,0 +1,27 @@
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
licenses(["notice"])
|
||||
|
||||
load(
|
||||
"@io_bazel_rules_go//go:def.bzl",
|
||||
"go_binary",
|
||||
"go_library",
|
||||
)
|
||||
|
||||
go_binary(
|
||||
name = "out-of-cluster-client-configuration",
|
||||
library = ":go_default_library",
|
||||
tags = ["automanaged"],
|
||||
)
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["main.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/client-go/kubernetes:go_default_library",
|
||||
"//vendor/k8s.io/client-go/tools/clientcmd:go_default_library",
|
||||
],
|
||||
)
|
||||
35
examples/out-of-cluster-client-configuration/README.md
Normal file
35
examples/out-of-cluster-client-configuration/README.md
Normal file
@@ -0,0 +1,35 @@
|
||||
# Authenticating outside the cluster
|
||||
|
||||
This example shows you how to configure a client with client-go to authenticate
|
||||
to the Kubernetes API from an application running outside the Kubernetes
|
||||
cluster.
|
||||
|
||||
You can use your kubeconfig file that contains the context information
|
||||
of your cluster to initialize a client. The kubeconfig file is also used
|
||||
by the `kubectl` command to authenticate to the clusters.
|
||||
|
||||
## Running this example
|
||||
|
||||
Make sure your `kubectl` is configured and pointed to a cluster. Run
|
||||
`kubectl get nodes` to confirm.
|
||||
|
||||
Run this application with:
|
||||
|
||||
cd out-of-cluster-client-configuration
|
||||
go build -o app .
|
||||
./app
|
||||
|
||||
Running this application will use the kubeconfig file and then authenticate to the
|
||||
cluster, and print the number of nodes in the cluster every 10 seconds:
|
||||
|
||||
$ ./app
|
||||
There are 3 pods in the cluster
|
||||
There are 3 pods in the cluster
|
||||
There are 3 pods in the cluster
|
||||
...
|
||||
|
||||
Press <kbd>Ctrl</kbd>+<kbd>C</kbd> to quit this application.
|
||||
|
||||
> **Note:** You can use the `-kubeconfig` option to use a different config file. By default
|
||||
this program picks up the default file used by kubectl (when `KUBECONFIG`
|
||||
environment variable is not set).
|
||||
85
examples/out-of-cluster-client-configuration/main.go
Normal file
85
examples/out-of-cluster-client-configuration/main.go
Normal file
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
Copyright 2016 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.
|
||||
*/
|
||||
|
||||
// Note: the example only works with the code within the same release/branch.
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
||||
"k8s.io/apimachinery/pkg/api/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/client-go/kubernetes"
|
||||
"k8s.io/client-go/tools/clientcmd"
|
||||
// Uncomment the following line to load the gcp plugin (only required to authenticate against GKE clusters).
|
||||
// _ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
|
||||
)
|
||||
|
||||
func main() {
|
||||
var kubeconfig *string
|
||||
if home := homeDir(); home != "" {
|
||||
kubeconfig = flag.String("kubeconfig", filepath.Join(home, ".kube", "config"), "(optional) absolute path to the kubeconfig file")
|
||||
} else {
|
||||
kubeconfig = flag.String("kubeconfig", "", "absolute path to the kubeconfig file")
|
||||
}
|
||||
flag.Parse()
|
||||
|
||||
// use the current context in kubeconfig
|
||||
config, err := clientcmd.BuildConfigFromFlags("", *kubeconfig)
|
||||
if err != nil {
|
||||
panic(err.Error())
|
||||
}
|
||||
|
||||
// create the clientset
|
||||
clientset, err := kubernetes.NewForConfig(config)
|
||||
if err != nil {
|
||||
panic(err.Error())
|
||||
}
|
||||
for {
|
||||
pods, err := clientset.CoreV1().Pods("").List(metav1.ListOptions{})
|
||||
if err != nil {
|
||||
panic(err.Error())
|
||||
}
|
||||
fmt.Printf("There are %d pods in the cluster\n", len(pods.Items))
|
||||
|
||||
// Examples for error handling:
|
||||
// - Use helper functions like e.g. errors.IsNotFound()
|
||||
// - And/or cast to StatusError and use its properties like e.g. ErrStatus.Message
|
||||
_, err = clientset.CoreV1().Pods("default").Get("example-xxxxx", metav1.GetOptions{})
|
||||
if errors.IsNotFound(err) {
|
||||
fmt.Printf("Pod not found\n")
|
||||
} else if statusError, isStatus := err.(*errors.StatusError); isStatus {
|
||||
fmt.Printf("Error getting pod %v\n", statusError.ErrStatus.Message)
|
||||
} else if err != nil {
|
||||
panic(err.Error())
|
||||
} else {
|
||||
fmt.Printf("Found pod\n")
|
||||
}
|
||||
|
||||
time.Sleep(10 * time.Second)
|
||||
}
|
||||
}
|
||||
|
||||
func homeDir() string {
|
||||
if h := os.Getenv("HOME"); h != "" {
|
||||
return h
|
||||
}
|
||||
return os.Getenv("USERPROFILE") // windows
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
/*
|
||||
Copyright 2016 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.
|
||||
*/
|
||||
|
||||
// Note: the example only works with the code within the same release/branch.
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/client-go/kubernetes"
|
||||
"k8s.io/client-go/tools/clientcmd"
|
||||
)
|
||||
|
||||
func main() {
|
||||
kubeconfig := flag.String("kubeconfig", "./config", "absolute path to the kubeconfig file")
|
||||
flag.Parse()
|
||||
// uses the current context in kubeconfig
|
||||
config, err := clientcmd.BuildConfigFromFlags("", *kubeconfig)
|
||||
if err != nil {
|
||||
panic(err.Error())
|
||||
}
|
||||
// creates the clientset
|
||||
clientset, err := kubernetes.NewForConfig(config)
|
||||
if err != nil {
|
||||
panic(err.Error())
|
||||
}
|
||||
for {
|
||||
pods, err := clientset.CoreV1().Pods("").List(metav1.ListOptions{})
|
||||
if err != nil {
|
||||
panic(err.Error())
|
||||
}
|
||||
fmt.Printf("There are %d pods in the cluster\n", len(pods.Items))
|
||||
time.Sleep(10 * time.Second)
|
||||
}
|
||||
}
|
||||
32
examples/third-party-resources-deprecated/BUILD
Normal file
32
examples/third-party-resources-deprecated/BUILD
Normal file
@@ -0,0 +1,32 @@
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
licenses(["notice"])
|
||||
|
||||
load(
|
||||
"@io_bazel_rules_go//go:def.bzl",
|
||||
"go_binary",
|
||||
"go_library",
|
||||
)
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["main.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/client-go/examples/third-party-resources-deprecated/apis/tpr/v1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/examples/third-party-resources-deprecated/client:go_default_library",
|
||||
"//vendor/k8s.io/client-go/examples/third-party-resources-deprecated/controller:go_default_library",
|
||||
"//vendor/k8s.io/client-go/kubernetes:go_default_library",
|
||||
"//vendor/k8s.io/client-go/pkg/api/v1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/rest:go_default_library",
|
||||
"//vendor/k8s.io/client-go/tools/clientcmd:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
go_binary(
|
||||
name = "third-party-resources-deprecated",
|
||||
library = ":go_default_library",
|
||||
tags = ["automanaged"],
|
||||
)
|
||||
@@ -1,9 +1,12 @@
|
||||
# Third Party Resources Example
|
||||
# Third Party Resources Example – Deprecated
|
||||
|
||||
**Note:** ThirdPartyResources are deprecated since 1.7. The successor is CustomResourceDefinition in the apiextensions.k8s.io API group.
|
||||
|
||||
This particular example demonstrates how to perform basic operations such as:
|
||||
|
||||
* How to register a new ThirdPartyResource (custom Resource type)
|
||||
* How to create/get/list instances of your new Resource type (update/delete/etc work as well but are not demonstrated)
|
||||
* How to setup a controller on Resource handling create/update/delete events
|
||||
|
||||
## Running
|
||||
|
||||
37
examples/third-party-resources-deprecated/apis/tpr/v1/BUILD
Normal file
37
examples/third-party-resources-deprecated/apis/tpr/v1/BUILD
Normal file
@@ -0,0 +1,37 @@
|
||||
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 = ["types_test.go"],
|
||||
library = ":go_default_library",
|
||||
tags = ["automanaged"],
|
||||
deps = [
|
||||
"//vendor/github.com/google/gofuzz:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/api/testing: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/serializer:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = [
|
||||
"register.go",
|
||||
"types.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",
|
||||
],
|
||||
)
|
||||
@@ -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 v1
|
||||
|
||||
import (
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
)
|
||||
|
||||
var (
|
||||
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
|
||||
AddToScheme = SchemeBuilder.AddToScheme
|
||||
)
|
||||
|
||||
// GroupName is the group name use in this package.
|
||||
const GroupName = "tpr.client-go.k8s.io"
|
||||
|
||||
// SchemeGroupVersion is the group version used to register these objects.
|
||||
var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1"}
|
||||
|
||||
// Resource takes an unqualified resource and returns a Group-qualified GroupResource.
|
||||
func Resource(resource string) schema.GroupResource {
|
||||
return SchemeGroupVersion.WithResource(resource).GroupResource()
|
||||
}
|
||||
|
||||
// addKnownTypes adds the set of types defined in this package to the supplied scheme.
|
||||
func addKnownTypes(scheme *runtime.Scheme) error {
|
||||
scheme.AddKnownTypes(SchemeGroupVersion,
|
||||
&Example{},
|
||||
&ExampleList{},
|
||||
)
|
||||
metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
|
||||
return nil
|
||||
}
|
||||
@@ -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 v1
|
||||
|
||||
import (
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
||||
const ExampleResourcePlural = "examples"
|
||||
|
||||
type Example struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ObjectMeta `json:"metadata"`
|
||||
Spec ExampleSpec `json:"spec"`
|
||||
Status ExampleStatus `json:"status,omitempty"`
|
||||
}
|
||||
|
||||
type ExampleSpec struct {
|
||||
Foo string `json:"foo"`
|
||||
Bar bool `json:"bar"`
|
||||
}
|
||||
|
||||
type ExampleStatus struct {
|
||||
State ExampleState `json:"state,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
}
|
||||
|
||||
type ExampleState string
|
||||
|
||||
const (
|
||||
ExampleStateCreated ExampleState = "Created"
|
||||
ExampleStateProcessed ExampleState = "Processed"
|
||||
)
|
||||
|
||||
type ExampleList struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ListMeta `json:"metadata"`
|
||||
Items []Example `json:"items"`
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
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 v1
|
||||
|
||||
import (
|
||||
"math/rand"
|
||||
"testing"
|
||||
|
||||
"github.com/google/gofuzz"
|
||||
|
||||
apitesting "k8s.io/apimachinery/pkg/api/testing"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/runtime/serializer"
|
||||
)
|
||||
|
||||
var _ runtime.Object = &Example{}
|
||||
var _ metav1.ObjectMetaAccessor = &Example{}
|
||||
|
||||
var _ runtime.Object = &ExampleList{}
|
||||
var _ metav1.ListMetaAccessor = &ExampleList{}
|
||||
|
||||
func exampleFuzzerFuncs(t apitesting.TestingCommon) []interface{} {
|
||||
return []interface{}{
|
||||
func(obj *ExampleList, c fuzz.Continue) {
|
||||
c.FuzzNoCustom(obj)
|
||||
obj.Items = make([]Example, c.Intn(10))
|
||||
for i := range obj.Items {
|
||||
c.Fuzz(&obj.Items[i])
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// TestRoundTrip tests that the third-party kinds can be marshaled and unmarshaled correctly to/from JSON
|
||||
// without the loss of information. Moreover, deep copy is tested.
|
||||
func TestRoundTrip(t *testing.T) {
|
||||
scheme := runtime.NewScheme()
|
||||
codecs := serializer.NewCodecFactory(scheme)
|
||||
|
||||
AddToScheme(scheme)
|
||||
|
||||
seed := rand.Int63()
|
||||
fuzzerFuncs := apitesting.MergeFuzzerFuncs(t, apitesting.GenericFuzzerFuncs(t, codecs), exampleFuzzerFuncs(t))
|
||||
fuzzer := apitesting.FuzzerFor(fuzzerFuncs, rand.NewSource(seed))
|
||||
|
||||
apitesting.RoundTripSpecificKindWithoutProtobuf(t, SchemeGroupVersion.WithKind("Example"), scheme, codecs, fuzzer, nil)
|
||||
apitesting.RoundTripSpecificKindWithoutProtobuf(t, SchemeGroupVersion.WithKind("ExampleList"), scheme, codecs, fuzzer, nil)
|
||||
}
|
||||
29
examples/third-party-resources-deprecated/client/BUILD
Normal file
29
examples/third-party-resources-deprecated/client/BUILD
Normal 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 = [
|
||||
"client.go",
|
||||
"tpr.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/runtime:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/runtime/serializer:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/util/wait:go_default_library",
|
||||
"//vendor/k8s.io/client-go/examples/third-party-resources-deprecated/apis/tpr/v1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/kubernetes:go_default_library",
|
||||
"//vendor/k8s.io/client-go/pkg/api/v1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/pkg/apis/extensions/v1beta1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/rest:go_default_library",
|
||||
],
|
||||
)
|
||||
45
examples/third-party-resources-deprecated/client/client.go
Normal file
45
examples/third-party-resources-deprecated/client/client.go
Normal file
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
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 client
|
||||
|
||||
import (
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/runtime/serializer"
|
||||
"k8s.io/client-go/rest"
|
||||
|
||||
tprv1 "k8s.io/client-go/examples/third-party-resources-deprecated/apis/tpr/v1"
|
||||
)
|
||||
|
||||
func NewClient(cfg *rest.Config) (*rest.RESTClient, *runtime.Scheme, error) {
|
||||
scheme := runtime.NewScheme()
|
||||
if err := tprv1.AddToScheme(scheme); err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
config := *cfg
|
||||
config.GroupVersion = &tprv1.SchemeGroupVersion
|
||||
config.APIPath = "/apis"
|
||||
config.ContentType = runtime.ContentTypeJSON
|
||||
config.NegotiatedSerializer = serializer.DirectCodecFactory{CodecFactory: serializer.NewCodecFactory(scheme)}
|
||||
|
||||
client, err := rest.RESTClientFor(&config)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
return client, scheme, nil
|
||||
}
|
||||
76
examples/third-party-resources-deprecated/client/tpr.go
Normal file
76
examples/third-party-resources-deprecated/client/tpr.go
Normal file
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
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 client
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/util/wait"
|
||||
tprv1 "k8s.io/client-go/examples/third-party-resources-deprecated/apis/tpr/v1"
|
||||
"k8s.io/client-go/kubernetes"
|
||||
apiv1 "k8s.io/client-go/pkg/api/v1"
|
||||
"k8s.io/client-go/pkg/apis/extensions/v1beta1"
|
||||
"k8s.io/client-go/rest"
|
||||
// Uncomment the following line to load the gcp plugin (only required to authenticate against GKE clusters).
|
||||
// _ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
|
||||
)
|
||||
|
||||
func CreateTPR(clientset kubernetes.Interface) error {
|
||||
tpr := &v1beta1.ThirdPartyResource{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "example." + tprv1.GroupName,
|
||||
},
|
||||
Versions: []v1beta1.APIVersion{
|
||||
{Name: tprv1.SchemeGroupVersion.Version},
|
||||
},
|
||||
Description: "An Example ThirdPartyResource",
|
||||
}
|
||||
_, err := clientset.ExtensionsV1beta1().ThirdPartyResources().Create(tpr)
|
||||
return err
|
||||
}
|
||||
|
||||
func WaitForExampleResource(exampleClient *rest.RESTClient) error {
|
||||
return wait.Poll(100*time.Millisecond, 60*time.Second, func() (bool, error) {
|
||||
_, err := exampleClient.Get().Namespace(apiv1.NamespaceDefault).Resource(tprv1.ExampleResourcePlural).DoRaw()
|
||||
if err == nil {
|
||||
return true, nil
|
||||
}
|
||||
if apierrors.IsNotFound(err) {
|
||||
return false, nil
|
||||
}
|
||||
return false, err
|
||||
})
|
||||
}
|
||||
|
||||
func WaitForExampleInstanceProcessed(exampleClient *rest.RESTClient, name string) error {
|
||||
return wait.Poll(100*time.Millisecond, 10*time.Second, func() (bool, error) {
|
||||
var example tprv1.Example
|
||||
err := exampleClient.Get().
|
||||
Resource(tprv1.ExampleResourcePlural).
|
||||
Namespace(apiv1.NamespaceDefault).
|
||||
Name(name).
|
||||
Do().Into(&example)
|
||||
|
||||
if err == nil && example.Status.State == tprv1.ExampleStateProcessed {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
return false, err
|
||||
})
|
||||
}
|
||||
22
examples/third-party-resources-deprecated/controller/BUILD
Normal file
22
examples/third-party-resources-deprecated/controller/BUILD
Normal file
@@ -0,0 +1,22 @@
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
licenses(["notice"])
|
||||
|
||||
load(
|
||||
"@io_bazel_rules_go//go:def.bzl",
|
||||
"go_library",
|
||||
)
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["controller.go"],
|
||||
tags = ["automanaged"],
|
||||
deps = [
|
||||
"//vendor/k8s.io/apimachinery/pkg/fields:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
|
||||
"//vendor/k8s.io/client-go/examples/third-party-resources-deprecated/apis/tpr/v1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/pkg/api/v1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/rest:go_default_library",
|
||||
"//vendor/k8s.io/client-go/tools/cache:go_default_library",
|
||||
],
|
||||
)
|
||||
@@ -0,0 +1,126 @@
|
||||
/*
|
||||
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 controller
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"k8s.io/apimachinery/pkg/fields"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
apiv1 "k8s.io/client-go/pkg/api/v1"
|
||||
"k8s.io/client-go/rest"
|
||||
"k8s.io/client-go/tools/cache"
|
||||
|
||||
tprv1 "k8s.io/client-go/examples/third-party-resources-deprecated/apis/tpr/v1"
|
||||
)
|
||||
|
||||
// Watcher is an example of watching on resource create/update/delete events
|
||||
type ExampleController struct {
|
||||
ExampleClient *rest.RESTClient
|
||||
ExampleScheme *runtime.Scheme
|
||||
}
|
||||
|
||||
// Run starts an Example resource controller
|
||||
func (c *ExampleController) Run(ctx context.Context) error {
|
||||
fmt.Print("Watch Example objects\n")
|
||||
|
||||
// Watch Example objects
|
||||
_, err := c.watchExamples(ctx)
|
||||
if err != nil {
|
||||
fmt.Printf("Failed to register watch for Example resource: %v\n", err)
|
||||
return err
|
||||
}
|
||||
|
||||
<-ctx.Done()
|
||||
return ctx.Err()
|
||||
}
|
||||
|
||||
func (c *ExampleController) watchExamples(ctx context.Context) (cache.Controller, error) {
|
||||
source := cache.NewListWatchFromClient(
|
||||
c.ExampleClient,
|
||||
tprv1.ExampleResourcePlural,
|
||||
apiv1.NamespaceAll,
|
||||
fields.Everything())
|
||||
|
||||
_, controller := cache.NewInformer(
|
||||
source,
|
||||
|
||||
// The object type.
|
||||
&tprv1.Example{},
|
||||
|
||||
// resyncPeriod
|
||||
// Every resyncPeriod, all resources in the cache will retrigger events.
|
||||
// Set to 0 to disable the resync.
|
||||
0,
|
||||
|
||||
// Your custom resource event handlers.
|
||||
cache.ResourceEventHandlerFuncs{
|
||||
AddFunc: c.onAdd,
|
||||
UpdateFunc: c.onUpdate,
|
||||
DeleteFunc: c.onDelete,
|
||||
})
|
||||
|
||||
go controller.Run(ctx.Done())
|
||||
return controller, nil
|
||||
}
|
||||
|
||||
func (c *ExampleController) onAdd(obj interface{}) {
|
||||
example := obj.(*tprv1.Example)
|
||||
fmt.Printf("[CONTROLLER] OnAdd %s\n", example.ObjectMeta.SelfLink)
|
||||
|
||||
// NEVER modify objects from the store. It's a read-only, local cache.
|
||||
// You can use exampleScheme.Copy() to make a deep copy of original object and modify this copy
|
||||
// Or create a copy manually for better performance
|
||||
copyObj, err := c.ExampleScheme.Copy(example)
|
||||
if err != nil {
|
||||
fmt.Printf("ERROR creating a deep copy of example object: %v\n", err)
|
||||
return
|
||||
}
|
||||
|
||||
exampleCopy := copyObj.(*tprv1.Example)
|
||||
exampleCopy.Status = tprv1.ExampleStatus{
|
||||
State: tprv1.ExampleStateProcessed,
|
||||
Message: "Successfully processed by controller",
|
||||
}
|
||||
|
||||
err = c.ExampleClient.Put().
|
||||
Name(example.ObjectMeta.Name).
|
||||
Namespace(example.ObjectMeta.Namespace).
|
||||
Resource(tprv1.ExampleResourcePlural).
|
||||
Body(exampleCopy).
|
||||
Do().
|
||||
Error()
|
||||
|
||||
if err != nil {
|
||||
fmt.Printf("ERROR updating status: %v\n", err)
|
||||
} else {
|
||||
fmt.Printf("UPDATED status: %#v\n", exampleCopy)
|
||||
}
|
||||
}
|
||||
|
||||
func (c *ExampleController) onUpdate(oldObj, newObj interface{}) {
|
||||
oldExample := oldObj.(*tprv1.Example)
|
||||
newExample := newObj.(*tprv1.Example)
|
||||
fmt.Printf("[CONTROLLER] OnUpdate oldObj: %s\n", oldExample.ObjectMeta.SelfLink)
|
||||
fmt.Printf("[CONTROLLER] OnUpdate newObj: %s\n", newExample.ObjectMeta.SelfLink)
|
||||
}
|
||||
|
||||
func (c *ExampleController) onDelete(obj interface{}) {
|
||||
example := obj.(*tprv1.Example)
|
||||
fmt.Printf("[CONTROLLER] OnDelete %s\n", example.ObjectMeta.SelfLink)
|
||||
}
|
||||
132
examples/third-party-resources-deprecated/main.go
Normal file
132
examples/third-party-resources-deprecated/main.go
Normal file
@@ -0,0 +1,132 @@
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
|
||||
// Note: the example only works with the code within the same release/branch.
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"flag"
|
||||
"fmt"
|
||||
|
||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/client-go/kubernetes"
|
||||
apiv1 "k8s.io/client-go/pkg/api/v1"
|
||||
"k8s.io/client-go/rest"
|
||||
"k8s.io/client-go/tools/clientcmd"
|
||||
|
||||
// Uncomment the following line to load the gcp plugin (only required to authenticate against GKE clusters).
|
||||
// _ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
|
||||
|
||||
tprv1 "k8s.io/client-go/examples/third-party-resources-deprecated/apis/tpr/v1"
|
||||
exampleclient "k8s.io/client-go/examples/third-party-resources-deprecated/client"
|
||||
examplecontroller "k8s.io/client-go/examples/third-party-resources-deprecated/controller"
|
||||
)
|
||||
|
||||
func main() {
|
||||
kubeconfig := flag.String("kubeconfig", "", "Path to a kube config. Only required if out-of-cluster.")
|
||||
flag.Parse()
|
||||
|
||||
// Create the client config. Use kubeconfig if given, otherwise assume in-cluster.
|
||||
config, err := buildConfig(*kubeconfig)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
clientset, err := kubernetes.NewForConfig(config)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
// initialize third party resource if it does not exist
|
||||
err = exampleclient.CreateTPR(clientset)
|
||||
if err != nil && !apierrors.IsAlreadyExists(err) {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
// make a new config for our extension's API group, using the first config as a baseline
|
||||
exampleClient, exampleScheme, err := exampleclient.NewClient(config)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
// wait until TPR gets processed
|
||||
err = exampleclient.WaitForExampleResource(exampleClient)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
// start a controller on instances of our TPR
|
||||
controller := examplecontroller.ExampleController{
|
||||
ExampleClient: exampleClient,
|
||||
ExampleScheme: exampleScheme,
|
||||
}
|
||||
|
||||
ctx, cancelFunc := context.WithCancel(context.Background())
|
||||
defer cancelFunc()
|
||||
go controller.Run(ctx)
|
||||
|
||||
// Create an instance of our TPR
|
||||
example := &tprv1.Example{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "example1",
|
||||
},
|
||||
Spec: tprv1.ExampleSpec{
|
||||
Foo: "hello",
|
||||
Bar: true,
|
||||
},
|
||||
Status: tprv1.ExampleStatus{
|
||||
State: tprv1.ExampleStateCreated,
|
||||
Message: "Created, not processed yet",
|
||||
},
|
||||
}
|
||||
var result tprv1.Example
|
||||
err = exampleClient.Post().
|
||||
Resource(tprv1.ExampleResourcePlural).
|
||||
Namespace(apiv1.NamespaceDefault).
|
||||
Body(example).
|
||||
Do().Into(&result)
|
||||
if err == nil {
|
||||
fmt.Printf("CREATED: %#v\n", result)
|
||||
} else if apierrors.IsAlreadyExists(err) {
|
||||
fmt.Printf("ALREADY EXISTS: %#v\n", result)
|
||||
} else {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
// Poll until Example object is handled by controller and gets status updated to "Processed"
|
||||
err = exampleclient.WaitForExampleInstanceProcessed(exampleClient, "example1")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
fmt.Print("PROCESSED\n")
|
||||
|
||||
// Fetch a list of our TPRs
|
||||
exampleList := tprv1.ExampleList{}
|
||||
err = exampleClient.Get().Resource(tprv1.ExampleResourcePlural).Do().Into(&exampleList)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
fmt.Printf("LIST: %#v\n", exampleList)
|
||||
}
|
||||
|
||||
func buildConfig(kubeconfig string) (*rest.Config, error) {
|
||||
if kubeconfig != "" {
|
||||
return clientcmd.BuildConfigFromFlags("", kubeconfig)
|
||||
}
|
||||
return rest.InClusterConfig()
|
||||
}
|
||||
@@ -1,167 +0,0 @@
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
|
||||
// Note: the example only works with the code within the same release/branch.
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
|
||||
"k8s.io/apimachinery/pkg/api/errors"
|
||||
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/client-go/kubernetes"
|
||||
"k8s.io/client-go/pkg/api"
|
||||
"k8s.io/client-go/pkg/apis/extensions/v1beta1"
|
||||
"k8s.io/client-go/rest"
|
||||
"k8s.io/client-go/tools/clientcmd"
|
||||
|
||||
// Only required to authenticate against GKE clusters
|
||||
_ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
|
||||
)
|
||||
|
||||
func main() {
|
||||
kubeconfig := flag.String("kubeconfig", "", "Path to a kube config. Only required if out-of-cluster.")
|
||||
flag.Parse()
|
||||
|
||||
// Create the client config. Use kubeconfig if given, otherwise assume in-cluster.
|
||||
config, err := buildConfig(*kubeconfig)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
clientset, err := kubernetes.NewForConfig(config)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
// initialize third party resource if it does not exist
|
||||
tpr, err := clientset.ExtensionsV1beta1().ThirdPartyResources().Get("example.k8s.io", metav1.GetOptions{})
|
||||
if err != nil {
|
||||
if errors.IsNotFound(err) {
|
||||
tpr := &v1beta1.ThirdPartyResource{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "example.k8s.io",
|
||||
},
|
||||
Versions: []v1beta1.APIVersion{
|
||||
{Name: "v1"},
|
||||
},
|
||||
Description: "An Example ThirdPartyResource",
|
||||
}
|
||||
|
||||
result, err := clientset.ExtensionsV1beta1().ThirdPartyResources().Create(tpr)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
fmt.Printf("CREATED: %#v\nFROM: %#v\n", result, tpr)
|
||||
} else {
|
||||
panic(err)
|
||||
}
|
||||
} else {
|
||||
fmt.Printf("SKIPPING: already exists %#v\n", tpr)
|
||||
}
|
||||
|
||||
// make a new config for our extension's API group, using the first config as a baseline
|
||||
var tprconfig *rest.Config
|
||||
tprconfig = config
|
||||
configureClient(tprconfig)
|
||||
|
||||
tprclient, err := rest.RESTClientFor(tprconfig)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
var example Example
|
||||
|
||||
err = tprclient.Get().
|
||||
Resource("examples").
|
||||
Namespace(api.NamespaceDefault).
|
||||
Name("example1").
|
||||
Do().Into(&example)
|
||||
|
||||
if err != nil {
|
||||
if errors.IsNotFound(err) {
|
||||
// Create an instance of our TPR
|
||||
example := &Example{
|
||||
Metadata: metav1.ObjectMeta{
|
||||
Name: "example1",
|
||||
},
|
||||
Spec: ExampleSpec{
|
||||
Foo: "hello",
|
||||
Bar: true,
|
||||
},
|
||||
}
|
||||
|
||||
var result Example
|
||||
err = tprclient.Post().
|
||||
Resource("examples").
|
||||
Namespace(api.NamespaceDefault).
|
||||
Body(example).
|
||||
Do().Into(&result)
|
||||
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
fmt.Printf("CREATED: %#v\n", result)
|
||||
} else {
|
||||
panic(err)
|
||||
}
|
||||
} else {
|
||||
fmt.Printf("GET: %#v\n", example)
|
||||
}
|
||||
|
||||
// Fetch a list of our TPRs
|
||||
exampleList := ExampleList{}
|
||||
err = tprclient.Get().Resource("examples").Do().Into(&exampleList)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
fmt.Printf("LIST: %#v\n", exampleList)
|
||||
}
|
||||
|
||||
func buildConfig(kubeconfig string) (*rest.Config, error) {
|
||||
if kubeconfig != "" {
|
||||
return clientcmd.BuildConfigFromFlags("", kubeconfig)
|
||||
}
|
||||
return rest.InClusterConfig()
|
||||
}
|
||||
|
||||
func configureClient(config *rest.Config) {
|
||||
groupversion := schema.GroupVersion{
|
||||
Group: "k8s.io",
|
||||
Version: "v1",
|
||||
}
|
||||
|
||||
config.GroupVersion = &groupversion
|
||||
config.APIPath = "/apis"
|
||||
config.ContentType = runtime.ContentTypeJSON
|
||||
config.NegotiatedSerializer = serializer.DirectCodecFactory{CodecFactory: api.Codecs}
|
||||
|
||||
schemeBuilder := runtime.NewSchemeBuilder(
|
||||
func(scheme *runtime.Scheme) error {
|
||||
scheme.AddKnownTypes(
|
||||
groupversion,
|
||||
&Example{},
|
||||
&ExampleList{},
|
||||
)
|
||||
return nil
|
||||
})
|
||||
metav1.AddToGroupVersion(api.Scheme, groupversion)
|
||||
schemeBuilder.AddToScheme(api.Scheme)
|
||||
}
|
||||
@@ -1,92 +0,0 @@
|
||||
/*
|
||||
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 (
|
||||
"encoding/json"
|
||||
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
)
|
||||
|
||||
type ExampleSpec struct {
|
||||
Foo string `json:"foo"`
|
||||
Bar bool `json:"bar"`
|
||||
}
|
||||
|
||||
type Example struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
Metadata metav1.ObjectMeta `json:"metadata"`
|
||||
|
||||
Spec ExampleSpec `json:"spec"`
|
||||
}
|
||||
|
||||
type ExampleList struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
Metadata metav1.ListMeta `json:"metadata"`
|
||||
|
||||
Items []Example `json:"items"`
|
||||
}
|
||||
|
||||
// Required to satisfy Object interface
|
||||
func (e *Example) GetObjectKind() schema.ObjectKind {
|
||||
return &e.TypeMeta
|
||||
}
|
||||
|
||||
// Required to satisfy ObjectMetaAccessor interface
|
||||
func (e *Example) GetObjectMeta() metav1.Object {
|
||||
return &e.Metadata
|
||||
}
|
||||
|
||||
// Required to satisfy Object interface
|
||||
func (el *ExampleList) GetObjectKind() schema.ObjectKind {
|
||||
return &el.TypeMeta
|
||||
}
|
||||
|
||||
// Required to satisfy ListMetaAccessor interface
|
||||
func (el *ExampleList) GetListMeta() metav1.List {
|
||||
return &el.Metadata
|
||||
}
|
||||
|
||||
// The code below is used only to work around a known problem with third-party
|
||||
// resources and ugorji. If/when these issues are resolved, the code below
|
||||
// should no longer be required.
|
||||
|
||||
type ExampleListCopy ExampleList
|
||||
type ExampleCopy Example
|
||||
|
||||
func (e *Example) UnmarshalJSON(data []byte) error {
|
||||
tmp := ExampleCopy{}
|
||||
err := json.Unmarshal(data, &tmp)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
tmp2 := Example(tmp)
|
||||
*e = tmp2
|
||||
return nil
|
||||
}
|
||||
|
||||
func (el *ExampleList) UnmarshalJSON(data []byte) error {
|
||||
tmp := ExampleListCopy{}
|
||||
err := json.Unmarshal(data, &tmp)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
tmp2 := ExampleList(tmp)
|
||||
*el = tmp2
|
||||
return nil
|
||||
}
|
||||
33
examples/workqueue/BUILD
Normal file
33
examples/workqueue/BUILD
Normal file
@@ -0,0 +1,33 @@
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
licenses(["notice"])
|
||||
|
||||
load(
|
||||
"@io_bazel_rules_go//go:def.bzl",
|
||||
"go_binary",
|
||||
"go_library",
|
||||
)
|
||||
|
||||
go_binary(
|
||||
name = "workqueue",
|
||||
library = ":go_default_library",
|
||||
tags = ["automanaged"],
|
||||
)
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["main.go"],
|
||||
tags = ["automanaged"],
|
||||
deps = [
|
||||
"//vendor/github.com/golang/glog:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/fields:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/util/runtime:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/util/wait:go_default_library",
|
||||
"//vendor/k8s.io/client-go/kubernetes:go_default_library",
|
||||
"//vendor/k8s.io/client-go/pkg/api/v1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/tools/cache:go_default_library",
|
||||
"//vendor/k8s.io/client-go/tools/clientcmd:go_default_library",
|
||||
"//vendor/k8s.io/client-go/util/workqueue:go_default_library",
|
||||
],
|
||||
)
|
||||
17
examples/workqueue/README.md
Normal file
17
examples/workqueue/README.md
Normal file
@@ -0,0 +1,17 @@
|
||||
# Workqueue Example
|
||||
|
||||
This example demonstrates how to write a controller which follows the states
|
||||
of watched resources.
|
||||
|
||||
It demonstrates how to:
|
||||
* combine the workqueue with a cache to a full controller
|
||||
* synchronize the controller on startup
|
||||
|
||||
The example is based on https://git.k8s.io/community/contributors/devel/controllers.md.
|
||||
|
||||
## Running
|
||||
|
||||
```
|
||||
# if outside of the cluster
|
||||
go run *.go -kubeconfig=/my/config -logtostderr=true
|
||||
```
|
||||
217
examples/workqueue/main.go
Normal file
217
examples/workqueue/main.go
Normal file
@@ -0,0 +1,217 @@
|
||||
/*
|
||||
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"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/golang/glog"
|
||||
|
||||
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/fields"
|
||||
"k8s.io/apimachinery/pkg/util/runtime"
|
||||
"k8s.io/apimachinery/pkg/util/wait"
|
||||
"k8s.io/client-go/kubernetes"
|
||||
"k8s.io/client-go/pkg/api/v1"
|
||||
"k8s.io/client-go/tools/cache"
|
||||
"k8s.io/client-go/tools/clientcmd"
|
||||
"k8s.io/client-go/util/workqueue"
|
||||
)
|
||||
|
||||
type Controller struct {
|
||||
indexer cache.Indexer
|
||||
queue workqueue.RateLimitingInterface
|
||||
informer cache.Controller
|
||||
}
|
||||
|
||||
func NewController(queue workqueue.RateLimitingInterface, indexer cache.Indexer, informer cache.Controller) *Controller {
|
||||
return &Controller{
|
||||
informer: informer,
|
||||
indexer: indexer,
|
||||
queue: queue,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Controller) processNextItem() bool {
|
||||
// Wait until there is a new item in the working queue
|
||||
key, quit := c.queue.Get()
|
||||
if quit {
|
||||
return false
|
||||
}
|
||||
// Tell the queue that we are done with processing this key. This unblocks the key for other workers
|
||||
// This allows safe parallel processing because two pods with the same key are never processed in
|
||||
// parallel.
|
||||
defer c.queue.Done(key)
|
||||
|
||||
// Invoke the method containing the business logic
|
||||
err := c.syncToStdout(key.(string))
|
||||
// Handle the error if something went wrong during the execution of the business logic
|
||||
c.handleErr(err, key)
|
||||
return true
|
||||
}
|
||||
|
||||
// syncToStdout is the business logic of the controller. In this controller it simply prints
|
||||
// information about the pod to stdout. In case an error happened, it has to simply return the error.
|
||||
// The retry logic should not be part of the business logic.
|
||||
func (c *Controller) syncToStdout(key string) error {
|
||||
obj, exists, err := c.indexer.GetByKey(key)
|
||||
if err != nil {
|
||||
glog.Errorf("Fetching object with key %s from store failed with %v", key, err)
|
||||
return err
|
||||
}
|
||||
|
||||
if !exists {
|
||||
// Below we will warm up our cache with a Pod, so that we will see a delete for one pod
|
||||
fmt.Printf("Pod %s does not exist anymore\n", key)
|
||||
} else {
|
||||
// Note that you also have to check the uid if you have a local controlled resource, which
|
||||
// is dependent on the actual instance, to detect that a Pod was recreated with the same name
|
||||
fmt.Printf("Sync/Add/Update for Pod %s\n", obj.(*v1.Pod).GetName())
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// handleErr checks if an error happened and makes sure we will retry later.
|
||||
func (c *Controller) handleErr(err error, key interface{}) {
|
||||
if err == nil {
|
||||
// Forget about the #AddRateLimited history of the key on every successful synchronization.
|
||||
// This ensures that future processing of updates for this key is not delayed because of
|
||||
// an outdated error history.
|
||||
c.queue.Forget(key)
|
||||
return
|
||||
}
|
||||
|
||||
// This controller retries 5 times if something goes wrong. After that, it stops trying.
|
||||
if c.queue.NumRequeues(key) < 5 {
|
||||
glog.Infof("Error syncing pod %v: %v", key, err)
|
||||
|
||||
// Re-enqueue the key rate limited. Based on the rate limiter on the
|
||||
// queue and the re-enqueue history, the key will be processed later again.
|
||||
c.queue.AddRateLimited(key)
|
||||
return
|
||||
}
|
||||
|
||||
c.queue.Forget(key)
|
||||
// Report to an external entity that, even after several retries, we could not successfully process this key
|
||||
runtime.HandleError(err)
|
||||
glog.Infof("Dropping pod %q out of the queue: %v", key, err)
|
||||
}
|
||||
|
||||
func (c *Controller) Run(threadiness int, stopCh chan struct{}) {
|
||||
defer runtime.HandleCrash()
|
||||
|
||||
// Let the workers stop when we are done
|
||||
defer c.queue.ShutDown()
|
||||
glog.Info("Starting Pod controller")
|
||||
|
||||
go c.informer.Run(stopCh)
|
||||
|
||||
// Wait for all involved caches to be synced, before processing items from the queue is started
|
||||
if !cache.WaitForCacheSync(stopCh, c.informer.HasSynced) {
|
||||
runtime.HandleError(fmt.Errorf("Timed out waiting for caches to sync"))
|
||||
return
|
||||
}
|
||||
|
||||
for i := 0; i < threadiness; i++ {
|
||||
go wait.Until(c.runWorker, time.Second, stopCh)
|
||||
}
|
||||
|
||||
<-stopCh
|
||||
glog.Info("Stopping Pod controller")
|
||||
}
|
||||
|
||||
func (c *Controller) runWorker() {
|
||||
for c.processNextItem() {
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
var kubeconfig string
|
||||
var master string
|
||||
|
||||
flag.StringVar(&kubeconfig, "kubeconfig", "", "absolute path to the kubeconfig file")
|
||||
flag.StringVar(&master, "master", "", "master url")
|
||||
flag.Parse()
|
||||
|
||||
// creates the connection
|
||||
config, err := clientcmd.BuildConfigFromFlags(master, kubeconfig)
|
||||
if err != nil {
|
||||
glog.Fatal(err)
|
||||
}
|
||||
|
||||
// creates the clientset
|
||||
clientset, err := kubernetes.NewForConfig(config)
|
||||
if err != nil {
|
||||
glog.Fatal(err)
|
||||
}
|
||||
|
||||
// create the pod watcher
|
||||
podListWatcher := cache.NewListWatchFromClient(clientset.Core().RESTClient(), "pods", v1.NamespaceDefault, fields.Everything())
|
||||
|
||||
// create the workqueue
|
||||
queue := workqueue.NewRateLimitingQueue(workqueue.DefaultControllerRateLimiter())
|
||||
|
||||
// Bind the workqueue to a cache with the help of an informer. This way we make sure that
|
||||
// whenever the cache is updated, the pod key is added to the workqueue.
|
||||
// Note that when we finally process the item from the workqueue, we might see a newer version
|
||||
// of the Pod than the version which was responsible for triggering the update.
|
||||
indexer, informer := cache.NewIndexerInformer(podListWatcher, &v1.Pod{}, 0, cache.ResourceEventHandlerFuncs{
|
||||
AddFunc: func(obj interface{}) {
|
||||
key, err := cache.MetaNamespaceKeyFunc(obj)
|
||||
if err == nil {
|
||||
queue.Add(key)
|
||||
}
|
||||
},
|
||||
UpdateFunc: func(old interface{}, new interface{}) {
|
||||
key, err := cache.MetaNamespaceKeyFunc(new)
|
||||
if err == nil {
|
||||
queue.Add(key)
|
||||
}
|
||||
},
|
||||
DeleteFunc: func(obj interface{}) {
|
||||
// IndexerInformer uses a delta queue, therefore for deletes we have to use this
|
||||
// key function.
|
||||
key, err := cache.DeletionHandlingMetaNamespaceKeyFunc(obj)
|
||||
if err == nil {
|
||||
queue.Add(key)
|
||||
}
|
||||
},
|
||||
}, cache.Indexers{})
|
||||
|
||||
controller := NewController(queue, indexer, informer)
|
||||
|
||||
// We can now warm up the cache for initial synchronization.
|
||||
// Let's suppose that we knew about a pod "mypod" on our last run, therefore add it to the cache.
|
||||
// If this pod is not there anymore, the controller will be notified about the removal after the
|
||||
// cache has synchronized.
|
||||
indexer.Add(&v1.Pod{
|
||||
ObjectMeta: meta_v1.ObjectMeta{
|
||||
Name: "mypod",
|
||||
Namespace: v1.NamespaceDefault,
|
||||
},
|
||||
})
|
||||
|
||||
// Now let's start the controller
|
||||
stop := make(chan struct{})
|
||||
defer close(stop)
|
||||
go controller.Run(1, stop)
|
||||
|
||||
// Wait forever
|
||||
select {}
|
||||
}
|
||||
52
informers/BUILD
Normal file
52
informers/BUILD
Normal file
@@ -0,0 +1,52 @@
|
||||
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/informers/admissionregistration:go_default_library",
|
||||
"//vendor/k8s.io/client-go/informers/apps:go_default_library",
|
||||
"//vendor/k8s.io/client-go/informers/autoscaling:go_default_library",
|
||||
"//vendor/k8s.io/client-go/informers/batch:go_default_library",
|
||||
"//vendor/k8s.io/client-go/informers/certificates:go_default_library",
|
||||
"//vendor/k8s.io/client-go/informers/core:go_default_library",
|
||||
"//vendor/k8s.io/client-go/informers/extensions:go_default_library",
|
||||
"//vendor/k8s.io/client-go/informers/internalinterfaces:go_default_library",
|
||||
"//vendor/k8s.io/client-go/informers/networking:go_default_library",
|
||||
"//vendor/k8s.io/client-go/informers/policy:go_default_library",
|
||||
"//vendor/k8s.io/client-go/informers/rbac:go_default_library",
|
||||
"//vendor/k8s.io/client-go/informers/settings:go_default_library",
|
||||
"//vendor/k8s.io/client-go/informers/storage:go_default_library",
|
||||
"//vendor/k8s.io/client-go/kubernetes:go_default_library",
|
||||
"//vendor/k8s.io/client-go/pkg/api/v1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/pkg/apis/admissionregistration/v1alpha1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/pkg/apis/apps/v1beta1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/pkg/apis/autoscaling/v1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/pkg/apis/autoscaling/v2alpha1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/pkg/apis/batch/v1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/pkg/apis/batch/v2alpha1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/pkg/apis/certificates/v1beta1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/pkg/apis/extensions/v1beta1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/pkg/apis/networking/v1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/pkg/apis/policy/v1beta1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/pkg/apis/rbac/v1alpha1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/pkg/apis/rbac/v1beta1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/pkg/apis/settings/v1alpha1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/pkg/apis/storage/v1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/pkg/apis/storage/v1beta1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/tools/cache:go_default_library",
|
||||
],
|
||||
)
|
||||
18
informers/admissionregistration/BUILD
Normal file
18
informers/admissionregistration/BUILD
Normal 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/client-go/informers/admissionregistration/v1alpha1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/informers/internalinterfaces:go_default_library",
|
||||
],
|
||||
)
|
||||
44
informers/admissionregistration/interface.go
Normal file
44
informers/admissionregistration/interface.go
Normal 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 admissionregistration
|
||||
|
||||
import (
|
||||
v1alpha1 "k8s.io/client-go/informers/admissionregistration/v1alpha1"
|
||||
internalinterfaces "k8s.io/client-go/informers/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)
|
||||
}
|
||||
28
informers/admissionregistration/v1alpha1/BUILD
Normal file
28
informers/admissionregistration/v1alpha1/BUILD
Normal 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 = [
|
||||
"externaladmissionhookconfiguration.go",
|
||||
"initializerconfiguration.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/informers/internalinterfaces:go_default_library",
|
||||
"//vendor/k8s.io/client-go/kubernetes:go_default_library",
|
||||
"//vendor/k8s.io/client-go/listers/admissionregistration/v1alpha1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/pkg/apis/admissionregistration/v1alpha1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/tools/cache:go_default_library",
|
||||
],
|
||||
)
|
||||
@@ -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"
|
||||
internalinterfaces "k8s.io/client-go/informers/internalinterfaces"
|
||||
kubernetes "k8s.io/client-go/kubernetes"
|
||||
v1alpha1 "k8s.io/client-go/listers/admissionregistration/v1alpha1"
|
||||
admissionregistration_v1alpha1 "k8s.io/client-go/pkg/apis/admissionregistration/v1alpha1"
|
||||
cache "k8s.io/client-go/tools/cache"
|
||||
time "time"
|
||||
)
|
||||
|
||||
// ExternalAdmissionHookConfigurationInformer provides access to a shared informer and lister for
|
||||
// ExternalAdmissionHookConfigurations.
|
||||
type ExternalAdmissionHookConfigurationInformer interface {
|
||||
Informer() cache.SharedIndexInformer
|
||||
Lister() v1alpha1.ExternalAdmissionHookConfigurationLister
|
||||
}
|
||||
|
||||
type externalAdmissionHookConfigurationInformer struct {
|
||||
factory internalinterfaces.SharedInformerFactory
|
||||
}
|
||||
|
||||
func newExternalAdmissionHookConfigurationInformer(client kubernetes.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
|
||||
sharedIndexInformer := cache.NewSharedIndexInformer(
|
||||
&cache.ListWatch{
|
||||
ListFunc: func(options v1.ListOptions) (runtime.Object, error) {
|
||||
return client.AdmissionregistrationV1alpha1().ExternalAdmissionHookConfigurations().List(options)
|
||||
},
|
||||
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
|
||||
return client.AdmissionregistrationV1alpha1().ExternalAdmissionHookConfigurations().Watch(options)
|
||||
},
|
||||
},
|
||||
&admissionregistration_v1alpha1.ExternalAdmissionHookConfiguration{},
|
||||
resyncPeriod,
|
||||
cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc},
|
||||
)
|
||||
|
||||
return sharedIndexInformer
|
||||
}
|
||||
|
||||
func (f *externalAdmissionHookConfigurationInformer) Informer() cache.SharedIndexInformer {
|
||||
return f.factory.InformerFor(&admissionregistration_v1alpha1.ExternalAdmissionHookConfiguration{}, newExternalAdmissionHookConfigurationInformer)
|
||||
}
|
||||
|
||||
func (f *externalAdmissionHookConfigurationInformer) Lister() v1alpha1.ExternalAdmissionHookConfigurationLister {
|
||||
return v1alpha1.NewExternalAdmissionHookConfigurationLister(f.Informer().GetIndexer())
|
||||
}
|
||||
@@ -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"
|
||||
internalinterfaces "k8s.io/client-go/informers/internalinterfaces"
|
||||
kubernetes "k8s.io/client-go/kubernetes"
|
||||
v1alpha1 "k8s.io/client-go/listers/admissionregistration/v1alpha1"
|
||||
admissionregistration_v1alpha1 "k8s.io/client-go/pkg/apis/admissionregistration/v1alpha1"
|
||||
cache "k8s.io/client-go/tools/cache"
|
||||
time "time"
|
||||
)
|
||||
|
||||
// InitializerConfigurationInformer provides access to a shared informer and lister for
|
||||
// InitializerConfigurations.
|
||||
type InitializerConfigurationInformer interface {
|
||||
Informer() cache.SharedIndexInformer
|
||||
Lister() v1alpha1.InitializerConfigurationLister
|
||||
}
|
||||
|
||||
type initializerConfigurationInformer struct {
|
||||
factory internalinterfaces.SharedInformerFactory
|
||||
}
|
||||
|
||||
func newInitializerConfigurationInformer(client kubernetes.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
|
||||
sharedIndexInformer := cache.NewSharedIndexInformer(
|
||||
&cache.ListWatch{
|
||||
ListFunc: func(options v1.ListOptions) (runtime.Object, error) {
|
||||
return client.AdmissionregistrationV1alpha1().InitializerConfigurations().List(options)
|
||||
},
|
||||
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
|
||||
return client.AdmissionregistrationV1alpha1().InitializerConfigurations().Watch(options)
|
||||
},
|
||||
},
|
||||
&admissionregistration_v1alpha1.InitializerConfiguration{},
|
||||
resyncPeriod,
|
||||
cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc},
|
||||
)
|
||||
|
||||
return sharedIndexInformer
|
||||
}
|
||||
|
||||
func (f *initializerConfigurationInformer) Informer() cache.SharedIndexInformer {
|
||||
return f.factory.InformerFor(&admissionregistration_v1alpha1.InitializerConfiguration{}, newInitializerConfigurationInformer)
|
||||
}
|
||||
|
||||
func (f *initializerConfigurationInformer) Lister() v1alpha1.InitializerConfigurationLister {
|
||||
return v1alpha1.NewInitializerConfigurationLister(f.Informer().GetIndexer())
|
||||
}
|
||||
50
informers/admissionregistration/v1alpha1/interface.go
Normal file
50
informers/admissionregistration/v1alpha1/interface.go
Normal file
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
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/client-go/informers/internalinterfaces"
|
||||
)
|
||||
|
||||
// Interface provides access to all the informers in this group version.
|
||||
type Interface interface {
|
||||
// ExternalAdmissionHookConfigurations returns a ExternalAdmissionHookConfigurationInformer.
|
||||
ExternalAdmissionHookConfigurations() ExternalAdmissionHookConfigurationInformer
|
||||
// InitializerConfigurations returns a InitializerConfigurationInformer.
|
||||
InitializerConfigurations() InitializerConfigurationInformer
|
||||
}
|
||||
|
||||
type version struct {
|
||||
internalinterfaces.SharedInformerFactory
|
||||
}
|
||||
|
||||
// New returns a new Interface.
|
||||
func New(f internalinterfaces.SharedInformerFactory) Interface {
|
||||
return &version{f}
|
||||
}
|
||||
|
||||
// ExternalAdmissionHookConfigurations returns a ExternalAdmissionHookConfigurationInformer.
|
||||
func (v *version) ExternalAdmissionHookConfigurations() ExternalAdmissionHookConfigurationInformer {
|
||||
return &externalAdmissionHookConfigurationInformer{factory: v.SharedInformerFactory}
|
||||
}
|
||||
|
||||
// InitializerConfigurations returns a InitializerConfigurationInformer.
|
||||
func (v *version) InitializerConfigurations() InitializerConfigurationInformer {
|
||||
return &initializerConfigurationInformer{factory: v.SharedInformerFactory}
|
||||
}
|
||||
18
informers/apps/BUILD
Normal file
18
informers/apps/BUILD
Normal 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/client-go/informers/apps/v1beta1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/informers/internalinterfaces:go_default_library",
|
||||
],
|
||||
)
|
||||
29
informers/apps/v1beta1/BUILD
Normal file
29
informers/apps/v1beta1/BUILD
Normal 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 = [
|
||||
"controllerrevision.go",
|
||||
"deployment.go",
|
||||
"interface.go",
|
||||
"statefulset.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/informers/internalinterfaces:go_default_library",
|
||||
"//vendor/k8s.io/client-go/kubernetes:go_default_library",
|
||||
"//vendor/k8s.io/client-go/listers/apps/v1beta1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/pkg/apis/apps/v1beta1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/tools/cache:go_default_library",
|
||||
],
|
||||
)
|
||||
68
informers/apps/v1beta1/controllerrevision.go
Normal file
68
informers/apps/v1beta1/controllerrevision.go
Normal 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 v1beta1
|
||||
|
||||
import (
|
||||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
||||
watch "k8s.io/apimachinery/pkg/watch"
|
||||
internalinterfaces "k8s.io/client-go/informers/internalinterfaces"
|
||||
kubernetes "k8s.io/client-go/kubernetes"
|
||||
v1beta1 "k8s.io/client-go/listers/apps/v1beta1"
|
||||
apps_v1beta1 "k8s.io/client-go/pkg/apis/apps/v1beta1"
|
||||
cache "k8s.io/client-go/tools/cache"
|
||||
time "time"
|
||||
)
|
||||
|
||||
// ControllerRevisionInformer provides access to a shared informer and lister for
|
||||
// ControllerRevisions.
|
||||
type ControllerRevisionInformer interface {
|
||||
Informer() cache.SharedIndexInformer
|
||||
Lister() v1beta1.ControllerRevisionLister
|
||||
}
|
||||
|
||||
type controllerRevisionInformer struct {
|
||||
factory internalinterfaces.SharedInformerFactory
|
||||
}
|
||||
|
||||
func newControllerRevisionInformer(client kubernetes.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
|
||||
sharedIndexInformer := cache.NewSharedIndexInformer(
|
||||
&cache.ListWatch{
|
||||
ListFunc: func(options v1.ListOptions) (runtime.Object, error) {
|
||||
return client.AppsV1beta1().ControllerRevisions(v1.NamespaceAll).List(options)
|
||||
},
|
||||
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
|
||||
return client.AppsV1beta1().ControllerRevisions(v1.NamespaceAll).Watch(options)
|
||||
},
|
||||
},
|
||||
&apps_v1beta1.ControllerRevision{},
|
||||
resyncPeriod,
|
||||
cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc},
|
||||
)
|
||||
|
||||
return sharedIndexInformer
|
||||
}
|
||||
|
||||
func (f *controllerRevisionInformer) Informer() cache.SharedIndexInformer {
|
||||
return f.factory.InformerFor(&apps_v1beta1.ControllerRevision{}, newControllerRevisionInformer)
|
||||
}
|
||||
|
||||
func (f *controllerRevisionInformer) Lister() v1beta1.ControllerRevisionLister {
|
||||
return v1beta1.NewControllerRevisionLister(f.Informer().GetIndexer())
|
||||
}
|
||||
@@ -24,6 +24,8 @@ import (
|
||||
|
||||
// Interface provides access to all the informers in this group version.
|
||||
type Interface interface {
|
||||
// ControllerRevisions returns a ControllerRevisionInformer.
|
||||
ControllerRevisions() ControllerRevisionInformer
|
||||
// Deployments returns a DeploymentInformer.
|
||||
Deployments() DeploymentInformer
|
||||
// StatefulSets returns a StatefulSetInformer.
|
||||
@@ -39,6 +41,11 @@ func New(f internalinterfaces.SharedInformerFactory) Interface {
|
||||
return &version{f}
|
||||
}
|
||||
|
||||
// ControllerRevisions returns a ControllerRevisionInformer.
|
||||
func (v *version) ControllerRevisions() ControllerRevisionInformer {
|
||||
return &controllerRevisionInformer{factory: v.SharedInformerFactory}
|
||||
}
|
||||
|
||||
// Deployments returns a DeploymentInformer.
|
||||
func (v *version) Deployments() DeploymentInformer {
|
||||
return &deploymentInformer{factory: v.SharedInformerFactory}
|
||||
|
||||
19
informers/autoscaling/BUILD
Normal file
19
informers/autoscaling/BUILD
Normal 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 = ["interface.go"],
|
||||
tags = ["automanaged"],
|
||||
deps = [
|
||||
"//vendor/k8s.io/client-go/informers/autoscaling/v1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/informers/autoscaling/v2alpha1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/informers/internalinterfaces:go_default_library",
|
||||
],
|
||||
)
|
||||
27
informers/autoscaling/v1/BUILD
Normal file
27
informers/autoscaling/v1/BUILD
Normal 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 = [
|
||||
"horizontalpodautoscaler.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/informers/internalinterfaces:go_default_library",
|
||||
"//vendor/k8s.io/client-go/kubernetes:go_default_library",
|
||||
"//vendor/k8s.io/client-go/listers/autoscaling/v1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/pkg/apis/autoscaling/v1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/tools/cache:go_default_library",
|
||||
],
|
||||
)
|
||||
27
informers/autoscaling/v2alpha1/BUILD
Normal file
27
informers/autoscaling/v2alpha1/BUILD
Normal 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 = [
|
||||
"horizontalpodautoscaler.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/informers/internalinterfaces:go_default_library",
|
||||
"//vendor/k8s.io/client-go/kubernetes:go_default_library",
|
||||
"//vendor/k8s.io/client-go/listers/autoscaling/v2alpha1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/pkg/apis/autoscaling/v2alpha1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/tools/cache:go_default_library",
|
||||
],
|
||||
)
|
||||
19
informers/batch/BUILD
Normal file
19
informers/batch/BUILD
Normal 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 = ["interface.go"],
|
||||
tags = ["automanaged"],
|
||||
deps = [
|
||||
"//vendor/k8s.io/client-go/informers/batch/v1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/informers/batch/v2alpha1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/informers/internalinterfaces:go_default_library",
|
||||
],
|
||||
)
|
||||
27
informers/batch/v1/BUILD
Normal file
27
informers/batch/v1/BUILD
Normal 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 = [
|
||||
"interface.go",
|
||||
"job.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/informers/internalinterfaces:go_default_library",
|
||||
"//vendor/k8s.io/client-go/kubernetes:go_default_library",
|
||||
"//vendor/k8s.io/client-go/listers/batch/v1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/pkg/apis/batch/v1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/tools/cache:go_default_library",
|
||||
],
|
||||
)
|
||||
27
informers/batch/v2alpha1/BUILD
Normal file
27
informers/batch/v2alpha1/BUILD
Normal 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 = [
|
||||
"cronjob.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/informers/internalinterfaces:go_default_library",
|
||||
"//vendor/k8s.io/client-go/kubernetes:go_default_library",
|
||||
"//vendor/k8s.io/client-go/listers/batch/v2alpha1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/pkg/apis/batch/v2alpha1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/tools/cache:go_default_library",
|
||||
],
|
||||
)
|
||||
18
informers/certificates/BUILD
Normal file
18
informers/certificates/BUILD
Normal 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/client-go/informers/certificates/v1beta1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/informers/internalinterfaces:go_default_library",
|
||||
],
|
||||
)
|
||||
27
informers/certificates/v1beta1/BUILD
Normal file
27
informers/certificates/v1beta1/BUILD
Normal 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 = [
|
||||
"certificatesigningrequest.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/informers/internalinterfaces:go_default_library",
|
||||
"//vendor/k8s.io/client-go/kubernetes:go_default_library",
|
||||
"//vendor/k8s.io/client-go/listers/certificates/v1beta1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/pkg/apis/certificates/v1beta1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/tools/cache:go_default_library",
|
||||
],
|
||||
)
|
||||
18
informers/core/BUILD
Normal file
18
informers/core/BUILD
Normal 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/client-go/informers/core/v1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/informers/internalinterfaces:go_default_library",
|
||||
],
|
||||
)
|
||||
42
informers/core/v1/BUILD
Normal file
42
informers/core/v1/BUILD
Normal file
@@ -0,0 +1,42 @@
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
licenses(["notice"])
|
||||
|
||||
load(
|
||||
"@io_bazel_rules_go//go:def.bzl",
|
||||
"go_library",
|
||||
)
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = [
|
||||
"componentstatus.go",
|
||||
"configmap.go",
|
||||
"endpoints.go",
|
||||
"event.go",
|
||||
"interface.go",
|
||||
"limitrange.go",
|
||||
"namespace.go",
|
||||
"node.go",
|
||||
"persistentvolume.go",
|
||||
"persistentvolumeclaim.go",
|
||||
"pod.go",
|
||||
"podtemplate.go",
|
||||
"replicationcontroller.go",
|
||||
"resourcequota.go",
|
||||
"secret.go",
|
||||
"service.go",
|
||||
"serviceaccount.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/informers/internalinterfaces:go_default_library",
|
||||
"//vendor/k8s.io/client-go/kubernetes:go_default_library",
|
||||
"//vendor/k8s.io/client-go/listers/core/v1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/pkg/api/v1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/tools/cache:go_default_library",
|
||||
],
|
||||
)
|
||||
18
informers/extensions/BUILD
Normal file
18
informers/extensions/BUILD
Normal 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/client-go/informers/extensions/v1beta1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/informers/internalinterfaces:go_default_library",
|
||||
],
|
||||
)
|
||||
32
informers/extensions/v1beta1/BUILD
Normal file
32
informers/extensions/v1beta1/BUILD
Normal file
@@ -0,0 +1,32 @@
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
licenses(["notice"])
|
||||
|
||||
load(
|
||||
"@io_bazel_rules_go//go:def.bzl",
|
||||
"go_library",
|
||||
)
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = [
|
||||
"daemonset.go",
|
||||
"deployment.go",
|
||||
"ingress.go",
|
||||
"interface.go",
|
||||
"podsecuritypolicy.go",
|
||||
"replicaset.go",
|
||||
"thirdpartyresource.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/informers/internalinterfaces:go_default_library",
|
||||
"//vendor/k8s.io/client-go/kubernetes:go_default_library",
|
||||
"//vendor/k8s.io/client-go/listers/extensions/v1beta1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/pkg/apis/extensions/v1beta1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/tools/cache:go_default_library",
|
||||
],
|
||||
)
|
||||
@@ -21,6 +21,7 @@ package informers
|
||||
import (
|
||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
||||
schema "k8s.io/apimachinery/pkg/runtime/schema"
|
||||
admissionregistration "k8s.io/client-go/informers/admissionregistration"
|
||||
apps "k8s.io/client-go/informers/apps"
|
||||
autoscaling "k8s.io/client-go/informers/autoscaling"
|
||||
batch "k8s.io/client-go/informers/batch"
|
||||
@@ -28,6 +29,7 @@ import (
|
||||
core "k8s.io/client-go/informers/core"
|
||||
extensions "k8s.io/client-go/informers/extensions"
|
||||
internalinterfaces "k8s.io/client-go/informers/internalinterfaces"
|
||||
networking "k8s.io/client-go/informers/networking"
|
||||
policy "k8s.io/client-go/informers/policy"
|
||||
rbac "k8s.io/client-go/informers/rbac"
|
||||
settings "k8s.io/client-go/informers/settings"
|
||||
@@ -73,6 +75,28 @@ func (f *sharedInformerFactory) Start(stopCh <-chan struct{}) {
|
||||
}
|
||||
}
|
||||
|
||||
// WaitForCacheSync waits for all started informers' cache were synced.
|
||||
func (f *sharedInformerFactory) WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool {
|
||||
informers := func() map[reflect.Type]cache.SharedIndexInformer {
|
||||
f.lock.Lock()
|
||||
defer f.lock.Unlock()
|
||||
|
||||
informers := map[reflect.Type]cache.SharedIndexInformer{}
|
||||
for informerType, informer := range f.informers {
|
||||
if f.startedInformers[informerType] {
|
||||
informers[informerType] = informer
|
||||
}
|
||||
}
|
||||
return informers
|
||||
}()
|
||||
|
||||
res := map[reflect.Type]bool{}
|
||||
for informType, informer := range informers {
|
||||
res[informType] = cache.WaitForCacheSync(stopCh, informer.HasSynced)
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
// InternalInformerFor returns the SharedIndexInformer for obj using an internal
|
||||
// client.
|
||||
func (f *sharedInformerFactory) InformerFor(obj runtime.Object, newFunc internalinterfaces.NewInformerFunc) cache.SharedIndexInformer {
|
||||
@@ -95,19 +119,26 @@ func (f *sharedInformerFactory) InformerFor(obj runtime.Object, newFunc internal
|
||||
type SharedInformerFactory interface {
|
||||
internalinterfaces.SharedInformerFactory
|
||||
ForResource(resource schema.GroupVersionResource) (GenericInformer, error)
|
||||
WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool
|
||||
|
||||
Admissionregistration() admissionregistration.Interface
|
||||
Apps() apps.Interface
|
||||
Autoscaling() autoscaling.Interface
|
||||
Batch() batch.Interface
|
||||
Certificates() certificates.Interface
|
||||
Core() core.Interface
|
||||
Extensions() extensions.Interface
|
||||
Networking() networking.Interface
|
||||
Policy() policy.Interface
|
||||
Rbac() rbac.Interface
|
||||
Settings() settings.Interface
|
||||
Storage() storage.Interface
|
||||
}
|
||||
|
||||
func (f *sharedInformerFactory) Admissionregistration() admissionregistration.Interface {
|
||||
return admissionregistration.New(f)
|
||||
}
|
||||
|
||||
func (f *sharedInformerFactory) Apps() apps.Interface {
|
||||
return apps.New(f)
|
||||
}
|
||||
@@ -132,6 +163,10 @@ func (f *sharedInformerFactory) Extensions() extensions.Interface {
|
||||
return extensions.New(f)
|
||||
}
|
||||
|
||||
func (f *sharedInformerFactory) Networking() networking.Interface {
|
||||
return networking.New(f)
|
||||
}
|
||||
|
||||
func (f *sharedInformerFactory) Policy() policy.Interface {
|
||||
return policy.New(f)
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import (
|
||||
"fmt"
|
||||
schema "k8s.io/apimachinery/pkg/runtime/schema"
|
||||
api_v1 "k8s.io/client-go/pkg/api/v1"
|
||||
v1alpha1 "k8s.io/client-go/pkg/apis/admissionregistration/v1alpha1"
|
||||
v1beta1 "k8s.io/client-go/pkg/apis/apps/v1beta1"
|
||||
v1 "k8s.io/client-go/pkg/apis/autoscaling/v1"
|
||||
v2alpha1 "k8s.io/client-go/pkg/apis/autoscaling/v2alpha1"
|
||||
@@ -29,8 +30,9 @@ import (
|
||||
batch_v2alpha1 "k8s.io/client-go/pkg/apis/batch/v2alpha1"
|
||||
certificates_v1beta1 "k8s.io/client-go/pkg/apis/certificates/v1beta1"
|
||||
extensions_v1beta1 "k8s.io/client-go/pkg/apis/extensions/v1beta1"
|
||||
networking_v1 "k8s.io/client-go/pkg/apis/networking/v1"
|
||||
policy_v1beta1 "k8s.io/client-go/pkg/apis/policy/v1beta1"
|
||||
v1alpha1 "k8s.io/client-go/pkg/apis/rbac/v1alpha1"
|
||||
rbac_v1alpha1 "k8s.io/client-go/pkg/apis/rbac/v1alpha1"
|
||||
rbac_v1beta1 "k8s.io/client-go/pkg/apis/rbac/v1beta1"
|
||||
settings_v1alpha1 "k8s.io/client-go/pkg/apis/settings/v1alpha1"
|
||||
storage_v1 "k8s.io/client-go/pkg/apis/storage/v1"
|
||||
@@ -64,7 +66,15 @@ func (f *genericInformer) Lister() cache.GenericLister {
|
||||
// TODO extend this to unknown resources with a client pool
|
||||
func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource) (GenericInformer, error) {
|
||||
switch resource {
|
||||
// Group=Apps, Version=V1beta1
|
||||
// Group=Admissionregistration, Version=V1alpha1
|
||||
case v1alpha1.SchemeGroupVersion.WithResource("externaladmissionhookconfigurations"):
|
||||
return &genericInformer{resource: resource.GroupResource(), informer: f.Admissionregistration().V1alpha1().ExternalAdmissionHookConfigurations().Informer()}, nil
|
||||
case v1alpha1.SchemeGroupVersion.WithResource("initializerconfigurations"):
|
||||
return &genericInformer{resource: resource.GroupResource(), informer: f.Admissionregistration().V1alpha1().InitializerConfigurations().Informer()}, nil
|
||||
|
||||
// Group=Apps, Version=V1beta1
|
||||
case v1beta1.SchemeGroupVersion.WithResource("controllerrevisions"):
|
||||
return &genericInformer{resource: resource.GroupResource(), informer: f.Apps().V1beta1().ControllerRevisions().Informer()}, nil
|
||||
case v1beta1.SchemeGroupVersion.WithResource("deployments"):
|
||||
return &genericInformer{resource: resource.GroupResource(), informer: f.Apps().V1beta1().Deployments().Informer()}, nil
|
||||
case v1beta1.SchemeGroupVersion.WithResource("statefulsets"):
|
||||
@@ -138,18 +148,22 @@ func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource
|
||||
case extensions_v1beta1.SchemeGroupVersion.WithResource("thirdpartyresources"):
|
||||
return &genericInformer{resource: resource.GroupResource(), informer: f.Extensions().V1beta1().ThirdPartyResources().Informer()}, nil
|
||||
|
||||
// Group=Networking, Version=V1
|
||||
case networking_v1.SchemeGroupVersion.WithResource("networkpolicies"):
|
||||
return &genericInformer{resource: resource.GroupResource(), informer: f.Networking().V1().NetworkPolicies().Informer()}, nil
|
||||
|
||||
// Group=Policy, Version=V1beta1
|
||||
case policy_v1beta1.SchemeGroupVersion.WithResource("poddisruptionbudgets"):
|
||||
return &genericInformer{resource: resource.GroupResource(), informer: f.Policy().V1beta1().PodDisruptionBudgets().Informer()}, nil
|
||||
|
||||
// Group=Rbac, Version=V1alpha1
|
||||
case v1alpha1.SchemeGroupVersion.WithResource("clusterroles"):
|
||||
case rbac_v1alpha1.SchemeGroupVersion.WithResource("clusterroles"):
|
||||
return &genericInformer{resource: resource.GroupResource(), informer: f.Rbac().V1alpha1().ClusterRoles().Informer()}, nil
|
||||
case v1alpha1.SchemeGroupVersion.WithResource("clusterrolebindings"):
|
||||
case rbac_v1alpha1.SchemeGroupVersion.WithResource("clusterrolebindings"):
|
||||
return &genericInformer{resource: resource.GroupResource(), informer: f.Rbac().V1alpha1().ClusterRoleBindings().Informer()}, nil
|
||||
case v1alpha1.SchemeGroupVersion.WithResource("roles"):
|
||||
case rbac_v1alpha1.SchemeGroupVersion.WithResource("roles"):
|
||||
return &genericInformer{resource: resource.GroupResource(), informer: f.Rbac().V1alpha1().Roles().Informer()}, nil
|
||||
case v1alpha1.SchemeGroupVersion.WithResource("rolebindings"):
|
||||
case rbac_v1alpha1.SchemeGroupVersion.WithResource("rolebindings"):
|
||||
return &genericInformer{resource: resource.GroupResource(), informer: f.Rbac().V1alpha1().RoleBindings().Informer()}, nil
|
||||
|
||||
// Group=Rbac, Version=V1beta1
|
||||
|
||||
19
informers/internalinterfaces/BUILD
Normal file
19
informers/internalinterfaces/BUILD
Normal 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/kubernetes:go_default_library",
|
||||
"//vendor/k8s.io/client-go/tools/cache:go_default_library",
|
||||
],
|
||||
)
|
||||
18
informers/networking/BUILD
Normal file
18
informers/networking/BUILD
Normal 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/client-go/informers/internalinterfaces:go_default_library",
|
||||
"//vendor/k8s.io/client-go/informers/networking/v1:go_default_library",
|
||||
],
|
||||
)
|
||||
44
informers/networking/interface.go
Normal file
44
informers/networking/interface.go
Normal 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 networking
|
||||
|
||||
import (
|
||||
internalinterfaces "k8s.io/client-go/informers/internalinterfaces"
|
||||
v1 "k8s.io/client-go/informers/networking/v1"
|
||||
)
|
||||
|
||||
// Interface provides access to each of this group's versions.
|
||||
type Interface interface {
|
||||
// V1 provides access to shared informers for resources in V1.
|
||||
V1() v1.Interface
|
||||
}
|
||||
|
||||
type group struct {
|
||||
internalinterfaces.SharedInformerFactory
|
||||
}
|
||||
|
||||
// New returns a new Interface.
|
||||
func New(f internalinterfaces.SharedInformerFactory) Interface {
|
||||
return &group{f}
|
||||
}
|
||||
|
||||
// V1 returns a new v1.Interface.
|
||||
func (g *group) V1() v1.Interface {
|
||||
return v1.New(g.SharedInformerFactory)
|
||||
}
|
||||
27
informers/networking/v1/BUILD
Normal file
27
informers/networking/v1/BUILD
Normal 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 = [
|
||||
"interface.go",
|
||||
"networkpolicy.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/informers/internalinterfaces:go_default_library",
|
||||
"//vendor/k8s.io/client-go/kubernetes:go_default_library",
|
||||
"//vendor/k8s.io/client-go/listers/networking/v1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/pkg/apis/networking/v1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/tools/cache:go_default_library",
|
||||
],
|
||||
)
|
||||
43
informers/networking/v1/interface.go
Normal file
43
informers/networking/v1/interface.go
Normal 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 v1
|
||||
|
||||
import (
|
||||
internalinterfaces "k8s.io/client-go/informers/internalinterfaces"
|
||||
)
|
||||
|
||||
// Interface provides access to all the informers in this group version.
|
||||
type Interface interface {
|
||||
// NetworkPolicies returns a NetworkPolicyInformer.
|
||||
NetworkPolicies() NetworkPolicyInformer
|
||||
}
|
||||
|
||||
type version struct {
|
||||
internalinterfaces.SharedInformerFactory
|
||||
}
|
||||
|
||||
// New returns a new Interface.
|
||||
func New(f internalinterfaces.SharedInformerFactory) Interface {
|
||||
return &version{f}
|
||||
}
|
||||
|
||||
// NetworkPolicies returns a NetworkPolicyInformer.
|
||||
func (v *version) NetworkPolicies() NetworkPolicyInformer {
|
||||
return &networkPolicyInformer{factory: v.SharedInformerFactory}
|
||||
}
|
||||
68
informers/networking/v1/networkpolicy.go
Normal file
68
informers/networking/v1/networkpolicy.go
Normal 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 v1
|
||||
|
||||
import (
|
||||
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
||||
watch "k8s.io/apimachinery/pkg/watch"
|
||||
internalinterfaces "k8s.io/client-go/informers/internalinterfaces"
|
||||
kubernetes "k8s.io/client-go/kubernetes"
|
||||
v1 "k8s.io/client-go/listers/networking/v1"
|
||||
networking_v1 "k8s.io/client-go/pkg/apis/networking/v1"
|
||||
cache "k8s.io/client-go/tools/cache"
|
||||
time "time"
|
||||
)
|
||||
|
||||
// NetworkPolicyInformer provides access to a shared informer and lister for
|
||||
// NetworkPolicies.
|
||||
type NetworkPolicyInformer interface {
|
||||
Informer() cache.SharedIndexInformer
|
||||
Lister() v1.NetworkPolicyLister
|
||||
}
|
||||
|
||||
type networkPolicyInformer struct {
|
||||
factory internalinterfaces.SharedInformerFactory
|
||||
}
|
||||
|
||||
func newNetworkPolicyInformer(client kubernetes.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
|
||||
sharedIndexInformer := cache.NewSharedIndexInformer(
|
||||
&cache.ListWatch{
|
||||
ListFunc: func(options meta_v1.ListOptions) (runtime.Object, error) {
|
||||
return client.NetworkingV1().NetworkPolicies(meta_v1.NamespaceAll).List(options)
|
||||
},
|
||||
WatchFunc: func(options meta_v1.ListOptions) (watch.Interface, error) {
|
||||
return client.NetworkingV1().NetworkPolicies(meta_v1.NamespaceAll).Watch(options)
|
||||
},
|
||||
},
|
||||
&networking_v1.NetworkPolicy{},
|
||||
resyncPeriod,
|
||||
cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc},
|
||||
)
|
||||
|
||||
return sharedIndexInformer
|
||||
}
|
||||
|
||||
func (f *networkPolicyInformer) Informer() cache.SharedIndexInformer {
|
||||
return f.factory.InformerFor(&networking_v1.NetworkPolicy{}, newNetworkPolicyInformer)
|
||||
}
|
||||
|
||||
func (f *networkPolicyInformer) Lister() v1.NetworkPolicyLister {
|
||||
return v1.NewNetworkPolicyLister(f.Informer().GetIndexer())
|
||||
}
|
||||
18
informers/policy/BUILD
Normal file
18
informers/policy/BUILD
Normal 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/client-go/informers/internalinterfaces:go_default_library",
|
||||
"//vendor/k8s.io/client-go/informers/policy/v1beta1:go_default_library",
|
||||
],
|
||||
)
|
||||
27
informers/policy/v1beta1/BUILD
Normal file
27
informers/policy/v1beta1/BUILD
Normal 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 = [
|
||||
"interface.go",
|
||||
"poddisruptionbudget.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/informers/internalinterfaces:go_default_library",
|
||||
"//vendor/k8s.io/client-go/kubernetes:go_default_library",
|
||||
"//vendor/k8s.io/client-go/listers/policy/v1beta1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/pkg/apis/policy/v1beta1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/tools/cache:go_default_library",
|
||||
],
|
||||
)
|
||||
19
informers/rbac/BUILD
Normal file
19
informers/rbac/BUILD
Normal 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 = ["interface.go"],
|
||||
tags = ["automanaged"],
|
||||
deps = [
|
||||
"//vendor/k8s.io/client-go/informers/internalinterfaces:go_default_library",
|
||||
"//vendor/k8s.io/client-go/informers/rbac/v1alpha1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/informers/rbac/v1beta1:go_default_library",
|
||||
],
|
||||
)
|
||||
30
informers/rbac/v1alpha1/BUILD
Normal file
30
informers/rbac/v1alpha1/BUILD
Normal file
@@ -0,0 +1,30 @@
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
licenses(["notice"])
|
||||
|
||||
load(
|
||||
"@io_bazel_rules_go//go:def.bzl",
|
||||
"go_library",
|
||||
)
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = [
|
||||
"clusterrole.go",
|
||||
"clusterrolebinding.go",
|
||||
"interface.go",
|
||||
"role.go",
|
||||
"rolebinding.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/informers/internalinterfaces:go_default_library",
|
||||
"//vendor/k8s.io/client-go/kubernetes:go_default_library",
|
||||
"//vendor/k8s.io/client-go/listers/rbac/v1alpha1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/pkg/apis/rbac/v1alpha1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/tools/cache:go_default_library",
|
||||
],
|
||||
)
|
||||
30
informers/rbac/v1beta1/BUILD
Normal file
30
informers/rbac/v1beta1/BUILD
Normal file
@@ -0,0 +1,30 @@
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
licenses(["notice"])
|
||||
|
||||
load(
|
||||
"@io_bazel_rules_go//go:def.bzl",
|
||||
"go_library",
|
||||
)
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = [
|
||||
"clusterrole.go",
|
||||
"clusterrolebinding.go",
|
||||
"interface.go",
|
||||
"role.go",
|
||||
"rolebinding.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/informers/internalinterfaces:go_default_library",
|
||||
"//vendor/k8s.io/client-go/kubernetes:go_default_library",
|
||||
"//vendor/k8s.io/client-go/listers/rbac/v1beta1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/pkg/apis/rbac/v1beta1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/tools/cache:go_default_library",
|
||||
],
|
||||
)
|
||||
18
informers/settings/BUILD
Normal file
18
informers/settings/BUILD
Normal 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/client-go/informers/internalinterfaces:go_default_library",
|
||||
"//vendor/k8s.io/client-go/informers/settings/v1alpha1:go_default_library",
|
||||
],
|
||||
)
|
||||
27
informers/settings/v1alpha1/BUILD
Normal file
27
informers/settings/v1alpha1/BUILD
Normal 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 = [
|
||||
"interface.go",
|
||||
"podpreset.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/informers/internalinterfaces:go_default_library",
|
||||
"//vendor/k8s.io/client-go/kubernetes:go_default_library",
|
||||
"//vendor/k8s.io/client-go/listers/settings/v1alpha1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/pkg/apis/settings/v1alpha1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/tools/cache:go_default_library",
|
||||
],
|
||||
)
|
||||
19
informers/storage/BUILD
Normal file
19
informers/storage/BUILD
Normal 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 = ["interface.go"],
|
||||
tags = ["automanaged"],
|
||||
deps = [
|
||||
"//vendor/k8s.io/client-go/informers/internalinterfaces:go_default_library",
|
||||
"//vendor/k8s.io/client-go/informers/storage/v1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/informers/storage/v1beta1:go_default_library",
|
||||
],
|
||||
)
|
||||
27
informers/storage/v1/BUILD
Normal file
27
informers/storage/v1/BUILD
Normal 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 = [
|
||||
"interface.go",
|
||||
"storageclass.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/informers/internalinterfaces:go_default_library",
|
||||
"//vendor/k8s.io/client-go/kubernetes:go_default_library",
|
||||
"//vendor/k8s.io/client-go/listers/storage/v1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/pkg/apis/storage/v1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/tools/cache:go_default_library",
|
||||
],
|
||||
)
|
||||
27
informers/storage/v1beta1/BUILD
Normal file
27
informers/storage/v1beta1/BUILD
Normal 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 = [
|
||||
"interface.go",
|
||||
"storageclass.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/informers/internalinterfaces:go_default_library",
|
||||
"//vendor/k8s.io/client-go/kubernetes:go_default_library",
|
||||
"//vendor/k8s.io/client-go/listers/storage/v1beta1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/pkg/apis/storage/v1beta1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/tools/cache:go_default_library",
|
||||
],
|
||||
)
|
||||
@@ -1 +1 @@
|
||||
9497139cb62015905ba5b3d11836f2b0c117ff80
|
||||
84dfa6a4e3c655bb3cf63756d1674dff1976fe06
|
||||
|
||||
43
kubernetes/BUILD
Normal file
43
kubernetes/BUILD
Normal file
@@ -0,0 +1,43 @@
|
||||
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/kubernetes/typed/admissionregistration/v1alpha1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/kubernetes/typed/apps/v1beta1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/kubernetes/typed/authentication/v1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/kubernetes/typed/authentication/v1beta1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/kubernetes/typed/authorization/v1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/kubernetes/typed/authorization/v1beta1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/kubernetes/typed/autoscaling/v1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/kubernetes/typed/autoscaling/v2alpha1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/kubernetes/typed/batch/v1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/kubernetes/typed/batch/v2alpha1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/kubernetes/typed/certificates/v1beta1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/kubernetes/typed/core/v1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/kubernetes/typed/extensions/v1beta1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/kubernetes/typed/networking/v1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/kubernetes/typed/policy/v1beta1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/kubernetes/typed/rbac/v1alpha1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/kubernetes/typed/rbac/v1beta1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/kubernetes/typed/settings/v1alpha1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/kubernetes/typed/storage/v1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/kubernetes/typed/storage/v1beta1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/rest:go_default_library",
|
||||
"//vendor/k8s.io/client-go/util/flowcontrol:go_default_library",
|
||||
],
|
||||
)
|
||||
@@ -19,6 +19,7 @@ package kubernetes
|
||||
import (
|
||||
glog "github.com/golang/glog"
|
||||
discovery "k8s.io/client-go/discovery"
|
||||
admissionregistrationv1alpha1 "k8s.io/client-go/kubernetes/typed/admissionregistration/v1alpha1"
|
||||
appsv1beta1 "k8s.io/client-go/kubernetes/typed/apps/v1beta1"
|
||||
authenticationv1 "k8s.io/client-go/kubernetes/typed/authentication/v1"
|
||||
authenticationv1beta1 "k8s.io/client-go/kubernetes/typed/authentication/v1beta1"
|
||||
@@ -31,6 +32,7 @@ import (
|
||||
certificatesv1beta1 "k8s.io/client-go/kubernetes/typed/certificates/v1beta1"
|
||||
corev1 "k8s.io/client-go/kubernetes/typed/core/v1"
|
||||
extensionsv1beta1 "k8s.io/client-go/kubernetes/typed/extensions/v1beta1"
|
||||
networkingv1 "k8s.io/client-go/kubernetes/typed/networking/v1"
|
||||
policyv1beta1 "k8s.io/client-go/kubernetes/typed/policy/v1beta1"
|
||||
rbacv1alpha1 "k8s.io/client-go/kubernetes/typed/rbac/v1alpha1"
|
||||
rbacv1beta1 "k8s.io/client-go/kubernetes/typed/rbac/v1beta1"
|
||||
@@ -43,6 +45,9 @@ import (
|
||||
|
||||
type Interface interface {
|
||||
Discovery() discovery.DiscoveryInterface
|
||||
AdmissionregistrationV1alpha1() admissionregistrationv1alpha1.AdmissionregistrationV1alpha1Interface
|
||||
// Deprecated: please explicitly pick a version if possible.
|
||||
Admissionregistration() admissionregistrationv1alpha1.AdmissionregistrationV1alpha1Interface
|
||||
CoreV1() corev1.CoreV1Interface
|
||||
// Deprecated: please explicitly pick a version if possible.
|
||||
Core() corev1.CoreV1Interface
|
||||
@@ -71,6 +76,9 @@ type Interface interface {
|
||||
ExtensionsV1beta1() extensionsv1beta1.ExtensionsV1beta1Interface
|
||||
// Deprecated: please explicitly pick a version if possible.
|
||||
Extensions() extensionsv1beta1.ExtensionsV1beta1Interface
|
||||
NetworkingV1() networkingv1.NetworkingV1Interface
|
||||
// Deprecated: please explicitly pick a version if possible.
|
||||
Networking() networkingv1.NetworkingV1Interface
|
||||
PolicyV1beta1() policyv1beta1.PolicyV1beta1Interface
|
||||
// Deprecated: please explicitly pick a version if possible.
|
||||
Policy() policyv1beta1.PolicyV1beta1Interface
|
||||
@@ -91,6 +99,7 @@ type Interface interface {
|
||||
// version included in a Clientset.
|
||||
type Clientset struct {
|
||||
*discovery.DiscoveryClient
|
||||
*admissionregistrationv1alpha1.AdmissionregistrationV1alpha1Client
|
||||
*corev1.CoreV1Client
|
||||
*appsv1beta1.AppsV1beta1Client
|
||||
*authenticationv1.AuthenticationV1Client
|
||||
@@ -103,6 +112,7 @@ type Clientset struct {
|
||||
*batchv2alpha1.BatchV2alpha1Client
|
||||
*certificatesv1beta1.CertificatesV1beta1Client
|
||||
*extensionsv1beta1.ExtensionsV1beta1Client
|
||||
*networkingv1.NetworkingV1Client
|
||||
*policyv1beta1.PolicyV1beta1Client
|
||||
*rbacv1beta1.RbacV1beta1Client
|
||||
*rbacv1alpha1.RbacV1alpha1Client
|
||||
@@ -111,6 +121,23 @@ type Clientset struct {
|
||||
*storagev1.StorageV1Client
|
||||
}
|
||||
|
||||
// AdmissionregistrationV1alpha1 retrieves the AdmissionregistrationV1alpha1Client
|
||||
func (c *Clientset) AdmissionregistrationV1alpha1() admissionregistrationv1alpha1.AdmissionregistrationV1alpha1Interface {
|
||||
if c == nil {
|
||||
return nil
|
||||
}
|
||||
return c.AdmissionregistrationV1alpha1Client
|
||||
}
|
||||
|
||||
// Deprecated: Admissionregistration retrieves the default version of AdmissionregistrationClient.
|
||||
// Please explicitly pick a version.
|
||||
func (c *Clientset) Admissionregistration() admissionregistrationv1alpha1.AdmissionregistrationV1alpha1Interface {
|
||||
if c == nil {
|
||||
return nil
|
||||
}
|
||||
return c.AdmissionregistrationV1alpha1Client
|
||||
}
|
||||
|
||||
// CoreV1 retrieves the CoreV1Client
|
||||
func (c *Clientset) CoreV1() corev1.CoreV1Interface {
|
||||
if c == nil {
|
||||
@@ -279,6 +306,23 @@ func (c *Clientset) Extensions() extensionsv1beta1.ExtensionsV1beta1Interface {
|
||||
return c.ExtensionsV1beta1Client
|
||||
}
|
||||
|
||||
// NetworkingV1 retrieves the NetworkingV1Client
|
||||
func (c *Clientset) NetworkingV1() networkingv1.NetworkingV1Interface {
|
||||
if c == nil {
|
||||
return nil
|
||||
}
|
||||
return c.NetworkingV1Client
|
||||
}
|
||||
|
||||
// Deprecated: Networking retrieves the default version of NetworkingClient.
|
||||
// Please explicitly pick a version.
|
||||
func (c *Clientset) Networking() networkingv1.NetworkingV1Interface {
|
||||
if c == nil {
|
||||
return nil
|
||||
}
|
||||
return c.NetworkingV1Client
|
||||
}
|
||||
|
||||
// PolicyV1beta1 retrieves the PolicyV1beta1Client
|
||||
func (c *Clientset) PolicyV1beta1() policyv1beta1.PolicyV1beta1Interface {
|
||||
if c == nil {
|
||||
@@ -379,6 +423,10 @@ func NewForConfig(c *rest.Config) (*Clientset, error) {
|
||||
}
|
||||
var cs Clientset
|
||||
var err error
|
||||
cs.AdmissionregistrationV1alpha1Client, err = admissionregistrationv1alpha1.NewForConfig(&configShallowCopy)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
cs.CoreV1Client, err = corev1.NewForConfig(&configShallowCopy)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -427,6 +475,10 @@ func NewForConfig(c *rest.Config) (*Clientset, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
cs.NetworkingV1Client, err = networkingv1.NewForConfig(&configShallowCopy)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
cs.PolicyV1beta1Client, err = policyv1beta1.NewForConfig(&configShallowCopy)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -464,6 +516,7 @@ func NewForConfig(c *rest.Config) (*Clientset, error) {
|
||||
// panics if there is an error in the config.
|
||||
func NewForConfigOrDie(c *rest.Config) *Clientset {
|
||||
var cs Clientset
|
||||
cs.AdmissionregistrationV1alpha1Client = admissionregistrationv1alpha1.NewForConfigOrDie(c)
|
||||
cs.CoreV1Client = corev1.NewForConfigOrDie(c)
|
||||
cs.AppsV1beta1Client = appsv1beta1.NewForConfigOrDie(c)
|
||||
cs.AuthenticationV1Client = authenticationv1.NewForConfigOrDie(c)
|
||||
@@ -476,6 +529,7 @@ func NewForConfigOrDie(c *rest.Config) *Clientset {
|
||||
cs.BatchV2alpha1Client = batchv2alpha1.NewForConfigOrDie(c)
|
||||
cs.CertificatesV1beta1Client = certificatesv1beta1.NewForConfigOrDie(c)
|
||||
cs.ExtensionsV1beta1Client = extensionsv1beta1.NewForConfigOrDie(c)
|
||||
cs.NetworkingV1Client = networkingv1.NewForConfigOrDie(c)
|
||||
cs.PolicyV1beta1Client = policyv1beta1.NewForConfigOrDie(c)
|
||||
cs.RbacV1beta1Client = rbacv1beta1.NewForConfigOrDie(c)
|
||||
cs.RbacV1alpha1Client = rbacv1alpha1.NewForConfigOrDie(c)
|
||||
@@ -490,6 +544,7 @@ func NewForConfigOrDie(c *rest.Config) *Clientset {
|
||||
// New creates a new Clientset for the given RESTClient.
|
||||
func New(c rest.Interface) *Clientset {
|
||||
var cs Clientset
|
||||
cs.AdmissionregistrationV1alpha1Client = admissionregistrationv1alpha1.New(c)
|
||||
cs.CoreV1Client = corev1.New(c)
|
||||
cs.AppsV1beta1Client = appsv1beta1.New(c)
|
||||
cs.AuthenticationV1Client = authenticationv1.New(c)
|
||||
@@ -502,6 +557,7 @@ func New(c rest.Interface) *Clientset {
|
||||
cs.BatchV2alpha1Client = batchv2alpha1.New(c)
|
||||
cs.CertificatesV1beta1Client = certificatesv1beta1.New(c)
|
||||
cs.ExtensionsV1beta1Client = extensionsv1beta1.New(c)
|
||||
cs.NetworkingV1Client = networkingv1.New(c)
|
||||
cs.PolicyV1beta1Client = policyv1beta1.New(c)
|
||||
cs.RbacV1beta1Client = rbacv1beta1.New(c)
|
||||
cs.RbacV1alpha1Client = rbacv1alpha1.New(c)
|
||||
|
||||
89
kubernetes/fake/BUILD
Normal file
89
kubernetes/fake/BUILD
Normal file
@@ -0,0 +1,89 @@
|
||||
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/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/kubernetes:go_default_library",
|
||||
"//vendor/k8s.io/client-go/kubernetes/typed/admissionregistration/v1alpha1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/kubernetes/typed/admissionregistration/v1alpha1/fake:go_default_library",
|
||||
"//vendor/k8s.io/client-go/kubernetes/typed/apps/v1beta1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/kubernetes/typed/apps/v1beta1/fake:go_default_library",
|
||||
"//vendor/k8s.io/client-go/kubernetes/typed/authentication/v1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/kubernetes/typed/authentication/v1/fake:go_default_library",
|
||||
"//vendor/k8s.io/client-go/kubernetes/typed/authentication/v1beta1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/kubernetes/typed/authentication/v1beta1/fake:go_default_library",
|
||||
"//vendor/k8s.io/client-go/kubernetes/typed/authorization/v1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/kubernetes/typed/authorization/v1/fake:go_default_library",
|
||||
"//vendor/k8s.io/client-go/kubernetes/typed/authorization/v1beta1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/kubernetes/typed/authorization/v1beta1/fake:go_default_library",
|
||||
"//vendor/k8s.io/client-go/kubernetes/typed/autoscaling/v1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/kubernetes/typed/autoscaling/v1/fake:go_default_library",
|
||||
"//vendor/k8s.io/client-go/kubernetes/typed/autoscaling/v2alpha1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/kubernetes/typed/autoscaling/v2alpha1/fake:go_default_library",
|
||||
"//vendor/k8s.io/client-go/kubernetes/typed/batch/v1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/kubernetes/typed/batch/v1/fake:go_default_library",
|
||||
"//vendor/k8s.io/client-go/kubernetes/typed/batch/v2alpha1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/kubernetes/typed/batch/v2alpha1/fake:go_default_library",
|
||||
"//vendor/k8s.io/client-go/kubernetes/typed/certificates/v1beta1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/kubernetes/typed/certificates/v1beta1/fake:go_default_library",
|
||||
"//vendor/k8s.io/client-go/kubernetes/typed/core/v1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/kubernetes/typed/core/v1/fake:go_default_library",
|
||||
"//vendor/k8s.io/client-go/kubernetes/typed/extensions/v1beta1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/kubernetes/typed/extensions/v1beta1/fake:go_default_library",
|
||||
"//vendor/k8s.io/client-go/kubernetes/typed/networking/v1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/kubernetes/typed/networking/v1/fake:go_default_library",
|
||||
"//vendor/k8s.io/client-go/kubernetes/typed/policy/v1beta1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/kubernetes/typed/policy/v1beta1/fake:go_default_library",
|
||||
"//vendor/k8s.io/client-go/kubernetes/typed/rbac/v1alpha1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/kubernetes/typed/rbac/v1alpha1/fake:go_default_library",
|
||||
"//vendor/k8s.io/client-go/kubernetes/typed/rbac/v1beta1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/kubernetes/typed/rbac/v1beta1/fake:go_default_library",
|
||||
"//vendor/k8s.io/client-go/kubernetes/typed/settings/v1alpha1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/kubernetes/typed/settings/v1alpha1/fake:go_default_library",
|
||||
"//vendor/k8s.io/client-go/kubernetes/typed/storage/v1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/kubernetes/typed/storage/v1/fake:go_default_library",
|
||||
"//vendor/k8s.io/client-go/kubernetes/typed/storage/v1beta1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/kubernetes/typed/storage/v1beta1/fake:go_default_library",
|
||||
"//vendor/k8s.io/client-go/pkg/api/v1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/pkg/apis/admissionregistration/v1alpha1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/pkg/apis/apps/v1beta1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/pkg/apis/authentication/v1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/pkg/apis/authentication/v1beta1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/pkg/apis/authorization/v1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/pkg/apis/authorization/v1beta1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/pkg/apis/autoscaling/v1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/pkg/apis/autoscaling/v2alpha1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/pkg/apis/batch/v1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/pkg/apis/batch/v2alpha1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/pkg/apis/certificates/v1beta1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/pkg/apis/extensions/v1beta1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/pkg/apis/networking/v1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/pkg/apis/policy/v1beta1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/pkg/apis/rbac/v1alpha1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/pkg/apis/rbac/v1beta1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/pkg/apis/settings/v1alpha1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/pkg/apis/storage/v1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/pkg/apis/storage/v1beta1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/testing:go_default_library",
|
||||
],
|
||||
)
|
||||
@@ -22,6 +22,8 @@ import (
|
||||
"k8s.io/client-go/discovery"
|
||||
fakediscovery "k8s.io/client-go/discovery/fake"
|
||||
kubernetes "k8s.io/client-go/kubernetes"
|
||||
admissionregistrationv1alpha1 "k8s.io/client-go/kubernetes/typed/admissionregistration/v1alpha1"
|
||||
fakeadmissionregistrationv1alpha1 "k8s.io/client-go/kubernetes/typed/admissionregistration/v1alpha1/fake"
|
||||
appsv1beta1 "k8s.io/client-go/kubernetes/typed/apps/v1beta1"
|
||||
fakeappsv1beta1 "k8s.io/client-go/kubernetes/typed/apps/v1beta1/fake"
|
||||
authenticationv1 "k8s.io/client-go/kubernetes/typed/authentication/v1"
|
||||
@@ -46,6 +48,8 @@ import (
|
||||
fakecorev1 "k8s.io/client-go/kubernetes/typed/core/v1/fake"
|
||||
extensionsv1beta1 "k8s.io/client-go/kubernetes/typed/extensions/v1beta1"
|
||||
fakeextensionsv1beta1 "k8s.io/client-go/kubernetes/typed/extensions/v1beta1/fake"
|
||||
networkingv1 "k8s.io/client-go/kubernetes/typed/networking/v1"
|
||||
fakenetworkingv1 "k8s.io/client-go/kubernetes/typed/networking/v1/fake"
|
||||
policyv1beta1 "k8s.io/client-go/kubernetes/typed/policy/v1beta1"
|
||||
fakepolicyv1beta1 "k8s.io/client-go/kubernetes/typed/policy/v1beta1/fake"
|
||||
rbacv1alpha1 "k8s.io/client-go/kubernetes/typed/rbac/v1alpha1"
|
||||
@@ -66,7 +70,7 @@ import (
|
||||
// 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())
|
||||
o := testing.NewObjectTracker(scheme, codecs.UniversalDecoder())
|
||||
for _, obj := range objects {
|
||||
if err := o.Add(obj); err != nil {
|
||||
panic(err)
|
||||
@@ -74,7 +78,7 @@ func NewSimpleClientset(objects ...runtime.Object) *Clientset {
|
||||
}
|
||||
|
||||
fakePtr := testing.Fake{}
|
||||
fakePtr.AddReactor("*", "*", testing.ObjectReaction(o, registry.RESTMapper()))
|
||||
fakePtr.AddReactor("*", "*", testing.ObjectReaction(o))
|
||||
|
||||
fakePtr.AddWatchReactor("*", testing.DefaultWatchReactor(watch.NewFake(), nil))
|
||||
|
||||
@@ -94,6 +98,16 @@ func (c *Clientset) Discovery() discovery.DiscoveryInterface {
|
||||
|
||||
var _ kubernetes.Interface = &Clientset{}
|
||||
|
||||
// AdmissionregistrationV1alpha1 retrieves the AdmissionregistrationV1alpha1Client
|
||||
func (c *Clientset) AdmissionregistrationV1alpha1() admissionregistrationv1alpha1.AdmissionregistrationV1alpha1Interface {
|
||||
return &fakeadmissionregistrationv1alpha1.FakeAdmissionregistrationV1alpha1{Fake: &c.Fake}
|
||||
}
|
||||
|
||||
// Admissionregistration retrieves the AdmissionregistrationV1alpha1Client
|
||||
func (c *Clientset) Admissionregistration() admissionregistrationv1alpha1.AdmissionregistrationV1alpha1Interface {
|
||||
return &fakeadmissionregistrationv1alpha1.FakeAdmissionregistrationV1alpha1{Fake: &c.Fake}
|
||||
}
|
||||
|
||||
// CoreV1 retrieves the CoreV1Client
|
||||
func (c *Clientset) CoreV1() corev1.CoreV1Interface {
|
||||
return &fakecorev1.FakeCoreV1{Fake: &c.Fake}
|
||||
@@ -194,6 +208,16 @@ func (c *Clientset) Extensions() extensionsv1beta1.ExtensionsV1beta1Interface {
|
||||
return &fakeextensionsv1beta1.FakeExtensionsV1beta1{Fake: &c.Fake}
|
||||
}
|
||||
|
||||
// NetworkingV1 retrieves the NetworkingV1Client
|
||||
func (c *Clientset) NetworkingV1() networkingv1.NetworkingV1Interface {
|
||||
return &fakenetworkingv1.FakeNetworkingV1{Fake: &c.Fake}
|
||||
}
|
||||
|
||||
// Networking retrieves the NetworkingV1Client
|
||||
func (c *Clientset) Networking() networkingv1.NetworkingV1Interface {
|
||||
return &fakenetworkingv1.FakeNetworkingV1{Fake: &c.Fake}
|
||||
}
|
||||
|
||||
// PolicyV1beta1 retrieves the PolicyV1beta1Client
|
||||
func (c *Clientset) PolicyV1beta1() policyv1beta1.PolicyV1beta1Interface {
|
||||
return &fakepolicyv1beta1.FakePolicyV1beta1{Fake: &c.Fake}
|
||||
|
||||
@@ -17,52 +17,75 @@ 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"
|
||||
core "k8s.io/client-go/pkg/api/install"
|
||||
apps "k8s.io/client-go/pkg/apis/apps/install"
|
||||
authentication "k8s.io/client-go/pkg/apis/authentication/install"
|
||||
authorization "k8s.io/client-go/pkg/apis/authorization/install"
|
||||
autoscaling "k8s.io/client-go/pkg/apis/autoscaling/install"
|
||||
batch "k8s.io/client-go/pkg/apis/batch/install"
|
||||
certificates "k8s.io/client-go/pkg/apis/certificates/install"
|
||||
extensions "k8s.io/client-go/pkg/apis/extensions/install"
|
||||
policy "k8s.io/client-go/pkg/apis/policy/install"
|
||||
rbac "k8s.io/client-go/pkg/apis/rbac/install"
|
||||
settings "k8s.io/client-go/pkg/apis/settings/install"
|
||||
storage "k8s.io/client-go/pkg/apis/storage/install"
|
||||
os "os"
|
||||
corev1 "k8s.io/client-go/pkg/api/v1"
|
||||
admissionregistrationv1alpha1 "k8s.io/client-go/pkg/apis/admissionregistration/v1alpha1"
|
||||
appsv1beta1 "k8s.io/client-go/pkg/apis/apps/v1beta1"
|
||||
authenticationv1 "k8s.io/client-go/pkg/apis/authentication/v1"
|
||||
authenticationv1beta1 "k8s.io/client-go/pkg/apis/authentication/v1beta1"
|
||||
authorizationv1 "k8s.io/client-go/pkg/apis/authorization/v1"
|
||||
authorizationv1beta1 "k8s.io/client-go/pkg/apis/authorization/v1beta1"
|
||||
autoscalingv1 "k8s.io/client-go/pkg/apis/autoscaling/v1"
|
||||
autoscalingv2alpha1 "k8s.io/client-go/pkg/apis/autoscaling/v2alpha1"
|
||||
batchv1 "k8s.io/client-go/pkg/apis/batch/v1"
|
||||
batchv2alpha1 "k8s.io/client-go/pkg/apis/batch/v2alpha1"
|
||||
certificatesv1beta1 "k8s.io/client-go/pkg/apis/certificates/v1beta1"
|
||||
extensionsv1beta1 "k8s.io/client-go/pkg/apis/extensions/v1beta1"
|
||||
networkingv1 "k8s.io/client-go/pkg/apis/networking/v1"
|
||||
policyv1beta1 "k8s.io/client-go/pkg/apis/policy/v1beta1"
|
||||
rbacv1alpha1 "k8s.io/client-go/pkg/apis/rbac/v1alpha1"
|
||||
rbacv1beta1 "k8s.io/client-go/pkg/apis/rbac/v1beta1"
|
||||
settingsv1alpha1 "k8s.io/client-go/pkg/apis/settings/v1alpha1"
|
||||
storagev1 "k8s.io/client-go/pkg/apis/storage/v1"
|
||||
storagev1beta1 "k8s.io/client-go/pkg/apis/storage/v1beta1"
|
||||
)
|
||||
|
||||
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)
|
||||
AddToScheme(scheme)
|
||||
}
|
||||
|
||||
// Install registers the API group and adds types to a scheme
|
||||
func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *registered.APIRegistrationManager, scheme *runtime.Scheme) {
|
||||
core.Install(groupFactoryRegistry, registry, scheme)
|
||||
apps.Install(groupFactoryRegistry, registry, scheme)
|
||||
authentication.Install(groupFactoryRegistry, registry, scheme)
|
||||
authorization.Install(groupFactoryRegistry, registry, scheme)
|
||||
autoscaling.Install(groupFactoryRegistry, registry, scheme)
|
||||
batch.Install(groupFactoryRegistry, registry, scheme)
|
||||
certificates.Install(groupFactoryRegistry, registry, scheme)
|
||||
extensions.Install(groupFactoryRegistry, registry, scheme)
|
||||
policy.Install(groupFactoryRegistry, registry, scheme)
|
||||
rbac.Install(groupFactoryRegistry, registry, scheme)
|
||||
settings.Install(groupFactoryRegistry, registry, scheme)
|
||||
storage.Install(groupFactoryRegistry, registry, 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) {
|
||||
admissionregistrationv1alpha1.AddToScheme(scheme)
|
||||
corev1.AddToScheme(scheme)
|
||||
appsv1beta1.AddToScheme(scheme)
|
||||
authenticationv1.AddToScheme(scheme)
|
||||
authenticationv1beta1.AddToScheme(scheme)
|
||||
authorizationv1.AddToScheme(scheme)
|
||||
authorizationv1beta1.AddToScheme(scheme)
|
||||
autoscalingv1.AddToScheme(scheme)
|
||||
autoscalingv2alpha1.AddToScheme(scheme)
|
||||
batchv1.AddToScheme(scheme)
|
||||
batchv2alpha1.AddToScheme(scheme)
|
||||
certificatesv1beta1.AddToScheme(scheme)
|
||||
extensionsv1beta1.AddToScheme(scheme)
|
||||
networkingv1.AddToScheme(scheme)
|
||||
policyv1beta1.AddToScheme(scheme)
|
||||
rbacv1beta1.AddToScheme(scheme)
|
||||
rbacv1alpha1.AddToScheme(scheme)
|
||||
settingsv1alpha1.AddToScheme(scheme)
|
||||
storagev1beta1.AddToScheme(scheme)
|
||||
storagev1.AddToScheme(scheme)
|
||||
|
||||
}
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
/*
|
||||
Copyright 2016 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 kubernetes
|
||||
|
||||
// These imports are the API groups the client will support.
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"k8s.io/client-go/pkg/api"
|
||||
_ "k8s.io/client-go/pkg/api/install"
|
||||
_ "k8s.io/client-go/pkg/apis/apps/install"
|
||||
_ "k8s.io/client-go/pkg/apis/authentication/install"
|
||||
_ "k8s.io/client-go/pkg/apis/authorization/install"
|
||||
_ "k8s.io/client-go/pkg/apis/autoscaling/install"
|
||||
_ "k8s.io/client-go/pkg/apis/batch/install"
|
||||
_ "k8s.io/client-go/pkg/apis/certificates/install"
|
||||
_ "k8s.io/client-go/pkg/apis/extensions/install"
|
||||
_ "k8s.io/client-go/pkg/apis/policy/install"
|
||||
_ "k8s.io/client-go/pkg/apis/rbac/install"
|
||||
_ "k8s.io/client-go/pkg/apis/settings/install"
|
||||
_ "k8s.io/client-go/pkg/apis/storage/install"
|
||||
)
|
||||
|
||||
func init() {
|
||||
if missingVersions := api.Registry.ValidateEnvRequestedVersions(); len(missingVersions) != 0 {
|
||||
panic(fmt.Sprintf("KUBE_API_VERSIONS contains versions that are not installed: %q.", missingVersions))
|
||||
}
|
||||
}
|
||||
43
kubernetes/scheme/BUILD
Normal file
43
kubernetes/scheme/BUILD
Normal file
@@ -0,0 +1,43 @@
|
||||
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/client-go/pkg/api/v1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/pkg/apis/admissionregistration/v1alpha1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/pkg/apis/apps/v1beta1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/pkg/apis/authentication/v1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/pkg/apis/authentication/v1beta1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/pkg/apis/authorization/v1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/pkg/apis/authorization/v1beta1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/pkg/apis/autoscaling/v1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/pkg/apis/autoscaling/v2alpha1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/pkg/apis/batch/v1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/pkg/apis/batch/v2alpha1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/pkg/apis/certificates/v1beta1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/pkg/apis/extensions/v1beta1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/pkg/apis/networking/v1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/pkg/apis/policy/v1beta1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/pkg/apis/rbac/v1alpha1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/pkg/apis/rbac/v1beta1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/pkg/apis/settings/v1alpha1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/pkg/apis/storage/v1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/pkg/apis/storage/v1beta1:go_default_library",
|
||||
],
|
||||
)
|
||||
@@ -22,6 +22,7 @@ import (
|
||||
schema "k8s.io/apimachinery/pkg/runtime/schema"
|
||||
serializer "k8s.io/apimachinery/pkg/runtime/serializer"
|
||||
corev1 "k8s.io/client-go/pkg/api/v1"
|
||||
admissionregistrationv1alpha1 "k8s.io/client-go/pkg/apis/admissionregistration/v1alpha1"
|
||||
appsv1beta1 "k8s.io/client-go/pkg/apis/apps/v1beta1"
|
||||
authenticationv1 "k8s.io/client-go/pkg/apis/authentication/v1"
|
||||
authenticationv1beta1 "k8s.io/client-go/pkg/apis/authentication/v1beta1"
|
||||
@@ -33,6 +34,7 @@ import (
|
||||
batchv2alpha1 "k8s.io/client-go/pkg/apis/batch/v2alpha1"
|
||||
certificatesv1beta1 "k8s.io/client-go/pkg/apis/certificates/v1beta1"
|
||||
extensionsv1beta1 "k8s.io/client-go/pkg/apis/extensions/v1beta1"
|
||||
networkingv1 "k8s.io/client-go/pkg/apis/networking/v1"
|
||||
policyv1beta1 "k8s.io/client-go/pkg/apis/policy/v1beta1"
|
||||
rbacv1alpha1 "k8s.io/client-go/pkg/apis/rbac/v1alpha1"
|
||||
rbacv1beta1 "k8s.io/client-go/pkg/apis/rbac/v1beta1"
|
||||
@@ -65,6 +67,7 @@ func init() {
|
||||
// After this, RawExtensions in Kubernetes types will serialize kube-aggregator types
|
||||
// correctly.
|
||||
func AddToScheme(scheme *runtime.Scheme) {
|
||||
admissionregistrationv1alpha1.AddToScheme(scheme)
|
||||
corev1.AddToScheme(scheme)
|
||||
appsv1beta1.AddToScheme(scheme)
|
||||
authenticationv1.AddToScheme(scheme)
|
||||
@@ -77,6 +80,7 @@ func AddToScheme(scheme *runtime.Scheme) {
|
||||
batchv2alpha1.AddToScheme(scheme)
|
||||
certificatesv1beta1.AddToScheme(scheme)
|
||||
extensionsv1beta1.AddToScheme(scheme)
|
||||
networkingv1.AddToScheme(scheme)
|
||||
policyv1beta1.AddToScheme(scheme)
|
||||
rbacv1beta1.AddToScheme(scheme)
|
||||
rbacv1alpha1.AddToScheme(scheme)
|
||||
|
||||
29
kubernetes/typed/admissionregistration/v1alpha1/BUILD
Normal file
29
kubernetes/typed/admissionregistration/v1alpha1/BUILD
Normal 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 = [
|
||||
"admissionregistration_client.go",
|
||||
"doc.go",
|
||||
"externaladmissionhookconfiguration.go",
|
||||
"generated_expansion.go",
|
||||
"initializerconfiguration.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/kubernetes/scheme:go_default_library",
|
||||
"//vendor/k8s.io/client-go/pkg/apis/admissionregistration/v1alpha1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/rest:go_default_library",
|
||||
],
|
||||
)
|
||||
@@ -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 v1alpha1
|
||||
|
||||
import (
|
||||
serializer "k8s.io/apimachinery/pkg/runtime/serializer"
|
||||
"k8s.io/client-go/kubernetes/scheme"
|
||||
v1alpha1 "k8s.io/client-go/pkg/apis/admissionregistration/v1alpha1"
|
||||
rest "k8s.io/client-go/rest"
|
||||
)
|
||||
|
||||
type AdmissionregistrationV1alpha1Interface interface {
|
||||
RESTClient() rest.Interface
|
||||
ExternalAdmissionHookConfigurationsGetter
|
||||
InitializerConfigurationsGetter
|
||||
}
|
||||
|
||||
// AdmissionregistrationV1alpha1Client is used to interact with features provided by the admissionregistration.k8s.io group.
|
||||
type AdmissionregistrationV1alpha1Client struct {
|
||||
restClient rest.Interface
|
||||
}
|
||||
|
||||
func (c *AdmissionregistrationV1alpha1Client) ExternalAdmissionHookConfigurations() ExternalAdmissionHookConfigurationInterface {
|
||||
return newExternalAdmissionHookConfigurations(c)
|
||||
}
|
||||
|
||||
func (c *AdmissionregistrationV1alpha1Client) InitializerConfigurations() InitializerConfigurationInterface {
|
||||
return newInitializerConfigurations(c)
|
||||
}
|
||||
|
||||
// NewForConfig creates a new AdmissionregistrationV1alpha1Client for the given config.
|
||||
func NewForConfig(c *rest.Config) (*AdmissionregistrationV1alpha1Client, error) {
|
||||
config := *c
|
||||
if err := setConfigDefaults(&config); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
client, err := rest.RESTClientFor(&config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &AdmissionregistrationV1alpha1Client{client}, nil
|
||||
}
|
||||
|
||||
// NewForConfigOrDie creates a new AdmissionregistrationV1alpha1Client for the given config and
|
||||
// panics if there is an error in the config.
|
||||
func NewForConfigOrDie(c *rest.Config) *AdmissionregistrationV1alpha1Client {
|
||||
client, err := NewForConfig(c)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return client
|
||||
}
|
||||
|
||||
// New creates a new AdmissionregistrationV1alpha1Client for the given RESTClient.
|
||||
func New(c rest.Interface) *AdmissionregistrationV1alpha1Client {
|
||||
return &AdmissionregistrationV1alpha1Client{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 *AdmissionregistrationV1alpha1Client) RESTClient() rest.Interface {
|
||||
if c == nil {
|
||||
return nil
|
||||
}
|
||||
return c.restClient
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user