Compare commits

...

416 Commits

Author SHA1 Message Date
Kubernetes Publisher
d92e8497f7 sync: resync vendor folder 2017-07-28 13:53:02 +00:00
Kubernetes Publisher
91e3f9312a sync(k8s.io/kubernetes) 84dfa6a4e3c655bb3cf63756d1674dff1976fe06 2017-07-28 13:52:41 +00:00
Wojciech Tyczynski
1f9a49df2c Kubernetes version v1.7.3-beta.0 file updates
Kubernetes-commit: 84dfa6a4e3c655bb3cf63756d1674dff1976fe06
2017-07-28 13:52:41 +00:00
Wojciech Tyczynski
ec392585e9 Kubernetes version v1.7.2 file updates
Kubernetes-commit: 922a86cfcd65915a9b2f69f3f193b8907d741d9c
2017-07-28 13:52:41 +00:00
Brendan Burns
d9588c19ff Cherry pick of #47140 on release-1.7
Kubernetes-commit: d7985a982d742444c0ce151b9c388ea370ae6b97
2017-07-28 13:52:41 +00:00
Maxim Ivanov
d1fa9c161c Fix subPath existence check to not follow symlink
Volume mounting logic introduced in #43775 and #45623 checks
for subPath existence before attempting to create a directory,
should subPath not be present.

This breaks if subPath is a dangling symlink, os.Stat returns
"do not exist" status, yet `os.MkdirAll` can't create directory
as symlink is present at the given path.

This patch makes existence check to use os.Lstat which works for
normal files/directories as well as doesn't not attempt to follow
symlink, therefore it's "do not exist" status is more reliable when
making a decision whether to create directory or not.

subPath symlinks can be dangling in situations where kubelet is
running in a container itself with access to docker socket, such
as CoreOS's kubelet-wrapper script

Kubernetes-commit: d552dff164dfc7b91d21bd7d7881838babab2a63
2017-07-28 13:52:41 +00:00
Kubernetes Publisher
0caf586a65 sync: reset Godeps.json 2017-07-28 13:52:40 +00:00
Kubernetes Publisher
16b0436fa2 sync(k8s.io/kubernetes) aa6ec59679c9041a772912788a550adca0d0996c 2017-07-16 04:05:19 +00:00
Chao Xu
9508caae84 Kubernetes version v1.7.2-beta.0 file updates
Kubernetes-commit: aa6ec59679c9041a772912788a550adca0d0996c
2017-07-16 04:05:19 +00:00
Chao Xu
25bffd9c45 Kubernetes version v1.7.1 file updates
Kubernetes-commit: 1dc5c66f5dd61da08412a74221ecc79208c2165b
2017-07-16 04:05:19 +00:00
Kubernetes Publisher
df46f7f13b sync(k8s.io/kubernetes) ebb8d6e0fadfc95f3d64ccecc36c8ed2ac9224ef 2017-07-07 20:27:35 +00:00
Chao Xu
684c9f06e8 Kubernetes version v1.7.1-beta.0 file updates
Kubernetes-commit: ebb8d6e0fadfc95f3d64ccecc36c8ed2ac9224ef
2017-07-07 20:27:35 +00:00
Chao Xu
e356aa2e77 Kubernetes version v1.7.0 file updates
Kubernetes-commit: d3ada0119e776222f11ec7945e6d860061339aad
2017-07-07 20:27:35 +00:00
Nikhita Raghunath
d8822e0597 Update CR example in client-go
Remove custom-resources directory from client-go

Add TPR example back

Mention CRD is successor to TPR

Kubernetes-commit: b0504c6bff0ea5f923f935a4844e1eeab0ae5405
2017-07-07 20:27:35 +00:00
Chao Xu
e83269bc2b Kubernetes version v1.7.0-rc.1 file updates
Kubernetes-commit: 6b9ded1649cfb512d4e88570c738aca9f8265639
2017-07-07 20:27:35 +00:00
Seth Jennings
382c391988 include object fieldpath in event key
Kubernetes-commit: dee9955b8c120cdbc8b235ec9278fe8c9fceba2f
2017-07-07 20:27:34 +00:00
Nikhita Raghunath
eddc268ce3 Fix typo in cross-repo link
Kubernetes-commit: ddfd2e0b1498249e0ee5fa710110f9ee4062c36a
2017-07-07 20:27:34 +00:00
Chao Xu
63a56d7439 Kubernetes version v1.7.0-beta.2 file updates
Kubernetes-commit: ceab7f7a6753c20d3be75463b17402fdcea856ba
2017-07-07 20:27:34 +00:00
Kubernetes Publisher
cc44961f93 sync(k8s.io/kubernetes) 797dc10a0ccd89bec0b29c41613025035ed23a0f 2017-06-22 18:11:06 +00:00
Ricky Pai
1cd03f0805 generated code
Kubernetes-commit: 797dc10a0ccd89bec0b29c41613025035ed23a0f
2017-06-22 18:11:06 +00:00
Kubernetes Publisher
51bf18f5e6 sync: resync vendor folder 2017-06-22 03:54:09 +00:00
Kubernetes Publisher
46003734b1 sync(k8s.io/kubernetes) 03014f486c86dbe8a7fbe275fe14250854aab219 2017-06-22 03:53:48 +00:00
Josh Horwitz
56e6e0e8fd Revert "Merge pull request #43946 from jhorwit2/jah/host-path-psp"
This reverts commit b5eadb5d6b9ce34a673caeafe4fa0971c4b91139, reversing
changes made to 1889d654f5c76fcc6ce14c6d3702c06a6498695d.

Kubernetes-commit: b6e08ec39dde2a6f3c24648aa8867c6aee9853cb
2017-06-22 03:53:48 +00:00
mbohlool
4030b37262 update generated files
Kubernetes-commit: 70c4fe7f4ff7f7acf5de9fee7551da1b2e5aa22c
2017-06-22 03:53:47 +00:00
mbohlool
1c32168167 Remove all references to types.UnixUserID and types.UnixGroupID
Kubernetes-commit: c91a12d205c0391d3c2649aadf40091222906281
2017-06-22 03:53:47 +00:00
Matt Tyler
cc9ad31a2a Clear auth config when gcp credentials fail
Specific use case is when utilizing multiple
gcp accounts, the user may provide credentials
for the wrong account.

This change ensures the incorrect credentials
are not cached in auth config, and logs an
appropriate message.

Kubernetes-commit: b92016769e30c541479e81d40dd3584e2f5aa822
2017-06-22 03:53:47 +00:00
Kubernetes Publisher
b131aa47b5 sync(k8s.io/kubernetes) 35016b153e70281c058eed96f5ecac0608c35575 2017-06-20 17:28:45 +00:00
Marc Sluiter
83b93de35a run update-bazel.sh
Kubernetes-commit: 92ac232790afefad522016f76b48dbb697a8e0f7
2017-06-20 17:28:45 +00:00
Marc Sluiter
6620bd1af9 Added namespace and better pod name in client go example
Kubernetes-commit: a71bb87ec714276264282197c99bbd3f86fd7b55
2017-06-20 17:28:45 +00:00
Marc Sluiter
ecd7406c9f Updated error handling example based on PR feedback
Kubernetes-commit: 601ab10dbd08debca4b8a835f8dea00a26666060
2017-06-20 17:28:45 +00:00
Marc Sluiter
2c59aca317 Added example for status errors in go client
Kubernetes-commit: 8ca1732023621063d1c91205cdf0efa4b03b5a30
2017-06-20 17:28:45 +00:00
Kubernetes Publisher
b3357e1e10 sync: resync vendor folder 2017-06-19 23:58:13 +00:00
Kubernetes Publisher
dbc1e28158 sync(k8s.io/kubernetes) 606825eea47f41c72a3da1d4d2a769a340e1b69d 2017-06-19 23:57:41 +00:00
Clayton Coleman
d54b530cba generated: protobuf with stable map ordering
Kubernetes-commit: 606825eea47f41c72a3da1d4d2a769a340e1b69d
2017-06-19 23:57:40 +00:00
Kubernetes Publisher
c1b6a1c0a4 sync(k8s.io/kubernetes) 532cb25d21b3af988f92f586f57fcb3a538bb293 2017-06-17 22:03:58 +00:00
Dr. Stefan Schimanski
7e76c26781 Fix cross-repo link
Kubernetes-commit: 2aa87e4fee7f78b2e567111835c9e14505cf3892
2017-06-17 22:03:57 +00:00
Kubernetes Publisher
5c999e1aec sync: resync vendor folder 2017-06-16 22:04:22 +00:00
Kubernetes Publisher
70922d408f sync(k8s.io/kubernetes) d7b631a52d4e18e698bfe805d63f8141769d4f2d 2017-06-16 22:03:56 +00:00
Janet Kuo
5adaf62880 Rename DaemonSet and StatefulSet hash label
Make them share the same hash label "controller-revision-hash", for
consistency

Kubernetes-commit: 25a67fc5cdac9c3b41bd0c7fdfb0a2c24a925894
2017-06-16 22:03:56 +00:00
Ahmet Alp Balkan
6df6f2148a clientgo/examples: add ToC for examples
Also add authenticate- prefix to auth samples.

Signed-off-by: Ahmet Alp Balkan <ahmetb@google.com>

Kubernetes-commit: 62d1251874cb259d38d727300ac4b2646c4122c8
2017-06-16 22:03:56 +00:00
zhengjiajin
2163038fbf Fix api description
Kubernetes-commit: f7ce20d2e4b4c24cfa7440e135abf78e538673bb
2017-06-16 22:03:56 +00:00
Kubernetes Publisher
36b51953e6 sync: resync vendor folder 2017-06-14 20:37:32 +00:00
Kubernetes Publisher
d184230daa sync(k8s.io/kubernetes) 7560142e27ba9c0c535695356a14ac169acd7476 2017-06-14 20:37:07 +00:00
Kenneth Owens
c2459566d6 Generated code
Kubernetes-commit: 37a54d521afa6b65f86426826068a1499b22a4c9
2017-06-14 20:37:07 +00:00
Cosmin Cojocar
e12b58626c Add client auth plugin for Azure Active Directory
This plugin acquires a fresh access token for apiserver from Azure Active
Directory using the device code flow. The access token is saved in the
configuration in order to be reused for upcomming accesses to appiserver.
In additon the access token is automatically refreshed when expired.

Kubernetes-commit: 682d5ec01f37c65117b2496865cc9bf0cd9e0902
2017-06-14 20:37:07 +00:00
Kubernetes Publisher
fabe644bb3 sync: reset Godeps.json 2017-06-14 20:37:06 +00:00
Chao Xu
1741b65fcb Merge pull request #210 from caesarxuchao/fix-travis
bump go version to 1.8.1 for travis
2017-06-13 16:02:11 -07:00
Chao Xu
794d95e91e bump go version to 1.8.1 for travis 2017-06-13 15:56:37 -07:00
Kubernetes Publisher
83b4b27326 sync: resync vendor folder 2017-06-13 20:39:14 +00:00
Kubernetes Publisher
5990d225d9 sync(k8s.io/kubernetes) a648e10910328500729548513a81c733aaef24a2 2017-06-13 20:38:48 +00:00
Guangya Liu
d44b3079ca Update client-go.
Kubernetes-commit: 4250c5d3f43bfcf6197c7361dac483a677c22d3d
2017-06-13 20:38:48 +00:00
Dr. Stefan Schimanski
92eadecb13 client-go: GetOptions for dynamic client
Kubernetes-commit: 30668b24fbd92e7ab532471f9518ba7b7ef66dcf
2017-06-13 20:38:48 +00:00
Simon Croome
5c16341058 Add StorageOS volume plugin
Kubernetes-commit: 5e2503e71fa51ae08fbbc90cc94e7d293709528e
2017-06-13 20:38:48 +00:00
Jeff Grafton
bbe6158ef3 Convert go_binary linkstamp to x_defs
Kubernetes-commit: 64bd79fad78d39788bd1073b836cd5fe89cc29e3
2017-06-13 20:38:48 +00:00
Klaus Ma
4f99d16391 generated client-go.
Kubernetes-commit: 6ad529be3ee75eb16f0e1c6b4d518bfe5edaeeaa
2017-06-13 20:38:48 +00:00
Dr. Stefan Schimanski
99b01357a0 client-go: deprecate TPR example and add CRD example
Kubernetes-commit: e2b50ac9b817dfb49c146b9423d1ee9a5da97cb2
2017-06-13 20:38:48 +00:00
Kenneth Owens
5f9a335584 Auto generated code for StatefulSet update
Kubernetes-commit: 1a784ef86ff94994e984753d885ffeff6e1772ac
2017-06-13 20:38:47 +00:00
Christoph Blecker
a8d18952cb Update docs/ URLs to point to proper locations
Kubernetes-commit: 1bdc7a29aee051ccef4bb21dcd9d43ee47b2a5d8
2017-06-13 20:38:47 +00:00
Jing Xu
1f501c6ac0 Add EmptyDir Volume and local storage for container overlay Isolation
This PR adds two features:
1. add support for isolating the emptyDir volume use. If user
sets a size limit for emptyDir volume, kubelet's eviction manager
monitors its usage
and evict the pod if the usage exceeds the limit.
2. add support for isolating the local storage for container overlay. If
the container's overly usage exceeds the limit defined in container
spec, eviction manager will evict the pod.

Kubernetes-commit: 0b13aee0c0f9bd06eb323ea249db29547b66bc46
2017-06-13 20:38:47 +00:00
Jeff Peeler
25e58688a7 Allow pods to opt out of PodPreset mutation
An annotation in the pod spec of the form:
podpreset.admission.kubernetes.io/exclude: "true"
Will cause the admission controller to skip manipulating the pod spec,
no matter the labelling.

The annotation for a podpreset acting on a pod has also been slightly
modified to contain a podpreset prefix:
podpreset.admission.kubernetes.io/podpreset-{name} = resource version

Fixes #44161

Kubernetes-commit: 08a59530e196ab9b30d306fb0fac5979b07298a1
2017-06-13 20:38:47 +00:00
Solly Ross
52247e9130 Update generated autoscaling files
This commit updates the generated autoscaling files to be up-to-date
with the HPA status condition changes.

Kubernetes-commit: c8fdeb022fbd11c3ac5333a772192a0d4f8213bb
2017-06-13 20:38:47 +00:00
Janet Kuo
b1f01ecf00 Autogen: run hack/update-all.sh
Kubernetes-commit: 4e6f70ff67ec435289984c9a162f0e75eb0180b8
2017-06-13 20:38:47 +00:00
Clayton Coleman
157df17111 generated: client-go staging
Kubernetes-commit: b993f7d303aa72961d6b0a32a42e7fcc5cb26190
2017-06-13 20:38:47 +00:00
Haoran Wang
1db1ab7b11 gcp auth provider not to override the Auth header if it's already exits
Kubernetes-commit: 9760dd9943f99c0ab850ac350b818406eead30cd
2017-06-13 20:38:47 +00:00
Tim Hockin
bf9b15475a 'Global' -> 'Cluster' for traffic policy
Kubernetes-commit: fc34a9d6ba4679298abc2d371b86eb32354f0c7b
2017-06-13 20:38:47 +00:00
Chao Xu
62a5cd0975 generated
Kubernetes-commit: e9d9b05234b46d2419112adb2009a9802998027c
2017-06-13 20:38:47 +00:00
Daniel Smith
38cb1a951d Implement dynamic admission webhooks
Also fix a bug in rest client

Kubernetes-commit: d6e1140b5d3c5c9d8696b7ccda0a5f92f36033df
2017-06-13 20:38:46 +00:00
Quintin Lee
d9ea62815a Add annotation for image policy webhook fail open.
Kubernetes-commit: a38c2b4ce183da25262791c791215697e7aeaaa0
2017-06-13 20:38:46 +00:00
Jing Xu
a23ebdbf48 generated files
Kubernetes-commit: 695f7be697b4137875e2fc93c39b06ab2784fa2f
2017-06-13 20:38:46 +00:00
Chao Xu
27aa69fcc8 generated
Kubernetes-commit: ec787db460c21af5d5d5989f90f8f6fc1640f73f
2017-06-13 20:38:46 +00:00
deads2k
aad51bc86d move labels to components which own the APIs
Kubernetes-commit: 954eb3ceb98032b50362da19a675bc9dacc110e2
2017-06-13 20:38:46 +00:00
Tomas Nozicka
b113bd5b26 Fix standardFinalizers - add missing metav1.FinalizerDeleteDependents
Kubernetes-commit: 9ed01e44a14e52ec8460b0282930b44964940972
2017-06-13 20:38:46 +00:00
Ahmet Alp Balkan
11c69ac127 clientgo/examples/out-of-cluster: add instructions
Adding instructions for out-of-cluster example and making it work without
specifying the -kubeconfig argument if the home directory can be inferred.

This is part of the body of work improving the client library samples.

Signed-off-by: Ahmet Alp Balkan <ahmetb@google.com>

Kubernetes-commit: e59f05fe0ee6980c4bdaae76f5a77ef884bd2da1
2017-06-13 20:38:46 +00:00
Ahmet Alp Balkan
8787fb55e2 client-go: Add CRUD Deployment sample
This sample adds sample code for create/list/replace/delete operations for
Deployment resource for client-go library. This patch also contains
documentation explaining what the example application does and how it can be
executed.

This patch is part of the body of work improving the client library samples.

Signed-off-by: Ahmet Alp Balkan <ahmetb@google.com>

Kubernetes-commit: d75710f9f4d2e74979f6da07de31b02fae0392b0
2017-06-13 20:38:46 +00:00
Clayton Coleman
8db6be287c Refactor printers to support rendering as a Table
Return tables from the server.

Kubernetes-commit: 7ce63eb608cdf95df429d6138ccf8dbf8b47a740
2017-06-13 20:38:46 +00:00
Josh Horwitz
375eed416f staging client
Kubernetes-commit: 24271c4c86ede012b6ecc42243ed01a82dcefdf4
2017-06-13 20:38:46 +00:00
Dr. Stefan Schimanski
c39a8b699d apimachinery: move unversioned registration to metav1
Kubernetes-commit: e3b92a11f1e9b898265d50eba92727b8209e0bb2
2017-06-13 20:38:45 +00:00
Dan Winship
5ae2719295 Regenerate files
Kubernetes-commit: 0923f860f1b9a05e9fbeeadc7345e0b0e6105040
2017-06-13 20:38:45 +00:00
Solly Ross
44b2cb7282 Regenerate protobuf and client-go
This commit regenerates the protobuf as per the recent generation
changes (removing erroneous imports, adding k8s.io/metrics), and
syncs the changes to client-go (which also ensures that client-go
protobuf IDL has the correct package names).

Kubernetes-commit: 8d03536d00b354aa299bf7359e482009146bf0da
2017-06-13 20:38:45 +00:00
deads2k
d3d2ebe2d3 prevent illegal verb/name combinations in default policy rules
Kubernetes-commit: 5539a6721dd3ea52261b51f859e5504c6b6affce
2017-06-13 20:38:45 +00:00
zhengjiajin
e65054aaa9 fix api description in swagger
Kubernetes-commit: 60c3152c56448aa72ed68a2a0da72a0e73d0dd08
2017-06-13 20:38:45 +00:00
Chao Xu
5ccf401176 generated
Kubernetes-commit: 89e506c46a3a8007e943aac1e743608f6bbc148c
2017-06-13 20:38:45 +00:00
xilabao
cad616fd7b add policy_compact to rbac validation
Kubernetes-commit: 9fe2ef54ba81144b4e0863212ddc0367e2498325
2017-06-13 20:38:45 +00:00
Kenneth Owens
10e9ca1449 Implements ControllerRevision API Object without codec and code
generation

Kubernetes-commit: ba128e6e417a8a2af062de0a81b4171e3a54a6fc
2017-06-13 20:38:45 +00:00
Michail Kargakis
b1f4aacc70 Generated changes for collision count
Signed-off-by: Michail Kargakis <mkargaki@redhat.com>

Kubernetes-commit: 9190a47c3769c329ed8b29844a667a1c959307df
2017-06-13 20:38:45 +00:00
Tim Hockin
7bef0aa41b Inject clock through flowcontrol
Kubernetes-commit: 3153ca2815c5a596adec770392248573c7e448b7
2017-06-13 20:38:45 +00:00
Tim Hockin
0c8efe21e2 Update godeps for juju ratelimit
This picked up an unrelated but missing change.

Kubernetes-commit: 3178433b9fb9a75ffe8b53c4c61fa8b71a409c65
2017-06-13 20:38:44 +00:00
Ken Simon
6bfadd9f8f Include event messages in aggregated events
This changes the event aggregation behavior so that, when multiple events are
deduplicated, the aggregated event includes the message of the latest related
event.

This fixes an issue where the original event expires due to TTL, and the
aggregate event doesn't contain any useful message.

Kubernetes-commit: 6ada269d8f199b02dd5852f1545746a14f58f4eb
2017-06-13 20:38:44 +00:00
zhengjiajin
2e44fe3560 /pkg/client/listers: fix some typo
Kubernetes-commit: dc48a5abc9233d7f3b18518d97d4842bdee694f7
2017-06-13 20:38:44 +00:00
Andy Goldstein
48409ad603 Fix in-cluster kubectl --namespace override
Before this change, if the config was empty, ConfirmUsable() would
return an "invalid configuration" error instead of examining and
honoring the value of the --namespace flag. This change looks at the
overrides first, and returns the overridden value if it exists before
attempting to check if the config is usable. This is most applicable to
in-cluster clients, where they don't have a kubeconfig but they do have
a token and can use KUBERNETES_SERVICE_HOST/_PORT.

Kubernetes-commit: 23e32b100fb9745b70203c30716697bd03926313
2017-06-13 20:38:44 +00:00
Anirudh
18c8914690 PDB MaxUnavailable: Generated
Kubernetes-commit: 48d76edc744ea2f8857717b51e6a564a4d49544b
2017-06-13 20:38:44 +00:00
System Administrator
ed614f066a Kubernetes core API changes for vSphere
Kubernetes-commit: 83520a7470e05362552a32fb97c4878fa05ce7de
2017-06-13 20:38:44 +00:00
Michelle Au
dc0c592386 Fix storage node affinity helpers
Kubernetes-commit: 5fcb82dde93429e443c77c8936e4412b9a936744
2017-06-13 20:38:44 +00:00
Eric Tune
0d7af62b83 Move PDB controller and type ownership to SIG-Apps
Created OWNERS_ALIASES called sig-apps-reviewers from the union of reviewers in:
 pkg/controller/{cronjob,deployment,daemon,job,replicaset,statefulset}/OWNERS
except removed inactive user bprashanth

Created OWNERS_ALIASES called sig-apps-api-reviewers as the intersection
of sig-apps-reviewers and the approvers from pkg/api/OWNERS.

Used those OWNERS_ALIASES as the reviewers/approvers for the disruption controller,
and API.

Kubernetes-commit: b17e3c14ebbdb66eacbf0bc4ae8d737df8e06869
2017-06-13 20:38:44 +00:00
Eric Chiang
1309db5ec6 oidc client plugin: reduce round trips and switch to golang.org/x/oauth2
This PR attempts to simplify the OpenID Connect client plugin to
reduce round trips. The steps taken by the client are now:

* If ID Token isn't expired:
   * Do nothing.
* If ID Token is expired:
   * Query /.well-known discovery URL to find token_endpoint.
   * Use an OAuth2 client and refresh token to request new ID token.

This avoids the previous pattern of always initializing a client,
which would hit the /.well-known endpoint several times.

The client no longer does token validation since the server already
does this. As a result, this code no longer imports
github.com/coreos/go-oidc, instead just using golang.org/x/oauth2
for refreshing.

Kubernetes-commit: 6915f857574505a2cd2072c32d9d6da66ce6f55a
2017-06-13 20:38:44 +00:00
Steven E. Harris
a5e25d7218 Remove redundant third-party type registration
Since NewSchemeBuilder registers the supplied Scheme transformation
functions synchronously, there's no need for a subsequent call
to (*SchemeBuilder).Register against the same instance.

Kubernetes-commit: 3a8e44bda80f74d674bf2df0b87cb4562a3587a0
2017-06-13 20:38:44 +00:00
Steven E. Harris
87c960d69b Copyedit third-party resource registration example
Kubernetes-commit: fe3ca9a6eba9b39a305b8cdffc2fbc7a66b812da
2017-06-13 20:38:44 +00:00
Jeffrey Regan
8debebccfb **What this PR does / why we need it**:
Remove kubectl's dependence on pkg/api/helper, as part of
broader effort to isolate kubectl from the rest of k8s.
In this case, the code becomes private to kubectl; nobody else uses it.

**Which issue this PR fixes**

Part of a series of PRs to address kubernetes/community#598

**Special notes for your reviewer**:

**Release note**:
```release-note
NONE
```

Kubernetes-commit: 5a9b06b717805ad47da1edda6018fea107ac4ce9
2017-06-13 20:38:43 +00:00
Michelle Au
309d9ec71a Generated code for local persistent volumes
Kubernetes-commit: 936269a2eb60be837685a632b78a11941cb9d434
2017-06-13 20:38:43 +00:00
Clayton Coleman
e06018a166 Support burst in stateful set scale up and down
The alpha field podManagementPolicy defines how pods are created,
deleted, and replaced. The new `Parallel` policy will replace pods
as fast as possible, not waiting for the pod to be `Ready` or providing
an order. This allows for advanced clustered software to take advantage
of rapid changes in scale.

Kubernetes-commit: 2861ae5eb986a059c69e812513c272566c346710
2017-06-13 20:38:43 +00:00
Klaus Ma
e15298083c generated client-go.
Kubernetes-commit: fd0190fd685d648ab2c4ddc5802d14ad8813d07f
2017-06-13 20:38:43 +00:00
Ahmet Alp Balkan
8efad6dbf0 clientgo/examples/in-cluster: add instructions to run the example
This patch adds instructions for how to run the in-cluster client-go example.
To make this example executable, providing a Dockerfile and build steps so
that it can directly be run on minikube.

This is part of the body of work improving the client library samples.

Signed-off-by: Ahmet Alp Balkan <ahmetb@google.com>

Kubernetes-commit: 8604ed6d9906ebfb33206b55467db41c87e9f148
2017-06-13 20:38:43 +00:00
xilabao
6e8ae30f39 update gopass to fix format error
Kubernetes-commit: 892980dd748bd99b0493b117ff4bf27eefb0ba63
2017-06-13 20:38:43 +00:00
fate-grand-order
d12329fb4d correct misspell "identify" in client_config.go
Kubernetes-commit: 8f2891c10267b5fb8e8bc1f8d6cb6d84145c9577
2017-06-13 20:38:43 +00:00
Kubernetes Publisher
07c4fcb4df sync: reset Godeps.json 2017-06-13 20:38:42 +00:00
Chao Xu
6b1566ccaa Merge pull request #195 from ahmetb/update-readme
Add travis build status & godoc badges to README
2017-05-22 10:54:13 -07:00
Kubernetes Publisher
450baa5d60 sync: resync vendor folder 2017-05-21 17:20:49 +00:00
Kubernetes Publisher
34de549141 sync(k8s.io/kubernetes) ad720cc651916aedd1d3aca665eff901c3445a88 2017-05-21 17:20:30 +00:00
Clayton Coleman
074f58b23a generated: bazel
Kubernetes-commit: ad720cc651916aedd1d3aca665eff901c3445a88
2017-05-21 17:20:29 +00:00
Clayton Coleman
25835dfc1e Mutation cache should support retrieving items from ByIndex()
Allows tokens controller to observe updates

Kubernetes-commit: 5ac3214c427614ec5c4a53ddc05d952474402412
2017-05-21 17:20:29 +00:00
Clayton Coleman
d84ceacdd1 Add a filtering resource handler for informers
Allows an informer consumer to easily filter a set of changes out,
possibly to maintain a smaller cache or to only operate on a known set
of objects.

Kubernetes-commit: 5439cfd24571a1727aacf741d3ab8bd33f974cab
2017-05-21 17:20:29 +00:00
Clayton Coleman
09165439d7 Refactor move of client-go/util/clock to apimachinery
Kubernetes-commit: 3e095d12b4f152a45b593927804e2e7b8816239a
2017-05-21 17:20:29 +00:00
Clayton Coleman
dd465010d3 Move client-go/util/clock to apimachinery/pkg/util/clock
For reuse

Kubernetes-commit: 8013212db54e95050c622675c6706cce5de42b45
2017-05-21 17:20:29 +00:00
Kubernetes Publisher
c6a3373021 sync: reset Godeps.json 2017-05-21 17:20:29 +00:00
Kubernetes Publisher
1f73522a95 sync(k8s.io/kubernetes) 113cf85612afafccd50eda03a6e9fa181bd4346a 2017-05-20 17:20:32 +00:00
Brendan Burns
b59661b22c more stuff.
Kubernetes-commit: 97f6c52ffde705bcdf127d890d3976740d70bbe6
2017-05-20 17:20:32 +00:00
Kubernetes Publisher
2255f22758 sync(k8s.io/kubernetes) dd9e0ecd06e7f11cb61c1549b00a6e6185b85e47 2017-05-19 17:20:32 +00:00
Tim St. Clair
4e6534081b Misc proto changes
Kubernetes-commit: dd9e0ecd06e7f11cb61c1549b00a6e6185b85e47
2017-05-19 17:20:32 +00:00
Kubernetes Publisher
45154911ef sync: resync vendor folder 2017-05-18 17:20:47 +00:00
Kubernetes Publisher
1788286020 sync(k8s.io/kubernetes) bdd4d34c7d514ec2eaae67fa462491711e02c8b9 2017-05-18 17:20:28 +00:00
Clayton Coleman
16495c6a8f generated: api changes
Kubernetes-commit: bdd4d34c7d514ec2eaae67fa462491711e02c8b9
2017-05-18 17:20:28 +00:00
Chao Xu
59a623b7ba restrict visibility of client-go/pkg/api
Kubernetes-commit: 88aed19e6361af6b2bcaaf1bb8ac35954e7079ae
2017-05-18 17:20:28 +00:00
Zihong Zheng
6a84e825d9 Autogenerated files
Kubernetes-commit: 931892af8a76ee768108798a8bcaecaac0c4d9f2
2017-05-18 17:20:28 +00:00
Christoph Blecker
b904f78ea0 Update generated files
Kubernetes-commit: 4361a9146e34d74fce9c0193b11b920ffbd0eda8
2017-05-18 17:20:27 +00:00
Zihong Zheng
3a86c93348 Autogenerated files
Kubernetes-commit: 5992425588dc9b370245d66fea2e46ff66982b2d
2017-05-18 17:20:27 +00:00
Ahmet Alp Balkan
24b46cb91b Add travis build status & godoc badges to README
Signed-off-by: Ahmet Alp Balkan <ahmetb@google.com>
2017-05-17 11:26:19 -07:00
Kubernetes Publisher
8aceb98010 sync: resync vendor folder 2017-05-17 17:20:47 +00:00
Kubernetes Publisher
5eab562d64 sync(k8s.io/kubernetes) edd2d973a3c777afd691d6abe7b1e6420ad43cba 2017-05-17 17:20:30 +00:00
deads2k
cf4d5c32f3 stop setting bad defaults that are indistinguishable from real values for clients
Kubernetes-commit: edd2d973a3c777afd691d6abe7b1e6420ad43cba
2017-05-17 17:20:30 +00:00
deads2k
cf4cea8c3f remove unnessary confusion of dead values
Kubernetes-commit: 75bd27a59504919694b7a38e61613f84813f8d93
2017-05-17 17:20:30 +00:00
deads2k
3290c558e2 start using customresourcedefinition.status
Kubernetes-commit: cb604f756a7147fab8b5b4cccd3fd6869ef9bb2c
2017-05-17 17:20:30 +00:00
deads2k
0aaf615b8c add mutation cache filter
Kubernetes-commit: f88c7725b4f9446c652d160bdcfab7c6201bddea
2017-05-17 17:20:30 +00:00
mbohlool
a53d10f5ad Update generated files
Kubernetes-commit: 103c1bfc1ea77c87bc187f76c5ea7d4ff31d329e
2017-05-17 17:20:30 +00:00
Ahmet Alp Balkan
2ea6418cfa Autogenerated files
Signed-off-by: Ahmet Alp Balkan <ahmetb@google.com>

Kubernetes-commit: c4fd4789589e9fadfc0d0c69c530a788a9a84ce5
2017-05-17 17:20:30 +00:00
Kubernetes Publisher
c5bdf38534 sync: reset Godeps.json 2017-05-17 17:20:29 +00:00
Kubernetes Publisher
299a25eb5a sync: resync vendor folder 2017-05-16 17:20:46 +00:00
Kubernetes Publisher
7ed1861317 sync(k8s.io/kubernetes) 294c6362bd2aa12d77777fba1b77312d6385624b 2017-05-16 17:20:28 +00:00
Dmitry Shulyak
9e7cf8d7ca Use streaming constants from pkg/api/v1 instead of pkg/api
Kubernetes-commit: a713604b24bfb4530b690e061e863e71e0bc1087
2017-05-16 17:20:28 +00:00
Dmitry Shulyak
28760732a9 Add remotecommand to client-go/pkg/api visibility rules
Kubernetes-commit: 64d98c2d92ca18e966a7b7cdabfec4f2c594fb6f
2017-05-16 17:20:28 +00:00
Dmitry Shulyak
dffa083760 Add exec module to client-go/util only with required code
client-go/pkt/util was removed in favor of client-go util, which consists
only from CodeExitError and ExitError interface

Kubernetes-commit: 8574bc564f4c54aa964d6c0c7ccec3202d9e2f1b
2017-05-16 17:20:28 +00:00
Dmitry Shulyak
20e59c60f8 Move client/unversioned/remotecommand to client-go
Module remotecommand originally part of kubernetes/pkg/client/unversioned was moved
to client-go/tools, and will be used as authoritative in kubectl, e2e and other places.

Module remotecommand relies on util/exec module which will be copied to client-go/pkg/util

Kubernetes-commit: 2612e0c78ad18ac87bbd200d547100cf99f36089
2017-05-16 17:20:28 +00:00
Cao Shufeng
29b5bff0fa add --as-group option to cli
The usecase of this change:
When a super user grant some RBAC permissions to a group, he can use
--as-group to test whether the group get the permissions.
Note that now we support as-groups, as-user-extra in kubeconfig file
after this change.

Kubernetes-commit: e541defd49d01024d17dddf8e966eba2c46a6db0
2017-05-16 17:20:28 +00:00
Jordan Liggitt
fdfa162aed Require nodeName for mirror pods, make mirror pod annotation immutable
Kubernetes-commit: cd3a1187a1736985ea32111a61646ab691849a4d
2017-05-16 17:20:27 +00:00
Kubernetes Publisher
8a36291845 sync: reset Godeps.json 2017-05-16 17:20:27 +00:00
Kubernetes Publisher
a546461dcc sync(k8s.io/kubernetes) 9590b94f7ce47862316bf5acaae7f1af3075db9a 2017-05-15 17:20:25 +00:00
Andy Lindeman
f851632ada Uses container/heap
Kubernetes-commit: dad64459a9b8c56d5bca681e37c3d0f44921d472
2017-05-15 17:20:25 +00:00
Andy Lindeman
fe9ac9f9c0 Adds benchmark test
Kubernetes-commit: 21ca6c498aec2879fd7b9796f55743e5f14d5a80
2017-05-15 17:20:25 +00:00
Kubernetes Publisher
1bf81ae841 sync(k8s.io/kubernetes) abaffb243e39067197344e650989bc9f89b2f62d 2017-05-13 17:20:26 +00:00
Zihong Zheng
f3b79c3323 Autogenerated files
Kubernetes-commit: 12b6c2b8792f375460c94f59c9bffe39895df37f
2017-05-13 17:20:25 +00:00
Chao Xu
3c049628f8 run visibility-control.sh to setup visibility for all internal versions of client-go api groups, and their install packages
Kubernetes-commit: b91f787d8368ae5499a2f25009f5acf17918ebf5
2017-05-13 17:20:25 +00:00
Chao Xu
7ee9bbd10c update visibility manually
Kubernetes-commit: b1b5ead8b400d123f0027408c054370c55c01230
2017-05-13 17:20:25 +00:00
Nail Islamov
f1648c6391 Replacing “Pod Injection Policy” with “Pod Preset” in the code documentation
Kubernetes-commit: 66f45195afd0b867d9c2befa5d43824723569758
2017-05-13 17:20:25 +00:00
Kubernetes Publisher
1b8c2a3e22 sync: resync vendor folder 2017-05-12 17:22:18 +00:00
Kubernetes Publisher
29ea990f7c sync(k8s.io/kubernetes) 0c5a7b434ca85b15cdabce1ff6bc928d15065c6e 2017-05-12 17:21:59 +00:00
Dr. Stefan Schimanski
6434e2e4bb NotRegisteredErr for known kinds not registered in target GV
The dynamic client uses NotRegisteredErr to fall back to core v1 if ListOptions is not known
in the given GV. This commit fixes the case that ListOptions is known in some group, but not
in the given one.

Kubernetes-commit: 2ece9e4dec483c9712d09dc7c1fd5be1fe68ea62
2017-05-12 17:21:59 +00:00
Guangya Liu
5a21aa58a2 Added indexer description for the API of NewIndexerInformer.
Kubernetes-commit: e42f7c7480c304144b3c90089232c5fc59229cce
2017-05-12 17:21:59 +00:00
Dr. Stefan Schimanski
bdefb3c11a Update generated files
Kubernetes-commit: b498019f2f7aebe1c0e5c0d7a825069e25650fc6
2017-05-12 17:21:59 +00:00
Dr. Stefan Schimanski
a46cb79cf4 client-go tpr example: round trip external tpr types
Kubernetes-commit: fb2298de18eee7cb3d677143d3dd2cfde440aa6a
2017-05-12 17:21:59 +00:00
Chao Xu
e833e172a0 generated
Kubernetes-commit: a5fd6b91e7986b1de2589077e3cfdafcdb6de013
2017-05-12 17:21:59 +00:00
Chao Xu
d112596ad6 make client-go/pkg/api invisible to k8s.io/metrics; except for the fake
client, which will be fixed soon

Kubernetes-commit: dec78eb9aef9d09dd9ef090a580a28ecf90dac21
2017-05-12 17:21:59 +00:00
Klaus Ma
02b7d62fd4 generated client-go.
Kubernetes-commit: 3278de723add74849089e9563be20005bb018af5
2017-05-12 17:21:59 +00:00
Dr. Stefan Schimanski
1120d7fc8d Add myself to client-go OWNERS
Kubernetes-commit: b7146bca19820bc320e8286f7edfd90a3ab0f9b7
2017-05-12 17:21:59 +00:00
Nail Islamov
8d49905c48 ThirdPartyResource client-go example: added TPR controller example, code cleanup and integration test
Kubernetes-commit: a6c97715ed7e24581dd9a02a256d57e56b70ac44
2017-05-12 17:21:59 +00:00
Haoran Wang
bb2e182124 oidc auth plugin not to override the Auth header if it's already exits
Kubernetes-commit: f54a08093d6d65be64fa9281622997126af966f8
2017-05-12 17:21:59 +00:00
mbohlool
650f6b4f1d Update go-restful dependency
Kubernetes-commit: ea042c6ca0fc7eb8017012ca56d6879b8cf10637
2017-05-12 17:21:59 +00:00
Jamie Hannaford
958f3df6a4 Use dedicated Unix User and Group ID types
Kubernetes-commit: 9440a68744ea97a45ceeef6d75466405ac101ea1
2017-05-12 17:21:59 +00:00
NickrenREN
dad27d745a remove deprecated NodeLegacyHostIP
Kubernetes-commit: 7d00e5cfb66d4501879125f4d3c732f9bb726d0c
2017-05-12 17:21:58 +00:00
Klaus Ma
ca719949f1 Set defaults for initContainer beta.
Kubernetes-commit: 7b7a759915c515c37455dafa2e98b4d95e6ce6b7
2017-05-12 17:21:58 +00:00
Kubernetes Publisher
1f311d1b79 sync: reset Godeps.json 2017-05-12 17:21:58 +00:00
Kubernetes Publisher
22eca115bd sync(k8s.io/kubernetes) 99540c6435075bad7522f60f0bcdc6e63c0a4f2d 2017-05-05 20:28:27 +00:00
Solly Ross
e71930600e OWNERS: add directxman12 to pkg/apis/autoscaling
Added directxman12 (current SIG lead of SIG-autoscaling) as a reviewer
for pkg/apis/autoscaling.

Kubernetes-commit: b6256e1f3f6f6dbf6f600bc3b958508f09d9e383
2017-05-05 20:28:27 +00:00
Kubernetes Publisher
d2e281defd sync: resync vendor folder 2017-05-04 20:28:52 +00:00
Kubernetes Publisher
69da22a50f sync(k8s.io/kubernetes) d22a9c25997c3b94078c76af72fd4c7071e6c882 2017-05-04 20:28:29 +00:00
Chao Xu
6db1a83402 generated clientset changes
propagate to client-go
update-bazel.sh

Kubernetes-commit: 5f5a70f65f7dbcfc9215caee27cfd9a4be23f348
2017-05-04 20:28:29 +00:00
Chao Xu
85c50f4ccb remove registry from testing/fixture.go; update client-gen to not use
registry in the generated clients

Kubernetes-commit: bbb94e42c108840c540c5667f8da97c33b81d84a
2017-05-04 20:28:29 +00:00
Chao Xu
ede4e68eb7 Remove redundent GetObjectKind() defined on top-level types
TypeMeta is embedded in all these types and TypeMeta has GetObjectKind()
method to implement the runtime.Object interface.

Kubernetes-commit: 47b410f58b4f00c010a2238d4faff44d16582315
2017-05-04 20:28:29 +00:00
Chao Xu
89e9cea531 control visibility client-go/pkg/api
Kubernetes-commit: c9844686781176b5d175728cbd6cc6327d62198e
2017-05-04 20:28:28 +00:00
Andy Goldstein
0389c75147 Fix typo in lister-gen, regenerate
NamespaeLister -> NamespaceLister

Kubernetes-commit: 11e4f149d906ad0c87d0a4062078cd4e24c813f6
2017-05-04 20:28:28 +00:00
Eric Chiang
8e696697e7 staging: run ./hack/update-staging-client-go.sh
Kubernetes-commit: 9fc727cf44ed4d00d8f51270d244cb140d3c1b3c
2017-05-04 20:28:28 +00:00
Kubernetes Publisher
64e947de2f sync: reset Godeps.json 2017-05-04 20:28:28 +00:00
Kubernetes Publisher
f0ab6b85bd sync: resync vendor folder 2017-05-03 20:28:57 +00:00
Kubernetes Publisher
ad97d39b91 sync(k8s.io/kubernetes) 80f26fa8a89ef5863cb19c71a620bb389d025166 2017-05-03 20:28:32 +00:00
Dr. Stefan Schimanski
b3c3c3d1fe apimachinery: rename meta.{ -> UnsafeGuess}KindToResource
Kubernetes-commit: b0b711119b48854e0b73805e42be2bcc4b2bd604
2017-05-03 20:28:32 +00:00
Chao Xu
7b1f9a193b remove references to client-go/pkg/api
Kubernetes-commit: d978f22e04519f6eecfde839110c398dc28d4e8e
2017-05-03 20:28:31 +00:00
Kubernetes Publisher
f1cb94b672 sync(k8s.io/kubernetes) 4a487cbb11c2cc10483fe9f19271a0b3dd910c2f 2017-05-02 20:28:24 +00:00
Henrique Truta
bc6311c19c Fixes broken link in PodSpec
The PodSpec reference to NodeSelector misses
 the .md extension in the file.

Kubernetes-commit: 4a487cbb11c2cc10483fe9f19271a0b3dd910c2f
2017-05-02 20:28:23 +00:00
Kubernetes Publisher
7ba6be5949 sync: resync vendor folder 2017-05-01 20:28:46 +00:00
Kubernetes Publisher
db4645fe45 sync: resync vendor folder 2017-04-29 20:28:42 +00:00
Kubernetes Publisher
ee36746f42 sync(k8s.io/kubernetes) a76ada8d5ac5f4cea2d7fabce23d7af9c62e3eb9 2017-04-29 20:28:22 +00:00
Ricky Pai
750abd4711 generated files
Kubernetes-commit: a76ada8d5ac5f4cea2d7fabce23d7af9c62e3eb9
2017-04-29 20:28:22 +00:00
deads2k
e7b07ed0c1 generated
Kubernetes-commit: afc5ae1539b0b27a8b569c4bd737db21bf1229ee
2017-04-29 20:28:22 +00:00
Kubernetes Publisher
9ccb531510 sync: reset Godeps.json 2017-04-29 20:28:22 +00:00
Kubernetes Publisher
54b86aca52 sync: resync vendor folder 2017-04-28 20:28:48 +00:00
Kubernetes Publisher
d4d5232db6 sync(k8s.io/kubernetes) 2b178ad608bd443efeaf3e9ea7c700e72ab68de1 2017-04-28 20:28:26 +00:00
Fabiano Franz
1a014f4539 Basic support for kubectl plugins
Kubernetes-commit: 2b178ad608bd443efeaf3e9ea7c700e72ab68de1
2017-04-28 20:28:26 +00:00
Chao Xu
153fd0bab2 make it possible to move SchemeBuilder with zz_generated.deepcopy.go
Kubernetes-commit: d0b94538b9744d0c06df6ddec2604be168568f9d
2017-04-28 20:28:26 +00:00
Chao Xu
384737846d bazel
Kubernetes-commit: 958903509c29fdfe216c0bbf0abce1ce0abd59a6
2017-04-28 20:28:26 +00:00
Chao Xu
cf012f20d0 easy changes
Kubernetes-commit: 3fa7b7824abbf3daec1189b118b91b5bb726958f
2017-04-28 20:28:25 +00:00
Kubernetes Publisher
670b68600e sync: resync vendor folder 2017-04-27 20:28:58 +00:00
Kubernetes Publisher
313ec0555a sync(k8s.io/kubernetes) c446132a97d5a1d035b031b4f8e322aea3a7cfac 2017-04-27 20:28:33 +00:00
Chao Xu
c6d944a2de bazel
Kubernetes-commit: ee61ffb4b15afc5e2a63eea687e95accb46fd44f
2017-04-27 20:28:33 +00:00
Chao Xu
3fa06e848c update list-gen to not import internal package in external listers
Kubernetes-commit: 0bac9b6aaabfe3dcf50fdcbdddfc8b4eb5aa805e
2017-04-27 20:28:33 +00:00
Andy Goldstein
6bc1999690 Add redirect support to SpdyRoundTripper
Add support for following redirects to the SpdyRoundTripper. This is
necessary for clients using it directly (e.g. the apiserver talking
directly to the kubelet) because the CRI streaming server issues a
redirect for streaming requests.

Also extract common logic for following redirects.

Kubernetes-commit: 715d5d9c91c669cf33c0bf9a9c9d352c6c4228a6
2017-04-27 20:28:33 +00:00
Phillip Wittrock
6cd603a009 kubectl OpenAPI bazel updates
Kubernetes-commit: 21e239fb82e7e81dfed9bfddc4e95ff8201c52fa
2017-04-27 20:28:33 +00:00
Phillip Wittrock
97a8b3b040 kubectl OpenAPI support
Kubernetes-commit: 212c2a3a7217ff7e0a7c895582c7a25d03ac7f8c
2017-04-27 20:28:33 +00:00
Phillip Wittrock
c192350f2c kubectl OpenAPI godeps updates
Kubernetes-commit: 70704196be463508d0a43dfd04a002364f28346a
2017-04-27 20:28:32 +00:00
Kubernetes Publisher
dee664a95b sync: reset Godeps.json 2017-04-27 20:28:32 +00:00
Kubernetes Publisher
71cbfce9d8 sync: resync vendor folder 2017-04-26 20:28:44 +00:00
Kubernetes Publisher
818c53c780 sync(k8s.io/kubernetes) 50af2e84ab699ef54dfadca9dda84f9dce552d10 2017-04-26 20:28:24 +00:00
Lucas Käldström
51e9e663fd Update the staging directory
Kubernetes-commit: 50af2e84ab699ef54dfadca9dda84f9dce552d10
2017-04-26 20:28:23 +00:00
Kubernetes Publisher
837527a2a0 sync: resync vendor folder 2017-04-25 20:28:46 +00:00
Kubernetes Publisher
70c13e394d sync(k8s.io/kubernetes) f4eed2477d649e8a516e77d6f8b8fa304475355d 2017-04-25 20:28:25 +00:00
Jan Safranek
d3789e9779 Regenerate everything
Kubernetes-commit: cde2746821954c8eba5ef4d2ab55691619cae4df
2017-04-25 20:28:25 +00:00
Jordan Liggitt
21a475eefb Stop treating in-cluster-config namespace as an override
Kubernetes-commit: 1305559abbcd1e5558980062221ed3e65a8f0387
2017-04-25 20:28:25 +00:00
NickrenREN
714e60e890 Define const annotation variable once
Move annotation to package imported by both pkg/volume and pkg/volume/validation

Kubernetes-commit: e443277d58e3ff1f0701ab97a1f4932389c27847
2017-04-25 20:28:24 +00:00
Kubernetes Publisher
e2c503b420 sync: resync vendor folder 2017-04-24 20:28:45 +00:00
Kubernetes Publisher
1aa489224e sync(k8s.io/kubernetes) fa750c02be9dca2caa1e3f0d755edf88e4677406 2017-04-22 20:28:23 +00:00
Jordan Liggitt
7972aac9f3 Explicit namespace from kubeconfig should override in-cluster config
Kubernetes-commit: 63b5650885acf6c2f4e68c8140ade2964bc2c6cb
2017-04-22 20:28:23 +00:00
Kubernetes Publisher
a4c9f96ebf sync: resync vendor folder 2017-04-21 20:28:40 +00:00
Kubernetes Publisher
a8293e2363 sync(k8s.io/kubernetes) c4bc7c1166dd494194c64a2a5edc3ed51dcf6003 2017-04-21 20:28:22 +00:00
Roman Mohr
3e24501bb6 client-go workqueue example
Demonstrates how to compose a controller out of cache.Controller,
cache.Indexer and a workqueue.

Kubernetes-commit: b39b3ba01675828c13bc0dea67d5114b4c225644
2017-04-21 20:28:22 +00:00
Yves Peter
1baf68dddb client-go PortForwarder: don't log an error if net.Listen fails
Kubernetes-commit: 99711a96a4e5fbd2bc26cbc070c96852c5939570
2017-04-21 20:28:21 +00:00
Kubernetes Publisher
f64a115c80 sync(k8s.io/kubernetes) 7b43f922aa059abfbbd9be1840499080cb7d6f54 2017-04-20 20:28:19 +00:00
Jordan Liggitt
e57428f505 Switch to pointer to policy rule, visit and short circuit during authorization
Kubernetes-commit: 67360883bc801b0f1334b146e8dce6f282e50e7e
2017-04-20 20:28:19 +00:00
Anthony Yeh
4c84996bc2 Job: Update Lister documentation for ControllerRef.
The Job Listers still use selectors, because this is the
behavior expected by callers. This clarifies the meaning of the
returned list. Some callers may need to switch to using
GetControllerOf() instead, but that is a separate, case-by-case issue.

Kubernetes-commit: ad026026e0252469bab05f9adba4bb1b20a8f6a9
2017-04-20 20:28:19 +00:00
Kubernetes Publisher
69f0a81e21 sync: resync vendor folder 2017-04-18 20:28:40 +00:00
Kubernetes Publisher
65b634c822 sync(k8s.io/kubernetes) a1684fea80d0470db1e30bc3e051e87a0b956c71 2017-04-18 20:28:21 +00:00
Chao Xu
354468e551 move pkg/api/v1/ref.go and pkg/api/v1/resource.go to subpackages. move some functions in resource.go to pkg/api/v1/node and pkg/api/v1/pod
Kubernetes-commit: 4f9591b1de11bff617c920f89144004669b0f461
2017-04-18 20:28:21 +00:00
Christoph Blecker
ad53524c7c Fix gofmt errors
Kubernetes-commit: 6681835b0c00122a408bd4addd47b02840b6208c
2017-04-18 20:28:21 +00:00
Antoine Pelisse
b128bee2cc OWNERS: Create sig-node alias
Create an alias group for sig-node
WaitForCacheSync method comment "contoller" is error word

Kubernetes-commit: 77cbdddb5907a81cb6bbd9b9234e2acfd4394004
2017-04-18 20:28:21 +00:00
Kubernetes Publisher
5188c3e3d4 sync(k8s.io/kubernetes) ca8f1bcf3d67bae574146a2adf9989b4a43046e3 2017-04-17 20:28:21 +00:00
Tim Hockin
2876fbe4ad --amend
Kubernetes-commit: fa93290b7276e1b3585de9ec70f26a935bce8746
2017-04-17 20:28:21 +00:00
xu fei
3113f909d8 change event count type
event count type had better to be uint.

Kubernetes-commit: 461761e5b0b4beb3f49cc5973b50e9a6de3875dd
2017-04-17 20:28:21 +00:00
Kubernetes Publisher
f215249656 sync: resync vendor folder 2017-04-16 20:28:34 +00:00
Kubernetes Publisher
4f4d9e78f5 sync: resync vendor folder 2017-04-15 20:28:35 +00:00
Kubernetes Publisher
dd45794e15 sync(k8s.io/kubernetes) f05ce1e8f171529773c9ca05c85e01f317d84ea4 2017-04-15 20:28:18 +00:00
Jeffrey Regan
633aab4bea Use OS-specific libs when computing client User-Agent.
**What this PR does / why we need it**:

The User-Agent reported by clients (e.g. kubectl) in request
headers should include the name of the client executable
but not the full path to that executable.

This PR changes how this name is determined by using the
operating-system specific package "path/filepath" (meant for
working with file system paths) instead of the "path" package
(meant for URL paths).

This fixes a problem on the Windows OS in the case where, if the
user has not set their PATH to point to the location of their
client executable, the User-Agent unnecessarily includes the
full path.

Fixes: #44419

Kubernetes-commit: 04f993250bc7a1aef0f2874d440ddb4bec1012c5
2017-04-15 20:28:18 +00:00
Chao Xu
bb2e2ad83c move pkg/api/v1/helpers.go to subpackage
Kubernetes-commit: d4850b6c2b3b367345ef944a12a778d860fdd0db
2017-04-15 20:28:18 +00:00
Mike Danese
4b15a8b136 add testdata for tests in //vendor/k8s.io/...
Kubernetes-commit: 981dd8dc6615f397a9b85c5b965998dc8a0b1338
2017-04-15 20:28:18 +00:00
Mike Danese
9a45999fa0 autogenerated
Kubernetes-commit: a05c3c0efdc5822049e34b1a5a1ee259c5fb1906
2017-04-15 20:28:18 +00:00
Kubernetes Publisher
a1a3cacf90 sync: resync vendor folder 2017-04-14 20:28:39 +00:00
Kubernetes Publisher
3cbc5ba655 sync(k8s.io/kubernetes) 47ccb092f499bbf02abfdea218b777c1715c69e5 2017-04-14 20:28:21 +00:00
Chao Xu
76c209704f move resource_helpers.go to a subpackage
Kubernetes-commit: 9837a98564b06ee1f8662b83960051463e8e3c36
2017-04-14 20:28:21 +00:00
Chao Xu
5b1ad11ba7 move ref.go to its own subpackage
Kubernetes-commit: d9920c53a575a7c017a9cd120220ef2ad761a962
2017-04-14 20:28:21 +00:00
Maciej Szulik
449f25e669 Staging changes for docs in batch types.go
Kubernetes-commit: a307c47dfd417889967413d5e50515e499b3b772
2017-04-14 20:28:20 +00:00
Jordan Liggitt
8a68cfcf75 Remove vestiges of defaulting from conversion path, switch to top-level default registration only
Kubernetes-commit: ad116026d9fefe70bbc37f30b9d299ca3af6e43c
2017-04-14 20:28:20 +00:00
StudyNick
268171e690 'workqueue' modify 'work queue'
Kubernetes-commit: dc460c3e15651d7e3527337c7997ab7f956ad6b1
2017-04-14 20:28:20 +00:00
Kubernetes Publisher
bc86c35183 sync(k8s.io/kubernetes) 868eb745abc4b12d53286cb2f6a279a9f375d5d3 2017-04-13 20:28:17 +00:00
Maciej Szulik
fcf5e39983 Staging client changes for defaults updates
Kubernetes-commit: ce013adfbba0df510e082e645daad971a069c9e5
2017-04-13 20:28:17 +00:00
Daniel Smith
d2a94be401 Merge pull request #179 from caesarxuchao/move-dep
Move dep to the last recommended vendoring tool
2017-04-13 12:25:15 -07:00
Chao Xu
57fb61ca9c move down dep to the last recommended vendoring tool 2017-04-13 11:25:49 -07:00
Kubernetes Publisher
5b0e11b577 sync: resync vendor folder 2017-04-12 20:28:38 +00:00
Kubernetes Publisher
faba476f26 sync(k8s.io/kubernetes) d70b55ead532f970876708cf4b96f84976a6e343 2017-04-12 20:28:20 +00:00
Chao Xu
b4836ee03e move helpers.go to helper
Kubernetes-commit: 08aa712a6c3bf429017e14cdec3dcfb4d983af82
2017-04-12 20:28:20 +00:00
Sahdev P. Zala
184fe30384 Conversion generated code changes for golint fix
The exported or public functions requires a doc comment to pass golint.
This commit has changes of conversion generated code. The actual doc
changes are added into a separate commit for a clean review.

Kubernetes-commit: 08639023d027e0b69e3b3e5535b04148e084b1bd
2017-04-12 20:28:20 +00:00
Timothy St. Clair
bcb754b775 Update staging files
Kubernetes-commit: fc04bba10e18eef666de3f7348513af49b27019c
2017-04-12 20:28:20 +00:00
Timothy St. Clair
656cf48fd6 Level sets dependency graph to consume etcd 3.1.5
Kubernetes-commit: 93c051e28fc43ed35cb9074f6de5a8c4de799eb2
2017-04-12 20:28:20 +00:00
NickrenREN
0865289f28 Remove alphaProvisioner in PVController and AlphaStorageClassAnnotation
Kubernetes-commit: fa7bd44966f02a87bd964dd63cba8e741aaaacc8
2017-04-12 20:28:20 +00:00
Dr. Stefan Schimanski
5cca8d5380 hack/verify-staging-imports.sh: check that plugins are not imported by default
Kubernetes-commit: 792d1f3dc0bd45ab63c59cfee298bfc4b898a914
2017-04-12 20:28:20 +00:00
Kubernetes Publisher
d7af91d796 sync: reset Godeps.json 2017-04-12 20:28:19 +00:00
Kubernetes Publisher
4a3ab2f5be sync: resync vendor folder 2017-04-11 20:28:38 +00:00
Kubernetes Publisher
e4963c97a8 sync(k8s.io/kubernetes) f1b9c17cef2f18268b3521dede120634c3f7252a 2017-04-11 20:28:18 +00:00
deads2k
5d5193044b make unstructured items correspond to other items for storage
Kubernetes-commit: 706823aaa8b34ac197230ff7952c095fc0a7a614
2017-04-11 20:28:18 +00:00
deads2k
bd7878428d remove objectmetafor
Kubernetes-commit: 04460c8750b9a47672aa708251de0e703cfb7266
2017-04-11 20:28:18 +00:00
Dan Winship
035f98d6c6 Regenerate files
Kubernetes-commit: 11471e965d1aa7f32f576186270b6d89001946ae
2017-04-11 20:28:18 +00:00
Andy Goldstein
634770b327 validateClusterInfo: use clientcmdapi.NewCluster()
Change validateClusterInfo to use clientcmdapi.NewCluster() instead of
clientcmdapi.Cluster{} when comparing against the passed in clusterInfo.
clusterInfo most likely will be a combination of
clientcmdapi.NewCluster() merged with potential overrides. This is
necessary because otherwise, the DeepEqual between what is supposed to
be an empty Cluster and clusterInfo will fail, resulting in an error
that doesn't allow fall-through to checking for in-cluster
configuration.

Kubernetes-commit: 266ba9ffdeeeeba8022ce94ae4e725d996c29363
2017-04-11 20:28:18 +00:00
Jacob Simpson
f503ec43c7 Change the PEM block type to use the constant
Kubernetes-commit: 515987db3f039f5f19c3f6292af072b937aacdd7
2017-04-11 20:28:18 +00:00
Kubernetes Publisher
1953732e1e sync: resync vendor folder 2017-04-10 20:28:32 +00:00
Kubernetes Publisher
0ec10d4351 sync: resync vendor folder 2017-04-08 20:28:36 +00:00
Kubernetes Publisher
875418b286 sync(k8s.io/kubernetes) d043e20febe4652a1a4281f327e2b6499bde7e8d 2017-04-08 20:28:19 +00:00
Chao Xu
b71dbc873e separate constants to their own file
Kubernetes-commit: 2e44bb1c3b4584b21f515511ac1389e38eb4aa8a
2017-04-08 20:28:19 +00:00
ymqytw
f065b8d2f7 autogen
Kubernetes-commit: 5f60dcd90bac8e08323e4a0bc50c23d3fcc81f58
2017-04-08 20:28:18 +00:00
ymqytw
f256b244db add patch comment tags in open api
Kubernetes-commit: 1804e5e54800182539edde31dc7bf579e9a55f03
2017-04-08 20:28:18 +00:00
Huamin Chen
8459297e5e generated files
Signed-off-by: Huamin Chen <hchen@redhat.com>

Kubernetes-commit: 777eb32e91ed1bf47a2d23e755734a1d85bbad68
2017-04-08 20:28:18 +00:00
Harry Zhang
74bee732dd Update generate staging client-go
Kubernetes-commit: 74a99e1e1dd1ae0b6daa6ddc8d67f1ddd9992c12
2017-04-08 20:28:18 +00:00
deads2k
dcd132623d remove ListMetaFor
Kubernetes-commit: 7df37c484dac3438530f2b8cb03cf63f85f2fc29
2017-04-08 20:28:18 +00:00
Kubernetes Publisher
623dbc3dc4 sync: resync vendor folder 2017-04-06 20:28:32 +00:00
Kubernetes Publisher
d89514765b sync(k8s.io/kubernetes) e3e44b77ff6a6574c956253cc384c44378d89737 2017-04-06 20:28:15 +00:00
Klaus Ma
1f9cd88972 generated client-go.
Kubernetes-commit: 98a52fd6b5fd50f45554c4c8f86350d62826fc26
2017-04-06 20:28:15 +00:00
fate-grand-order
7f5f33cf4b fix misspell "underlying" in request.go
Kubernetes-commit: 122ea2551202e5edb3e840a97518170e060c484f
2017-04-06 20:28:15 +00:00
Kubernetes Publisher
dabf37f5df sync(k8s.io/kubernetes) dc4b8e3496791ca6e9f847007666baeb113da036 2017-04-05 20:28:15 +00:00
Chris Hupman
e4d1dd445d Fixed inaccurate comments for Secret and ConfigMap
Fixes #42203

ran documentation update scripts in hack folder

Signed-off-by: Chris Hupman <chupman@us.ibm.com>

Kubernetes-commit: dc4b8e3496791ca6e9f847007666baeb113da036
2017-04-05 20:28:15 +00:00
Kubernetes Publisher
4e221f82e2 sync(k8s.io/kubernetes) e28cb42706c32795b15a4159a275a53e020d4ac6 2017-04-04 20:28:14 +00:00
andrewsykim
6919445563 Regenerate code for api change
Kubernetes-commit: f05d584a4aa5a2071755c7bc97b2c3048f1557cb
2017-04-04 20:28:14 +00:00
Daniel Smith
e65642b619 Merge pull request #172 from caesarxuchao/3.0-changelog
update CHANGELOG for v3.0.0-beta.0
2017-04-03 15:53:08 -07:00
Chao Xu
bcb98146bb update CHANGELOG entry for v3.0.0-beta.0 2017-04-03 15:49:49 -07:00
Chao Xu
e8ae1e5c8e Merge pull request #171 from caesarxuchao/update-dep-readme
minor update to installation guide using dep
2017-04-03 14:32:39 -07:00
Chao Xu
388446dfe7 minor update to INSTALL guide using dep 2017-04-03 14:26:19 -07:00
Kubernetes Publisher
8c2f08eadb sync(k8s.io/kubernetes) 81545c2922b5e933eff52c19502510b906499d4f 2017-04-03 20:28:13 +00:00
Morgan Bauer
16f41facbc Update godoc to match
Kubernetes-commit: 3e5f904c89619bd158b241a31255541967fc99b4
2017-04-03 20:28:13 +00:00
Daniel Smith
1b8a363f59 Merge pull request #169 from caesarxuchao/3.0-tag
Add client-go 3.0 beta to compatibility matrix
2017-04-03 12:35:07 -07:00
Chao Xu
20aa040788 add client-go 3.0 beta to compatibility entry 2017-04-03 10:48:45 -07:00
Daniel Smith
63e44d4493 Merge pull request #157 from caesarxuchao/go-get
We support `go get` now, update INSTALL.md
2017-03-31 16:55:44 -07:00
Kubernetes Publisher
4c84db01ca sync: resync vendor folder 2017-03-31 20:29:47 +00:00
Kubernetes Publisher
8462402abd sync(k8s.io/kubernetes) bb656f97f1fa6d043dc3465285ba8bf4959cd595 2017-03-31 20:29:30 +00:00
yupengzte
f15453e5cd Fix typo
Signed-off-by: yupengzte <yu.peng36@zte.com.cn>

Kubernetes-commit: bb656f97f1fa6d043dc3465285ba8bf4959cd595
2017-03-31 20:29:30 +00:00
deads2k
999c0d5c20 move category expansion out of restmapper
Kubernetes-commit: 8895f314b478714a561dc1fc79d7411d31f91dc6
2017-03-31 20:29:30 +00:00
deads2k
9be38b2aa2 wire in aggregation
Kubernetes-commit: 8e26fa25da6d3b1deb333fe2484f794795d1c6b9
2017-03-31 20:29:30 +00:00
Avesh Agarwal
45bc41463a Auto generated stuff.
Kubernetes-commit: 0f65df66e68d9fbd4c1cb4a84ef30c751c0588fa
2017-03-31 20:29:30 +00:00
Jordan Liggitt
09ffb13d76 Update client-go
Kubernetes-commit: 7ceeee8665a80dca701bada1d85b4edbc8d8a281
2017-03-31 20:29:30 +00:00
Chao Xu
98caa049f9 remove timed_queue, its functionality is supported by a regular queue now
Kubernetes-commit: 29432ce05476e3452b3afe0563d45bdc66ef8c27
2017-03-31 20:29:30 +00:00
Chao Xu
6be328a96b fix fake_event_expansion.go
Kubernetes-commit: 68effc7b2d2428a1cca6322d8d87e17b4ff6f1b0
2017-03-31 20:29:30 +00:00
Lou Yihua
45e7f68a04 Update generated & client-go
Kubernetes-commit: 64f2b0c0fc183291553ff96cddd9d42e6d8e43eb
2017-03-31 20:29:29 +00:00
Kris
200ba6b1ab Remove krousey from some OWNERS files
Kubernetes-commit: ee4227f4bfe8c33426f1ac267a945094bfbc83cf
2017-03-31 20:29:29 +00:00
Chao Xu
399b27ce31 we support go get now, update INSTALL.md 2017-03-21 16:09:02 -07:00
David Eads
76153773ea Merge pull request #154 from caesarxuchao/generated-by-scripts
Round2: Generated by scripts
2017-03-21 17:09:59 -04:00
Kubernetes Publisher
5571124637 sync: resync vendor folder 2017-03-20 21:55:08 +00:00
Kubernetes Publisher
5f5adbd882 sync: reset Godeps.json 2017-03-20 21:54:52 +00:00
Chao Xu
2cb68a18c3 Merge pull request #140 from caesarxuchao/generated-by-scripts
Generated by robot
2017-03-20 13:30:55 -07:00
Kubernetes Publisher
22e5b7f1e5 sync: resync vendor folder 2017-03-18 19:50:39 +00:00
Kubernetes Publisher
584752ae88 sync(k8s.io/kubernetes) 9497139cb62015905ba5b3d11836f2b0c117ff80 2017-03-18 19:50:25 +00:00
Janet Kuo
6c610aff05 Auto-generate
Kubernetes-commit: 263d605112f65d7a2aff5ae09864edb1deab1f1f
2017-03-18 19:50:25 +00:00
Jordan Liggitt
fd507f71e6 update client-go
Kubernetes-commit: cc6bc17ab49baaf95d5d93b55ac7386f976cf20b
2017-03-18 19:50:25 +00:00
Chao Xu
3426f69f71 update-all.sh
Kubernetes-commit: 2378d397717ef972b31f3a396f38f696d8003f33
2017-03-18 19:50:25 +00:00
Christoph Blecker
c43b329d2e Bump godep version to v79
Kubernetes-commit: d31a88fee70fb1dd58c4da5251ad4c181ae946a0
2017-03-18 19:50:25 +00:00
Curtis Allen
7f2b2a8d71 bump(github.com/coreos/go-oidc): be73733bb8cc830d0205609b95d125215f8e9c70
Includes updates that enable OIDC with OKTA as a IDP

Kubernetes-commit: 7d409b3731596493b3e54743eb11593e9ba64ac3
2017-03-18 19:50:25 +00:00
Avesh Agarwal
41b2639c6a Auto update of staging client.
Kubernetes-commit: f88c90151840684c687759a1a3a4dc3fc2c1aa9c
2017-03-18 19:50:25 +00:00
Michael Fraenkel
ca95d09fc0 Update docs and client
Kubernetes-commit: cadc8a141d0b2b73f9ffe5238c164e184f17e189
2017-03-18 19:50:25 +00:00
Anthony Yeh
8fabaa8f6e DaemonSet: Update Lister documentation for ControllerRef.
The DaemonSet Listers still use selectors, because this is the
behavior expected by callers. This clarifies the meaning of the
returned list. Some callers may need to switch to using
GetControllerOf() instead, but that is a separate, case-by-case issue.

Kubernetes-commit: c288f52d2f3a05c305c9e5fb54ca01374b84ffa3
2017-03-18 19:50:25 +00:00
Chao Xu
338a282983 adding note
Kubernetes-commit: cecf0ca7300961b7a1bfba9d7f1c152a8a7db258
2017-03-18 19:50:25 +00:00
Klaus Ma
f64798435d Updated auto generated codes.
Kubernetes-commit: 42fe60105573951f2e7cf0104e82ca559ceb256b
2017-03-18 19:50:24 +00:00
Anthony Yeh
a5e766ba6a Deployment: Update Lister documentation for ControllerRef.
The Deployment Listers still use selectors, because this is the
behavior expected by callers. This clarifies the meaning of the
returned list. Some callers may need to switch to using
GetControllerOf() instead, but that is a separate, case-by-case issue.

Kubernetes-commit: 57fb5e2bba0b55053973398fd8abb3371379c64f
2017-03-18 19:50:24 +00:00
Jeff Lowdermilk
bab65175bb Support whitespace in command path for gcp auth plugin
Specific use case is GKE users running gcloud/kubectl on Windows
with a cloud sdk installation path containing spaces. Also improving
test coverage using trick borrowed from exec_test.go

Kubernetes-commit: 995ecfe84ea92d77cac2921babbbe03f7c2e4967
2017-03-18 19:50:24 +00:00
Anthony Yeh
ad81b3551c StatefulSet: Update Lister documentation for ControllerRef.
The StatefulSet Listers still use selectors, because this is the
behavior expected by callers. This clarifies the meaning of the
returned list. Some callers may need to switch to using
GetControllerOf() instead, but that is a separate, case-by-case issue.

Kubernetes-commit: 25d90cdaec71e38165742a0ebe37411bdd2e66e2
2017-03-18 19:50:24 +00:00
Maciej Szulik
3f88c175ed Staging client changes for cleaning batch/v2alpha1
Kubernetes-commit: 591b2e005c07cf87f4990277d2022665e4c68d21
2017-03-18 19:50:24 +00:00
Vladimir Vivien
6dab156779 Addition of ScaleIO Kubernetes Volume Plugin
This commits implements the Kubernetes volume plugin allowing pods to seamlessly access and use data stored on ScaleIO volumes.

Kubernetes-commit: 915a54180deca06e6befd3bd6a3712b22fb88791
2017-03-18 19:50:24 +00:00
Jan Safranek
7eb14114aa Regenerate everything
Kubernetes-commit: 9487552e4171562a56b3a45ee2de7aa0e5ee9f9d
2017-03-18 19:50:24 +00:00
Jan Safranek
f2dbd57c78 Regenerate everything
Kubernetes-commit: c535c3e20bdb3ad5dcad06433cf97f794cd74210
2017-03-18 19:50:24 +00:00
Klaus Ma
54f3f67453 generated client-go.
Kubernetes-commit: a74fcd0a8d1d68f663bc7e9dee80bba01f1816a8
2017-03-18 19:50:24 +00:00
Anthony Yeh
c11b7bc45b RC/RS: Update Lister documentation for ControllerRef.
The RC/RS Listers still use selectors, because this is the behavior
expected by callers. This clarifies the meaning of the returned list.
Some callers may need to switch to using GetControllerOf() instead,
but that is a separate, case-by-case issue.

Kubernetes-commit: f54a5c9728a91336433ad190e4323b44b4de86a0
2017-03-18 19:50:23 +00:00
deads2k
7395acc6da discovery restmapping should always prefer /v1
Kubernetes-commit: 49f8a37c6488c40c6533cc908467b05038c7ef24
2017-03-18 19:50:23 +00:00
Jordan Liggitt
1f37358b93 Apply custom defaults to init containers
Kubernetes-commit: cfb1cd486e9b4d5ba0ee647c6e8888301b760506
2017-03-18 19:50:23 +00:00
Jordan Liggitt
012d8620e3 Only set a groupresource on errors if a resource was specified
Kubernetes-commit: 69510237598df78c456ebb36a312f86c8a2d2e37
2017-03-18 19:50:23 +00:00
Daniel Smith
d04a6004ff Merge pull request #146 from WilliamDenniss/master
Updated installation instructions.
2017-03-14 16:17:33 -07:00
William Denniss
701d3f42ac Updated installation instructions.
– dep is now alpha, not pre-alpha
– Added a link to the correctly versioned samples for use with these instructions.
2017-03-14 14:02:18 -07:00
Chao Xu
0b5e2de859 check in SHA1 2017-03-08 12:24:47 -08:00
Chao Xu
6c315a68f3 manully sync up to 1634d8f9f72a626b16c55573d78e8da2d75e6356
(merging https://github.com/kubernetes/kubernetes/pull/42084). For the new publish
script to work, client-go has to be synced up to when k8s.io/kubernetes doesn't
include _vendor
2017-03-08 11:31:44 -08:00
Mehdy Bohlool
8147f564df Merge pull request #138 from caesarxuchao/add-warning
Adding note about examples only work with the code in the same branch
2017-03-07 10:24:22 -08:00
Chao Xu
c04eceb596 adding note about examples only work with the code in the same branch 2017-03-06 22:30:23 -08:00
Daniel Smith
ca90456a21 Merge pull request #134 from jbeda/update-readme
Update INSTALL.md to match reality
2017-03-02 10:21:54 -08:00
Joe Beda
af0517a86e Update INSTALL.md to match reality
Signed-off-by: Joe Beda <joe.github@bedafamily.com>
2017-03-01 14:59:48 -08:00
Chao Xu
6500775c58 Merge pull request #130 from caesarxuchao/minor-fix-install.md
minor fix of 'go get' command
2017-02-24 12:55:54 -08:00
Chao Xu
04fe5faa35 minor fix of 'go get' command 2017-02-24 12:54:48 -08:00
Chao Xu
65ac4e638a Merge pull request #129 from caesarxuchao/sync-Feb-23
Sync with k8s.io/kubernetes/staging
2017-02-24 12:36:39 -08:00
Chao Xu
13a1262624 update CHANGELOG 2017-02-23 12:36:54 -08:00
Chao Xu
088dc4a30d manually sync with k8s.io/kubernetest at 17375fc59fff39135af63bd1750bb07c36ef873b, k8s.io/apimachinery at d90aa2c8531f13b0ca734845934c10dcb6a56ca7 2017-02-23 12:27:32 -08:00
Chao Xu
5fbce75e01 Merge pull request #127 from ericchiang/glide-instructions
INSTALL.md: update Glide instructions to prefer glide update
2017-02-23 10:17:38 -08:00
Eric Chiang
416948da08 INSTALL.md: update Glide instructions to prefer glide update
`glide get` has weird dependencies on the glide cache.
`glide install` just updates `glide.lock` but doesn't update /vendor.
`glide init` will detect dependencies from your current project,
making it dependent on the external files.

Just recommend users create a `glide.yaml` manually, then use
`glide update` to populate their /vendor directory. Technically you
could do a dance of `glide init` -> `glide get` -> `glide update`[0]
but this seems less error prone.

Additionally, provide instructions for users who want to use
different versions of packages than `client-go`, and add a note
about glide-vc.

[0] https://github.com/coreos/etcd/blob/v3.1.1/scripts/updatedep.sh
2017-02-22 12:04:09 -08:00
Chao Xu
82a657e390 Merge pull request #124 from atlassian/fix-readme
Fix readme
2017-02-22 08:46:43 -08:00
Daniel Smith
766a1c2983 Merge pull request #125 from caesarxuchao/allow-issues
Fix README: client-go issues should be reported at k8s.io/client-go now
2017-02-21 16:48:51 -08:00
Chao Xu
f163222bdd client-go issues should be reported at this repo now 2017-02-21 16:41:33 -08:00
Mikhail Mazurskiy
b35d0cbc34 Fix readme 2017-02-21 23:23:14 +11:00
Daniel Smith
bcde30fb7e Merge pull request #121 from lavalamp/bt
fix dep install command
2017-02-17 13:41:07 -08:00
Daniel Smith
bf876db9b2 fix dep install command 2017-02-17 13:40:20 -08:00
Daniel Smith
88caeea7ea Merge pull request #118 from hongchaodeng/patch-1
INSTALL.md: fix link to dep
2017-02-17 13:23:29 -08:00
Hongchao Deng
02373be9d7 INSTALL.md: fix link to dep 2017-02-16 15:00:55 -08:00
Daniel Smith
f98510f4d5 Merge pull request #115 from Firemango/patch-2
Fix broken link to Dep
2017-02-16 10:56:57 -08:00
Daniel Smith
abc8616fc4 Merge pull request #116 from lavalamp/bt
Add deprecation status/policy, version recommendation
2017-02-16 10:53:44 -08:00
Daniel Smith
2f1c0eef9a Add deprecation status/policy, version recommendation 2017-02-16 10:52:26 -08:00
Kasper Bentsen
0dff3f49d8 Fix broken link to Dep
Fix broken link to Dep
2017-02-16 19:32:40 +01:00
Daniel Smith
5adfdb2d35 Merge pull request #113 from caesarxuchao/update-INSTALL-for-2.0.0
update INSTALL.md to use 2.0.0 as example
2017-02-16 09:43:01 -08:00
Daniel Smith
65e34307ed Merge pull request #112 from caesarxuchao/changelog
update CHANGELOG
2017-02-16 09:42:38 -08:00
Chao Xu
1ac605be0f update INSTALL.md to use 2.0.0 as example 2017-02-16 04:39:15 -08:00
Chao Xu
543d9386dd update CHANGELOG 2017-02-16 04:33:59 -08:00
Daniel Smith
8b466d64c5 Merge pull request #106 from lavalamp/master
Detailed installation instructions
2017-02-15 10:41:55 -08:00
Daniel Smith
933c034a12 Detailed installation instructions 2017-02-15 10:36:45 -08:00
Daniel Smith
5614504eca Merge pull request #109 from caesarxuchao/minor-readme
minor change to README
2017-02-15 10:26:07 -08:00
Chao Xu
c3e0964ba4 minor change to README 2017-02-15 05:51:00 -08:00
Chao Xu
58d844e6f0 Merge pull request #108 from lavalamp/bt
Update README to explain versioning better
2017-02-15 05:49:16 -08:00
Daniel Smith
a0a777840a Update README to explain versioning better 2017-02-14 17:05:16 -08:00
Chao Xu
86a2be1b44 Merge pull request #101 from caesarxuchao/fix-master
manually fix master, revert to when client-go depends on apimachinery 7080e
2017-02-12 20:05:37 -08:00
Chao Xu
17c583b142 manually fix master, revert to when client-go depends on apimachinery 7080e31e90e981181435294bca96c80a37db8941 2017-02-11 19:16:07 -08:00
Chao Xu
decc012434 Merge pull request #96 from caesarxuchao/master-travis
add back travis
2017-02-11 05:33:53 -08:00
Chao Xu
5396c67ba4 add back travis 2017-02-11 05:33:11 -08:00
Kubernetes Publisher
7ac1236194 published by bot
(https://github.com/kubernetes/test-infra/tree/master/mungegithub)

copied from https://github.com/kubernetes/kubernetes.git, branch master,
last commit is ab794c612853e6c6dfda63594cb5d74914e7e151
2017-02-03 22:09:57 +00:00
Daniel Smith
1679e38db8 Merge pull request #87 from lavalamp/master
enable travis
2017-02-01 17:01:48 -08:00
Daniel Smith
a7f2cee95d enable travis 2017-02-01 16:58:22 -08:00
Daniel Smith
69171ff7bb Merge pull request #86 from lavalamp/master
Fix examples that don't build
2017-02-01 16:30:51 -08:00
Daniel Smith
b7db396afa Fix examples that don't build 2017-02-01 16:28:36 -08:00
Kubernetes Publisher
49948ae0ca published by bot
(https://github.com/kubernetes/test-infra/tree/master/mungegithub)

copied from https://github.com/kubernetes/kubernetes.git, branch master,
last commit is c09311fa32be02ebb79c7959447e3e4294cc12a3
2017-02-01 03:06:37 +00:00
Kubernetes Publisher
b766ef93a4 published by bot
(https://github.com/kubernetes/contrib/tree/master/mungegithub)

copied from https://github.com/kubernetes/kubernetes.git, branch master,
last commit is a2b65f03bf83013d1af05c99b7aa22049ca63de3
2017-01-31 15:19:42 +00:00
Kubernetes Publisher
a88e2b8a0e published by bot
(https://github.com/kubernetes/contrib/tree/master/mungegithub)

copied from https://github.com/kubernetes/kubernetes.git, branch master,
last commit is 914402281b80c60cc901cf1ca223f42c2bc34cf7
2017-01-30 15:19:43 +00:00
Kubernetes Publisher
fb6075f2e0 published by bot
(https://github.com/kubernetes/contrib/tree/master/mungegithub)

copied from https://github.com/kubernetes/kubernetes.git, branch master,
last commit is abed7461722c195f8c77b4c502743e012d19d095
2017-01-27 15:19:42 +00:00
Kubernetes Publisher
f427d46f91 published by bot
(https://github.com/kubernetes/contrib/tree/master/mungegithub)

copied from https://github.com/kubernetes/kubernetes.git, branch master,
last commit is 122bf004bf5d03f96d9f205d4008b6ea8b47d209
2017-01-26 15:19:41 +00:00
Kubernetes Publisher
fcdf37233b published by bot
(https://github.com/kubernetes/contrib/tree/master/mungegithub)

copied from https://github.com/kubernetes/kubernetes.git, branch master,
last commit is baaaf26609565b4299008018486ec75fb30903eb
2017-01-25 15:19:43 +00:00
Kubernetes Publisher
687fd42903 published by bot
(https://github.com/kubernetes/contrib/tree/master/mungegithub)

copied from https://github.com/kubernetes/kubernetes.git, branch master,
last commit is 68f123dfa036bef57495f014a78144a9a1b517ca
2017-01-24 15:19:42 +00:00
Kubernetes Publisher
0eb5431cb7 published by bot
(https://github.com/kubernetes/contrib/tree/master/mungegithub)

copied from https://github.com/kubernetes/kubernetes.git, branch master,
last commit is 8d5227bb2e05e01031ace81fa6611a13f598278e
2017-01-21 15:19:42 +00:00
Kubernetes Publisher
98aceecbfb published by bot
(https://github.com/kubernetes/contrib/tree/master/mungegithub)

copied from https://github.com/kubernetes/kubernetes.git, branch master,
last commit is 4f8f6006cf17a3189fbd51a83fe3864d247d6796
2017-01-20 15:19:41 +00:00
Kubernetes Publisher
14ee64eb52 published by bot
(https://github.com/kubernetes/contrib/tree/master/mungegithub)

copied from https://github.com/kubernetes/kubernetes.git, branch master,
last commit is ac857a5adefb894a8049ebf5295cabb719c9648d
2017-01-19 15:19:43 +00:00
Kubernetes Publisher
8fa0506b26 published by bot
(https://github.com/kubernetes/contrib/tree/master/mungegithub)

copied from https://github.com/kubernetes/kubernetes.git, branch master,
last commit is d9467519245c3858ac58c5fa91ec9e5b16c1f507
2017-01-18 15:19:42 +00:00
Kubernetes Publisher
0e140df9af published by bot
(https://github.com/kubernetes/contrib/tree/master/mungegithub)

copied from https://github.com/kubernetes/kubernetes.git, branch master,
last commit is 3aa29bca4f6f9e43d8e2a8e3a1587d92b1b2dfe2
2017-01-17 15:19:43 +00:00
Kubernetes Publisher
204f12b1f3 published by bot
(https://github.com/kubernetes/contrib/tree/master/mungegithub)

copied from https://github.com/kubernetes/kubernetes.git, branch master,
last commit is 616038db1b0d1e852b4a3d10c8c512a052f91fba
2017-01-14 15:19:47 +00:00
Kubernetes Publisher
8ab7dd3ce9 published by bot
(https://github.com/kubernetes/contrib/tree/master/mungegithub)

copied from https://github.com/kubernetes/kubernetes.git, branch master,
last commit is 3fa44312adcd9ec69a18bf615f672fd30571d7c2
2017-01-13 15:19:43 +00:00
Kubernetes Publisher
24a02a6d7d published by bot
(https://github.com/kubernetes/contrib/tree/master/mungegithub)

copied from https://github.com/kubernetes/kubernetes.git, branch master,
last commit is 856c3623b5e2b134a8fb001c17aa877194225aef
2017-01-02 15:19:42 +00:00
Kubernetes Publisher
5fe6fc56cb published by bot
(https://github.com/kubernetes/contrib/tree/master/mungegithub)

copied from https://github.com/kubernetes/kubernetes.git, branch master,
last commit is 5b2823adb9a8777f7819884fa79a6e1daa26b9c2
2016-12-17 15:19:41 +00:00
Kubernetes Publisher
dd9bc19bbb published by bot
(https://github.com/kubernetes/contrib/tree/master/mungegithub)

copied from https://github.com/kubernetes/kubernetes.git, branch master,
last commit is cbbe421db8157e2f27d25dc1edf1e146e3709384
2016-12-15 15:19:41 +00:00
Chao Xu
e84bb27caf Merge pull request #53 from caesarxuchao/update-thirdparty-example
fix thirdparty example
2016-12-14 12:34:54 -08:00
Chao Xu
b8fd850e88 fix thirdparty example 2016-12-14 11:52:08 -08:00
Kubernetes Publisher
243d8a9cb6 published by bot
(https://github.com/kubernetes/contrib/tree/master/mungegithub)

copied from https://github.com/kubernetes/kubernetes.git, branch master,
last commit is d8c925319a23f6bbf865baa53ae23f48f60dd73b
2016-12-11 15:19:40 +00:00
Kubernetes Publisher
6841809cf1 published by bot
(https://github.com/kubernetes/contrib/tree/master/mungegithub)

copied from https://github.com/kubernetes/kubernetes.git, branch master,
last commit is 9a89e8cdcb0fd8a887822bc3c573cdb2259424c5
2016-12-08 12:17:59 +00:00
Kubernetes Publisher
124670e99d published by bot
(https://github.com/kubernetes/contrib/tree/master/mungegithub)

copied from https://github.com/kubernetes/kubernetes.git, branch master,
last commit is 81d788dd6e0748e5d53a62c16d933c5f7a0718af
2016-12-04 11:39:55 +00:00
Kubernetes Publisher
41a99d711a published by bot
(https://github.com/kubernetes/contrib/tree/master/mungegithub)

copied from https://github.com/kubernetes/kubernetes.git, branch master,
last commit is 238ffdd0d6d79d610cea2ebe3a03868a197283c8
2016-12-03 08:16:09 +00:00
Kubernetes Publisher
5d8c36c93c published by bot
(https://github.com/kubernetes/contrib/tree/master/mungegithub)

copied from https://github.com/kubernetes/kubernetes.git, branch master,
last commit is 124fb610dcbd445fa710da67508ac6d5b822f61d
2016-11-24 08:15:51 +00:00
Chao Xu
ecd05810bd Merge pull request #39 from dtan4/update-examples
Make example codes buildable with the latest client-go
2016-11-21 14:09:49 -08:00
Daisuke Fujita
b51b7defab Make third-party example buildable 2016-11-15 10:47:29 +09:00
Daisuke Fujita
e60355686b Make in-cluster example buildable 2016-11-15 10:43:26 +09:00
Daisuke Fujita
d83a7abb0c Make out-of-cluster example buildable 2016-11-15 10:42:44 +09:00
Kubernetes Publisher
89c6009983 published by bot
(https://github.com/kubernetes/contrib/tree/master/mungegithub)

copied from https://github.com/kubernetes/kubernetes.git, branch master,
last commit is 800ef09dc19c04789c49c2e83e963bbd986cda7a
2016-11-12 03:39:06 +00:00
Chao Xu
febd848390 Merge pull request #29 from wfarr/thirdpartyresources-examples
Thirdpartyresources examples
2016-11-10 21:45:48 -08:00
Kubernetes Publisher
ae6775eeec published by bot
(https://github.com/kubernetes/contrib/tree/master/mungegithub)

copied from https://github.com/kubernetes/kubernetes.git, branch master,
last commit is 1bc5b822cd566321c115d4ebac5d97cfd347d687
2016-11-11 03:39:04 +00:00
Kubernetes Publisher
24b73253cd published by bot
(https://github.com/kubernetes/contrib/tree/master/mungegithub)

copied from https://github.com/kubernetes/kubernetes.git, branch master,
last commit is 8558768650b1da489aa63050bc03f1d42912c968
2016-11-08 03:38:56 +00:00
Kubernetes Publisher
49f8f1bf91 published by bot
(https://github.com/kubernetes/contrib/tree/master/mungegithub)

copied from https://github.com/kubernetes/kubernetes.git, branch master,
last commit is d1d8e428b14907b2cf67ba78cce2dae4c2fdf15b
2016-11-07 13:04:45 +00:00
Kubernetes Publisher
0742ae7ca5 published by bot
(https://github.com/kubernetes/contrib/tree/master/mungegithub)

copied from https://github.com/kubernetes/kubernetes.git, branch master,
last commit is 66a7a1f961489b81e0357a6307270d50b00c5f50
2016-11-05 06:43:38 +00:00
Will Farrington
cf262eae7d CLA bump 2016-11-04 15:29:34 -04:00
Will Farrington
d6263b114f Add README 2016-11-04 15:21:23 -04:00
Will Farrington
6fb6707824 Add an example for standard CRUD operations with ThirdPartyResources 2016-11-04 14:50:22 -04:00
1662 changed files with 220415 additions and 271196 deletions

8
.travis.yml Normal file
View File

@@ -0,0 +1,8 @@
language: go
go_import_path: k8s.io/client-go
go:
- 1.8.1
script: go build ./...

View File

@@ -1,7 +1,45 @@
TODO: This document was neglected and is currently not complete. Working on
fixing this.
# HEAD (changes that will go into the next release)
# 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
* Included bug fixes in k8s.io/kuberentes release-1.5 branch, up to commit
bde8578d9675129b7a2aa08f1b825ec6cc0f3420
# v2.0.0-alpha.1
* Removed top-level version folder (e.g., 1.4 and 1.5), switching to maintaining separate versions
in separate branches.
* Clientset supported multiple versions per API group
* Added ThirdPartyResources example
* Kubernetes API changes
* Apps API group graduated to v1beta1
* Policy API group graduated to v1beta1
* Added support for batch/v2alpha1/cronjob
* Renamed PetSet to StatefulSet
# v1.5.0
## Changelog since v1.4.0
### Added
* Include the auth plugin (https://github.com/kubernetes/kubernetes/pull/33334)
* Add timeout field to RESTClient config (https://github.com/kubernetes/kubernetes/pull/33958)
* Included the auth plugin (https://github.com/kubernetes/kubernetes/pull/33334)
* Added timeout field to RESTClient config (https://github.com/kubernetes/kubernetes/pull/33958)

371
Godeps/Godeps.json generated
View File

@@ -1,7 +1,7 @@
{
"ImportPath": "k8s.io/client-go",
"GoVersion": "go1.6",
"GodepVersion": "v74",
"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",
@@ -25,30 +45,25 @@
"ImportPath": "github.com/PuerkitoBio/urlesc",
"Rev": "5bd2802263f21d8788851d5305584c82a5c75d7e"
},
{
"ImportPath": "github.com/blang/semver",
"Comment": "v3.0.1",
"Rev": "31b736133b98f26d5e078ec9eb591666edfd091f"
},
{
"ImportPath": "github.com/coreos/go-oidc/http",
"Rev": "5644a2f50e2d2d5ba0b474bc5bc55fea1925936d"
"Rev": "be73733bb8cc830d0205609b95d125215f8e9c70"
},
{
"ImportPath": "github.com/coreos/go-oidc/jose",
"Rev": "5644a2f50e2d2d5ba0b474bc5bc55fea1925936d"
"Rev": "be73733bb8cc830d0205609b95d125215f8e9c70"
},
{
"ImportPath": "github.com/coreos/go-oidc/key",
"Rev": "5644a2f50e2d2d5ba0b474bc5bc55fea1925936d"
"Rev": "be73733bb8cc830d0205609b95d125215f8e9c70"
},
{
"ImportPath": "github.com/coreos/go-oidc/oauth2",
"Rev": "5644a2f50e2d2d5ba0b474bc5bc55fea1925936d"
"Rev": "be73733bb8cc830d0205609b95d125215f8e9c70"
},
{
"ImportPath": "github.com/coreos/go-oidc/oidc",
"Rev": "5644a2f50e2d2d5ba0b474bc5bc55fea1925936d"
"Rev": "be73733bb8cc830d0205609b95d125215f8e9c70"
},
{
"ImportPath": "github.com/coreos/pkg/health",
@@ -69,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",
@@ -89,23 +109,27 @@
},
{
"ImportPath": "github.com/emicklei/go-restful",
"Comment": "v1.2-79-g89ef8af",
"Rev": "89ef8af493ab468a45a42bb0d89a06fccdd2fb22"
"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-79-g89ef8af",
"Rev": "89ef8af493ab468a45a42bb0d89a06fccdd2fb22"
},
{
"ImportPath": "github.com/emicklei/go-restful/swagger",
"Comment": "v1.2-79-g89ef8af",
"Rev": "89ef8af493ab468a45a42bb0d89a06fccdd2fb22"
"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"
@@ -114,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"
@@ -124,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",
@@ -142,15 +170,23 @@
},
{
"ImportPath": "github.com/golang/protobuf/proto",
"Rev": "8616e8ee5e20a1704615e6c8d7afcdac06087a67"
"Rev": "4bd1920723d7b7c925de087aa32e2187708897f7"
},
{
"ImportPath": "github.com/google/gofuzz",
"Rev": "bbcb9da2d746f8bdbd6a936686a0a6067ada0ec5"
"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",
@@ -163,7 +199,7 @@
},
{
"ImportPath": "github.com/juju/ratelimit",
"Rev": "77ed1c8a01217656d2080ad51981f6e99adaa177"
"Rev": "5b9ff866471762aa2ab2dced63c9fb6f53921342"
},
{
"ImportPath": "github.com/mailru/easyjson/buffer",
@@ -178,64 +214,69 @@
"Rev": "d5b7844b561a7bc640052f1b935f7b800330d7e0"
},
{
"ImportPath": "github.com/pborman/uuid",
"Rev": "ca53cad383cad2479bbba7f7a1a05797ec1386e4"
"ImportPath": "github.com/pmezard/go-difflib/difflib",
"Rev": "d8ed2627bdf02c080bf22230dbb337003b7aba2d"
},
{
"ImportPath": "github.com/spf13/pflag",
"Rev": "c7e63cf4530bcd3ba943729cee0efeff2ebea63f"
"Rev": "9ff6c6923cfffbcd502984b8e0c80539a94968b7"
},
{
"ImportPath": "github.com/stretchr/testify/assert",
"Comment": "v1.0-88-ge3a8ff8",
"Rev": "e3a8ff8ce36581f87a15341206f205b1da467059"
},
{
"ImportPath": "github.com/ugorji/go/codec",
"Rev": "f1f1a805ed361a0e078bb537e4ea78cd37dcf065"
"Rev": "ded73eae5db7e7a0ef6f55aace87a2873c5d2b74"
},
{
"ImportPath": "golang.org/x/crypto/ssh/terminal",
"Rev": "1f22c0103821b9390939b6776727195525381532"
"Rev": "d172538b2cfce0c13cee31e647d0367aa8cd2486"
},
{
"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",
@@ -281,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",
@@ -321,6 +330,214 @@
{
"ImportPath": "gopkg.in/yaml.v2",
"Rev": "53feefa2559fb8dfa8d81baad31be332c97d6c77"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/api/equality",
"Rev": "1fd2e63a9a370677308a42f24fd40c86438afddf"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/api/errors",
"Rev": "1fd2e63a9a370677308a42f24fd40c86438afddf"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/api/meta",
"Rev": "1fd2e63a9a370677308a42f24fd40c86438afddf"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/api/resource",
"Rev": "1fd2e63a9a370677308a42f24fd40c86438afddf"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/api/testing",
"Rev": "1fd2e63a9a370677308a42f24fd40c86438afddf"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/apimachinery",
"Rev": "1fd2e63a9a370677308a42f24fd40c86438afddf"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/apimachinery/announced",
"Rev": "1fd2e63a9a370677308a42f24fd40c86438afddf"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/apimachinery/registered",
"Rev": "1fd2e63a9a370677308a42f24fd40c86438afddf"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1",
"Rev": "1fd2e63a9a370677308a42f24fd40c86438afddf"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured",
"Rev": "1fd2e63a9a370677308a42f24fd40c86438afddf"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1alpha1",
"Rev": "1fd2e63a9a370677308a42f24fd40c86438afddf"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/conversion",
"Rev": "1fd2e63a9a370677308a42f24fd40c86438afddf"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/conversion/queryparams",
"Rev": "1fd2e63a9a370677308a42f24fd40c86438afddf"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/conversion/unstructured",
"Rev": "1fd2e63a9a370677308a42f24fd40c86438afddf"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/fields",
"Rev": "1fd2e63a9a370677308a42f24fd40c86438afddf"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/labels",
"Rev": "1fd2e63a9a370677308a42f24fd40c86438afddf"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/openapi",
"Rev": "1fd2e63a9a370677308a42f24fd40c86438afddf"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/runtime",
"Rev": "1fd2e63a9a370677308a42f24fd40c86438afddf"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/runtime/schema",
"Rev": "1fd2e63a9a370677308a42f24fd40c86438afddf"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer",
"Rev": "1fd2e63a9a370677308a42f24fd40c86438afddf"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/json",
"Rev": "1fd2e63a9a370677308a42f24fd40c86438afddf"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/protobuf",
"Rev": "1fd2e63a9a370677308a42f24fd40c86438afddf"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/recognizer",
"Rev": "1fd2e63a9a370677308a42f24fd40c86438afddf"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/streaming",
"Rev": "1fd2e63a9a370677308a42f24fd40c86438afddf"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/versioning",
"Rev": "1fd2e63a9a370677308a42f24fd40c86438afddf"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/selection",
"Rev": "1fd2e63a9a370677308a42f24fd40c86438afddf"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/types",
"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": "1fd2e63a9a370677308a42f24fd40c86438afddf"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/errors",
"Rev": "1fd2e63a9a370677308a42f24fd40c86438afddf"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/framer",
"Rev": "1fd2e63a9a370677308a42f24fd40c86438afddf"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/httpstream",
"Rev": "1fd2e63a9a370677308a42f24fd40c86438afddf"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/httpstream/spdy",
"Rev": "1fd2e63a9a370677308a42f24fd40c86438afddf"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/intstr",
"Rev": "1fd2e63a9a370677308a42f24fd40c86438afddf"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/json",
"Rev": "1fd2e63a9a370677308a42f24fd40c86438afddf"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/mergepatch",
"Rev": "1fd2e63a9a370677308a42f24fd40c86438afddf"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/net",
"Rev": "1fd2e63a9a370677308a42f24fd40c86438afddf"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/rand",
"Rev": "1fd2e63a9a370677308a42f24fd40c86438afddf"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/remotecommand",
"Rev": "1fd2e63a9a370677308a42f24fd40c86438afddf"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/runtime",
"Rev": "1fd2e63a9a370677308a42f24fd40c86438afddf"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/sets",
"Rev": "1fd2e63a9a370677308a42f24fd40c86438afddf"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/strategicpatch",
"Rev": "1fd2e63a9a370677308a42f24fd40c86438afddf"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/validation",
"Rev": "1fd2e63a9a370677308a42f24fd40c86438afddf"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/validation/field",
"Rev": "1fd2e63a9a370677308a42f24fd40c86438afddf"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/wait",
"Rev": "1fd2e63a9a370677308a42f24fd40c86438afddf"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/yaml",
"Rev": "1fd2e63a9a370677308a42f24fd40c86438afddf"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/version",
"Rev": "1fd2e63a9a370677308a42f24fd40c86438afddf"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/watch",
"Rev": "1fd2e63a9a370677308a42f24fd40c86438afddf"
},
{
"ImportPath": "k8s.io/apimachinery/third_party/forked/golang/json",
"Rev": "1fd2e63a9a370677308a42f24fd40c86438afddf"
},
{
"ImportPath": "k8s.io/apimachinery/third_party/forked/golang/netutil",
"Rev": "1fd2e63a9a370677308a42f24fd40c86438afddf"
},
{
"ImportPath": "k8s.io/apimachinery/third_party/forked/golang/reflect",
"Rev": "1fd2e63a9a370677308a42f24fd40c86438afddf"
}
]
}

180
INSTALL.md Normal file
View File

@@ -0,0 +1,180 @@
# Installing client-go
## For the casual user
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
on every dependency has not necessarily been tested with client-go. In fact,
HEAD from all dependencies may not even compile with client-go!
## Dependency management for the serious (or reluctant) user
Reasons why you might need to use a dependency management system:
* You use a dependency that client-go also uses, and don't want two copies of
the dependency compiled into your application. For some dependencies with
singletons or global inits (e.g. `glog`) this wouldn't even compile...
* You want to lock in a particular version (so you don't have to change your
code every time we change a public interface).
* You want your install to be reproducible. For example, for your CI system or
for new team members.
There are three tools you could in theory use for this. Instructions
for each follows.
### Godep
[godep](https://github.com/tools/godep) is an older dependency management tool, which is
used by the main Kubernetes repo and `client-go` to manage dependencies.
Before proceeding with the below instructions, you should ensure that your
$GOPATH is empty except for containing your own package and its dependencies,
and you have a copy of godep somewhere in your $PATH.
To install `client-go` and place its dependencies in your `$GOPATH`:
```sh
go get k8s.io/client-go/...
cd $GOPATH/src/k8s.io/client-go
git checkout v2.0.0
# cd 1.5 # only necessary with 1.5 and 1.4 clients.
godep restore ./...
```
At this point, `client-go`'s dependencies have been placed in your $GOPATH, but
if you were to build, `client-go` would still see its own copy of its
dependencies in its `vendor` directory. You have two options at this point.
If you would like to keep dependencies in your own project's vendor directory,
then you can continue like this:
```sh
cd $GOPATH/src/<my-pkg>
godep save ./...
```
Alternatively, if you want to build using the dependencies in your `$GOPATH`,
then `rm -rf vendor/` to remove `client-go`'s copy of its dependencies.
### Glide
[Glide](https://github.com/Masterminds/glide) is another popular dependency
management tool for Go. Glide will manage your /vendor directory, but unlike
godep, will not use or modify your $GOPATH (there's no equivalent of
`godep restore` or `godep save`).
Generally, it's best to avoid Glide's many subcommands, favoring modifying
Glide's manifest file (`glide.yaml`) directly, then running
`glide update --strip-vendor`. First create a `glide.yaml` file at the root of
your project:
```yaml
package: ( your project's import path ) # e.g. github.com/foo/bar
import:
- package: k8s.io/client-go
version: v2.0.0
```
Second, add a Go file that imports `client-go` somewhere in your project,
otherwise `client-go`'s dependencies will not be added to your project's
vendor/. Then run the following command in the same directory as `glide.yaml`:
```sh
glide update --strip-vendor
```
This can also be abbreviated as:
```sh
glide up -v
```
At this point, `k8s.io/client-go` should be added to your project's vendor/.
`client-go`'s dependencies should be flattened and be added to your project's
vendor/ as well.
Glide will detect the versions of dependencies `client-go` specified in
`client-go`'s Godep.json file, and automatically set the versions of these
imports in your /vendor directory. It will also record the detected version of
all dependencies in the `glide.lock` file.
Projects that require a different version of a dependency than `client-go`
requests can override the version manually in `glide.yaml`. For example:
```yaml
package: ( your project's import path ) # e.g. github.com/foo/bar
import:
- package: k8s.io/client-go
version: v2.0.0
# Use a newer version of go-spew even though client-go wants an old one.
- package: github.com/davecgh/go-spew
version: v1.1.0
```
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.

View File

@@ -187,7 +187,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright 2014 The Kubernetes Authors.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.

45
OWNERS Normal file
View File

@@ -0,0 +1,45 @@
approvers:
- caesarxuchao
- deads2k
- krousey
- lavalamp
- smarterclayton
- sttts
reviewers:
- thockin
- lavalamp
- smarterclayton
- wojtek-t
- deads2k
- yujuhong
- derekwaynecarr
- caesarxuchao
- vishh
- mikedanese
- liggitt
- nikhiljindal
- bprashanth
- gmarek
- erictune
- davidopp
- pmorie
- sttts
- kargakis
- dchen1107
- saad-ali
- zmerlynn
- luxas
- janetkuo
- justinsb
- roberthbailey
- ncdc
- timstclair
- yifan-gu
- eparis
- mwielgus
- timothysc
- feiskyer
- jlowdermilk
- soltysh
- piosz
- jsafrane

110
README.md
View File

@@ -2,6 +2,13 @@
Go clients for talking to a [kubernetes](http://kubernetes.io/) cluster.
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.
[![Build Status](https://travis-ci.org/kubernetes/client-go.svg?branch=master)](https://travis-ci.org/kubernetes/client-go)
[![GoDoc](https://godoc.org/k8s.io/client-go?status.svg)](https://godoc.org/k8s.io/client-go)
## Table of Contents
- [What's included](#whats-included)
@@ -13,7 +20,6 @@ Go clients for talking to a [kubernetes](http://kubernetes.io/) cluster.
- [How to get it](#how-to-get-it)
- [How to use it](#how-to-use-it)
- [Dependency management](#dependency-management)
- [Reporting bugs](#reporting-bugs)
- [Contributing code](#contributing-code)
### What's included
@@ -26,40 +32,108 @@ Go clients for talking to a [kubernetes](http://kubernetes.io/) cluster.
### Versioning
`client-go` version numbers are unrelated to Kubernetes version numbers. Please see the [compatibility matrix](#compatibility-matrix) for the compatible Kubernetes clusters.
`client-go` follows [semver](http://semver.org/). We will not make
backwards-incompatible changes without incrementing the major version number. A
change is backwards-incompatible either if it *i)* changes the public interfaces
of `client-go`, or *ii)* makes `client-go` incompatible with otherwise supported
versions of Kubernetes clusters.
`client-go` follows [semver](http://semver.org/). We will not make backwards-incompatible changes without incrementing the major version number. A change is backwards-incompatible either if it *i)* changes the public interfaces of `client-go`, or *ii)* makes `client-go` incompatible with otherwise supported versions of Kubernetes clusters.
Changes that add features in a backwards-compatible way will result in bumping
the minor version (second digit) number.
We will create a new branch for each increment in the major version number or minor version number. We will create a new tag for each increment in the patch version number. See [semver](http://semver.org/) for definitions of major, minor, and patch.
Bugfixes will result in the patch version (third digit) changing. PRs that are
cherry-picked into an older Kubernetes release branch will result in an update
to the corresponding branch in `client-go`, with a corresponding new tag
changing the patch version.
The master branch will track the head in the main Kubernetes repo and accumulating changes. We will make a new client-go major/minor/patch version when:
* A new major (very rare) or a new minor version is released in the Kubernetes main repository.
* A feature or a bug fix in the master branch is popular and users want it in a stable branch or with a stable tag.
A consequence of this is that `client-go` version numbers will be unrelated to
Kubernetes version numbers.
#### Branches and tags.
We will create a new branch and tag for each increment in the major version number or
minor version number. We will create only a new tag for each increment in the patch
version number. See [semver](http://semver.org/) for definitions of major,
minor, and patch.
The master branch will track HEAD in the main Kubernetes repo and
accumulate changes. Consider HEAD to have the version `x.(y+1).0-alpha` or
`(x+1).0.0-alpha` (depending on whether it has accumulated a breaking change or
not), where `x` and `y` are the current major and minor versions.
#### Compatibility: your code <-> client-go
`client-go` follows [semver](http://semver.org/), so until the major version of client-go gets increased, your code will compile and will continue to work with explicitly supported versions of Kubernetes clusters.
`client-go` follows [semver](http://semver.org/), so until the major version of
client-go gets increased, your code will compile and will continue to work with
explicitly supported versions of Kubernetes clusters. You must use a dependency
management system and pin a specific major version of `client-go` to get this
benefit, as HEAD follows the upstream Kubernetes repo.
#### Compatibility: client-go <-> Kubernetes clusters
`client-go` versions will be backwards compatible with many Kubernetes clusters. As we increment `client-go` versions, we will note which Kubernetes versions we expect them to work with.
Since Kubernetes is backwards compatible with clients, older `client-go`
versions will work with many different Kubernetes cluster versions.
We will backport bugfixes--but not new features--into older versions of
`client-go`.
We do not back-port new Kubernetes features into older clients. If you need a new feature, you are expected to upgrade to the new client. You can check out the [CHANGELOG](./CHANGELOG.md) for notable changes.
#### Compatibility matrix
* **client-go/1.4** is compatible with Kubernetes 1.3 through 1.5; it includes all features provided by Kubernetes 1.4.
* **client-go/1.5** is compatible with Kubernetes 1.3 through 1.5; it includes all features provided by Kubernetes 1.4.
| | 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
version.
* `+` 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
(additional API objects, etc).
See the [CHANGELOG](./CHANGELOG.md) for a detailed description of changes
between client-go versions.
| Branch | Canonical source code location | Maintenance status |
|----------------|--------------------------------------|-------------------------------|
| 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.
#### Deprecation policy
We will maintain branches for at least six months after their first stable tag
is cut. (E.g., the clock for the release-2.0 branch started ticking when we
tagged v2.0.0, not when we made the first alpha.) This policy applies to
every version greater than or equal to 2.0.
#### Why do the 1.4 and 1.5 branch contain top-level folder named after the version?
1.4 and 1.5 branch keep the top-level folders so they do not break the import lines of existing users. These top-level folders are deprecated and are removed from the master branch and future branches.
For the initial release of client-go, we thought it would be easiest to keep
separate directories for each minor version. That soon proved to be a mistake.
We are keeping the top-level folders in the 1.4 and 1.5 branches so that
existing users won't be broken.
### How to get it
If you use `go get` to get client-go, **you will get the unstable master branch!** You can `git checkout` a stable branch.
We recommend using a vendor tool, like [godep](https://github.com/tools/godep), [glide](https://github.com/Masterminds/glide), or [govendor](https://github.com/kardianos/govendor) to track a stable version of `client-go`.
You can use `go get k8s.io/client-go/...` to get client-go, but **you will get
the unstable master branch** and `client-go`'s vendored dependencies will not be
added to your `$GOPATH`. So we think most users will want to use a dependency
management system. See [INSTALL.md](/INSTALL.md) for detailed instructions.
### How to use it
@@ -71,9 +145,5 @@ If your application depends on a package that client-go depends on, and you let
* run `godep restore` ([godep](https://github.com/tools/godep)) in the client-go/ folder, then remove the vendor folder of client-go. Then the packages in your GOPATH will be the only copy
* or run `godep save` in your application folder to flatten all dependencies.
### Reporting bugs
Please report bugs to the main Kubernetes [repository](https://github.com/kubernetes/kubernetes/issues/new).
### Contributing code
Please send pull requests against the client packages in the Kubernetes main [repository](https://github.com/kubernetes/kubernetes), and run the `/staging/copy.sh` script to update the staging area in the main repository. Changes in the staging area will be published to this repository every day.

63
discovery/BUILD Normal file
View 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",
],
)

View File

@@ -23,47 +23,63 @@ import (
"sort"
"strings"
"github.com/emicklei/go-restful/swagger"
"github.com/emicklei/go-restful-swagger12"
"k8s.io/client-go/pkg/api"
"k8s.io/client-go/pkg/api/errors"
"k8s.io/client-go/pkg/api/unversioned"
"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/kubernetes/scheme"
"k8s.io/client-go/pkg/api/v1"
"k8s.io/client-go/pkg/runtime"
"k8s.io/client-go/pkg/runtime/serializer"
"k8s.io/client-go/pkg/version"
"k8s.io/client-go/rest"
restclient "k8s.io/client-go/rest"
)
// defaultRetries is the number of times a resource discovery is repeated if an api group disappears on the fly (e.g. ThirdPartyResources).
const defaultRetries = 2
// DiscoveryInterface holds the methods that discover server-supported API groups,
// versions and resources.
type DiscoveryInterface interface {
RESTClient() rest.Interface
RESTClient() restclient.Interface
ServerGroupsInterface
ServerResourcesInterface
ServerVersionInterface
SwaggerSchemaInterface
OpenAPISchemaInterface
}
// CachedDiscoveryInterface is a DiscoveryInterface with cache invalidation and freshness.
type CachedDiscoveryInterface interface {
DiscoveryInterface
// Fresh returns true if no cached data was used that had been retrieved before the instantiation.
Fresh() bool
// Invalidate enforces that no cached data is used in the future that is older than the current time.
Invalidate()
}
// ServerGroupsInterface has methods for obtaining supported groups on the API server
type ServerGroupsInterface interface {
// ServerGroups returns the supported groups, with information like supported versions and the
// preferred version.
ServerGroups() (*unversioned.APIGroupList, error)
ServerGroups() (*metav1.APIGroupList, error)
}
// ServerResourcesInterface has methods for obtaining supported resources on the API server
type ServerResourcesInterface interface {
// ServerResourcesForGroupVersion returns the supported resources for a group and version.
ServerResourcesForGroupVersion(groupVersion string) (*unversioned.APIResourceList, error)
ServerResourcesForGroupVersion(groupVersion string) (*metav1.APIResourceList, error)
// ServerResources returns the supported resources for all groups and versions.
ServerResources() (map[string]*unversioned.APIResourceList, error)
ServerResources() ([]*metav1.APIResourceList, error)
// ServerPreferredResources returns the supported resources with the version preferred by the
// server.
ServerPreferredResources() ([]unversioned.GroupVersionResource, error)
ServerPreferredResources() ([]*metav1.APIResourceList, error)
// ServerPreferredNamespacedResources returns the supported namespaced resources with the
// version preferred by the server.
ServerPreferredNamespacedResources() ([]unversioned.GroupVersionResource, error)
ServerPreferredNamespacedResources() ([]*metav1.APIResourceList, error)
}
// ServerVersionInterface has a method for retrieving the server's version.
@@ -75,23 +91,29 @@ type ServerVersionInterface interface {
// SwaggerSchemaInterface has a method to retrieve the swagger schema.
type SwaggerSchemaInterface interface {
// SwaggerSchema retrieves and parses the swagger API schema the server supports.
SwaggerSchema(version unversioned.GroupVersion) (*swagger.ApiDeclaration, error)
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 {
restClient rest.Interface
restClient restclient.Interface
LegacyPrefix string
}
// Convert unversioned.APIVersions to unversioned.APIGroup. APIVersions is used by legacy v1, so
// Convert metav1.APIVersions to metav1.APIGroup. APIVersions is used by legacy v1, so
// group would be "".
func apiVersionsToAPIGroup(apiVersions *unversioned.APIVersions) (apiGroup unversioned.APIGroup) {
groupVersions := []unversioned.GroupVersionForDiscovery{}
func apiVersionsToAPIGroup(apiVersions *metav1.APIVersions) (apiGroup metav1.APIGroup) {
groupVersions := []metav1.GroupVersionForDiscovery{}
for _, version := range apiVersions.Versions {
groupVersion := unversioned.GroupVersionForDiscovery{
groupVersion := metav1.GroupVersionForDiscovery{
GroupVersion: version,
Version: version,
}
@@ -105,12 +127,12 @@ func apiVersionsToAPIGroup(apiVersions *unversioned.APIVersions) (apiGroup unver
// ServerGroups returns the supported groups, with information like supported versions and the
// preferred version.
func (d *DiscoveryClient) ServerGroups() (apiGroupList *unversioned.APIGroupList, err error) {
func (d *DiscoveryClient) ServerGroups() (apiGroupList *metav1.APIGroupList, err error) {
// Get the groupVersions exposed at /api
v := &unversioned.APIVersions{}
v := &metav1.APIVersions{}
err = d.restClient.Get().AbsPath(d.LegacyPrefix).Do().Into(v)
apiGroup := unversioned.APIGroup{}
if err == nil {
apiGroup := metav1.APIGroup{}
if err == nil && len(v.Versions) != 0 {
apiGroup = apiVersionsToAPIGroup(v)
}
if err != nil && !errors.IsNotFound(err) && !errors.IsForbidden(err) {
@@ -118,23 +140,25 @@ func (d *DiscoveryClient) ServerGroups() (apiGroupList *unversioned.APIGroupList
}
// Get the groupVersions exposed at /apis
apiGroupList = &unversioned.APIGroupList{}
apiGroupList = &metav1.APIGroupList{}
err = d.restClient.Get().AbsPath("/apis").Do().Into(apiGroupList)
if err != nil && !errors.IsNotFound(err) && !errors.IsForbidden(err) {
return nil, err
}
// to be compatible with a v1.0 server, if it's a 403 or 404, ignore and return whatever we got from /api
if err != nil && (errors.IsNotFound(err) || errors.IsForbidden(err)) {
apiGroupList = &unversioned.APIGroupList{}
apiGroupList = &metav1.APIGroupList{}
}
// append the group retrieved from /api to the list
apiGroupList.Groups = append(apiGroupList.Groups, apiGroup)
// append the group retrieved from /api to the list if not empty
if len(v.Versions) != 0 {
apiGroupList.Groups = append(apiGroupList.Groups, apiGroup)
}
return apiGroupList, nil
}
// ServerResourcesForGroupVersion returns the supported resources for a group and version.
func (d *DiscoveryClient) ServerResourcesForGroupVersion(groupVersion string) (resources *unversioned.APIResourceList, err error) {
func (d *DiscoveryClient) ServerResourcesForGroupVersion(groupVersion string) (resources *metav1.APIResourceList, err error) {
url := url.URL{}
if len(groupVersion) == 0 {
return nil, fmt.Errorf("groupVersion shouldn't be empty")
@@ -144,7 +168,9 @@ func (d *DiscoveryClient) ServerResourcesForGroupVersion(groupVersion string) (r
} else {
url.Path = "/apis/" + groupVersion
}
resources = &unversioned.APIResourceList{}
resources = &metav1.APIResourceList{
GroupVersion: groupVersion,
}
err = d.restClient.Get().AbsPath(url.String()).Do().Into(resources)
if err != nil {
// ignore 403 or 404 error to be compatible with an v1.0 server.
@@ -156,28 +182,49 @@ func (d *DiscoveryClient) ServerResourcesForGroupVersion(groupVersion string) (r
return resources, nil
}
// ServerResources returns the supported resources for all groups and versions.
func (d *DiscoveryClient) ServerResources() (map[string]*unversioned.APIResourceList, error) {
// serverResources returns the supported resources for all groups and versions.
func (d *DiscoveryClient) serverResources(failEarly bool) ([]*metav1.APIResourceList, error) {
apiGroups, err := d.ServerGroups()
if err != nil {
return nil, err
}
groupVersions := unversioned.ExtractGroupVersions(apiGroups)
result := map[string]*unversioned.APIResourceList{}
for _, groupVersion := range groupVersions {
resources, err := d.ServerResourcesForGroupVersion(groupVersion)
if err != nil {
return nil, err
result := []*metav1.APIResourceList{}
failedGroups := make(map[schema.GroupVersion]error)
for _, apiGroup := range apiGroups.Groups {
for _, version := range apiGroup.Versions {
gv := schema.GroupVersion{Group: apiGroup.Name, Version: version.Version}
resources, err := d.ServerResourcesForGroupVersion(version.GroupVersion)
if err != nil {
// TODO: maybe restrict this to NotFound errors
failedGroups[gv] = err
if failEarly {
return nil, &ErrGroupDiscoveryFailed{Groups: failedGroups}
}
continue
}
result = append(result, resources)
}
result[groupVersion] = resources
}
return result, nil
if len(failedGroups) == 0 {
return result, nil
}
return result, &ErrGroupDiscoveryFailed{Groups: failedGroups}
}
// ServerResources returns the supported resources for all groups and versions.
func (d *DiscoveryClient) ServerResources() ([]*metav1.APIResourceList, error) {
return withRetries(defaultRetries, d.serverResources)
}
// ErrGroupDiscoveryFailed is returned if one or more API groups fail to load.
type ErrGroupDiscoveryFailed struct {
// Groups is a list of the groups that failed to load and the error cause
Groups map[unversioned.GroupVersion]error
Groups map[schema.GroupVersion]error
}
// Error implements the error interface
@@ -197,61 +244,86 @@ func IsGroupDiscoveryFailedError(err error) bool {
return err != nil && ok
}
// serverPreferredResources returns the supported resources with the version preferred by the
// server. If namespaced is true, only namespaced resources will be returned.
func (d *DiscoveryClient) serverPreferredResources(namespaced bool) ([]unversioned.GroupVersionResource, error) {
// retry in case the groups supported by the server change after ServerGroup() returns.
const maxRetries = 2
var failedGroups map[unversioned.GroupVersion]error
var results []unversioned.GroupVersionResource
RetrieveGroups:
for i := 0; i < maxRetries; i++ {
results = []unversioned.GroupVersionResource{}
failedGroups = make(map[unversioned.GroupVersion]error)
serverGroupList, err := d.ServerGroups()
if err != nil {
return results, err
}
// serverPreferredResources returns the supported resources with the version preferred by the server.
func (d *DiscoveryClient) serverPreferredResources(failEarly bool) ([]*metav1.APIResourceList, error) {
serverGroupList, err := d.ServerGroups()
if err != nil {
return nil, err
}
for _, apiGroup := range serverGroupList.Groups {
preferredVersion := apiGroup.PreferredVersion
groupVersion := unversioned.GroupVersion{Group: apiGroup.Name, Version: preferredVersion.Version}
apiResourceList, err := d.ServerResourcesForGroupVersion(preferredVersion.GroupVersion)
result := []*metav1.APIResourceList{}
failedGroups := make(map[schema.GroupVersion]error)
grVersions := map[schema.GroupResource]string{} // selected version of a GroupResource
grApiResources := map[schema.GroupResource]*metav1.APIResource{} // selected APIResource for a GroupResource
gvApiResourceLists := map[schema.GroupVersion]*metav1.APIResourceList{} // blueprint for a APIResourceList for later grouping
for _, apiGroup := range serverGroupList.Groups {
for _, version := range apiGroup.Versions {
groupVersion := schema.GroupVersion{Group: apiGroup.Name, Version: version.Version}
apiResourceList, err := d.ServerResourcesForGroupVersion(version.GroupVersion)
if err != nil {
if i < maxRetries-1 {
continue RetrieveGroups
}
// TODO: maybe restrict this to NotFound errors
failedGroups[groupVersion] = err
if failEarly {
return nil, &ErrGroupDiscoveryFailed{Groups: failedGroups}
}
continue
}
for _, apiResource := range apiResourceList.APIResources {
// ignore the root scoped resources if "namespaced" is true.
if namespaced && !apiResource.Namespaced {
continue
}
// create empty list which is filled later in another loop
emptyApiResourceList := metav1.APIResourceList{
GroupVersion: version.GroupVersion,
}
gvApiResourceLists[groupVersion] = &emptyApiResourceList
result = append(result, &emptyApiResourceList)
for i := range apiResourceList.APIResources {
apiResource := &apiResourceList.APIResources[i]
if strings.Contains(apiResource.Name, "/") {
continue
}
results = append(results, groupVersion.WithResource(apiResource.Name))
gv := schema.GroupResource{Group: apiGroup.Name, Resource: apiResource.Name}
if _, ok := grApiResources[gv]; ok && version.Version != apiGroup.PreferredVersion.Version {
// only override with preferred version
continue
}
grVersions[gv] = version.Version
grApiResources[gv] = apiResource
}
}
if len(failedGroups) == 0 {
return results, nil
}
}
return results, &ErrGroupDiscoveryFailed{Groups: failedGroups}
// group selected APIResources according to GroupVersion into APIResourceLists
for groupResource, apiResource := range grApiResources {
version := grVersions[groupResource]
groupVersion := schema.GroupVersion{Group: groupResource.Group, Version: version}
apiResourceList := gvApiResourceLists[groupVersion]
apiResourceList.APIResources = append(apiResourceList.APIResources, *apiResource)
}
if len(failedGroups) == 0 {
return result, nil
}
return result, &ErrGroupDiscoveryFailed{Groups: failedGroups}
}
// ServerPreferredResources returns the supported resources with the version preferred by the
// server.
func (d *DiscoveryClient) ServerPreferredResources() ([]unversioned.GroupVersionResource, error) {
return d.serverPreferredResources(false)
func (d *DiscoveryClient) ServerPreferredResources() ([]*metav1.APIResourceList, error) {
return withRetries(defaultRetries, func(retryEarly bool) ([]*metav1.APIResourceList, error) {
return d.serverPreferredResources(retryEarly)
})
}
// ServerPreferredNamespacedResources returns the supported namespaced resources with the
// version preferred by the server.
func (d *DiscoveryClient) ServerPreferredNamespacedResources() ([]unversioned.GroupVersionResource, error) {
return d.serverPreferredResources(true)
func (d *DiscoveryClient) ServerPreferredNamespacedResources() ([]*metav1.APIResourceList, error) {
all, err := d.ServerPreferredResources()
return FilteredBy(ResourcePredicateFunc(func(groupVersion string, r *metav1.APIResource) bool {
return r.Namespaced
}), all), err
}
// ServerVersion retrieves and parses the server's version (git version).
@@ -269,7 +341,8 @@ func (d *DiscoveryClient) ServerVersion() (*version.Info, error) {
}
// SwaggerSchema retrieves and parses the swagger API schema the server supports.
func (d *DiscoveryClient) SwaggerSchema(version unversioned.GroupVersion) (*swagger.ApiDeclaration, error) {
// 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")
}
@@ -278,7 +351,7 @@ func (d *DiscoveryClient) SwaggerSchema(version unversioned.GroupVersion) (*swag
if err != nil {
return nil, err
}
groupVersions := unversioned.ExtractGroupVersions(groupList)
groupVersions := metav1.ExtractGroupVersions(groupList)
// This check also takes care the case that kubectl is newer than the running endpoint
if stringDoesntExistIn(version.String(), groupVersions) {
return nil, fmt.Errorf("API version: %v is not supported by the server. Use one of: %v", version, groupVersions)
@@ -302,31 +375,63 @@ func (d *DiscoveryClient) SwaggerSchema(version unversioned.GroupVersion) (*swag
return &schema, nil
}
func setDiscoveryDefaults(config *rest.Config) error {
// 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
var err error
for i := 0; i < maxRetries; i++ {
failEarly := i < maxRetries-1
result, err = f(failEarly)
if err == nil {
return result, nil
}
if _, ok := err.(*ErrGroupDiscoveryFailed); !ok {
return nil, err
}
}
return result, err
}
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 = rest.DefaultKubernetesUserAgent()
config.UserAgent = restclient.DefaultKubernetesUserAgent()
}
return nil
}
// NewDiscoveryClientForConfig creates a new DiscoveryClient for the given config. This client
// can be used to discover supported resources in the API server.
func NewDiscoveryClientForConfig(c *rest.Config) (*DiscoveryClient, error) {
func NewDiscoveryClientForConfig(c *restclient.Config) (*DiscoveryClient, error) {
config := *c
if err := setDiscoveryDefaults(&config); err != nil {
return nil, err
}
client, err := rest.UnversionedRESTClientFor(&config)
client, err := restclient.UnversionedRESTClientFor(&config)
return &DiscoveryClient{restClient: client, LegacyPrefix: "/api"}, err
}
// NewDiscoveryClientForConfig creates a new DiscoveryClient for the given config. If
// there is an error, it panics.
func NewDiscoveryClientForConfigOrDie(c *rest.Config) *DiscoveryClient {
func NewDiscoveryClientForConfigOrDie(c *restclient.Config) *DiscoveryClient {
client, err := NewDiscoveryClientForConfig(c)
if err != nil {
panic(err)
@@ -336,7 +441,7 @@ func NewDiscoveryClientForConfigOrDie(c *rest.Config) *DiscoveryClient {
}
// New creates a new DiscoveryClient for the given RESTClient.
func NewDiscoveryClient(c rest.Interface) *DiscoveryClient {
func NewDiscoveryClient(c restclient.Interface) *DiscoveryClient {
return &DiscoveryClient{restClient: c, LegacyPrefix: "/api"}
}
@@ -351,7 +456,7 @@ func stringDoesntExistIn(str string, slice []string) bool {
// RESTClient returns a RESTClient that is used to communicate
// with API server by this client implementation.
func (c *DiscoveryClient) RESTClient() rest.Interface {
func (c *DiscoveryClient) RESTClient() restclient.Interface {
if c == nil {
return nil
}

View File

@@ -14,21 +14,26 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package discovery
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"
"k8s.io/client-go/pkg/api/unversioned"
"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"
"k8s.io/apimachinery/pkg/version"
. "k8s.io/client-go/discovery"
"k8s.io/client-go/pkg/api/v1"
"k8s.io/client-go/pkg/version"
"k8s.io/client-go/rest"
restclient "k8s.io/client-go/rest"
)
func TestGetServerVersion(t *testing.T) {
@@ -48,7 +53,7 @@ func TestGetServerVersion(t *testing.T) {
w.Write(output)
}))
defer server.Close()
client := NewDiscoveryClientForConfigOrDie(&rest.Config{Host: server.URL})
client := NewDiscoveryClientForConfigOrDie(&restclient.Config{Host: server.URL})
got, err := client.ServerVersion()
if err != nil {
@@ -64,7 +69,7 @@ func TestGetServerGroupsWithV1Server(t *testing.T) {
var obj interface{}
switch req.URL.Path {
case "/api":
obj = &unversioned.APIVersions{
obj = &metav1.APIVersions{
Versions: []string{
"v1",
},
@@ -83,13 +88,13 @@ func TestGetServerGroupsWithV1Server(t *testing.T) {
w.Write(output)
}))
defer server.Close()
client := NewDiscoveryClientForConfigOrDie(&rest.Config{Host: server.URL})
client := NewDiscoveryClientForConfigOrDie(&restclient.Config{Host: server.URL})
// ServerGroups should not return an error even if server returns error at /api and /apis
apiGroupList, err := client.ServerGroups()
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
groupVersions := unversioned.ExtractGroupVersions(apiGroupList)
groupVersions := metav1.ExtractGroupVersions(apiGroupList)
if !reflect.DeepEqual(groupVersions, []string{"v1"}) {
t.Errorf("expected: %q, got: %q", []string{"v1"}, groupVersions)
}
@@ -101,13 +106,13 @@ func TestGetServerGroupsWithBrokenServer(t *testing.T) {
w.WriteHeader(statusCode)
}))
defer server.Close()
client := NewDiscoveryClientForConfigOrDie(&rest.Config{Host: server.URL})
client := NewDiscoveryClientForConfigOrDie(&restclient.Config{Host: server.URL})
// ServerGroups should not return an error even if server returns Not Found or Forbidden error at all end points
apiGroupList, err := client.ServerGroups()
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
groupVersions := unversioned.ExtractGroupVersions(apiGroupList)
groupVersions := metav1.ExtractGroupVersions(apiGroupList)
if len(groupVersions) != 0 {
t.Errorf("expected empty list, got: %q", groupVersions)
}
@@ -119,7 +124,7 @@ func TestGetServerResourcesWithV1Server(t *testing.T) {
var obj interface{}
switch req.URL.Path {
case "/api":
obj = &unversioned.APIVersions{
obj = &metav1.APIVersions{
Versions: []string{
"v1",
},
@@ -138,37 +143,37 @@ func TestGetServerResourcesWithV1Server(t *testing.T) {
w.Write(output)
}))
defer server.Close()
client := NewDiscoveryClientForConfigOrDie(&rest.Config{Host: server.URL})
client := NewDiscoveryClientForConfigOrDie(&restclient.Config{Host: server.URL})
// ServerResources should not return an error even if server returns error at /api/v1.
resourceMap, err := client.ServerResources()
serverResources, err := client.ServerResources()
if err != nil {
t.Errorf("unexpected error: %v", err)
}
if _, found := resourceMap["v1"]; !found {
t.Errorf("missing v1 in resource map")
gvs := groupVersions(serverResources)
if !sets.NewString(gvs...).Has("v1") {
t.Errorf("missing v1 in resource list: %v", serverResources)
}
}
func TestGetServerResources(t *testing.T) {
stable := unversioned.APIResourceList{
stable := metav1.APIResourceList{
GroupVersion: "v1",
APIResources: []unversioned.APIResource{
APIResources: []metav1.APIResource{
{Name: "pods", Namespaced: true, Kind: "Pod"},
{Name: "services", Namespaced: true, Kind: "Service"},
{Name: "namespaces", Namespaced: false, Kind: "Namespace"},
},
}
beta := unversioned.APIResourceList{
GroupVersion: "extensions/v1",
APIResources: []unversioned.APIResource{
beta := metav1.APIResourceList{
GroupVersion: "extensions/v1beta1",
APIResources: []metav1.APIResource{
{Name: "deployments", Namespaced: true, Kind: "Deployment"},
{Name: "ingresses", Namespaced: true, Kind: "Ingress"},
{Name: "jobs", Namespaced: true, Kind: "Job"},
},
}
tests := []struct {
resourcesList *unversioned.APIResourceList
resourcesList *metav1.APIResourceList
path string
request string
expectErr bool
@@ -200,16 +205,16 @@ func TestGetServerResources(t *testing.T) {
case "/apis/extensions/v1beta1":
list = &beta
case "/api":
list = &unversioned.APIVersions{
list = &metav1.APIVersions{
Versions: []string{
"v1",
},
}
case "/apis":
list = &unversioned.APIGroupList{
Groups: []unversioned.APIGroup{
list = &metav1.APIGroupList{
Groups: []metav1.APIGroup{
{
Versions: []unversioned.GroupVersionForDiscovery{
Versions: []metav1.GroupVersionForDiscovery{
{GroupVersion: "extensions/v1beta1"},
},
},
@@ -230,7 +235,7 @@ func TestGetServerResources(t *testing.T) {
w.Write(output)
}))
defer server.Close()
client := NewDiscoveryClientForConfigOrDie(&rest.Config{Host: server.URL})
client := NewDiscoveryClientForConfigOrDie(&restclient.Config{Host: server.URL})
for _, test := range tests {
got, err := client.ServerResourcesForGroupVersion(test.request)
if test.expectErr {
@@ -248,13 +253,14 @@ func TestGetServerResources(t *testing.T) {
}
}
resourceMap, err := client.ServerResources()
serverResources, err := client.ServerResources()
if err != nil {
t.Errorf("unexpected error: %v", err)
}
serverGroupVersions := sets.NewString(groupVersions(serverResources)...)
for _, api := range []string{"v1", "extensions/v1beta1"} {
if _, found := resourceMap[api]; !found {
t.Errorf("missing expected api: %s", api)
if !serverGroupVersions.Has(api) {
t.Errorf("missing expected api %q in %v", api, serverResources)
}
}
}
@@ -266,7 +272,7 @@ func swaggerSchemaFakeServer() (*httptest.Server, error) {
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
var resp interface{}
if request == 1 {
resp = unversioned.APIVersions{Versions: []string{"v1", "v2", "v3"}}
resp = metav1.APIVersions{Versions: []string{"v1", "v2", "v3"}}
request++
} else {
resp = swagger.ApiDeclaration{}
@@ -292,7 +298,7 @@ func TestGetSwaggerSchema(t *testing.T) {
}
defer server.Close()
client := NewDiscoveryClientForConfigOrDie(&rest.Config{Host: server.URL})
client := NewDiscoveryClientForConfigOrDie(&restclient.Config{Host: server.URL})
got, err := client.SwaggerSchema(v1.SchemeGroupVersion)
if err != nil {
t.Fatalf("unexpected encoding error: %v", err)
@@ -311,8 +317,8 @@ func TestGetSwaggerSchemaFail(t *testing.T) {
}
defer server.Close()
client := NewDiscoveryClientForConfigOrDie(&rest.Config{Host: server.URL})
got, err := client.SwaggerSchema(unversioned.GroupVersion{Group: "api.group", Version: "v4"})
client := NewDiscoveryClientForConfigOrDie(&restclient.Config{Host: server.URL})
got, err := client.SwaggerSchema(schema.GroupVersion{Group: "api.group", Version: "v4"})
if got != nil {
t.Fatalf("unexpected response: %v", got)
}
@@ -321,30 +327,97 @@ func TestGetSwaggerSchemaFail(t *testing.T) {
}
}
func TestGetServerPreferredResources(t *testing.T) {
stable := unversioned.APIResourceList{
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",
APIResources: []unversioned.APIResource{
APIResources: []metav1.APIResource{
{Name: "pods", Namespaced: true, Kind: "Pod"},
{Name: "services", Namespaced: true, Kind: "Service"},
{Name: "namespaces", Namespaced: false, Kind: "Namespace"},
},
}
/*beta := unversioned.APIResourceList{
GroupVersion: "extensions/v1",
APIResources: []unversioned.APIResource{
{Name: "deployments", Namespaced: true, Kind: "Deployment"},
{Name: "ingresses", Namespaced: true, Kind: "Ingress"},
{Name: "jobs", Namespaced: true, Kind: "Job"},
},
}*/
tests := []struct {
resourcesList *unversioned.APIResourceList
resourcesList []*metav1.APIResourceList
response func(w http.ResponseWriter, req *http.Request)
expectErr func(err error) bool
}{
{
resourcesList: &stable,
resourcesList: []*metav1.APIResourceList{&stable},
expectErr: IsGroupDiscoveryFailedError,
response: func(w http.ResponseWriter, req *http.Request) {
var list interface{}
@@ -355,16 +428,16 @@ func TestGetServerPreferredResources(t *testing.T) {
case "/api/v1":
list = &stable
case "/api":
list = &unversioned.APIVersions{
list = &metav1.APIVersions{
Versions: []string{
"v1",
},
}
case "/apis":
list = &unversioned.APIGroupList{
Groups: []unversioned.APIGroup{
list = &metav1.APIGroupList{
Groups: []metav1.APIGroup{
{
Versions: []unversioned.GroupVersionForDiscovery{
Versions: []metav1.GroupVersionForDiscovery{
{GroupVersion: "extensions/v1beta1"},
},
},
@@ -397,16 +470,16 @@ func TestGetServerPreferredResources(t *testing.T) {
case "/api/v1":
w.WriteHeader(http.StatusInternalServerError)
case "/api":
list = &unversioned.APIVersions{
list = &metav1.APIVersions{
Versions: []string{
"v1",
},
}
case "/apis":
list = &unversioned.APIGroupList{
Groups: []unversioned.APIGroup{
list = &metav1.APIGroupList{
Groups: []metav1.APIGroup{
{
Versions: []unversioned.GroupVersionForDiscovery{
Versions: []metav1.GroupVersionForDiscovery{
{GroupVersion: "extensions/v1beta1"},
},
},
@@ -427,16 +500,13 @@ func TestGetServerPreferredResources(t *testing.T) {
w.Write(output)
},
},
/*{
resourcesList: &stable,
},*/
}
for _, test := range tests {
server := httptest.NewServer(http.HandlerFunc(test.response))
defer server.Close()
client := NewDiscoveryClientForConfigOrDie(&rest.Config{Host: server.URL})
got, err := client.ServerPreferredResources()
client := NewDiscoveryClientForConfigOrDie(&restclient.Config{Host: server.URL})
resources, err := client.ServerPreferredResources()
if test.expectErr != nil {
if err == nil {
t.Error("unexpected non-error")
@@ -448,23 +518,29 @@ func TestGetServerPreferredResources(t *testing.T) {
t.Errorf("unexpected error: %v", err)
continue
}
if !reflect.DeepEqual(got, test.resourcesList) {
got, err := GroupVersionResources(resources)
if err != nil {
t.Errorf("unexpected error: %v", err)
continue
}
expected, _ := GroupVersionResources(test.resourcesList)
if !reflect.DeepEqual(got, expected) {
t.Errorf("expected:\n%v\ngot:\n%v\n", test.resourcesList, got)
}
server.Close()
}
}
func TestGetServerPreferredResourcesRetries(t *testing.T) {
stable := unversioned.APIResourceList{
func TestServerPreferredResourcesRetries(t *testing.T) {
stable := metav1.APIResourceList{
GroupVersion: "v1",
APIResources: []unversioned.APIResource{
APIResources: []metav1.APIResource{
{Name: "pods", Namespaced: true, Kind: "Pod"},
},
}
beta := unversioned.APIResourceList{
beta := metav1.APIResourceList{
GroupVersion: "extensions/v1",
APIResources: []unversioned.APIResource{
APIResources: []metav1.APIResource{
{Name: "deployments", Namespaced: true, Kind: "Deployment"},
},
}
@@ -484,20 +560,20 @@ func TestGetServerPreferredResourcesRetries(t *testing.T) {
case "/api/v1":
list = &stable
case "/api":
list = &unversioned.APIVersions{
list = &metav1.APIVersions{
Versions: []string{
"v1",
},
}
case "/apis":
list = &unversioned.APIGroupList{
Groups: []unversioned.APIGroup{
list = &metav1.APIGroupList{
Groups: []metav1.APIGroup{
{
Name: "extensions",
Versions: []unversioned.GroupVersionForDiscovery{
Versions: []metav1.GroupVersionForDiscovery{
{GroupVersion: "extensions/v1beta1"},
},
PreferredVersion: unversioned.GroupVersionForDiscovery{
PreferredVersion: metav1.GroupVersionForDiscovery{
GroupVersion: "extensions/v1beta1",
Version: "v1beta1",
},
@@ -542,14 +618,200 @@ func TestGetServerPreferredResourcesRetries(t *testing.T) {
server := httptest.NewServer(http.HandlerFunc(response(tc.responseErrors)))
defer server.Close()
client := NewDiscoveryClientForConfigOrDie(&rest.Config{Host: server.URL})
got, err := client.ServerPreferredResources()
client := NewDiscoveryClientForConfigOrDie(&restclient.Config{Host: server.URL})
resources, err := client.ServerPreferredResources()
if !tc.expectedError(err) {
t.Errorf("case %d: unexpected error: %v", i, err)
}
got, err := GroupVersionResources(resources)
if err != nil {
t.Errorf("case %d: unexpected error: %v", i, err)
}
if len(got) != tc.expectResources {
t.Errorf("case %d: expect %d resources, got %#v", i, tc.expectResources, got)
}
server.Close()
}
}
func TestServerPreferredNamespacedResources(t *testing.T) {
stable := metav1.APIResourceList{
GroupVersion: "v1",
APIResources: []metav1.APIResource{
{Name: "pods", Namespaced: true, Kind: "Pod"},
{Name: "services", Namespaced: true, Kind: "Service"},
{Name: "namespaces", Namespaced: false, Kind: "Namespace"},
},
}
batchv1 := metav1.APIResourceList{
GroupVersion: "batch/v1",
APIResources: []metav1.APIResource{
{Name: "jobs", Namespaced: true, Kind: "Job"},
},
}
batchv2alpha1 := metav1.APIResourceList{
GroupVersion: "batch/v2alpha1",
APIResources: []metav1.APIResource{
{Name: "jobs", Namespaced: true, Kind: "Job"},
{Name: "cronjobs", Namespaced: true, Kind: "CronJob"},
},
}
batchv3alpha1 := metav1.APIResourceList{
GroupVersion: "batch/v3alpha1",
APIResources: []metav1.APIResource{
{Name: "jobs", Namespaced: true, Kind: "Job"},
{Name: "cronjobs", Namespaced: true, Kind: "CronJob"},
},
}
tests := []struct {
response func(w http.ResponseWriter, req *http.Request)
expected map[schema.GroupVersionResource]struct{}
}{
{
response: func(w http.ResponseWriter, req *http.Request) {
var list interface{}
switch req.URL.Path {
case "/api/v1":
list = &stable
case "/api":
list = &metav1.APIVersions{
Versions: []string{
"v1",
},
}
default:
t.Logf("unexpected request: %s", req.URL.Path)
w.WriteHeader(http.StatusNotFound)
return
}
output, err := json.Marshal(list)
if err != nil {
t.Errorf("unexpected encoding error: %v", err)
return
}
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
w.Write(output)
},
expected: map[schema.GroupVersionResource]struct{}{
{Group: "", Version: "v1", Resource: "pods"}: {},
{Group: "", Version: "v1", Resource: "services"}: {},
},
},
{
response: func(w http.ResponseWriter, req *http.Request) {
var list interface{}
switch req.URL.Path {
case "/apis":
list = &metav1.APIGroupList{
Groups: []metav1.APIGroup{
{
Name: "batch",
Versions: []metav1.GroupVersionForDiscovery{
{GroupVersion: "batch/v1", Version: "v1"},
{GroupVersion: "batch/v2alpha1", Version: "v2alpha1"},
{GroupVersion: "batch/v3alpha1", Version: "v3alpha1"},
},
PreferredVersion: metav1.GroupVersionForDiscovery{GroupVersion: "batch/v1", Version: "v1"},
},
},
}
case "/apis/batch/v1":
list = &batchv1
case "/apis/batch/v2alpha1":
list = &batchv2alpha1
case "/apis/batch/v3alpha1":
list = &batchv3alpha1
default:
t.Logf("unexpected request: %s", req.URL.Path)
w.WriteHeader(http.StatusNotFound)
return
}
output, err := json.Marshal(list)
if err != nil {
t.Errorf("unexpected encoding error: %v", err)
return
}
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
w.Write(output)
},
expected: map[schema.GroupVersionResource]struct{}{
{Group: "batch", Version: "v1", Resource: "jobs"}: {},
{Group: "batch", Version: "v2alpha1", Resource: "cronjobs"}: {},
},
},
{
response: func(w http.ResponseWriter, req *http.Request) {
var list interface{}
switch req.URL.Path {
case "/apis":
list = &metav1.APIGroupList{
Groups: []metav1.APIGroup{
{
Name: "batch",
Versions: []metav1.GroupVersionForDiscovery{
{GroupVersion: "batch/v1", Version: "v1"},
{GroupVersion: "batch/v2alpha1", Version: "v2alpha1"},
{GroupVersion: "batch/v3alpha1", Version: "v3alpha1"},
},
PreferredVersion: metav1.GroupVersionForDiscovery{GroupVersion: "batch/v2alpha", Version: "v2alpha1"},
},
},
}
case "/apis/batch/v1":
list = &batchv1
case "/apis/batch/v2alpha1":
list = &batchv2alpha1
case "/apis/batch/v3alpha1":
list = &batchv3alpha1
default:
t.Logf("unexpected request: %s", req.URL.Path)
w.WriteHeader(http.StatusNotFound)
return
}
output, err := json.Marshal(list)
if err != nil {
t.Errorf("unexpected encoding error: %v", err)
return
}
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
w.Write(output)
},
expected: map[schema.GroupVersionResource]struct{}{
{Group: "batch", Version: "v2alpha1", Resource: "jobs"}: {},
{Group: "batch", Version: "v2alpha1", Resource: "cronjobs"}: {},
},
},
}
for i, test := range tests {
server := httptest.NewServer(http.HandlerFunc(test.response))
defer server.Close()
client := NewDiscoveryClientForConfigOrDie(&restclient.Config{Host: server.URL})
resources, err := client.ServerPreferredNamespacedResources()
if err != nil {
t.Errorf("[%d] unexpected error: %v", i, err)
continue
}
got, err := GroupVersionResources(resources)
if err != nil {
t.Errorf("[%d] unexpected error: %v", i, err)
continue
}
if !reflect.DeepEqual(got, test.expected) {
t.Errorf("[%d] expected:\n%v\ngot:\n%v\n", i, test.expected, got)
}
server.Close()
}
}
func groupVersions(resources []*metav1.APIResourceList) []string {
result := []string{}
for _, resourceList := range resources {
result = append(result, resourceList.GroupVersion)
}
return result
}

25
discovery/fake/BUILD Normal file
View File

@@ -0,0 +1,25 @@
package(default_visibility = ["//visibility:public"])
licenses(["notice"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = ["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",
],
)

View File

@@ -17,11 +17,17 @@ limitations under the License.
package fake
import (
"github.com/emicklei/go-restful/swagger"
"k8s.io/client-go/pkg/api/unversioned"
"fmt"
"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"
"k8s.io/client-go/pkg/api/v1"
"k8s.io/client-go/pkg/version"
"k8s.io/client-go/rest"
kubeversion "k8s.io/client-go/pkg/version"
restclient "k8s.io/client-go/rest"
"k8s.io/client-go/testing"
)
@@ -29,59 +35,66 @@ type FakeDiscovery struct {
*testing.Fake
}
func (c *FakeDiscovery) ServerResourcesForGroupVersion(groupVersion string) (*unversioned.APIResourceList, error) {
func (c *FakeDiscovery) ServerResourcesForGroupVersion(groupVersion string) (*metav1.APIResourceList, error) {
action := testing.ActionImpl{
Verb: "get",
Resource: unversioned.GroupVersionResource{Resource: "resource"},
Resource: schema.GroupVersionResource{Resource: "resource"},
}
c.Invokes(action, nil)
return c.Resources[groupVersion], nil
for _, resourceList := range c.Resources {
if resourceList.GroupVersion == groupVersion {
return resourceList, nil
}
}
return nil, fmt.Errorf("GroupVersion %q not found", groupVersion)
}
func (c *FakeDiscovery) ServerResources() (map[string]*unversioned.APIResourceList, error) {
func (c *FakeDiscovery) ServerResources() ([]*metav1.APIResourceList, error) {
action := testing.ActionImpl{
Verb: "get",
Resource: unversioned.GroupVersionResource{Resource: "resource"},
Resource: schema.GroupVersionResource{Resource: "resource"},
}
c.Invokes(action, nil)
return c.Resources, nil
}
func (c *FakeDiscovery) ServerPreferredResources() ([]unversioned.GroupVersionResource, error) {
func (c *FakeDiscovery) ServerPreferredResources() ([]*metav1.APIResourceList, error) {
return nil, nil
}
func (c *FakeDiscovery) ServerPreferredNamespacedResources() ([]unversioned.GroupVersionResource, error) {
func (c *FakeDiscovery) ServerPreferredNamespacedResources() ([]*metav1.APIResourceList, error) {
return nil, nil
}
func (c *FakeDiscovery) ServerGroups() (*unversioned.APIGroupList, error) {
func (c *FakeDiscovery) ServerGroups() (*metav1.APIGroupList, error) {
return nil, nil
}
func (c *FakeDiscovery) ServerVersion() (*version.Info, error) {
action := testing.ActionImpl{}
action.Verb = "get"
action.Resource = unversioned.GroupVersionResource{Resource: "version"}
action.Resource = schema.GroupVersionResource{Resource: "version"}
c.Invokes(action, nil)
versionInfo := version.Get()
versionInfo := kubeversion.Get()
return &versionInfo, nil
}
func (c *FakeDiscovery) SwaggerSchema(version unversioned.GroupVersion) (*swagger.ApiDeclaration, error) {
func (c *FakeDiscovery) SwaggerSchema(version schema.GroupVersion) (*swagger.ApiDeclaration, error) {
action := testing.ActionImpl{}
action.Verb = "get"
if version == v1.SchemeGroupVersion {
action.Resource = unversioned.GroupVersionResource{Resource: "/swaggerapi/api/" + version.Version}
action.Resource = schema.GroupVersionResource{Resource: "/swaggerapi/api/" + version.Version}
} else {
action.Resource = unversioned.GroupVersionResource{Resource: "/swaggerapi/apis/" + version.Group + "/" + version.Version}
action.Resource = schema.GroupVersionResource{Resource: "/swaggerapi/apis/" + version.Group + "/" + version.Version}
}
c.Invokes(action, nil)
return &swagger.ApiDeclaration{}, nil
}
func (c *FakeDiscovery) RESTClient() rest.Interface {
func (c *FakeDiscovery) OpenAPISchema() (*spec.Swagger, error) { return &spec.Swagger{}, nil }
func (c *FakeDiscovery) RESTClient() restclient.Interface {
return nil
}

View File

@@ -19,117 +19,103 @@ package discovery
import (
"fmt"
"k8s.io/client-go/pkg/api/unversioned"
"k8s.io/client-go/pkg/util/sets"
"k8s.io/client-go/pkg/version"
"k8s.io/client-go/rest"
// Import solely to initialize client auth plugins.
_ "k8s.io/client-go/plugin/pkg/client/auth"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/util/sets"
apimachineryversion "k8s.io/apimachinery/pkg/version"
)
// MatchesServerVersion queries the server to compares the build version
// (git hash) of the client with the server's build version. It returns an error
// if it failed to contact the server or if the versions are not an exact match.
func MatchesServerVersion(client DiscoveryInterface, c *rest.Config) error {
var err error
if client == nil {
client, err = NewDiscoveryClientForConfig(c)
if err != nil {
return err
}
}
cVer := version.Get()
func MatchesServerVersion(clientVersion apimachineryversion.Info, client DiscoveryInterface) error {
sVer, err := client.ServerVersion()
if err != nil {
return fmt.Errorf("couldn't read version from server: %v\n", err)
}
// GitVersion includes GitCommit and GitTreeState, but best to be safe?
if cVer.GitVersion != sVer.GitVersion || cVer.GitCommit != sVer.GitCommit || cVer.GitTreeState != sVer.GitTreeState {
return fmt.Errorf("server version (%#v) differs from client version (%#v)!\n", sVer, cVer)
if clientVersion.GitVersion != sVer.GitVersion || clientVersion.GitCommit != sVer.GitCommit || clientVersion.GitTreeState != sVer.GitTreeState {
return fmt.Errorf("server version (%#v) differs from client version (%#v)!\n", sVer, clientVersion)
}
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, but not default config (explicitly requested via
// commandline flag), and is unsupported by the server, print a warning to
// stderr and try client's registered versions in order of preference.
// - If version is config default, and the server does not support it,
// return an error.
func NegotiateVersion(client DiscoveryInterface, c *rest.Config, requestedGV *unversioned.GroupVersion, clientRegisteredGVs []unversioned.GroupVersion) (*unversioned.GroupVersion, error) {
var err error
if client == nil {
client, err = NewDiscoveryClientForConfig(c)
if err != nil {
return nil, err
}
}
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 := unversioned.ExtractGroupVersions(groups)
versions := metav1.ExtractGroupVersions(groups)
serverVersions := sets.String{}
for _, v := range versions {
serverVersions.Insert(v)
}
// If no version requested, use config version (may also be empty).
// make a copy of the original so we don't risk mutating input here or in the returned value
var preferredGV *unversioned.GroupVersion
switch {
case requestedGV != nil:
t := *requestedGV
preferredGV = &t
case c.GroupVersion != nil:
t := *c.GroupVersion
preferredGV = &t
if serverVersions.Has(requiredGV.String()) {
return nil
}
// 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 preferredGV != nil {
if !clientVersions.Has(preferredGV.String()) {
return nil, fmt.Errorf("client does not support API version %q; client supported API versions: %v", preferredGV, 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 preferredGV, nil
}
if serverVersions.Has(preferredGV.String()) {
return preferredGV, nil
}
// If we are using an explicit config version the server does not support, fail.
if (c.GroupVersion != nil) && (*preferredGV == *c.GroupVersion) {
return nil, fmt.Errorf("server does not support API version %q", preferredGV)
}
// 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
}
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
}
}
return nil, fmt.Errorf("failed to negotiate an api version; server supports: %v, client supports: %v",
serverVersions, clientVersions)
return fmt.Errorf("server does not support API version %q", requiredGV)
}
// GroupVersionResources converts APIResourceLists to the GroupVersionResources.
func GroupVersionResources(rls []*metav1.APIResourceList) (map[schema.GroupVersionResource]struct{}, error) {
gvrs := map[schema.GroupVersionResource]struct{}{}
for _, rl := range rls {
gv, err := schema.ParseGroupVersion(rl.GroupVersion)
if err != nil {
return nil, err
}
for i := range rl.APIResources {
gvrs[schema.GroupVersionResource{Group: gv.Group, Version: gv.Version, Resource: rl.APIResources[i].Name}] = struct{}{}
}
}
return gvrs, nil
}
// FilteredBy filters by the given predicate. Empty APIResourceLists are dropped.
func FilteredBy(pred ResourcePredicate, rls []*metav1.APIResourceList) []*metav1.APIResourceList {
result := []*metav1.APIResourceList{}
for _, rl := range rls {
filtered := *rl
filtered.APIResources = nil
for i := range rl.APIResources {
if pred.Match(rl.GroupVersion, &rl.APIResources[i]) {
filtered.APIResources = append(filtered.APIResources, rl.APIResources[i])
}
}
if filtered.APIResources != nil {
result = append(result, &filtered)
}
}
return result
}
type ResourcePredicate interface {
Match(groupVersion string, r *metav1.APIResource) bool
}
type ResourcePredicateFunc func(groupVersion string, r *metav1.APIResource) bool
func (fn ResourcePredicateFunc) Match(groupVersion string, r *metav1.APIResource) bool {
return fn(groupVersion, r)
}
// SupportsAllVerbs is a predicate matching a resource iff all given verbs are supported.
type SupportsAllVerbs struct {
Verbs []string
}
func (p SupportsAllVerbs) Match(groupVersion string, r *metav1.APIResource) bool {
return sets.NewString([]string(r.Verbs)...).HasAll(p.Verbs...)
}

View File

@@ -26,13 +26,15 @@ import (
"strings"
"testing"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
uapi "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"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/pkg/api/testapi"
uapi "k8s.io/client-go/pkg/api/unversioned"
"k8s.io/client-go/pkg/apimachinery/registered"
"k8s.io/client-go/pkg/runtime"
"k8s.io/client-go/rest"
"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"
)
@@ -44,88 +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
version *uapi.GroupVersion
expectedVersion *uapi.GroupVersion
requiredVersion schema.GroupVersion
serverVersions []string
clientVersions []uapi.GroupVersion
config *rest.Config
expectErr func(err error) bool
sendErr error
statusCode int
}{
{
name: "server supports client default",
version: &uapi.GroupVersion{Version: "version1"},
config: &rest.Config{},
serverVersions: []string{"version1", registered.GroupOrDie(api.GroupName).GroupVersion.String()},
clientVersions: []uapi.GroupVersion{{Version: "version1"}, registered.GroupOrDie(api.GroupName).GroupVersion},
expectedVersion: &uapi.GroupVersion{Version: "version1"},
statusCode: http.StatusOK,
},
{
name: "server falls back to client supported",
version: &registered.GroupOrDie(api.GroupName).GroupVersion,
config: &rest.Config{},
serverVersions: []string{"version1"},
clientVersions: []uapi.GroupVersion{{Version: "version1"}, registered.GroupOrDie(api.GroupName).GroupVersion},
expectedVersion: &uapi.GroupVersion{Version: "version1"},
statusCode: http.StatusOK,
},
{
name: "explicit version supported",
config: &rest.Config{ContentConfig: rest.ContentConfig{GroupVersion: &registered.GroupOrDie(api.GroupName).GroupVersion}},
serverVersions: []string{"/version1", registered.GroupOrDie(api.GroupName).GroupVersion.String()},
clientVersions: []uapi.GroupVersion{{Version: "version1"}, registered.GroupOrDie(api.GroupName).GroupVersion},
expectedVersion: &registered.GroupOrDie(api.GroupName).GroupVersion,
requiredVersion: schema.GroupVersion{Version: "v1"},
serverVersions: []string{"/version1", v1.SchemeGroupVersion.String()},
statusCode: http.StatusOK,
},
{
name: "explicit version not supported",
config: &rest.Config{ContentConfig: rest.ContentConfig{GroupVersion: &registered.GroupOrDie(api.GroupName).GroupVersion}},
serverVersions: []string{"version1"},
clientVersions: []uapi.GroupVersion{{Version: "version1"}, registered.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 server",
requiredVersion: schema.GroupVersion{Version: "v1"},
serverVersions: []string{"version1"},
expectErr: func(err error) bool { return strings.Contains(err.Error(), `server does not support API version "v1"`) },
statusCode: http.StatusOK,
},
{
name: "connection refused error",
config: &rest.Config{ContentConfig: rest.ContentConfig{GroupVersion: &registered.GroupOrDie(api.GroupName).GroupVersion}},
serverVersions: []string{"version1"},
clientVersions: []uapi.GroupVersion{{Version: "version1"}, registered.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",
config: &rest.Config{ContentConfig: rest.ContentConfig{GroupVersion: &registered.GroupOrDie(api.GroupName).GroupVersion}},
clientVersions: []uapi.GroupVersion{{Version: "version1"}, registered.GroupOrDie(api.GroupName).GroupVersion},
expectedVersion: &registered.GroupOrDie(api.GroupName).GroupVersion,
statusCode: http.StatusForbidden,
},
{
name: "discovery fails due to 404 Not Found errors and thus serverVersions is empty, use requested GroupVersion",
version: &uapi.GroupVersion{Version: "version1"},
config: &rest.Config{ContentConfig: rest.ContentConfig{GroupVersion: &registered.GroupOrDie(api.GroupName).GroupVersion}},
clientVersions: []uapi.GroupVersion{{Version: "version1"}, registered.GroupOrDie(api.GroupName).GroupVersion},
expectedVersion: &uapi.GroupVersion{Version: "version1"},
requiredVersion: schema.GroupVersion{Version: "version1"},
statusCode: http.StatusNotFound,
},
{
name: "discovery fails due to 403 Forbidden errors and thus serverVersions is empty, no fallback GroupVersion",
config: &rest.Config{},
clientVersions: []uapi.GroupVersion{{Version: "version1"}, registered.GroupOrDie(api.GroupName).GroupVersion},
expectErr: func(err error) bool { return strings.Contains(err.Error(), "failed to negotiate an api version;") },
statusCode: http.StatusForbidden,
},
}
for _, test := range tests {
fakeClient := &fake.RESTClient{
NegotiatedSerializer: testapi.Default.NegotiatedSerializer(),
NegotiatedSerializer: scheme.Codecs,
Resp: &http.Response{
StatusCode: test.statusCode,
Body: objBody(&uapi.APIVersions{Versions: test.serverVersions}),
@@ -139,9 +98,9 @@ func TestNegotiateVersion(t *testing.T) {
return &http.Response{StatusCode: test.statusCode, Header: header, Body: objBody(&uapi.APIVersions{Versions: test.serverVersions})}, nil
}),
}
c := discovery.NewDiscoveryClientForConfigOrDie(test.config)
c.RESTClient().(*rest.RESTClient).Client = fakeClient.Client
response, err := discovery.NegotiateVersion(c, test.config, test.version, test.clientVersions)
c := discovery.NewDiscoveryClientForConfigOrDie(&restclient.Config{})
c.RESTClient().(*restclient.RESTClient).Client = fakeClient.Client
err := discovery.ServerSupportsVersion(c, test.requiredVersion)
if err == nil && test.expectErr != nil {
t.Errorf("expected error, got nil for [%s].", test.name)
}
@@ -151,8 +110,76 @@ func TestNegotiateVersion(t *testing.T) {
}
continue
}
if *response != *test.expectedVersion {
t.Errorf("%s: expected version %s, got %s.", test.name, test.expectedVersion, response)
}
}
func TestFilteredBy(t *testing.T) {
all := discovery.ResourcePredicateFunc(func(gv string, r *metav1.APIResource) bool {
return true
})
none := discovery.ResourcePredicateFunc(func(gv string, r *metav1.APIResource) bool {
return false
})
onlyV2 := discovery.ResourcePredicateFunc(func(gv string, r *metav1.APIResource) bool {
return strings.HasSuffix(gv, "/v2") || gv == "v2"
})
onlyBar := discovery.ResourcePredicateFunc(func(gv string, r *metav1.APIResource) bool {
return r.Kind == "Bar"
})
foo := []*metav1.APIResourceList{
{
GroupVersion: "foo/v1",
APIResources: []metav1.APIResource{
{Name: "bar", Kind: "Bar"},
{Name: "test", Kind: "Test"},
},
},
{
GroupVersion: "foo/v2",
APIResources: []metav1.APIResource{
{Name: "bar", Kind: "Bar"},
{Name: "test", Kind: "Test"},
},
},
{
GroupVersion: "foo/v3",
APIResources: []metav1.APIResource{},
},
}
tests := []struct {
input []*metav1.APIResourceList
pred discovery.ResourcePredicate
expectedResources []string
}{
{nil, all, []string{}},
{[]*metav1.APIResourceList{
{GroupVersion: "foo/v1"},
}, all, []string{}},
{foo, all, []string{"foo/v1.bar", "foo/v1.test", "foo/v2.bar", "foo/v2.test"}},
{foo, onlyV2, []string{"foo/v2.bar", "foo/v2.test"}},
{foo, onlyBar, []string{"foo/v1.bar", "foo/v2.bar"}},
{foo, none, []string{}},
}
for i, test := range tests {
filtered := discovery.FilteredBy(test.pred, test.input)
if expected, got := sets.NewString(test.expectedResources...), sets.NewString(stringify(filtered)...); !expected.Equal(got) {
t.Errorf("[%d] unexpected group versions: expected=%v, got=%v", i, test.expectedResources, stringify(filtered))
}
}
}
func stringify(rls []*metav1.APIResourceList) []string {
result := []string{}
for _, rl := range rls {
for _, r := range rl.APIResources {
result = append(result, rl.GroupVersion+"."+r.Name)
}
if len(rl.APIResources) == 0 {
result = append(result, rl.GroupVersion)
}
}
return result
}

View File

@@ -20,42 +20,45 @@ import (
"fmt"
"sync"
"k8s.io/client-go/pkg/api/errors"
"k8s.io/client-go/pkg/api/meta"
"k8s.io/client-go/pkg/api/unversioned"
"k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime/schema"
"github.com/golang/glog"
)
// APIGroupResources is an API group with a mapping of versions to
// resources.
type APIGroupResources struct {
Group unversioned.APIGroup
Group metav1.APIGroup
// A mapping of version string to a slice of APIResources for
// that version.
VersionedResources map[string][]unversioned.APIResource
VersionedResources map[string][]metav1.APIResource
}
// NewRESTMapper returns a PriorityRESTMapper based on the discovered
// groups and resourced passed in.
// groups and resources passed in.
func NewRESTMapper(groupResources []*APIGroupResources, versionInterfaces meta.VersionInterfacesFunc) meta.RESTMapper {
unionMapper := meta.MultiRESTMapper{}
var groupPriority []string
var resourcePriority []unversioned.GroupVersionResource
var kindPriority []unversioned.GroupVersionKind
// /v1 is special. It should always come first
resourcePriority := []schema.GroupVersionResource{{Group: "", Version: "v1", Resource: meta.AnyResource}}
kindPriority := []schema.GroupVersionKind{{Group: "", Version: "v1", Kind: meta.AnyKind}}
for _, group := range groupResources {
groupPriority = append(groupPriority, group.Group.Name)
if len(group.Group.PreferredVersion.Version) != 0 {
preffered := group.Group.PreferredVersion.Version
if _, ok := group.VersionedResources[preffered]; ok {
resourcePriority = append(resourcePriority, unversioned.GroupVersionResource{
preferred := group.Group.PreferredVersion.Version
if _, ok := group.VersionedResources[preferred]; ok {
resourcePriority = append(resourcePriority, schema.GroupVersionResource{
Group: group.Group.Name,
Version: group.Group.PreferredVersion.Version,
Resource: meta.AnyResource,
})
kindPriority = append(kindPriority, unversioned.GroupVersionKind{
kindPriority = append(kindPriority, schema.GroupVersionKind{
Group: group.Group.Name,
Version: group.Group.PreferredVersion.Version,
Kind: meta.AnyKind,
@@ -69,8 +72,8 @@ func NewRESTMapper(groupResources []*APIGroupResources, versionInterfaces meta.V
continue
}
gv := unversioned.GroupVersion{Group: group.Group.Name, Version: discoveryVersion.Version}
versionMapper := meta.NewDefaultRESTMapper([]unversioned.GroupVersion{gv}, versionInterfaces)
gv := schema.GroupVersion{Group: group.Group.Name, Version: discoveryVersion.Version}
versionMapper := meta.NewDefaultRESTMapper([]schema.GroupVersion{gv}, versionInterfaces)
for _, resource := range resources {
scope := meta.RESTScopeNamespace
@@ -88,12 +91,12 @@ func NewRESTMapper(groupResources []*APIGroupResources, versionInterfaces meta.V
}
for _, group := range groupPriority {
resourcePriority = append(resourcePriority, unversioned.GroupVersionResource{
resourcePriority = append(resourcePriority, schema.GroupVersionResource{
Group: group,
Version: meta.AnyVersion,
Resource: meta.AnyResource,
})
kindPriority = append(kindPriority, unversioned.GroupVersionKind{
kindPriority = append(kindPriority, schema.GroupVersionKind{
Group: group,
Version: meta.AnyVersion,
Kind: meta.AnyKind,
@@ -118,15 +121,14 @@ func GetAPIGroupResources(cl DiscoveryInterface) ([]*APIGroupResources, error) {
for _, group := range apiGroups.Groups {
groupResources := &APIGroupResources{
Group: group,
VersionedResources: make(map[string][]unversioned.APIResource),
VersionedResources: make(map[string][]metav1.APIResource),
}
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
}
@@ -141,14 +143,14 @@ func GetAPIGroupResources(cl DiscoveryInterface) ([]*APIGroupResources, error) {
type DeferredDiscoveryRESTMapper struct {
initMu sync.Mutex
delegate meta.RESTMapper
cl DiscoveryInterface
cl CachedDiscoveryInterface
versionInterface meta.VersionInterfacesFunc
}
// NewDeferredDiscoveryRESTMapper returns a
// DeferredDiscoveryRESTMapper that will lazily query the provided
// client for discovery information to do REST mappings.
func NewDeferredDiscoveryRESTMapper(cl DiscoveryInterface, versionInterface meta.VersionInterfacesFunc) *DeferredDiscoveryRESTMapper {
func NewDeferredDiscoveryRESTMapper(cl CachedDiscoveryInterface, versionInterface meta.VersionInterfacesFunc) *DeferredDiscoveryRESTMapper {
return &DeferredDiscoveryRESTMapper{
cl: cl,
versionInterface: versionInterface,
@@ -175,79 +177,104 @@ func (d *DeferredDiscoveryRESTMapper) getDelegate() (meta.RESTMapper, error) {
// Reset resets the internally cached Discovery information and will
// cause the next mapping request to re-discover.
func (d *DeferredDiscoveryRESTMapper) Reset() {
glog.V(5).Info("Invalidating discovery information")
d.initMu.Lock()
defer d.initMu.Unlock()
d.cl.Invalidate()
d.delegate = nil
d.initMu.Unlock()
}
// KindFor takes a partial resource and returns back the single match.
// It returns an error if there are multiple matches.
func (d *DeferredDiscoveryRESTMapper) KindFor(resource unversioned.GroupVersionResource) (unversioned.GroupVersionKind, error) {
func (d *DeferredDiscoveryRESTMapper) KindFor(resource schema.GroupVersionResource) (gvk schema.GroupVersionKind, err error) {
del, err := d.getDelegate()
if err != nil {
return unversioned.GroupVersionKind{}, err
return schema.GroupVersionKind{}, err
}
return del.KindFor(resource)
gvk, err = del.KindFor(resource)
if err != nil && !d.cl.Fresh() {
d.Reset()
gvk, err = d.KindFor(resource)
}
return
}
// KindsFor takes a partial resource and returns back the list of
// potential kinds in priority order.
func (d *DeferredDiscoveryRESTMapper) KindsFor(resource unversioned.GroupVersionResource) ([]unversioned.GroupVersionKind, error) {
func (d *DeferredDiscoveryRESTMapper) KindsFor(resource schema.GroupVersionResource) (gvks []schema.GroupVersionKind, err error) {
del, err := d.getDelegate()
if err != nil {
return nil, err
}
return del.KindsFor(resource)
gvks, err = del.KindsFor(resource)
if len(gvks) == 0 && !d.cl.Fresh() {
d.Reset()
gvks, err = d.KindsFor(resource)
}
return
}
// ResourceFor takes a partial resource and returns back the single
// match. It returns an error if there are multiple matches.
func (d *DeferredDiscoveryRESTMapper) ResourceFor(input unversioned.GroupVersionResource) (unversioned.GroupVersionResource, error) {
func (d *DeferredDiscoveryRESTMapper) ResourceFor(input schema.GroupVersionResource) (gvr schema.GroupVersionResource, err error) {
del, err := d.getDelegate()
if err != nil {
return unversioned.GroupVersionResource{}, err
return schema.GroupVersionResource{}, err
}
return del.ResourceFor(input)
gvr, err = del.ResourceFor(input)
if err != nil && !d.cl.Fresh() {
d.Reset()
gvr, err = d.ResourceFor(input)
}
return
}
// ResourcesFor takes a partial resource and returns back the list of
// potential resource in priority order.
func (d *DeferredDiscoveryRESTMapper) ResourcesFor(input unversioned.GroupVersionResource) ([]unversioned.GroupVersionResource, error) {
func (d *DeferredDiscoveryRESTMapper) ResourcesFor(input schema.GroupVersionResource) (gvrs []schema.GroupVersionResource, err error) {
del, err := d.getDelegate()
if err != nil {
return nil, err
}
return del.ResourcesFor(input)
gvrs, err = del.ResourcesFor(input)
if len(gvrs) == 0 && !d.cl.Fresh() {
d.Reset()
gvrs, err = d.ResourcesFor(input)
}
return
}
// RESTMapping identifies a preferred resource mapping for the
// provided group kind.
func (d *DeferredDiscoveryRESTMapper) RESTMapping(gk unversioned.GroupKind, versions ...string) (*meta.RESTMapping, error) {
func (d *DeferredDiscoveryRESTMapper) RESTMapping(gk schema.GroupKind, versions ...string) (m *meta.RESTMapping, err error) {
del, err := d.getDelegate()
if err != nil {
return nil, err
}
return del.RESTMapping(gk, versions...)
m, err = del.RESTMapping(gk, versions...)
if err != nil && !d.cl.Fresh() {
d.Reset()
m, err = d.RESTMapping(gk, versions...)
}
return
}
// RESTMappings returns the RESTMappings for the provided group kind
// in a rough internal preferred order. If no kind is found, it will
// return a NoResourceMatchError.
func (d *DeferredDiscoveryRESTMapper) RESTMappings(gk unversioned.GroupKind) ([]*meta.RESTMapping, error) {
func (d *DeferredDiscoveryRESTMapper) RESTMappings(gk schema.GroupKind, versions ...string) (ms []*meta.RESTMapping, err error) {
del, err := d.getDelegate()
if err != nil {
return nil, err
}
return del.RESTMappings(gk)
}
// AliasesForResource returns whether a resource has an alias or not.
func (d *DeferredDiscoveryRESTMapper) AliasesForResource(resource string) ([]string, bool) {
del, err := d.getDelegate()
if err != nil {
return nil, false
ms, err = del.RESTMappings(gk, versions...)
if len(ms) == 0 && !d.cl.Fresh() {
d.Reset()
ms, err = d.RESTMappings(gk, versions...)
}
return del.AliasesForResource(resource)
return
}
// ResourceSingularizer converts a resource name from plural to
@@ -257,7 +284,12 @@ func (d *DeferredDiscoveryRESTMapper) ResourceSingularizer(resource string) (sin
if err != nil {
return resource, err
}
return del.ResourceSingularizer(resource)
singular, err = del.ResourceSingularizer(resource)
if err != nil && !d.cl.Fresh() {
d.Reset()
singular, err = d.ResourceSingularizer(resource)
}
return
}
func (d *DeferredDiscoveryRESTMapper) String() string {

View File

@@ -14,26 +14,51 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package discovery
package discovery_test
import (
"reflect"
"testing"
"k8s.io/client-go/pkg/api/unversioned"
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/version"
. "k8s.io/client-go/discovery"
restclient "k8s.io/client-go/rest"
"k8s.io/client-go/rest/fake"
"github.com/emicklei/go-restful-swagger12"
"github.com/go-openapi/spec"
"github.com/stretchr/testify/assert"
)
func TestRESTMapper(t *testing.T) {
resources := []*APIGroupResources{
{
Group: unversioned.APIGroup{
Versions: []unversioned.GroupVersionForDiscovery{
Group: metav1.APIGroup{
Name: "extensions",
Versions: []metav1.GroupVersionForDiscovery{
{Version: "v1beta"},
},
PreferredVersion: metav1.GroupVersionForDiscovery{Version: "v1beta"},
},
VersionedResources: map[string][]metav1.APIResource{
"v1beta": {
{Name: "jobs", Namespaced: true, Kind: "Job"},
{Name: "pods", Namespaced: true, Kind: "Pod"},
},
},
},
{
Group: metav1.APIGroup{
Versions: []metav1.GroupVersionForDiscovery{
{Version: "v1"},
{Version: "v2"},
},
PreferredVersion: unversioned.GroupVersionForDiscovery{Version: "v1"},
PreferredVersion: metav1.GroupVersionForDiscovery{Version: "v1"},
},
VersionedResources: map[string][]unversioned.APIResource{
VersionedResources: map[string][]metav1.APIResource{
"v1": {
{Name: "pods", Namespaced: true, Kind: "Pod"},
},
@@ -42,62 +67,57 @@ func TestRESTMapper(t *testing.T) {
},
},
},
{
Group: unversioned.APIGroup{
Name: "extensions",
Versions: []unversioned.GroupVersionForDiscovery{
{Version: "v1beta"},
},
PreferredVersion: unversioned.GroupVersionForDiscovery{Version: "v1beta"},
},
VersionedResources: map[string][]unversioned.APIResource{
"v1beta": {
{Name: "jobs", Namespaced: true, Kind: "Job"},
},
},
},
}
restMapper := NewRESTMapper(resources, nil)
kindTCs := []struct {
input unversioned.GroupVersionResource
want unversioned.GroupVersionKind
input schema.GroupVersionResource
want schema.GroupVersionKind
}{
{
input: unversioned.GroupVersionResource{
Version: "v1",
input: schema.GroupVersionResource{
Resource: "pods",
},
want: unversioned.GroupVersionKind{
want: schema.GroupVersionKind{
Version: "v1",
Kind: "Pod",
},
},
{
input: unversioned.GroupVersionResource{
input: schema.GroupVersionResource{
Version: "v1",
Resource: "pods",
},
want: schema.GroupVersionKind{
Version: "v1",
Kind: "Pod",
},
},
{
input: schema.GroupVersionResource{
Version: "v2",
Resource: "pods",
},
want: unversioned.GroupVersionKind{
want: schema.GroupVersionKind{
Version: "v2",
Kind: "Pod",
},
},
{
input: unversioned.GroupVersionResource{
input: schema.GroupVersionResource{
Resource: "pods",
},
want: unversioned.GroupVersionKind{
want: schema.GroupVersionKind{
Version: "v1",
Kind: "Pod",
},
},
{
input: unversioned.GroupVersionResource{
input: schema.GroupVersionResource{
Resource: "jobs",
},
want: unversioned.GroupVersionKind{
want: schema.GroupVersionKind{
Group: "extensions",
Version: "v1beta",
Kind: "Job",
@@ -118,43 +138,52 @@ func TestRESTMapper(t *testing.T) {
}
resourceTCs := []struct {
input unversioned.GroupVersionResource
want unversioned.GroupVersionResource
input schema.GroupVersionResource
want schema.GroupVersionResource
}{
{
input: unversioned.GroupVersionResource{
Version: "v1",
input: schema.GroupVersionResource{
Resource: "pods",
},
want: unversioned.GroupVersionResource{
want: schema.GroupVersionResource{
Version: "v1",
Resource: "pods",
},
},
{
input: unversioned.GroupVersionResource{
input: schema.GroupVersionResource{
Version: "v1",
Resource: "pods",
},
want: schema.GroupVersionResource{
Version: "v1",
Resource: "pods",
},
},
{
input: schema.GroupVersionResource{
Version: "v2",
Resource: "pods",
},
want: unversioned.GroupVersionResource{
want: schema.GroupVersionResource{
Version: "v2",
Resource: "pods",
},
},
{
input: unversioned.GroupVersionResource{
input: schema.GroupVersionResource{
Resource: "pods",
},
want: unversioned.GroupVersionResource{
want: schema.GroupVersionResource{
Version: "v1",
Resource: "pods",
},
},
{
input: unversioned.GroupVersionResource{
input: schema.GroupVersionResource{
Resource: "jobs",
},
want: unversioned.GroupVersionResource{
want: schema.GroupVersionResource{
Group: "extensions",
Version: "v1beta",
Resource: "jobs",
@@ -174,3 +203,151 @@ func TestRESTMapper(t *testing.T) {
}
}
}
func TestDeferredDiscoveryRESTMapper_CacheMiss(t *testing.T) {
assert := assert.New(t)
cdc := fakeCachedDiscoveryInterface{fresh: false}
m := NewDeferredDiscoveryRESTMapper(&cdc, nil)
assert.False(cdc.fresh, "should NOT be fresh after instantiation")
assert.Zero(cdc.invalidateCalls, "should not have called Invalidate()")
gvk, err := m.KindFor(schema.GroupVersionResource{
Group: "a",
Version: "v1",
Resource: "foo",
})
assert.NoError(err)
assert.True(cdc.fresh, "should be fresh after a cache-miss")
assert.Equal(cdc.invalidateCalls, 1, "should have called Invalidate() once")
assert.Equal(gvk.Kind, "Foo")
gvk, err = m.KindFor(schema.GroupVersionResource{
Group: "a",
Version: "v1",
Resource: "foo",
})
assert.NoError(err)
assert.Equal(cdc.invalidateCalls, 1, "should NOT have called Invalidate() again")
gvk, err = m.KindFor(schema.GroupVersionResource{
Group: "a",
Version: "v1",
Resource: "bar",
})
assert.Error(err)
assert.Equal(cdc.invalidateCalls, 1, "should NOT have called Invalidate() again after another cache-miss, but with fresh==true")
cdc.fresh = false
gvk, err = m.KindFor(schema.GroupVersionResource{
Group: "a",
Version: "v1",
Resource: "bar",
})
assert.Error(err)
assert.Equal(cdc.invalidateCalls, 2, "should HAVE called Invalidate() again after another cache-miss, but with fresh==false")
}
type fakeCachedDiscoveryInterface struct {
invalidateCalls int
fresh bool
enabledA bool
}
var _ CachedDiscoveryInterface = &fakeCachedDiscoveryInterface{}
func (c *fakeCachedDiscoveryInterface) Fresh() bool {
return c.fresh
}
func (c *fakeCachedDiscoveryInterface) Invalidate() {
c.invalidateCalls = c.invalidateCalls + 1
c.fresh = true
c.enabledA = true
}
func (c *fakeCachedDiscoveryInterface) RESTClient() restclient.Interface {
return &fake.RESTClient{}
}
func (c *fakeCachedDiscoveryInterface) ServerGroups() (*metav1.APIGroupList, error) {
if c.enabledA {
return &metav1.APIGroupList{
Groups: []metav1.APIGroup{
{
Name: "a",
Versions: []metav1.GroupVersionForDiscovery{
{
GroupVersion: "a/v1",
Version: "v1",
},
},
PreferredVersion: metav1.GroupVersionForDiscovery{
GroupVersion: "a/v1",
Version: "v1",
},
},
},
}, nil
}
return &metav1.APIGroupList{}, nil
}
func (c *fakeCachedDiscoveryInterface) ServerResourcesForGroupVersion(groupVersion string) (*metav1.APIResourceList, error) {
if c.enabledA && groupVersion == "a/v1" {
return &metav1.APIResourceList{
GroupVersion: "a/v1",
APIResources: []metav1.APIResource{
{
Name: "foo",
Kind: "Foo",
Namespaced: false,
},
},
}, nil
}
return nil, errors.NewNotFound(schema.GroupResource{}, "")
}
func (c *fakeCachedDiscoveryInterface) ServerResources() ([]*metav1.APIResourceList, error) {
if c.enabledA {
av1, _ := c.ServerResourcesForGroupVersion("a/v1")
return []*metav1.APIResourceList{av1}, nil
}
return []*metav1.APIResourceList{}, nil
}
func (c *fakeCachedDiscoveryInterface) ServerPreferredResources() ([]*metav1.APIResourceList, error) {
if c.enabledA {
return []*metav1.APIResourceList{
{
GroupVersion: "a/v1",
APIResources: []metav1.APIResource{
{
Name: "foo",
Kind: "Foo",
Verbs: []string{},
},
},
},
}, nil
}
return nil, nil
}
func (c *fakeCachedDiscoveryInterface) ServerPreferredNamespacedResources() ([]*metav1.APIResourceList, error) {
return nil, nil
}
func (c *fakeCachedDiscoveryInterface) ServerVersion() (*version.Info, error) {
return &version.Info{}, nil
}
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
}

View File

@@ -19,20 +19,20 @@ package discovery
import (
"fmt"
"k8s.io/client-go/pkg/api/unversioned"
"k8s.io/client-go/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
)
// UnstructuredObjectTyper provides a runtime.ObjectTyper implmentation for
// runtime.Unstructured object based on discovery information.
type UnstructuredObjectTyper struct {
registered map[unversioned.GroupVersionKind]bool
registered map[schema.GroupVersionKind]bool
}
// NewUnstructuredObjectTyper returns a runtime.ObjectTyper for
// unstructred objects based on discovery information.
func NewUnstructuredObjectTyper(groupResources []*APIGroupResources) *UnstructuredObjectTyper {
dot := &UnstructuredObjectTyper{registered: make(map[unversioned.GroupVersionKind]bool)}
dot := &UnstructuredObjectTyper{registered: make(map[schema.GroupVersionKind]bool)}
for _, group := range groupResources {
for _, discoveryVersion := range group.Group.Versions {
resources, ok := group.VersionedResources[discoveryVersion.Version]
@@ -40,7 +40,7 @@ func NewUnstructuredObjectTyper(groupResources []*APIGroupResources) *Unstructur
continue
}
gv := unversioned.GroupVersion{Group: group.Group.Name, Version: discoveryVersion.Version}
gv := schema.GroupVersion{Group: group.Group.Name, Version: discoveryVersion.Version}
for _, resource := range resources {
dot.registered[gv.WithKind(resource.Kind)] = true
}
@@ -50,39 +50,39 @@ func NewUnstructuredObjectTyper(groupResources []*APIGroupResources) *Unstructur
}
// ObjectKind returns the group,version,kind of the provided object, or an error
// if the object in not *runtime.Unstructured or has no group,version,kind
// if the object in not runtime.Unstructured or has no group,version,kind
// information.
func (d *UnstructuredObjectTyper) ObjectKind(obj runtime.Object) (unversioned.GroupVersionKind, error) {
if _, ok := obj.(*runtime.Unstructured); !ok {
return unversioned.GroupVersionKind{}, fmt.Errorf("type %T is invalid for dynamic object typer", obj)
func (d *UnstructuredObjectTyper) ObjectKind(obj runtime.Object) (schema.GroupVersionKind, error) {
if _, ok := obj.(runtime.Unstructured); !ok {
return schema.GroupVersionKind{}, fmt.Errorf("type %T is invalid for dynamic object typer", obj)
}
return obj.GetObjectKind().GroupVersionKind(), nil
}
// ObjectKinds returns a slice of one element with the group,version,kind of the
// provided object, or an error if the object is not *runtime.Unstructured or
// provided object, or an error if the object is not runtime.Unstructured or
// has no group,version,kind information. unversionedType will always be false
// because runtime.Unstructured object should always have group,version,kind
// information set.
func (d *UnstructuredObjectTyper) ObjectKinds(obj runtime.Object) (gvks []unversioned.GroupVersionKind, unversionedType bool, err error) {
func (d *UnstructuredObjectTyper) ObjectKinds(obj runtime.Object) (gvks []schema.GroupVersionKind, unversionedType bool, err error) {
gvk, err := d.ObjectKind(obj)
if err != nil {
return nil, false, err
}
return []unversioned.GroupVersionKind{gvk}, false, nil
return []schema.GroupVersionKind{gvk}, false, nil
}
// Recognizes returns true if the provided group,version,kind was in the
// discovery information.
func (d *UnstructuredObjectTyper) Recognizes(gvk unversioned.GroupVersionKind) bool {
func (d *UnstructuredObjectTyper) Recognizes(gvk schema.GroupVersionKind) bool {
return d.registered[gvk]
}
// IsUnversioned returns false always because *runtime.Unstructured objects
// IsUnversioned returns false always because runtime.Unstructured objects
// should always have group,version,kind information set. ok will be true if the
// object's group,version,kind is registered.
// object's group,version,kind is api.Registry.
func (d *UnstructuredObjectTyper) IsUnversioned(obj runtime.Object) (unversioned bool, ok bool) {
gvk, err := d.ObjectKind(obj)
if err != nil {

55
dynamic/BUILD Normal file
View 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",
],
)

View File

@@ -26,27 +26,30 @@ import (
"net/url"
"strings"
"k8s.io/client-go/pkg/api"
"k8s.io/client-go/pkg/api/unversioned"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/conversion/queryparams"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/runtime/serializer"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/watch"
"k8s.io/client-go/kubernetes/scheme"
"k8s.io/client-go/pkg/api/v1"
"k8s.io/client-go/pkg/conversion/queryparams"
"k8s.io/client-go/pkg/runtime"
"k8s.io/client-go/pkg/runtime/serializer"
"k8s.io/client-go/pkg/util/flowcontrol"
"k8s.io/client-go/pkg/watch"
"k8s.io/client-go/rest"
restclient "k8s.io/client-go/rest"
"k8s.io/client-go/util/flowcontrol"
)
// Client is a Kubernetes client that allows you to access metadata
// and manipulate metadata of a Kubernetes API group.
type Client struct {
cl *rest.RESTClient
cl *restclient.RESTClient
parameterCodec runtime.ParameterCodec
}
// NewClient returns a new client based on the passed in config. The
// codec is ignored, as the dynamic client uses it's own codec.
func NewClient(conf *rest.Config) (*Client, error) {
func NewClient(conf *restclient.Config) (*Client, error) {
// avoid changing the original config
confCopy := *conf
conf = &confCopy
@@ -63,10 +66,10 @@ func NewClient(conf *rest.Config) (*Client, error) {
}
if len(conf.UserAgent) == 0 {
conf.UserAgent = rest.DefaultKubernetesUserAgent()
conf.UserAgent = restclient.DefaultKubernetesUserAgent()
}
cl, err := rest.RESTClientFor(conf)
cl, err := restclient.RESTClientFor(conf)
if err != nil {
return nil, err
}
@@ -82,7 +85,7 @@ func (c *Client) GetRateLimiter() flowcontrol.RateLimiter {
// Resource returns an API interface to the specified resource for this client's
// group and version. If resource is not a namespaced resource, then namespace
// is ignored. The ResourceClient inherits the parameter codec of c.
func (c *Client) Resource(resource *unversioned.APIResource, namespace string) *ResourceClient {
func (c *Client) Resource(resource *metav1.APIResource, namespace string) *ResourceClient {
return &ResourceClient{
cl: c.cl,
resource: resource,
@@ -102,14 +105,14 @@ func (c *Client) ParameterCodec(parameterCodec runtime.ParameterCodec) *Client {
// ResourceClient is an API interface to a specific resource under a
// dynamic client.
type ResourceClient struct {
cl *rest.RESTClient
resource *unversioned.APIResource
cl *restclient.RESTClient
resource *metav1.APIResource
ns string
parameterCodec runtime.ParameterCodec
}
// List returns a list of objects for this resource.
func (rc *ResourceClient) List(opts runtime.Object) (runtime.Object, error) {
func (rc *ResourceClient) List(opts metav1.ListOptions) (runtime.Object, error) {
parameterEncoder := rc.parameterCodec
if parameterEncoder == nil {
parameterEncoder = defaultParameterEncoder
@@ -117,17 +120,22 @@ func (rc *ResourceClient) List(opts runtime.Object) (runtime.Object, error) {
return rc.cl.Get().
NamespaceIfScoped(rc.ns, rc.resource.Namespaced).
Resource(rc.resource.Name).
VersionedParams(opts, parameterEncoder).
VersionedParams(&opts, parameterEncoder).
Do().
Get()
}
// Get gets the resource with the specified name.
func (rc *ResourceClient) Get(name string) (*runtime.Unstructured, error) {
result := new(runtime.Unstructured)
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)
@@ -135,7 +143,7 @@ func (rc *ResourceClient) Get(name string) (*runtime.Unstructured, error) {
}
// Delete deletes the resource with the specified name.
func (rc *ResourceClient) Delete(name string, opts *v1.DeleteOptions) error {
func (rc *ResourceClient) Delete(name string, opts *metav1.DeleteOptions) error {
return rc.cl.Delete().
NamespaceIfScoped(rc.ns, rc.resource.Namespaced).
Resource(rc.resource.Name).
@@ -146,7 +154,7 @@ func (rc *ResourceClient) Delete(name string, opts *v1.DeleteOptions) error {
}
// DeleteCollection deletes a collection of objects.
func (rc *ResourceClient) DeleteCollection(deleteOptions *v1.DeleteOptions, listOptions runtime.Object) error {
func (rc *ResourceClient) DeleteCollection(deleteOptions *metav1.DeleteOptions, listOptions metav1.ListOptions) error {
parameterEncoder := rc.parameterCodec
if parameterEncoder == nil {
parameterEncoder = defaultParameterEncoder
@@ -154,15 +162,15 @@ func (rc *ResourceClient) DeleteCollection(deleteOptions *v1.DeleteOptions, list
return rc.cl.Delete().
NamespaceIfScoped(rc.ns, rc.resource.Namespaced).
Resource(rc.resource.Name).
VersionedParams(listOptions, parameterEncoder).
VersionedParams(&listOptions, parameterEncoder).
Body(deleteOptions).
Do().
Error()
}
// Create creates the provided resource.
func (rc *ResourceClient) Create(obj *runtime.Unstructured) (*runtime.Unstructured, error) {
result := new(runtime.Unstructured)
func (rc *ResourceClient) Create(obj *unstructured.Unstructured) (*unstructured.Unstructured, error) {
result := new(unstructured.Unstructured)
err := rc.cl.Post().
NamespaceIfScoped(rc.ns, rc.resource.Namespaced).
Resource(rc.resource.Name).
@@ -173,8 +181,8 @@ func (rc *ResourceClient) Create(obj *runtime.Unstructured) (*runtime.Unstructur
}
// Update updates the provided resource.
func (rc *ResourceClient) Update(obj *runtime.Unstructured) (*runtime.Unstructured, error) {
result := new(runtime.Unstructured)
func (rc *ResourceClient) Update(obj *unstructured.Unstructured) (*unstructured.Unstructured, error) {
result := new(unstructured.Unstructured)
if len(obj.GetName()) == 0 {
return result, errors.New("object missing name")
}
@@ -189,21 +197,21 @@ func (rc *ResourceClient) Update(obj *runtime.Unstructured) (*runtime.Unstructur
}
// Watch returns a watch.Interface that watches the resource.
func (rc *ResourceClient) Watch(opts runtime.Object) (watch.Interface, error) {
func (rc *ResourceClient) Watch(opts metav1.ListOptions) (watch.Interface, error) {
parameterEncoder := rc.parameterCodec
if parameterEncoder == nil {
parameterEncoder = defaultParameterEncoder
}
opts.Watch = true
return rc.cl.Get().
Prefix("watch").
NamespaceIfScoped(rc.ns, rc.resource.Namespaced).
Resource(rc.resource.Name).
VersionedParams(opts, parameterEncoder).
VersionedParams(&opts, parameterEncoder).
Watch()
}
func (rc *ResourceClient) Patch(name string, pt api.PatchType, data []byte) (*runtime.Unstructured, error) {
result := new(runtime.Unstructured)
func (rc *ResourceClient) Patch(name string, pt types.PatchType, data []byte) (*unstructured.Unstructured, error) {
result := new(unstructured.Unstructured)
err := rc.cl.Patch(pt).
NamespaceIfScoped(rc.ns, rc.resource.Namespaced).
Resource(rc.resource.Name).
@@ -218,14 +226,14 @@ func (rc *ResourceClient) Patch(name string, pt api.PatchType, data []byte) (*ru
// with special handling for Status objects.
type dynamicCodec struct{}
func (dynamicCodec) Decode(data []byte, gvk *unversioned.GroupVersionKind, obj runtime.Object) (runtime.Object, *unversioned.GroupVersionKind, error) {
obj, gvk, err := runtime.UnstructuredJSONScheme.Decode(data, gvk, obj)
func (dynamicCodec) Decode(data []byte, gvk *schema.GroupVersionKind, obj runtime.Object) (runtime.Object, *schema.GroupVersionKind, error) {
obj, gvk, err := unstructured.UnstructuredJSONScheme.Decode(data, gvk, obj)
if err != nil {
return nil, nil, err
}
if _, ok := obj.(*unversioned.Status); !ok && strings.ToLower(gvk.Kind) == "status" {
obj = &unversioned.Status{}
if _, ok := obj.(*metav1.Status); !ok && strings.ToLower(gvk.Kind) == "status" {
obj = &metav1.Status{}
err := json.Unmarshal(data, obj)
if err != nil {
return nil, nil, err
@@ -236,15 +244,15 @@ func (dynamicCodec) Decode(data []byte, gvk *unversioned.GroupVersionKind, obj r
}
func (dynamicCodec) Encode(obj runtime.Object, w io.Writer) error {
return runtime.UnstructuredJSONScheme.Encode(obj, w)
return unstructured.UnstructuredJSONScheme.Encode(obj, w)
}
// ContentConfig returns a rest.ContentConfig for dynamic types.
func ContentConfig() rest.ContentConfig {
// 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
@@ -253,7 +261,7 @@ func ContentConfig() rest.ContentConfig {
jsonInfo.Serializer = dynamicCodec{}
jsonInfo.PrettySerializer = nil
return rest.ContentConfig{
return restclient.ContentConfig{
AcceptContentTypes: runtime.ContentTypeJSON,
ContentType: runtime.ContentTypeJSON,
NegotiatedSerializer: serializer.NegotiatedSerializerWrapper(jsonInfo),
@@ -264,11 +272,11 @@ func ContentConfig() rest.ContentConfig {
// parameters without trying to convert to the target version.
type parameterCodec struct{}
func (parameterCodec) EncodeParameters(obj runtime.Object, to unversioned.GroupVersion) (url.Values, error) {
func (parameterCodec) EncodeParameters(obj runtime.Object, to schema.GroupVersion) (url.Values, error) {
return queryparams.Convert(obj)
}
func (parameterCodec) DecodeParameters(parameters url.Values, from unversioned.GroupVersion, into runtime.Object) error {
func (parameterCodec) DecodeParameters(parameters url.Values, from schema.GroupVersion, into runtime.Object) error {
return errors.New("DecodeParameters not implemented on dynamic parameterCodec")
}
@@ -276,16 +284,16 @@ var defaultParameterEncoder runtime.ParameterCodec = parameterCodec{}
type versionedParameterEncoderWithV1Fallback struct{}
func (versionedParameterEncoderWithV1Fallback) EncodeParameters(obj runtime.Object, to unversioned.GroupVersion) (url.Values, error) {
ret, err := api.ParameterCodec.EncodeParameters(obj, to)
func (versionedParameterEncoderWithV1Fallback) EncodeParameters(obj runtime.Object, to schema.GroupVersion) (url.Values, error) {
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
}
func (versionedParameterEncoderWithV1Fallback) DecodeParameters(parameters url.Values, from unversioned.GroupVersion, into runtime.Object) error {
func (versionedParameterEncoderWithV1Fallback) DecodeParameters(parameters url.Values, from schema.GroupVersion, into runtime.Object) error {
return errors.New("DecodeParameters not implemented on versionedParameterEncoderWithV1Fallback")
}

View File

@@ -19,27 +19,27 @@ package dynamic
import (
"sync"
"k8s.io/client-go/pkg/api/meta"
"k8s.io/client-go/pkg/api/unversioned"
"k8s.io/client-go/rest"
"k8s.io/apimachinery/pkg/api/meta"
"k8s.io/apimachinery/pkg/runtime/schema"
restclient "k8s.io/client-go/rest"
)
// ClientPool manages a pool of dynamic clients.
type ClientPool interface {
// ClientForGroupVersionKind returns a client configured for the specified groupVersionResource.
// Resource may be empty.
ClientForGroupVersionResource(resource unversioned.GroupVersionResource) (*Client, error)
ClientForGroupVersionResource(resource schema.GroupVersionResource) (*Client, error)
// ClientForGroupVersionKind returns a client configured for the specified groupVersionKind.
// Kind may be empty.
ClientForGroupVersionKind(kind unversioned.GroupVersionKind) (*Client, error)
ClientForGroupVersionKind(kind schema.GroupVersionKind) (*Client, error)
}
// APIPathResolverFunc knows how to convert a groupVersion to its API path. The Kind field is
// optional.
type APIPathResolverFunc func(kind unversioned.GroupVersionKind) string
type APIPathResolverFunc func(kind schema.GroupVersionKind) string
// LegacyAPIPathResolverFunc can resolve paths properly with the legacy API.
func LegacyAPIPathResolverFunc(kind unversioned.GroupVersionKind) string {
func LegacyAPIPathResolverFunc(kind schema.GroupVersionKind) string {
if len(kind.Group) == 0 {
return "/api"
}
@@ -50,8 +50,8 @@ func LegacyAPIPathResolverFunc(kind unversioned.GroupVersionKind) string {
// is asked to retrieve. This type is thread safe.
type clientPoolImpl struct {
lock sync.RWMutex
config *rest.Config
clients map[unversioned.GroupVersion]*Client
config *restclient.Config
clients map[schema.GroupVersion]*Client
apiPathResolverFunc APIPathResolverFunc
mapper meta.RESTMapper
}
@@ -59,24 +59,31 @@ type clientPoolImpl struct {
// NewClientPool returns a ClientPool from the specified config. It reuses clients for the the same
// group version. It is expected this type may be wrapped by specific logic that special cases certain
// resources or groups.
func NewClientPool(config *rest.Config, mapper meta.RESTMapper, apiPathResolverFunc APIPathResolverFunc) ClientPool {
func NewClientPool(config *restclient.Config, mapper meta.RESTMapper, apiPathResolverFunc APIPathResolverFunc) ClientPool {
confCopy := *config
return &clientPoolImpl{
config: &confCopy,
clients: map[unversioned.GroupVersion]*Client{},
clients: map[schema.GroupVersion]*Client{},
apiPathResolverFunc: apiPathResolverFunc,
mapper: mapper,
}
}
// Instantiates a new dynamic client pool with the given config.
func NewDynamicClientPool(cfg *restclient.Config) ClientPool {
// 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
// be empty. If no matching kind is found the underlying client for that group is still returned.
func (c *clientPoolImpl) ClientForGroupVersionResource(resource unversioned.GroupVersionResource) (*Client, error) {
func (c *clientPoolImpl) ClientForGroupVersionResource(resource schema.GroupVersionResource) (*Client, error) {
kinds, err := c.mapper.KindsFor(resource)
if err != nil {
if meta.IsNoMatchError(err) {
return c.ClientForGroupVersionKind(unversioned.GroupVersionKind{Group: resource.Group, Version: resource.Version})
return c.ClientForGroupVersionKind(schema.GroupVersionKind{Group: resource.Group, Version: resource.Version})
}
return nil, err
}
@@ -85,7 +92,7 @@ func (c *clientPoolImpl) ClientForGroupVersionResource(resource unversioned.Grou
// ClientForGroupVersion returns a client for the specified groupVersion, creates one if none exists. Kind
// in the GroupVersionKind may be empty.
func (c *clientPoolImpl) ClientForGroupVersionKind(kind unversioned.GroupVersionKind) (*Client, error) {
func (c *clientPoolImpl) ClientForGroupVersionKind(kind schema.GroupVersionKind) (*Client, error) {
c.lock.Lock()
defer c.lock.Unlock()

View File

@@ -25,14 +25,15 @@ import (
"reflect"
"testing"
"k8s.io/client-go/pkg/api"
"k8s.io/client-go/pkg/api/unversioned"
"k8s.io/client-go/pkg/api/v1"
"k8s.io/client-go/pkg/runtime"
"k8s.io/client-go/pkg/runtime/serializer/streaming"
"k8s.io/client-go/pkg/watch"
"k8s.io/client-go/pkg/watch/versioned"
"k8s.io/client-go/rest"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/runtime/serializer/streaming"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/watch"
restclient "k8s.io/client-go/rest"
restclientwatch "k8s.io/client-go/rest/watch"
)
func getJSON(version, kind, name string) []byte {
@@ -45,8 +46,8 @@ func getListJSON(version, kind string, items ...[]byte) []byte {
return []byte(json)
}
func getObject(version, kind, name string) *runtime.Unstructured {
return &runtime.Unstructured{
func getObject(version, kind, name string) *unstructured.Unstructured {
return &unstructured.Unstructured{
Object: map[string]interface{}{
"apiVersion": version,
"kind": kind,
@@ -57,11 +58,11 @@ func getObject(version, kind, name string) *runtime.Unstructured {
}
}
func getClientServer(gv *unversioned.GroupVersion, h func(http.ResponseWriter, *http.Request)) (*Client, *httptest.Server, error) {
func getClientServer(gv *schema.GroupVersion, h func(http.ResponseWriter, *http.Request)) (*Client, *httptest.Server, error) {
srv := httptest.NewServer(http.HandlerFunc(h))
cl, err := NewClient(&rest.Config{
cl, err := NewClient(&restclient.Config{
Host: srv.URL,
ContentConfig: rest.ContentConfig{GroupVersion: gv},
ContentConfig: restclient.ContentConfig{GroupVersion: gv},
})
if err != nil {
srv.Close()
@@ -76,7 +77,7 @@ func TestList(t *testing.T) {
namespace string
path string
resp []byte
want *runtime.UnstructuredList
want *unstructured.UnstructuredList
}{
{
name: "normal_list",
@@ -84,14 +85,14 @@ func TestList(t *testing.T) {
resp: getListJSON("vTest", "rTestList",
getJSON("vTest", "rTest", "item1"),
getJSON("vTest", "rTest", "item2")),
want: &runtime.UnstructuredList{
want: &unstructured.UnstructuredList{
Object: map[string]interface{}{
"apiVersion": "vTest",
"kind": "rTestList",
},
Items: []*runtime.Unstructured{
getObject("vTest", "rTest", "item1"),
getObject("vTest", "rTest", "item2"),
Items: []unstructured.Unstructured{
*getObject("vTest", "rTest", "item1"),
*getObject("vTest", "rTest", "item2"),
},
},
},
@@ -102,21 +103,21 @@ func TestList(t *testing.T) {
resp: getListJSON("vTest", "rTestList",
getJSON("vTest", "rTest", "item1"),
getJSON("vTest", "rTest", "item2")),
want: &runtime.UnstructuredList{
want: &unstructured.UnstructuredList{
Object: map[string]interface{}{
"apiVersion": "vTest",
"kind": "rTestList",
},
Items: []*runtime.Unstructured{
getObject("vTest", "rTest", "item1"),
getObject("vTest", "rTest", "item2"),
Items: []unstructured.Unstructured{
*getObject("vTest", "rTest", "item1"),
*getObject("vTest", "rTest", "item2"),
},
},
},
}
for _, tc := range tcs {
gv := &unversioned.GroupVersion{Group: "gtest", Version: "vtest"}
resource := &unversioned.APIResource{Name: "rtest", Namespaced: len(tc.namespace) != 0}
gv := &schema.GroupVersion{Group: "gtest", Version: "vtest"}
resource := &metav1.APIResource{Name: "rtest", Namespaced: len(tc.namespace) != 0}
cl, srv, err := getClientServer(gv, func(w http.ResponseWriter, r *http.Request) {
if r.Method != "GET" {
t.Errorf("List(%q) got HTTP method %s. wanted GET", tc.name, r.Method)
@@ -135,7 +136,7 @@ func TestList(t *testing.T) {
}
defer srv.Close()
got, err := cl.Resource(resource, tc.namespace).List(&v1.ListOptions{})
got, err := cl.Resource(resource, tc.namespace).List(metav1.ListOptions{})
if err != nil {
t.Errorf("unexpected error when listing %q: %v", tc.name, err)
continue
@@ -153,7 +154,7 @@ func TestGet(t *testing.T) {
name string
path string
resp []byte
want *runtime.Unstructured
want *unstructured.Unstructured
}{
{
name: "normal_get",
@@ -170,8 +171,8 @@ func TestGet(t *testing.T) {
},
}
for _, tc := range tcs {
gv := &unversioned.GroupVersion{Group: "gtest", Version: "vtest"}
resource := &unversioned.APIResource{Name: "rtest", Namespaced: len(tc.namespace) != 0}
gv := &schema.GroupVersion{Group: "gtest", Version: "vtest"}
resource := &metav1.APIResource{Name: "rtest", Namespaced: len(tc.namespace) != 0}
cl, srv, err := getClientServer(gv, func(w http.ResponseWriter, r *http.Request) {
if r.Method != "GET" {
t.Errorf("Get(%q) got HTTP method %s. wanted GET", tc.name, r.Method)
@@ -190,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
@@ -203,9 +204,9 @@ func TestGet(t *testing.T) {
}
func TestDelete(t *testing.T) {
statusOK := &unversioned.Status{
TypeMeta: unversioned.TypeMeta{Kind: "Status"},
Status: unversioned.StatusSuccess,
statusOK := &metav1.Status{
TypeMeta: metav1.TypeMeta{Kind: "Status"},
Status: metav1.StatusSuccess,
}
tcs := []struct {
namespace string
@@ -223,8 +224,8 @@ func TestDelete(t *testing.T) {
},
}
for _, tc := range tcs {
gv := &unversioned.GroupVersion{Group: "gtest", Version: "vtest"}
resource := &unversioned.APIResource{Name: "rtest", Namespaced: len(tc.namespace) != 0}
gv := &schema.GroupVersion{Group: "gtest", Version: "vtest"}
resource := &metav1.APIResource{Name: "rtest", Namespaced: len(tc.namespace) != 0}
cl, srv, err := getClientServer(gv, func(w http.ResponseWriter, r *http.Request) {
if r.Method != "DELETE" {
t.Errorf("Delete(%q) got HTTP method %s. wanted DELETE", tc.name, r.Method)
@@ -235,7 +236,7 @@ func TestDelete(t *testing.T) {
}
w.Header().Set("Content-Type", runtime.ContentTypeJSON)
runtime.UnstructuredJSONScheme.Encode(statusOK, w)
unstructured.UnstructuredJSONScheme.Encode(statusOK, w)
})
if err != nil {
t.Errorf("unexpected error when creating client: %v", err)
@@ -252,9 +253,9 @@ func TestDelete(t *testing.T) {
}
func TestDeleteCollection(t *testing.T) {
statusOK := &unversioned.Status{
TypeMeta: unversioned.TypeMeta{Kind: "Status"},
Status: unversioned.StatusSuccess,
statusOK := &metav1.Status{
TypeMeta: metav1.TypeMeta{Kind: "Status"},
Status: metav1.StatusSuccess,
}
tcs := []struct {
namespace string
@@ -272,8 +273,8 @@ func TestDeleteCollection(t *testing.T) {
},
}
for _, tc := range tcs {
gv := &unversioned.GroupVersion{Group: "gtest", Version: "vtest"}
resource := &unversioned.APIResource{Name: "rtest", Namespaced: len(tc.namespace) != 0}
gv := &schema.GroupVersion{Group: "gtest", Version: "vtest"}
resource := &metav1.APIResource{Name: "rtest", Namespaced: len(tc.namespace) != 0}
cl, srv, err := getClientServer(gv, func(w http.ResponseWriter, r *http.Request) {
if r.Method != "DELETE" {
t.Errorf("DeleteCollection(%q) got HTTP method %s. wanted DELETE", tc.name, r.Method)
@@ -284,7 +285,7 @@ func TestDeleteCollection(t *testing.T) {
}
w.Header().Set("Content-Type", runtime.ContentTypeJSON)
runtime.UnstructuredJSONScheme.Encode(statusOK, w)
unstructured.UnstructuredJSONScheme.Encode(statusOK, w)
})
if err != nil {
t.Errorf("unexpected error when creating client: %v", err)
@@ -292,7 +293,7 @@ func TestDeleteCollection(t *testing.T) {
}
defer srv.Close()
err = cl.Resource(resource, tc.namespace).DeleteCollection(nil, &v1.ListOptions{})
err = cl.Resource(resource, tc.namespace).DeleteCollection(nil, metav1.ListOptions{})
if err != nil {
t.Errorf("unexpected error when deleting collection %q: %v", tc.name, err)
continue
@@ -304,7 +305,7 @@ func TestCreate(t *testing.T) {
tcs := []struct {
name string
namespace string
obj *runtime.Unstructured
obj *unstructured.Unstructured
path string
}{
{
@@ -320,8 +321,8 @@ func TestCreate(t *testing.T) {
},
}
for _, tc := range tcs {
gv := &unversioned.GroupVersion{Group: "gtest", Version: "vtest"}
resource := &unversioned.APIResource{Name: "rtest", Namespaced: len(tc.namespace) != 0}
gv := &schema.GroupVersion{Group: "gtest", Version: "vtest"}
resource := &metav1.APIResource{Name: "rtest", Namespaced: len(tc.namespace) != 0}
cl, srv, err := getClientServer(gv, func(w http.ResponseWriter, r *http.Request) {
if r.Method != "POST" {
t.Errorf("Create(%q) got HTTP method %s. wanted POST", tc.name, r.Method)
@@ -363,7 +364,7 @@ func TestUpdate(t *testing.T) {
tcs := []struct {
name string
namespace string
obj *runtime.Unstructured
obj *unstructured.Unstructured
path string
}{
{
@@ -379,8 +380,8 @@ func TestUpdate(t *testing.T) {
},
}
for _, tc := range tcs {
gv := &unversioned.GroupVersion{Group: "gtest", Version: "vtest"}
resource := &unversioned.APIResource{Name: "rtest", Namespaced: len(tc.namespace) != 0}
gv := &schema.GroupVersion{Group: "gtest", Version: "vtest"}
resource := &metav1.APIResource{Name: "rtest", Namespaced: len(tc.namespace) != 0}
cl, srv, err := getClientServer(gv, func(w http.ResponseWriter, r *http.Request) {
if r.Method != "PUT" {
t.Errorf("Update(%q) got HTTP method %s. wanted PUT", tc.name, r.Method)
@@ -424,10 +425,12 @@ func TestWatch(t *testing.T) {
namespace string
events []watch.Event
path string
query string
}{
{
name: "normal_watch",
path: "/api/gtest/vtest/watch/rtest",
name: "normal_watch",
path: "/api/gtest/vtest/rtest",
query: "watch=true",
events: []watch.Event{
{Type: watch.Added, Object: getObject("vTest", "rTest", "normal_watch")},
{Type: watch.Modified, Object: getObject("vTest", "rTest", "normal_watch")},
@@ -437,7 +440,8 @@ func TestWatch(t *testing.T) {
{
name: "namespaced_watch",
namespace: "nstest",
path: "/api/gtest/vtest/watch/namespaces/nstest/rtest",
path: "/api/gtest/vtest/namespaces/nstest/rtest",
query: "watch=true",
events: []watch.Event{
{Type: watch.Added, Object: getObject("vTest", "rTest", "namespaced_watch")},
{Type: watch.Modified, Object: getObject("vTest", "rTest", "namespaced_watch")},
@@ -446,8 +450,8 @@ func TestWatch(t *testing.T) {
},
}
for _, tc := range tcs {
gv := &unversioned.GroupVersion{Group: "gtest", Version: "vtest"}
resource := &unversioned.APIResource{Name: "rtest", Namespaced: len(tc.namespace) != 0}
gv := &schema.GroupVersion{Group: "gtest", Version: "vtest"}
resource := &metav1.APIResource{Name: "rtest", Namespaced: len(tc.namespace) != 0}
cl, srv, err := getClientServer(gv, func(w http.ResponseWriter, r *http.Request) {
if r.Method != "GET" {
t.Errorf("Watch(%q) got HTTP method %s. wanted GET", tc.name, r.Method)
@@ -456,8 +460,11 @@ func TestWatch(t *testing.T) {
if r.URL.Path != tc.path {
t.Errorf("Watch(%q) got path %s. wanted %s", tc.name, r.URL.Path, tc.path)
}
if r.URL.RawQuery != tc.query {
t.Errorf("Watch(%q) got query %s. wanted %s", tc.name, r.URL.RawQuery, tc.query)
}
enc := versioned.NewEncoder(streaming.NewEncoder(w, dynamicCodec{}), dynamicCodec{})
enc := restclientwatch.NewEncoder(streaming.NewEncoder(w, dynamicCodec{}), dynamicCodec{})
for _, e := range tc.events {
enc.Encode(&e)
}
@@ -468,7 +475,7 @@ func TestWatch(t *testing.T) {
}
defer srv.Close()
watcher, err := cl.Resource(resource, tc.namespace).Watch(&v1.ListOptions{})
watcher, err := cl.Resource(resource, tc.namespace).Watch(metav1.ListOptions{})
if err != nil {
t.Errorf("unexpected error when watching %q: %v", tc.name, err)
continue
@@ -488,7 +495,7 @@ func TestPatch(t *testing.T) {
name string
namespace string
patch []byte
want *runtime.Unstructured
want *unstructured.Unstructured
path string
}{
{
@@ -506,8 +513,8 @@ func TestPatch(t *testing.T) {
},
}
for _, tc := range tcs {
gv := &unversioned.GroupVersion{Group: "gtest", Version: "vtest"}
resource := &unversioned.APIResource{Name: "rtest", Namespaced: len(tc.namespace) != 0}
gv := &schema.GroupVersion{Group: "gtest", Version: "vtest"}
resource := &metav1.APIResource{Name: "rtest", Namespaced: len(tc.namespace) != 0}
cl, srv, err := getClientServer(gv, func(w http.ResponseWriter, r *http.Request) {
if r.Method != "PATCH" {
t.Errorf("Patch(%q) got HTTP method %s. wanted PATCH", tc.name, r.Method)
@@ -518,8 +525,8 @@ func TestPatch(t *testing.T) {
}
content := r.Header.Get("Content-Type")
if content != string(api.StrategicMergePatchType) {
t.Errorf("Patch(%q) got Content-Type %s. wanted %s", tc.name, content, api.StrategicMergePatchType)
if content != string(types.StrategicMergePatchType) {
t.Errorf("Patch(%q) got Content-Type %s. wanted %s", tc.name, content, types.StrategicMergePatchType)
}
data, err := ioutil.ReadAll(r.Body)
@@ -538,7 +545,7 @@ func TestPatch(t *testing.T) {
}
defer srv.Close()
got, err := cl.Resource(resource, tc.namespace).Patch(tc.name, api.StrategicMergePatchType, tc.patch)
got, err := cl.Resource(resource, tc.namespace).Patch(tc.name, types.StrategicMergePatchType, tc.patch)
if err != nil {
t.Errorf("unexpected error when patching %q: %v", tc.name, err)
continue
@@ -549,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)
}
}

View File

@@ -19,25 +19,27 @@ package dynamic
import (
"fmt"
"k8s.io/client-go/pkg/api/meta"
"k8s.io/client-go/pkg/api/unversioned"
"k8s.io/client-go/pkg/runtime"
"k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
)
// VersionInterfaces provides an object converter and metadata
// accessor appropriate for use with unstructured objects.
func VersionInterfaces(unversioned.GroupVersion) (*meta.VersionInterfaces, error) {
func VersionInterfaces(schema.GroupVersion) (*meta.VersionInterfaces, error) {
return &meta.VersionInterfaces{
ObjectConvertor: &runtime.UnstructuredObjectConverter{},
ObjectConvertor: &unstructured.UnstructuredObjectConverter{},
MetadataAccessor: meta.NewAccessor(),
}, nil
}
// NewDiscoveryRESTMapper returns a RESTMapper based on discovery information.
func NewDiscoveryRESTMapper(resources []*unversioned.APIResourceList, versionFunc meta.VersionInterfacesFunc) (*meta.DefaultRESTMapper, error) {
func NewDiscoveryRESTMapper(resources []*metav1.APIResourceList, versionFunc meta.VersionInterfacesFunc) (*meta.DefaultRESTMapper, error) {
rm := meta.NewDefaultRESTMapper(nil, versionFunc)
for _, resourceList := range resources {
gv, err := unversioned.ParseGroupVersion(resourceList.GroupVersion)
gv, err := schema.ParseGroupVersion(resourceList.GroupVersion)
if err != nil {
return nil, err
}
@@ -55,16 +57,16 @@ func NewDiscoveryRESTMapper(resources []*unversioned.APIResourceList, versionFun
}
// ObjectTyper provides an ObjectTyper implementation for
// runtime.Unstructured object based on discovery information.
// unstructured.Unstructured object based on discovery information.
type ObjectTyper struct {
registered map[unversioned.GroupVersionKind]bool
registered map[schema.GroupVersionKind]bool
}
// NewObjectTyper constructs an ObjectTyper from discovery information.
func NewObjectTyper(resources []*unversioned.APIResourceList) (runtime.ObjectTyper, error) {
ot := &ObjectTyper{registered: make(map[unversioned.GroupVersionKind]bool)}
func NewObjectTyper(resources []*metav1.APIResourceList) (runtime.ObjectTyper, error) {
ot := &ObjectTyper{registered: make(map[schema.GroupVersionKind]bool)}
for _, resourceList := range resources {
gv, err := unversioned.ParseGroupVersion(resourceList.GroupVersion)
gv, err := schema.ParseGroupVersion(resourceList.GroupVersion)
if err != nil {
return nil, err
}
@@ -78,17 +80,17 @@ func NewObjectTyper(resources []*unversioned.APIResourceList) (runtime.ObjectTyp
// ObjectKinds returns a slice of one element with the
// group,version,kind of the provided object, or an error if the
// object is not *runtime.Unstructured or has no group,version,kind
// object is not *unstructured.Unstructured or has no group,version,kind
// information.
func (ot *ObjectTyper) ObjectKinds(obj runtime.Object) ([]unversioned.GroupVersionKind, bool, error) {
if _, ok := obj.(*runtime.Unstructured); !ok {
func (ot *ObjectTyper) ObjectKinds(obj runtime.Object) ([]schema.GroupVersionKind, bool, error) {
if _, ok := obj.(*unstructured.Unstructured); !ok {
return nil, false, fmt.Errorf("type %T is invalid for dynamic object typer", obj)
}
return []unversioned.GroupVersionKind{obj.GetObjectKind().GroupVersionKind()}, false, nil
return []schema.GroupVersionKind{obj.GetObjectKind().GroupVersionKind()}, false, nil
}
// Recognizes returns true if the provided group,version,kind was in
// the discovery information.
func (ot *ObjectTyper) Recognizes(gvk unversioned.GroupVersionKind) bool {
func (ot *ObjectTyper) Recognizes(gvk schema.GroupVersionKind) bool {
return ot.registered[gvk]
}

View File

@@ -19,14 +19,15 @@ package dynamic
import (
"testing"
"k8s.io/client-go/pkg/api/unversioned"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime/schema"
)
func TestDiscoveryRESTMapper(t *testing.T) {
resources := []*unversioned.APIResourceList{
resources := []*metav1.APIResourceList{
{
GroupVersion: "test/beta1",
APIResources: []unversioned.APIResource{
APIResources: []metav1.APIResource{
{
Name: "test_kinds",
Namespaced: true,
@@ -36,7 +37,7 @@ func TestDiscoveryRESTMapper(t *testing.T) {
},
}
gvk := unversioned.GroupVersionKind{
gvk := schema.GroupVersionKind{
Group: "test",
Version: "beta1",
Kind: "test_kind",
@@ -47,7 +48,7 @@ func TestDiscoveryRESTMapper(t *testing.T) {
t.Fatalf("unexpected error creating mapper: %s", err)
}
for _, res := range []unversioned.GroupVersionResource{
for _, res := range []schema.GroupVersionResource{
{
Group: "test",
Version: "beta1",

31
examples/README.md Normal file
View 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

View 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",
],
)

View 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/

View 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 }

View 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",
],
)

View File

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

View 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/

View File

@@ -14,15 +14,17 @@ 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 (
"fmt"
"time"
"k8s.io/client-go/1.4/kubernetes"
"k8s.io/client-go/1.4/pkg/api"
"k8s.io/client-go/1.4/rest"
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
)
func main() {
@@ -37,11 +39,26 @@ func main() {
panic(err.Error())
}
for {
pods, err := clientset.Core().Pods("").List(api.ListOptions{})
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)
}
}

View 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",
],
)

View 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).

View 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
}

View File

@@ -1,53 +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 main
import (
"flag"
"fmt"
"time"
"k8s.io/client-go/1.4/kubernetes"
"k8s.io/client-go/1.4/pkg/api"
"k8s.io/client-go/1.4/tools/clientcmd"
)
var (
kubeconfig = flag.String("kubeconfig", "./config", "absolute path to the kubeconfig file")
)
func main() {
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.Core().Pods("").List(api.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)
}
}

View 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"],
)

View File

@@ -0,0 +1,46 @@
# 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
```
# assumes you have a working kubeconfig, not required if operating in-cluster
go run *.go -kubeconfig=$HOME/.kube/config
```
## Use Cases
ThirdPartyResources can be used to implement custom Resource types for your Kubernetes cluster.
These act like most other Resources in Kubernetes, and may be `kubectl apply`'d, etc.
Some example use cases:
* Provisioning/Management of external datastores/databases (eg. CloudSQL/RDS instances)
* Higher level abstractions around Kubernetes primitives (eg. a single Resource to define an etcd cluster, backed by a Service and a ReplicationController)
## Defining types
Each instance of your ThirdPartyResource has an attached Spec, which should be defined via a `struct{}` to provide data format validation.
In practice, this Spec is arbitrary key-value data that specifies the configuration/behavior of your Resource.
For example, if you were implementing a ThirdPartyResource for a Database, you might provide a DatabaseSpec like the following:
``` go
type DatabaseSpec struct {
Databases []string `json:"databases"`
Users []User `json:"users"`
Version string `json:"version"`
}
type User struct {
Name string `json:"name"`
Password string `json:"password"`
}
```

View 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",
],
)

View File

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

View File

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

View File

@@ -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)
}

View File

@@ -0,0 +1,29 @@
package(default_visibility = ["//visibility:public"])
licenses(["notice"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = [
"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",
],
)

View 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
}

View 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
})
}

View 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",
],
)

View File

@@ -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)
}

View 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()
}

33
examples/workqueue/BUILD Normal file
View 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",
],
)

View 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
View 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
View 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",
],
)

View File

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

View File

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

View File

@@ -0,0 +1,28 @@
package(default_visibility = ["//visibility:public"])
licenses(["notice"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = [
"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",
],
)

View File

@@ -0,0 +1,68 @@
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// This file was automatically generated by informer-gen
package v1alpha1
import (
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
runtime "k8s.io/apimachinery/pkg/runtime"
watch "k8s.io/apimachinery/pkg/watch"
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())
}

View File

@@ -0,0 +1,68 @@
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// This file was automatically generated by informer-gen
package v1alpha1
import (
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
runtime "k8s.io/apimachinery/pkg/runtime"
watch "k8s.io/apimachinery/pkg/watch"
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())
}

View 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
View File

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

View File

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

View File

@@ -0,0 +1,29 @@
package(default_visibility = ["//visibility:public"])
licenses(["notice"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = [
"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",
],
)

View File

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

View File

@@ -0,0 +1,68 @@
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// This file was automatically generated by informer-gen
package 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"
)
// DeploymentInformer provides access to a shared informer and lister for
// Deployments.
type DeploymentInformer interface {
Informer() cache.SharedIndexInformer
Lister() v1beta1.DeploymentLister
}
type deploymentInformer struct {
factory internalinterfaces.SharedInformerFactory
}
func newDeploymentInformer(client kubernetes.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
sharedIndexInformer := cache.NewSharedIndexInformer(
&cache.ListWatch{
ListFunc: func(options v1.ListOptions) (runtime.Object, error) {
return client.AppsV1beta1().Deployments(v1.NamespaceAll).List(options)
},
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
return client.AppsV1beta1().Deployments(v1.NamespaceAll).Watch(options)
},
},
&apps_v1beta1.Deployment{},
resyncPeriod,
cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc},
)
return sharedIndexInformer
}
func (f *deploymentInformer) Informer() cache.SharedIndexInformer {
return f.factory.InformerFor(&apps_v1beta1.Deployment{}, newDeploymentInformer)
}
func (f *deploymentInformer) Lister() v1beta1.DeploymentLister {
return v1beta1.NewDeploymentLister(f.Informer().GetIndexer())
}

View File

@@ -0,0 +1,57 @@
/*
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 (
internalinterfaces "k8s.io/client-go/informers/internalinterfaces"
)
// 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.
StatefulSets() StatefulSetInformer
}
type version struct {
internalinterfaces.SharedInformerFactory
}
// New returns a new Interface.
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}
}
// StatefulSets returns a StatefulSetInformer.
func (v *version) StatefulSets() StatefulSetInformer {
return &statefulSetInformer{factory: v.SharedInformerFactory}
}

View File

@@ -0,0 +1,68 @@
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// This file was automatically generated by informer-gen
package 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"
)
// StatefulSetInformer provides access to a shared informer and lister for
// StatefulSets.
type StatefulSetInformer interface {
Informer() cache.SharedIndexInformer
Lister() v1beta1.StatefulSetLister
}
type statefulSetInformer struct {
factory internalinterfaces.SharedInformerFactory
}
func newStatefulSetInformer(client kubernetes.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
sharedIndexInformer := cache.NewSharedIndexInformer(
&cache.ListWatch{
ListFunc: func(options v1.ListOptions) (runtime.Object, error) {
return client.AppsV1beta1().StatefulSets(v1.NamespaceAll).List(options)
},
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
return client.AppsV1beta1().StatefulSets(v1.NamespaceAll).Watch(options)
},
},
&apps_v1beta1.StatefulSet{},
resyncPeriod,
cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc},
)
return sharedIndexInformer
}
func (f *statefulSetInformer) Informer() cache.SharedIndexInformer {
return f.factory.InformerFor(&apps_v1beta1.StatefulSet{}, newStatefulSetInformer)
}
func (f *statefulSetInformer) Lister() v1beta1.StatefulSetLister {
return v1beta1.NewStatefulSetLister(f.Informer().GetIndexer())
}

View File

@@ -0,0 +1,19 @@
package(default_visibility = ["//visibility:public"])
licenses(["notice"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = ["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",
],
)

View File

@@ -0,0 +1,52 @@
/*
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 autoscaling
import (
v1 "k8s.io/client-go/informers/autoscaling/v1"
v2alpha1 "k8s.io/client-go/informers/autoscaling/v2alpha1"
internalinterfaces "k8s.io/client-go/informers/internalinterfaces"
)
// 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
// V2alpha1 provides access to shared informers for resources in V2alpha1.
V2alpha1() v2alpha1.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)
}
// V2alpha1 returns a new v2alpha1.Interface.
func (g *group) V2alpha1() v2alpha1.Interface {
return v2alpha1.New(g.SharedInformerFactory)
}

View File

@@ -0,0 +1,27 @@
package(default_visibility = ["//visibility:public"])
licenses(["notice"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = [
"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",
],
)

View File

@@ -0,0 +1,68 @@
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// This file was automatically generated by informer-gen
package 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/autoscaling/v1"
autoscaling_v1 "k8s.io/client-go/pkg/apis/autoscaling/v1"
cache "k8s.io/client-go/tools/cache"
time "time"
)
// HorizontalPodAutoscalerInformer provides access to a shared informer and lister for
// HorizontalPodAutoscalers.
type HorizontalPodAutoscalerInformer interface {
Informer() cache.SharedIndexInformer
Lister() v1.HorizontalPodAutoscalerLister
}
type horizontalPodAutoscalerInformer struct {
factory internalinterfaces.SharedInformerFactory
}
func newHorizontalPodAutoscalerInformer(client kubernetes.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
sharedIndexInformer := cache.NewSharedIndexInformer(
&cache.ListWatch{
ListFunc: func(options meta_v1.ListOptions) (runtime.Object, error) {
return client.AutoscalingV1().HorizontalPodAutoscalers(meta_v1.NamespaceAll).List(options)
},
WatchFunc: func(options meta_v1.ListOptions) (watch.Interface, error) {
return client.AutoscalingV1().HorizontalPodAutoscalers(meta_v1.NamespaceAll).Watch(options)
},
},
&autoscaling_v1.HorizontalPodAutoscaler{},
resyncPeriod,
cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc},
)
return sharedIndexInformer
}
func (f *horizontalPodAutoscalerInformer) Informer() cache.SharedIndexInformer {
return f.factory.InformerFor(&autoscaling_v1.HorizontalPodAutoscaler{}, newHorizontalPodAutoscalerInformer)
}
func (f *horizontalPodAutoscalerInformer) Lister() v1.HorizontalPodAutoscalerLister {
return v1.NewHorizontalPodAutoscalerLister(f.Informer().GetIndexer())
}

View File

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

View File

@@ -0,0 +1,27 @@
package(default_visibility = ["//visibility:public"])
licenses(["notice"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = [
"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",
],
)

View File

@@ -0,0 +1,68 @@
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// This file was automatically generated by informer-gen
package v2alpha1
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"
v2alpha1 "k8s.io/client-go/listers/autoscaling/v2alpha1"
autoscaling_v2alpha1 "k8s.io/client-go/pkg/apis/autoscaling/v2alpha1"
cache "k8s.io/client-go/tools/cache"
time "time"
)
// HorizontalPodAutoscalerInformer provides access to a shared informer and lister for
// HorizontalPodAutoscalers.
type HorizontalPodAutoscalerInformer interface {
Informer() cache.SharedIndexInformer
Lister() v2alpha1.HorizontalPodAutoscalerLister
}
type horizontalPodAutoscalerInformer struct {
factory internalinterfaces.SharedInformerFactory
}
func newHorizontalPodAutoscalerInformer(client kubernetes.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
sharedIndexInformer := cache.NewSharedIndexInformer(
&cache.ListWatch{
ListFunc: func(options v1.ListOptions) (runtime.Object, error) {
return client.AutoscalingV2alpha1().HorizontalPodAutoscalers(v1.NamespaceAll).List(options)
},
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
return client.AutoscalingV2alpha1().HorizontalPodAutoscalers(v1.NamespaceAll).Watch(options)
},
},
&autoscaling_v2alpha1.HorizontalPodAutoscaler{},
resyncPeriod,
cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc},
)
return sharedIndexInformer
}
func (f *horizontalPodAutoscalerInformer) Informer() cache.SharedIndexInformer {
return f.factory.InformerFor(&autoscaling_v2alpha1.HorizontalPodAutoscaler{}, newHorizontalPodAutoscalerInformer)
}
func (f *horizontalPodAutoscalerInformer) Lister() v2alpha1.HorizontalPodAutoscalerLister {
return v2alpha1.NewHorizontalPodAutoscalerLister(f.Informer().GetIndexer())
}

View File

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

19
informers/batch/BUILD Normal file
View File

@@ -0,0 +1,19 @@
package(default_visibility = ["//visibility:public"])
licenses(["notice"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = ["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",
],
)

View File

@@ -0,0 +1,52 @@
/*
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 batch
import (
v1 "k8s.io/client-go/informers/batch/v1"
v2alpha1 "k8s.io/client-go/informers/batch/v2alpha1"
internalinterfaces "k8s.io/client-go/informers/internalinterfaces"
)
// 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
// V2alpha1 provides access to shared informers for resources in V2alpha1.
V2alpha1() v2alpha1.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)
}
// V2alpha1 returns a new v2alpha1.Interface.
func (g *group) V2alpha1() v2alpha1.Interface {
return v2alpha1.New(g.SharedInformerFactory)
}

27
informers/batch/v1/BUILD Normal file
View File

@@ -0,0 +1,27 @@
package(default_visibility = ["//visibility:public"])
licenses(["notice"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = [
"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",
],
)

View File

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

68
informers/batch/v1/job.go Normal file
View File

@@ -0,0 +1,68 @@
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// This file was automatically generated by informer-gen
package 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/batch/v1"
batch_v1 "k8s.io/client-go/pkg/apis/batch/v1"
cache "k8s.io/client-go/tools/cache"
time "time"
)
// JobInformer provides access to a shared informer and lister for
// Jobs.
type JobInformer interface {
Informer() cache.SharedIndexInformer
Lister() v1.JobLister
}
type jobInformer struct {
factory internalinterfaces.SharedInformerFactory
}
func newJobInformer(client kubernetes.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
sharedIndexInformer := cache.NewSharedIndexInformer(
&cache.ListWatch{
ListFunc: func(options meta_v1.ListOptions) (runtime.Object, error) {
return client.BatchV1().Jobs(meta_v1.NamespaceAll).List(options)
},
WatchFunc: func(options meta_v1.ListOptions) (watch.Interface, error) {
return client.BatchV1().Jobs(meta_v1.NamespaceAll).Watch(options)
},
},
&batch_v1.Job{},
resyncPeriod,
cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc},
)
return sharedIndexInformer
}
func (f *jobInformer) Informer() cache.SharedIndexInformer {
return f.factory.InformerFor(&batch_v1.Job{}, newJobInformer)
}
func (f *jobInformer) Lister() v1.JobLister {
return v1.NewJobLister(f.Informer().GetIndexer())
}

View File

@@ -0,0 +1,27 @@
package(default_visibility = ["//visibility:public"])
licenses(["notice"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = [
"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",
],
)

View File

@@ -0,0 +1,68 @@
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// This file was automatically generated by informer-gen
package v2alpha1
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"
v2alpha1 "k8s.io/client-go/listers/batch/v2alpha1"
batch_v2alpha1 "k8s.io/client-go/pkg/apis/batch/v2alpha1"
cache "k8s.io/client-go/tools/cache"
time "time"
)
// CronJobInformer provides access to a shared informer and lister for
// CronJobs.
type CronJobInformer interface {
Informer() cache.SharedIndexInformer
Lister() v2alpha1.CronJobLister
}
type cronJobInformer struct {
factory internalinterfaces.SharedInformerFactory
}
func newCronJobInformer(client kubernetes.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
sharedIndexInformer := cache.NewSharedIndexInformer(
&cache.ListWatch{
ListFunc: func(options v1.ListOptions) (runtime.Object, error) {
return client.BatchV2alpha1().CronJobs(v1.NamespaceAll).List(options)
},
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
return client.BatchV2alpha1().CronJobs(v1.NamespaceAll).Watch(options)
},
},
&batch_v2alpha1.CronJob{},
resyncPeriod,
cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc},
)
return sharedIndexInformer
}
func (f *cronJobInformer) Informer() cache.SharedIndexInformer {
return f.factory.InformerFor(&batch_v2alpha1.CronJob{}, newCronJobInformer)
}
func (f *cronJobInformer) Lister() v2alpha1.CronJobLister {
return v2alpha1.NewCronJobLister(f.Informer().GetIndexer())
}

View File

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

View File

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

View File

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

View File

@@ -0,0 +1,27 @@
package(default_visibility = ["//visibility:public"])
licenses(["notice"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = [
"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",
],
)

View File

@@ -0,0 +1,68 @@
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// This file was automatically generated by informer-gen
package 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/certificates/v1beta1"
certificates_v1beta1 "k8s.io/client-go/pkg/apis/certificates/v1beta1"
cache "k8s.io/client-go/tools/cache"
time "time"
)
// CertificateSigningRequestInformer provides access to a shared informer and lister for
// CertificateSigningRequests.
type CertificateSigningRequestInformer interface {
Informer() cache.SharedIndexInformer
Lister() v1beta1.CertificateSigningRequestLister
}
type certificateSigningRequestInformer struct {
factory internalinterfaces.SharedInformerFactory
}
func newCertificateSigningRequestInformer(client kubernetes.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
sharedIndexInformer := cache.NewSharedIndexInformer(
&cache.ListWatch{
ListFunc: func(options v1.ListOptions) (runtime.Object, error) {
return client.CertificatesV1beta1().CertificateSigningRequests().List(options)
},
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
return client.CertificatesV1beta1().CertificateSigningRequests().Watch(options)
},
},
&certificates_v1beta1.CertificateSigningRequest{},
resyncPeriod,
cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc},
)
return sharedIndexInformer
}
func (f *certificateSigningRequestInformer) Informer() cache.SharedIndexInformer {
return f.factory.InformerFor(&certificates_v1beta1.CertificateSigningRequest{}, newCertificateSigningRequestInformer)
}
func (f *certificateSigningRequestInformer) Lister() v1beta1.CertificateSigningRequestLister {
return v1beta1.NewCertificateSigningRequestLister(f.Informer().GetIndexer())
}

View File

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

18
informers/core/BUILD Normal file
View File

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

View File

@@ -0,0 +1,44 @@
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// This file was automatically generated by informer-gen
package core
import (
v1 "k8s.io/client-go/informers/core/v1"
internalinterfaces "k8s.io/client-go/informers/internalinterfaces"
)
// 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)
}

42
informers/core/v1/BUILD Normal file
View 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",
],
)

View File

@@ -0,0 +1,68 @@
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// This file was automatically generated by informer-gen
package 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/core/v1"
api_v1 "k8s.io/client-go/pkg/api/v1"
cache "k8s.io/client-go/tools/cache"
time "time"
)
// ComponentStatusInformer provides access to a shared informer and lister for
// ComponentStatuses.
type ComponentStatusInformer interface {
Informer() cache.SharedIndexInformer
Lister() v1.ComponentStatusLister
}
type componentStatusInformer struct {
factory internalinterfaces.SharedInformerFactory
}
func newComponentStatusInformer(client kubernetes.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
sharedIndexInformer := cache.NewSharedIndexInformer(
&cache.ListWatch{
ListFunc: func(options meta_v1.ListOptions) (runtime.Object, error) {
return client.CoreV1().ComponentStatuses().List(options)
},
WatchFunc: func(options meta_v1.ListOptions) (watch.Interface, error) {
return client.CoreV1().ComponentStatuses().Watch(options)
},
},
&api_v1.ComponentStatus{},
resyncPeriod,
cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc},
)
return sharedIndexInformer
}
func (f *componentStatusInformer) Informer() cache.SharedIndexInformer {
return f.factory.InformerFor(&api_v1.ComponentStatus{}, newComponentStatusInformer)
}
func (f *componentStatusInformer) Lister() v1.ComponentStatusLister {
return v1.NewComponentStatusLister(f.Informer().GetIndexer())
}

View File

@@ -0,0 +1,68 @@
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// This file was automatically generated by informer-gen
package 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/core/v1"
api_v1 "k8s.io/client-go/pkg/api/v1"
cache "k8s.io/client-go/tools/cache"
time "time"
)
// ConfigMapInformer provides access to a shared informer and lister for
// ConfigMaps.
type ConfigMapInformer interface {
Informer() cache.SharedIndexInformer
Lister() v1.ConfigMapLister
}
type configMapInformer struct {
factory internalinterfaces.SharedInformerFactory
}
func newConfigMapInformer(client kubernetes.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
sharedIndexInformer := cache.NewSharedIndexInformer(
&cache.ListWatch{
ListFunc: func(options meta_v1.ListOptions) (runtime.Object, error) {
return client.CoreV1().ConfigMaps(meta_v1.NamespaceAll).List(options)
},
WatchFunc: func(options meta_v1.ListOptions) (watch.Interface, error) {
return client.CoreV1().ConfigMaps(meta_v1.NamespaceAll).Watch(options)
},
},
&api_v1.ConfigMap{},
resyncPeriod,
cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc},
)
return sharedIndexInformer
}
func (f *configMapInformer) Informer() cache.SharedIndexInformer {
return f.factory.InformerFor(&api_v1.ConfigMap{}, newConfigMapInformer)
}
func (f *configMapInformer) Lister() v1.ConfigMapLister {
return v1.NewConfigMapLister(f.Informer().GetIndexer())
}

View File

@@ -0,0 +1,68 @@
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// This file was automatically generated by informer-gen
package 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/core/v1"
api_v1 "k8s.io/client-go/pkg/api/v1"
cache "k8s.io/client-go/tools/cache"
time "time"
)
// EndpointsInformer provides access to a shared informer and lister for
// Endpoints.
type EndpointsInformer interface {
Informer() cache.SharedIndexInformer
Lister() v1.EndpointsLister
}
type endpointsInformer struct {
factory internalinterfaces.SharedInformerFactory
}
func newEndpointsInformer(client kubernetes.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
sharedIndexInformer := cache.NewSharedIndexInformer(
&cache.ListWatch{
ListFunc: func(options meta_v1.ListOptions) (runtime.Object, error) {
return client.CoreV1().Endpoints(meta_v1.NamespaceAll).List(options)
},
WatchFunc: func(options meta_v1.ListOptions) (watch.Interface, error) {
return client.CoreV1().Endpoints(meta_v1.NamespaceAll).Watch(options)
},
},
&api_v1.Endpoints{},
resyncPeriod,
cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc},
)
return sharedIndexInformer
}
func (f *endpointsInformer) Informer() cache.SharedIndexInformer {
return f.factory.InformerFor(&api_v1.Endpoints{}, newEndpointsInformer)
}
func (f *endpointsInformer) Lister() v1.EndpointsLister {
return v1.NewEndpointsLister(f.Informer().GetIndexer())
}

View File

@@ -0,0 +1,68 @@
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// This file was automatically generated by informer-gen
package 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/core/v1"
api_v1 "k8s.io/client-go/pkg/api/v1"
cache "k8s.io/client-go/tools/cache"
time "time"
)
// EventInformer provides access to a shared informer and lister for
// Events.
type EventInformer interface {
Informer() cache.SharedIndexInformer
Lister() v1.EventLister
}
type eventInformer struct {
factory internalinterfaces.SharedInformerFactory
}
func newEventInformer(client kubernetes.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
sharedIndexInformer := cache.NewSharedIndexInformer(
&cache.ListWatch{
ListFunc: func(options meta_v1.ListOptions) (runtime.Object, error) {
return client.CoreV1().Events(meta_v1.NamespaceAll).List(options)
},
WatchFunc: func(options meta_v1.ListOptions) (watch.Interface, error) {
return client.CoreV1().Events(meta_v1.NamespaceAll).Watch(options)
},
},
&api_v1.Event{},
resyncPeriod,
cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc},
)
return sharedIndexInformer
}
func (f *eventInformer) Informer() cache.SharedIndexInformer {
return f.factory.InformerFor(&api_v1.Event{}, newEventInformer)
}
func (f *eventInformer) Lister() v1.EventLister {
return v1.NewEventLister(f.Informer().GetIndexer())
}

View File

@@ -0,0 +1,148 @@
/*
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 {
// ComponentStatuses returns a ComponentStatusInformer.
ComponentStatuses() ComponentStatusInformer
// ConfigMaps returns a ConfigMapInformer.
ConfigMaps() ConfigMapInformer
// Endpoints returns a EndpointsInformer.
Endpoints() EndpointsInformer
// Events returns a EventInformer.
Events() EventInformer
// LimitRanges returns a LimitRangeInformer.
LimitRanges() LimitRangeInformer
// Namespaces returns a NamespaceInformer.
Namespaces() NamespaceInformer
// Nodes returns a NodeInformer.
Nodes() NodeInformer
// PersistentVolumes returns a PersistentVolumeInformer.
PersistentVolumes() PersistentVolumeInformer
// PersistentVolumeClaims returns a PersistentVolumeClaimInformer.
PersistentVolumeClaims() PersistentVolumeClaimInformer
// Pods returns a PodInformer.
Pods() PodInformer
// PodTemplates returns a PodTemplateInformer.
PodTemplates() PodTemplateInformer
// ReplicationControllers returns a ReplicationControllerInformer.
ReplicationControllers() ReplicationControllerInformer
// ResourceQuotas returns a ResourceQuotaInformer.
ResourceQuotas() ResourceQuotaInformer
// Secrets returns a SecretInformer.
Secrets() SecretInformer
// Services returns a ServiceInformer.
Services() ServiceInformer
// ServiceAccounts returns a ServiceAccountInformer.
ServiceAccounts() ServiceAccountInformer
}
type version struct {
internalinterfaces.SharedInformerFactory
}
// New returns a new Interface.
func New(f internalinterfaces.SharedInformerFactory) Interface {
return &version{f}
}
// ComponentStatuses returns a ComponentStatusInformer.
func (v *version) ComponentStatuses() ComponentStatusInformer {
return &componentStatusInformer{factory: v.SharedInformerFactory}
}
// ConfigMaps returns a ConfigMapInformer.
func (v *version) ConfigMaps() ConfigMapInformer {
return &configMapInformer{factory: v.SharedInformerFactory}
}
// Endpoints returns a EndpointsInformer.
func (v *version) Endpoints() EndpointsInformer {
return &endpointsInformer{factory: v.SharedInformerFactory}
}
// Events returns a EventInformer.
func (v *version) Events() EventInformer {
return &eventInformer{factory: v.SharedInformerFactory}
}
// LimitRanges returns a LimitRangeInformer.
func (v *version) LimitRanges() LimitRangeInformer {
return &limitRangeInformer{factory: v.SharedInformerFactory}
}
// Namespaces returns a NamespaceInformer.
func (v *version) Namespaces() NamespaceInformer {
return &namespaceInformer{factory: v.SharedInformerFactory}
}
// Nodes returns a NodeInformer.
func (v *version) Nodes() NodeInformer {
return &nodeInformer{factory: v.SharedInformerFactory}
}
// PersistentVolumes returns a PersistentVolumeInformer.
func (v *version) PersistentVolumes() PersistentVolumeInformer {
return &persistentVolumeInformer{factory: v.SharedInformerFactory}
}
// PersistentVolumeClaims returns a PersistentVolumeClaimInformer.
func (v *version) PersistentVolumeClaims() PersistentVolumeClaimInformer {
return &persistentVolumeClaimInformer{factory: v.SharedInformerFactory}
}
// Pods returns a PodInformer.
func (v *version) Pods() PodInformer {
return &podInformer{factory: v.SharedInformerFactory}
}
// PodTemplates returns a PodTemplateInformer.
func (v *version) PodTemplates() PodTemplateInformer {
return &podTemplateInformer{factory: v.SharedInformerFactory}
}
// ReplicationControllers returns a ReplicationControllerInformer.
func (v *version) ReplicationControllers() ReplicationControllerInformer {
return &replicationControllerInformer{factory: v.SharedInformerFactory}
}
// ResourceQuotas returns a ResourceQuotaInformer.
func (v *version) ResourceQuotas() ResourceQuotaInformer {
return &resourceQuotaInformer{factory: v.SharedInformerFactory}
}
// Secrets returns a SecretInformer.
func (v *version) Secrets() SecretInformer {
return &secretInformer{factory: v.SharedInformerFactory}
}
// Services returns a ServiceInformer.
func (v *version) Services() ServiceInformer {
return &serviceInformer{factory: v.SharedInformerFactory}
}
// ServiceAccounts returns a ServiceAccountInformer.
func (v *version) ServiceAccounts() ServiceAccountInformer {
return &serviceAccountInformer{factory: v.SharedInformerFactory}
}

View File

@@ -0,0 +1,68 @@
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// This file was automatically generated by informer-gen
package 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/core/v1"
api_v1 "k8s.io/client-go/pkg/api/v1"
cache "k8s.io/client-go/tools/cache"
time "time"
)
// LimitRangeInformer provides access to a shared informer and lister for
// LimitRanges.
type LimitRangeInformer interface {
Informer() cache.SharedIndexInformer
Lister() v1.LimitRangeLister
}
type limitRangeInformer struct {
factory internalinterfaces.SharedInformerFactory
}
func newLimitRangeInformer(client kubernetes.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
sharedIndexInformer := cache.NewSharedIndexInformer(
&cache.ListWatch{
ListFunc: func(options meta_v1.ListOptions) (runtime.Object, error) {
return client.CoreV1().LimitRanges(meta_v1.NamespaceAll).List(options)
},
WatchFunc: func(options meta_v1.ListOptions) (watch.Interface, error) {
return client.CoreV1().LimitRanges(meta_v1.NamespaceAll).Watch(options)
},
},
&api_v1.LimitRange{},
resyncPeriod,
cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc},
)
return sharedIndexInformer
}
func (f *limitRangeInformer) Informer() cache.SharedIndexInformer {
return f.factory.InformerFor(&api_v1.LimitRange{}, newLimitRangeInformer)
}
func (f *limitRangeInformer) Lister() v1.LimitRangeLister {
return v1.NewLimitRangeLister(f.Informer().GetIndexer())
}

View File

@@ -0,0 +1,68 @@
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// This file was automatically generated by informer-gen
package 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/core/v1"
api_v1 "k8s.io/client-go/pkg/api/v1"
cache "k8s.io/client-go/tools/cache"
time "time"
)
// NamespaceInformer provides access to a shared informer and lister for
// Namespaces.
type NamespaceInformer interface {
Informer() cache.SharedIndexInformer
Lister() v1.NamespaceLister
}
type namespaceInformer struct {
factory internalinterfaces.SharedInformerFactory
}
func newNamespaceInformer(client kubernetes.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
sharedIndexInformer := cache.NewSharedIndexInformer(
&cache.ListWatch{
ListFunc: func(options meta_v1.ListOptions) (runtime.Object, error) {
return client.CoreV1().Namespaces().List(options)
},
WatchFunc: func(options meta_v1.ListOptions) (watch.Interface, error) {
return client.CoreV1().Namespaces().Watch(options)
},
},
&api_v1.Namespace{},
resyncPeriod,
cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc},
)
return sharedIndexInformer
}
func (f *namespaceInformer) Informer() cache.SharedIndexInformer {
return f.factory.InformerFor(&api_v1.Namespace{}, newNamespaceInformer)
}
func (f *namespaceInformer) Lister() v1.NamespaceLister {
return v1.NewNamespaceLister(f.Informer().GetIndexer())
}

68
informers/core/v1/node.go Normal file
View File

@@ -0,0 +1,68 @@
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// This file was automatically generated by informer-gen
package 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/core/v1"
api_v1 "k8s.io/client-go/pkg/api/v1"
cache "k8s.io/client-go/tools/cache"
time "time"
)
// NodeInformer provides access to a shared informer and lister for
// Nodes.
type NodeInformer interface {
Informer() cache.SharedIndexInformer
Lister() v1.NodeLister
}
type nodeInformer struct {
factory internalinterfaces.SharedInformerFactory
}
func newNodeInformer(client kubernetes.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
sharedIndexInformer := cache.NewSharedIndexInformer(
&cache.ListWatch{
ListFunc: func(options meta_v1.ListOptions) (runtime.Object, error) {
return client.CoreV1().Nodes().List(options)
},
WatchFunc: func(options meta_v1.ListOptions) (watch.Interface, error) {
return client.CoreV1().Nodes().Watch(options)
},
},
&api_v1.Node{},
resyncPeriod,
cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc},
)
return sharedIndexInformer
}
func (f *nodeInformer) Informer() cache.SharedIndexInformer {
return f.factory.InformerFor(&api_v1.Node{}, newNodeInformer)
}
func (f *nodeInformer) Lister() v1.NodeLister {
return v1.NewNodeLister(f.Informer().GetIndexer())
}

View File

@@ -0,0 +1,68 @@
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// This file was automatically generated by informer-gen
package 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/core/v1"
api_v1 "k8s.io/client-go/pkg/api/v1"
cache "k8s.io/client-go/tools/cache"
time "time"
)
// PersistentVolumeInformer provides access to a shared informer and lister for
// PersistentVolumes.
type PersistentVolumeInformer interface {
Informer() cache.SharedIndexInformer
Lister() v1.PersistentVolumeLister
}
type persistentVolumeInformer struct {
factory internalinterfaces.SharedInformerFactory
}
func newPersistentVolumeInformer(client kubernetes.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
sharedIndexInformer := cache.NewSharedIndexInformer(
&cache.ListWatch{
ListFunc: func(options meta_v1.ListOptions) (runtime.Object, error) {
return client.CoreV1().PersistentVolumes().List(options)
},
WatchFunc: func(options meta_v1.ListOptions) (watch.Interface, error) {
return client.CoreV1().PersistentVolumes().Watch(options)
},
},
&api_v1.PersistentVolume{},
resyncPeriod,
cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc},
)
return sharedIndexInformer
}
func (f *persistentVolumeInformer) Informer() cache.SharedIndexInformer {
return f.factory.InformerFor(&api_v1.PersistentVolume{}, newPersistentVolumeInformer)
}
func (f *persistentVolumeInformer) Lister() v1.PersistentVolumeLister {
return v1.NewPersistentVolumeLister(f.Informer().GetIndexer())
}

View File

@@ -0,0 +1,68 @@
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// This file was automatically generated by informer-gen
package 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/core/v1"
api_v1 "k8s.io/client-go/pkg/api/v1"
cache "k8s.io/client-go/tools/cache"
time "time"
)
// PersistentVolumeClaimInformer provides access to a shared informer and lister for
// PersistentVolumeClaims.
type PersistentVolumeClaimInformer interface {
Informer() cache.SharedIndexInformer
Lister() v1.PersistentVolumeClaimLister
}
type persistentVolumeClaimInformer struct {
factory internalinterfaces.SharedInformerFactory
}
func newPersistentVolumeClaimInformer(client kubernetes.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
sharedIndexInformer := cache.NewSharedIndexInformer(
&cache.ListWatch{
ListFunc: func(options meta_v1.ListOptions) (runtime.Object, error) {
return client.CoreV1().PersistentVolumeClaims(meta_v1.NamespaceAll).List(options)
},
WatchFunc: func(options meta_v1.ListOptions) (watch.Interface, error) {
return client.CoreV1().PersistentVolumeClaims(meta_v1.NamespaceAll).Watch(options)
},
},
&api_v1.PersistentVolumeClaim{},
resyncPeriod,
cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc},
)
return sharedIndexInformer
}
func (f *persistentVolumeClaimInformer) Informer() cache.SharedIndexInformer {
return f.factory.InformerFor(&api_v1.PersistentVolumeClaim{}, newPersistentVolumeClaimInformer)
}
func (f *persistentVolumeClaimInformer) Lister() v1.PersistentVolumeClaimLister {
return v1.NewPersistentVolumeClaimLister(f.Informer().GetIndexer())
}

68
informers/core/v1/pod.go Normal file
View File

@@ -0,0 +1,68 @@
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// This file was automatically generated by informer-gen
package 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/core/v1"
api_v1 "k8s.io/client-go/pkg/api/v1"
cache "k8s.io/client-go/tools/cache"
time "time"
)
// PodInformer provides access to a shared informer and lister for
// Pods.
type PodInformer interface {
Informer() cache.SharedIndexInformer
Lister() v1.PodLister
}
type podInformer struct {
factory internalinterfaces.SharedInformerFactory
}
func newPodInformer(client kubernetes.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
sharedIndexInformer := cache.NewSharedIndexInformer(
&cache.ListWatch{
ListFunc: func(options meta_v1.ListOptions) (runtime.Object, error) {
return client.CoreV1().Pods(meta_v1.NamespaceAll).List(options)
},
WatchFunc: func(options meta_v1.ListOptions) (watch.Interface, error) {
return client.CoreV1().Pods(meta_v1.NamespaceAll).Watch(options)
},
},
&api_v1.Pod{},
resyncPeriod,
cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc},
)
return sharedIndexInformer
}
func (f *podInformer) Informer() cache.SharedIndexInformer {
return f.factory.InformerFor(&api_v1.Pod{}, newPodInformer)
}
func (f *podInformer) Lister() v1.PodLister {
return v1.NewPodLister(f.Informer().GetIndexer())
}

View File

@@ -0,0 +1,68 @@
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// This file was automatically generated by informer-gen
package 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/core/v1"
api_v1 "k8s.io/client-go/pkg/api/v1"
cache "k8s.io/client-go/tools/cache"
time "time"
)
// PodTemplateInformer provides access to a shared informer and lister for
// PodTemplates.
type PodTemplateInformer interface {
Informer() cache.SharedIndexInformer
Lister() v1.PodTemplateLister
}
type podTemplateInformer struct {
factory internalinterfaces.SharedInformerFactory
}
func newPodTemplateInformer(client kubernetes.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
sharedIndexInformer := cache.NewSharedIndexInformer(
&cache.ListWatch{
ListFunc: func(options meta_v1.ListOptions) (runtime.Object, error) {
return client.CoreV1().PodTemplates(meta_v1.NamespaceAll).List(options)
},
WatchFunc: func(options meta_v1.ListOptions) (watch.Interface, error) {
return client.CoreV1().PodTemplates(meta_v1.NamespaceAll).Watch(options)
},
},
&api_v1.PodTemplate{},
resyncPeriod,
cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc},
)
return sharedIndexInformer
}
func (f *podTemplateInformer) Informer() cache.SharedIndexInformer {
return f.factory.InformerFor(&api_v1.PodTemplate{}, newPodTemplateInformer)
}
func (f *podTemplateInformer) Lister() v1.PodTemplateLister {
return v1.NewPodTemplateLister(f.Informer().GetIndexer())
}

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