diff --git a/Gopkg.lock b/Gopkg.lock index 7c676bf743..19686e20f7 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -291,14 +291,6 @@ revision = "5c8c8bd35d3832f5d134ae1e1e375b69a4d25242" version = "v1.0.1" -[[projects]] - digest = "1:8262e3107286b0c69c68baa93b252901620bd3bfbc21ea8fdee02223f7a7d727" - name = "github.com/kubernetes-incubator/apiserver-builder" - packages = ["pkg/controller"] - pruneopts = "T" - revision = "83b2c178a8f935a738cebbf41aa5b8af1f19162d" - version = "v0.2-alpha.0" - [[projects]] digest = "1:3804a3a02964db8e6db3e5e7960ac1c1a9b12835642dd4f4ac4e56c749ec73eb" name = "github.com/markbates/inflect" @@ -933,6 +925,14 @@ pruneopts = "T" revision = "7338e4bfd6915369a1375890db1bbda0158c9863" +[[projects]] + digest = "1:7a3ef99d492d30157b8e933624a8f0292b4cee5934c23269f7640c8030eb83cd" + name = "k8s.io/klog" + packages = ["."] + pruneopts = "T" + revision = "a5bc97fbc634d635061f3146511332c7e313a55a" + version = "v0.1.0" + [[projects]] branch = "master" digest = "1:152cd19bedf58a86d6b8b9ca42a428e4f16a9415f81e248a800b6a46c77dc486" @@ -942,7 +942,8 @@ revision = "72693cb1fadd73ae2742f6fe29af77d1aecdd8cd" [[projects]] - digest = "1:e99adef47e9f7029c5fa2f0ba03e78a32194cf24ada000a6b8753d6f8cde02cc" + branch = "master" + digest = "1:7dcbe4d792c3e524fd0e08722294b4553eefb2609a708a4470d1abcd87aa12a6" name = "sigs.k8s.io/cluster-api" packages = [ "pkg/apis", @@ -953,10 +954,11 @@ "pkg/client/clientset_generated/clientset/typed/cluster/v1alpha1", "pkg/controller/error", "pkg/controller/machine", + "pkg/errors", "pkg/util", ] pruneopts = "T" - revision = "0734939e05aeb64ab198e3feeee8b4e90ee5cbb2" + revision = "cba244b06de7d29777036551e6b32817878d1fcd" [[projects]] digest = "1:ca3f51201a90f3a23bf35938ee910d2fb3095ece453cf56c8b723e935c194ebd" @@ -1045,7 +1047,6 @@ "github.com/ghodss/yaml", "github.com/golang/glog", "github.com/golang/mock/gomock", - "github.com/kubernetes-incubator/apiserver-builder/pkg/controller", "github.com/onsi/ginkgo", "github.com/onsi/gomega", "github.com/openshift/cluster-api-actuator-pkg/pkg/e2e/framework", @@ -1053,8 +1054,10 @@ "github.com/openshift/cluster-api-actuator-pkg/pkg/types", "github.com/prometheus/common/log", "github.com/spf13/cobra", + "github.com/spf13/pflag", "github.com/stretchr/testify/assert", "golang.org/x/net/context", + "k8s.io/api/apps/v1", "k8s.io/api/core/v1", "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1", "k8s.io/apimachinery/pkg/api/equality", @@ -1071,13 +1074,14 @@ "k8s.io/client-go/kubernetes/fake", "k8s.io/client-go/kubernetes/scheme", "k8s.io/client-go/plugin/pkg/client/auth/gcp", + "k8s.io/client-go/tools/record", "k8s.io/code-generator/cmd/deepcopy-gen", "sigs.k8s.io/cluster-api/pkg/apis", "sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1", - "sigs.k8s.io/cluster-api/pkg/client/clientset_generated/clientset", "sigs.k8s.io/cluster-api/pkg/client/clientset_generated/clientset/typed/cluster/v1alpha1", "sigs.k8s.io/cluster-api/pkg/controller/error", "sigs.k8s.io/cluster-api/pkg/controller/machine", + "sigs.k8s.io/cluster-api/pkg/errors", "sigs.k8s.io/controller-runtime/pkg/client", "sigs.k8s.io/controller-runtime/pkg/client/config", "sigs.k8s.io/controller-runtime/pkg/client/fake", diff --git a/Gopkg.toml b/Gopkg.toml index 1e96837fd1..fb886f3571 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -23,8 +23,9 @@ required = [ version = "v1.15.5" [[override]] -name = "sigs.k8s.io/cluster-api" -revision = "0734939e05aeb64ab198e3feeee8b4e90ee5cbb2" + name = "sigs.k8s.io/cluster-api" + branch = "master" + #revision = "0734939e05aeb64ab198e3feeee8b4e90ee5cbb2" # STANZAS BELOW ARE GENERATED AND MAY BE WRITTEN - DO NOT MODIFY BELOW THIS LINE. diff --git a/vendor/github.com/kubernetes-incubator/apiserver-builder/.travis.yml b/vendor/github.com/kubernetes-incubator/apiserver-builder/.travis.yml deleted file mode 100644 index fad93b8d86..0000000000 --- a/vendor/github.com/kubernetes-incubator/apiserver-builder/.travis.yml +++ /dev/null @@ -1,14 +0,0 @@ -language: go - -go: -- 1.8.1 - -git: - depth: 3 - -install: -- scripts/install_etcd.sh - -script: -- cd example -- PATH=$PATH:/tmp/test-etcd make test diff --git a/vendor/github.com/kubernetes-incubator/apiserver-builder/LICENSE b/vendor/github.com/kubernetes-incubator/apiserver-builder/LICENSE deleted file mode 100644 index 8dada3edaf..0000000000 --- a/vendor/github.com/kubernetes-incubator/apiserver-builder/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "{}" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - 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. - 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. diff --git a/vendor/github.com/kubernetes-incubator/apiserver-builder/OWNERS b/vendor/github.com/kubernetes-incubator/apiserver-builder/OWNERS deleted file mode 100644 index e9c64766e6..0000000000 --- a/vendor/github.com/kubernetes-incubator/apiserver-builder/OWNERS +++ /dev/null @@ -1,16 +0,0 @@ -reviewers: - - jimmidyson - - MHBauer - - pwittrock - - directxman12 - - brancz - - xiang90 - - hongchaodeng -approvers: - - jimmidyson - - MHBauer - - pwittrock - - directxman12 - - brancz - - xiang90 - - hongchaodeng diff --git a/vendor/github.com/kubernetes-incubator/apiserver-builder/README.md b/vendor/github.com/kubernetes-incubator/apiserver-builder/README.md deleted file mode 100644 index 1b84c15fe6..0000000000 --- a/vendor/github.com/kubernetes-incubator/apiserver-builder/README.md +++ /dev/null @@ -1,148 +0,0 @@ -## `apiserver-builder` - -[![Build Status](https://travis-ci.org/kubernetes-incubator/apiserver-builder.svg?branch=master)](https://travis-ci.org/kubernetes-incubator/apiserver-builder "Travis") - -Apiserver Builder is a collection of libraries and tools to build native -Kubernetes extensions using Kubernetes apiserver code. - -## Quick start - -### Installation - -Instructions on installing the set of binary tools for: - -- bootstrapping new apiserver code, godeps, and APIs -- generating code for APIs -- generating docs - -Details [here](https://github.com/kubernetes-incubator/apiserver-builder/blob/master/docs/installing.md) - -### Getting started - -Instructions on how to bootstrap a new apiserver with a simple type - -Details [here](https://github.com/kubernetes-incubator/apiserver-builder/blob/master/docs/getting_started.md) - -### Adding a new resource with a controller - -Instructions on how to add a new resource - -Details [here](https://github.com/kubernetes-incubator/apiserver-builder/blob/master/docs/adding_resources.md) - -### Adding validation - -Instructions on how to add schema validation an existing resource - -Details [here](https://github.com/kubernetes-incubator/apiserver-builder/blob/master/docs/adding_validation.md) - -### Adding defaulting - -Instructions on how to add field value defaulting to an existing resource - -Details [here](https://github.com/kubernetes-incubator/apiserver-builder/blob/master/docs/adding_defaulting.md) - -### Adding subresource - -Instructions on how to add a new subresource to an existing resource - -Details [here](https://github.com/kubernetes-incubator/apiserver-builder/blob/master/docs/adding_subresources.md) - -### Defining custom REST handlers - -Instructions on how to Overriding the default resource storage with -custom REST handlers - -Details [here](https://github.com/kubernetes-incubator/apiserver-builder/blob/master/docs/adding_custom_rest.md) - -### Generating code - -Run: - -`apiserver-boot generate"` - -### Generating docs - -Run: - -`apiserver-boot generate docs --server ` - -### Build and run etcd + apiserver + controller manager - -Run: - -`apiserver-boot build` - -`apiserver-boot run` - -This will create a kubeconfig file to use with `kubectl --kubeconfig` - -### Using delegated auth with minikube - -Instructions on how to run an apiserver using delegated auth with a minikube cluster - -Details [here](https://github.com/kubernetes-incubator/apiserver-builder/blob/master/docs/using_minikube.md) - - -## Motivation - -Standing up apiservers from scratch and adding apis requires 100's of lines of boilerplate -code that must be understood and maintained (rebased against master). There are few defaults, -requiring the common case configuration to be repeated for each new apiserver and resource. -Apiservers rely heavily on code generation to build libraries used by the apiserver, putting a -steep learning curve on Kubernetes community members that want to implement a native api. -Frameworks like Ruby on Rails and Spring have made standing up REST apis trivial by eliminating -boilerplate and defaulting common values, allowing developers to focus on creating -implementing the business logic of their component. - -## Goals - -- Working hello-world apiserver in ~5 lines. -- Users can make a new resource type by simply defining a struct and tagging it - as a resource. -- Adding sub-resources requires only defining the request-type struct definition, - implementing the REST implementation, and tagging the parent resource. -- Adding validation / defaulting to a type only requires defining the validation / defaulting method - as a function of the appropriate struct type. -- All necessary generated code can be generated running a single command, passing in repo root. - - -### Binary distribution of build tools - -- Distribute binaries for all code-generators -- Write porcelain wrapper for code-generators that is able to detect the - appropriate arguments for each from the GOPATH and `types.go`. - -### Helper libraries - -- Implement common-case defaults for create/update strategies - - Define implementable interfaces for default actions requiring - type specific knowledge - e.g. HasStatus - how to set and get Status -- Implement libraries for registering types and setting up strategies - - Implement structs to defining wiring semantics instead of linking - directly to package variables for declarations -- Implement libraries for registering subresources - -### Generate code for common defaults that require type or variable declarations - -- Implementations for "unversioned" types -- Implementations for "List" types -- Package variables used by code generation -- Generate invocations of helper libraries from the types in `types.go`. - -### Support hooks for overriding defaults - -- Try to support 100% of the flexibility of manually writing the boilerplate by - providing hooks. - - Users can call functions to register overrides. - -### Support for generating reference documentation - -- Generate k8s.io style reference documentation for declared types - - Support request / response examples and manual edits - -### Thorough documentation and examples - -- Hello-world example -- How to override each default -- Build tools -- How to use libraries directly (without relying on code generation) diff --git a/vendor/github.com/kubernetes-incubator/apiserver-builder/cmd/.import-restrictions b/vendor/github.com/kubernetes-incubator/apiserver-builder/cmd/.import-restrictions deleted file mode 100644 index 8832a0234b..0000000000 --- a/vendor/github.com/kubernetes-incubator/apiserver-builder/cmd/.import-restrictions +++ /dev/null @@ -1,14 +0,0 @@ -{ - "Rules": [ - { - "SelectorRegexp": "k8s[.]io", - "AllowedPrefixes": [ - "k8s.io/kubernetes/cmd/libs/go2idl", - "k8s.io/gengo", - "k8s.io/kubernetes/third_party", - "k8s.io/apimachinery/third_party", - "k8s.io/apimachinery/pkg/util/sets" - ] - } - ] -} diff --git a/vendor/github.com/kubernetes-incubator/apiserver-builder/cmd/apiregister-gen/generators/apis_generator.go b/vendor/github.com/kubernetes-incubator/apiserver-builder/cmd/apiregister-gen/generators/apis_generator.go deleted file mode 100644 index bdceeb20fd..0000000000 --- a/vendor/github.com/kubernetes-incubator/apiserver-builder/cmd/apiregister-gen/generators/apis_generator.go +++ /dev/null @@ -1,99 +0,0 @@ -/* -Copyright 2017 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package generators - -import ( - "io" - "text/template" - - "fmt" - "k8s.io/gengo/generator" -) - -type apiGenerator struct { - generator.DefaultGen - apis *APIs -} - -var _ generator.Generator = &apiGenerator{} - -func CreateApisGenerator(apis *APIs, filename string) generator.Generator { - return &apiGenerator{ - generator.DefaultGen{OptionalName: filename}, - apis, - } -} - -func (d *apiGenerator) Imports(c *generator.Context) []string { - imports := []string{ - "github.com/kubernetes-incubator/apiserver-builder/pkg/builders", - } - for _, group := range d.apis.Groups { - imports = append(imports, group.PkgPath) - for _, version := range group.Versions { - imports = append(imports, fmt.Sprintf( - "%s%s \"%s\"", group.Group, version.Version, version.Pkg.Path)) - } - } - return imports -} - -func (d *apiGenerator) Finalize(context *generator.Context, w io.Writer) error { - temp := template.Must(template.New("apis-template").Parse(APIsTemplate)) - err := temp.Execute(w, d.apis) - if err != nil { - return err - } - return err -} - -var APIsTemplate = ` -// GetAllApiBuilders returns all known APIGroupBuilders -// so they can be registered with the apiserver -func GetAllApiBuilders() []*builders.APIGroupBuilder { - return []*builders.APIGroupBuilder{ - {{ range $group := .Groups -}} - Get{{ $group.GroupTitle }}APIBuilder(), - {{ end -}} - } -} - -{{ range $group := .Groups -}} -var {{ $group.Group }}ApiGroup = builders.NewApiGroupBuilder( - "{{ $group.Group }}.{{ $group.Domain }}", - "{{ $group.PkgPath}}"). - WithUnVersionedApi({{ $group.Group }}.ApiVersion). - WithVersionedApis( - {{ range $version := $group.Versions -}} - {{ $group.Group }}{{ $version.Version }}.ApiVersion, - {{ end -}} - ). - WithRootScopedKinds( - {{ range $version := $group.Versions -}} - {{ range $res := $version.Resources -}} - {{ if $res.NonNamespaced -}} - "{{ $res.Kind }}", - {{ end -}} - {{ end -}} - {{ end -}} - ) - -func Get{{ $group.GroupTitle }}APIBuilder() *builders.APIGroupBuilder { - return {{ $group.Group }}ApiGroup -} -{{ end -}} -` diff --git a/vendor/github.com/kubernetes-incubator/apiserver-builder/cmd/apiregister-gen/generators/controller_generator.go b/vendor/github.com/kubernetes-incubator/apiserver-builder/cmd/apiregister-gen/generators/controller_generator.go deleted file mode 100644 index a68f28f806..0000000000 --- a/vendor/github.com/kubernetes-incubator/apiserver-builder/cmd/apiregister-gen/generators/controller_generator.go +++ /dev/null @@ -1,257 +0,0 @@ -/* -Copyright 2017 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package generators - -import ( - "io" - "strings" - "text/template" - - "k8s.io/gengo/generator" - "github.com/markbates/inflect" -) - -type controllerGenerator struct { - generator.DefaultGen - controller Controller -} - -var _ generator.Generator = &controllerGenerator{} - -func CreateControllerGenerator(controller Controller, filename string) generator.Generator { - return &controllerGenerator{ - generator.DefaultGen{OptionalName: filename}, - controller, - } -} - -func (d *controllerGenerator) Imports(c *generator.Context) []string { - im := []string{ - "github.com/golang/glog", - "github.com/kubernetes-incubator/apiserver-builder/pkg/controller", - "k8s.io/apimachinery/pkg/api/errors", - "k8s.io/client-go/rest", - "k8s.io/client-go/tools/cache", - "k8s.io/client-go/util/workqueue", - d.controller.Repo + "/pkg/controller/sharedinformers", - } - - return im -} - -func (d *controllerGenerator) Finalize(context *generator.Context, w io.Writer) error { - temp := template.Must(template.New("controller-template").Funcs( - template.FuncMap{ - "title": strings.Title, - }, - ).Parse(ControllerAPITemplate)) - return temp.Execute(w, d.controller) -} - -var ControllerAPITemplate = ` -// {{.Target.Kind}}Controller implements the controller.{{.Target.Kind}}Controller interface -type {{.Target.Kind}}Controller struct { - queue *controller.QueueWorker - - // Handles messages - controller *{{.Target.Kind}}ControllerImpl - - Name string - - BeforeReconcile func(key string) - AfterReconcile func(key string, err error) -} - -// NewController returns a new {{.Target.Kind}}Controller for responding to {{.Target.Kind}} events -func New{{.Target.Kind}}Controller(config *rest.Config, si *sharedinformers.SharedInformers) *{{.Target.Kind}}Controller { - q := workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), "{{.Target.Kind}}") - - // For non-generated code to add events - uc := &{{.Target.Kind}}ControllerImpl{} - uc.Init(config, si, q) - - queue := &controller.QueueWorker{q, 10, "{{.Target.Kind}}", nil} - c := &{{.Target.Kind}}Controller{queue, uc, "{{.Target.Kind}}", nil, nil} - queue.Reconcile = c.reconcile - return c -} - -func (c *{{.Target.Kind}}Controller) GetName() string { - return c.Name -} - -func (c *{{.Target.Kind}}Controller) reconcile(key string) (err error) { - var namespace, name string - - if c.BeforeReconcile != nil { - c.BeforeReconcile(key) - } - if c.AfterReconcile != nil { - // Wrap in a function so err is evaluated after it is set - defer func() { c.AfterReconcile(key, err) }() - } - - namespace, name, err = cache.SplitMetaNamespaceKey(key) - if err != nil { - return - } - - u, err := c.controller.Get(namespace, name) - if errors.IsNotFound(err) { - glog.Infof("Not doing work for {{.Target.Kind}} %v because it has been deleted", key) - // Set error so it is picked up by AfterReconcile and the return function - err = nil - return - } - if err != nil { - glog.Errorf("Unable to retrieve {{.Target.Kind}} %v from store: %v", key, err) - return - } - - // Set error so it is picked up by AfterReconcile and the return function - err = c.controller.Reconcile(u) - - return -} - -func (c *{{.Target.Kind}}Controller) Run(stopCh <-chan struct{}) { - c.queue.Run(stopCh) -} -` - -type allControllerGenerator struct { - generator.DefaultGen - Controllers []Controller -} - -var _ generator.Generator = &allControllerGenerator{} - -func CreateAllControllerGenerator(controllers []Controller, filename string) generator.Generator { - return &allControllerGenerator{ - generator.DefaultGen{OptionalName: filename}, - controllers, - } -} - -func (d *allControllerGenerator) Imports(c *generator.Context) []string { - if len(d.Controllers) == 0 { - return []string{} - } - - repo := d.Controllers[0].Repo - im := []string{ - "k8s.io/client-go/rest", - "github.com/kubernetes-incubator/apiserver-builder/pkg/controller", - repo + "/pkg/controller/sharedinformers", - } - - // Import package for each controller - repos := map[string]string{} - for _, c := range d.Controllers { - repos[c.Pkg.Path] = "" - } - for k, _ := range repos { - im = append(im, k) - } - - return im -} - -func (d *allControllerGenerator) Finalize(context *generator.Context, w io.Writer) error { - temp := template.Must(template.New("all-controller-template").Funcs( - template.FuncMap{ - "title": strings.Title, - }, - ).Parse(AllControllerAPITemplate)) - return temp.Execute(w, d) -} - -var AllControllerAPITemplate = ` - -func GetAllControllers(config *rest.Config) ([]controller.Controller, chan struct{}) { - shutdown := make(chan struct{}) - si := sharedinformers.NewSharedInformers(config, shutdown) - return []controller.Controller{ - {{ range $c := .Controllers -}} - {{ $c.Pkg.Name }}.New{{ $c.Target.Kind }}Controller(config, si), - {{ end -}} - }, shutdown -} - -` - -type informersGenerator struct { - generator.DefaultGen - Controllers []Controller -} - -var _ generator.Generator = &informersGenerator{} - -func CreateInformersGenerator(controllers []Controller, filename string) generator.Generator { - return &informersGenerator{ - generator.DefaultGen{OptionalName: filename}, - controllers, - } -} - -func (d *informersGenerator) Imports(c *generator.Context) []string { - if len(d.Controllers) == 0 { - return []string{} - } - - repo := d.Controllers[0].Repo - return []string{ - "time", - "k8s.io/client-go/rest", - repo + "/pkg/client/clientset_generated/clientset", - repo + "/pkg/client/informers_generated/externalversions", - } -} - -func (d *informersGenerator) Finalize(context *generator.Context, w io.Writer) error { - temp := template.Must(template.New("informersGenerator-template").Funcs( - template.FuncMap{ - "title": strings.Title, - "plural": inflect.NewDefaultRuleset().Pluralize, - }, - ).Parse(InformersTemplate)) - return temp.Execute(w, d.Controllers) -} - -var InformersTemplate = ` -// SharedInformers wraps all informers used by controllers so that -// they are shared across controller implementations -type SharedInformers struct { - Factory externalversions.SharedInformerFactory -} - -// newSharedInformers returns a set of started informers -func NewSharedInformers(config *rest.Config, shutdown <-chan struct{}) *SharedInformers { - cs := clientset.NewForConfigOrDie(config) - si := &SharedInformers{externalversions.NewSharedInformerFactory(cs, 10*time.Minute)} - si.startInformers(shutdown) - return si -} - -// startInformers starts all of the informers -func (si *SharedInformers) startInformers(shutdown <-chan struct{}) { - {{ range $c := . -}} - go si.Factory.{{title $c.Target.Group}}().{{title $c.Target.Version}}().{{plural $c.Target.Kind}}().Informer().Run(shutdown) - {{ end -}} -} - -` diff --git a/vendor/github.com/kubernetes-incubator/apiserver-builder/cmd/apiregister-gen/generators/install_generator.go b/vendor/github.com/kubernetes-incubator/apiserver-builder/cmd/apiregister-gen/generators/install_generator.go deleted file mode 100644 index 993e642f27..0000000000 --- a/vendor/github.com/kubernetes-incubator/apiserver-builder/cmd/apiregister-gen/generators/install_generator.go +++ /dev/null @@ -1,67 +0,0 @@ -/* -Copyright 2017 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package generators - -import ( - "io" - "text/template" - - "k8s.io/gengo/generator" - "path" -) - -type installGenerator struct { - generator.DefaultGen - apigroup *APIGroup -} - -var _ generator.Generator = &unversionedGenerator{} - -func CreateInstallGenerator(apigroup *APIGroup, filename string) generator.Generator { - return &installGenerator{ - generator.DefaultGen{OptionalName: filename}, - apigroup, - } -} - -func (d *installGenerator) Imports(c *generator.Context) []string { - return []string{ - "k8s.io/apimachinery/pkg/apimachinery/announced", - "k8s.io/apimachinery/pkg/apimachinery/registered", - "k8s.io/apimachinery/pkg/runtime", - path.Dir(d.apigroup.Pkg.Path), - } -} - -func (d *installGenerator) Finalize(context *generator.Context, w io.Writer) error { - temp := template.Must(template.New("install-template").Parse(InstallAPITemplate)) - err := temp.Execute(w, d.apigroup) - if err != nil { - return err - } - return err -} - -var InstallAPITemplate = ` -func Install( - groupFactoryRegistry announced.APIGroupFactoryRegistry, - registry *registered.APIRegistrationManager, - scheme *runtime.Scheme) { - - apis.Get{{ .GroupTitle }}APIBuilder().Install(groupFactoryRegistry, registry, scheme) -} -` diff --git a/vendor/github.com/kubernetes-incubator/apiserver-builder/cmd/apiregister-gen/generators/package.go b/vendor/github.com/kubernetes-incubator/apiserver-builder/cmd/apiregister-gen/generators/package.go deleted file mode 100644 index ac5c1f61b1..0000000000 --- a/vendor/github.com/kubernetes-incubator/apiserver-builder/cmd/apiregister-gen/generators/package.go +++ /dev/null @@ -1,178 +0,0 @@ -/* -Copyright 2017 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package generators - -import ( - "path" - "path/filepath" - "strings" - - "k8s.io/apimachinery/pkg/util/sets" - "k8s.io/gengo/args" - "k8s.io/gengo/generator" - "k8s.io/gengo/namer" - "k8s.io/gengo/types" - - "github.com/pkg/errors" -) - -// CustomArgs is used tby the go2idl framework to pass args specific to this -// generator. -type CustomArgs struct{} - -type Gen struct { - p []generator.Package -} - -func (g *Gen) Execute(arguments *args.GeneratorArgs) error { - return arguments.Execute( - g.NameSystems(), - g.DefaultNameSystem(), - g.Packages) -} - -// DefaultNameSystem returns the default name system for ordering the types to be -// processed by the generators in this package. -func (g *Gen) DefaultNameSystem() string { - return "public" -} - -// NameSystems returns the name system used by the generators in this package. -func (g *Gen) NameSystems() namer.NameSystems { - return namer.NameSystems{ - "public": namer.NewPublicNamer(1), - "raw": namer.NewRawNamer("", nil), - } -} - -func (g *Gen) ParsePackages(context *generator.Context, arguments *args.GeneratorArgs) (sets.String, sets.String, string, string) { - versionedPkgs := sets.NewString() - unversionedPkgs := sets.NewString() - mainPkg := "" - apisPkg := "" - for _, o := range context.Order { - if IsAPIResource(o) { - versioned := o.Name.Package - versionedPkgs.Insert(versioned) - unversioned := filepath.Dir(versioned) - unversionedPkgs.Insert(unversioned) - - if apis := filepath.Dir(unversioned); apis != apisPkg && len(apisPkg) > 0 { - panic(errors.Errorf( - "Found multiple apis directory paths: %v and %v", apisPkg, apis)) - } else { - apisPkg = apis - mainPkg = filepath.Dir(apisPkg) - } - } - } - return versionedPkgs, unversionedPkgs, apisPkg, mainPkg -} - -func (g *Gen) Packages(context *generator.Context, arguments *args.GeneratorArgs) generator.Packages { - g.p = generator.Packages{} - - b := NewAPIsBuilder(context, arguments) - for _, apigroup := range b.APIs.Groups { - for _, apiversion := range apigroup.Versions { - factory := &packageFactory{apiversion.Pkg.Path, arguments} - // Add generators for versioned types - gen := CreateVersionedGenerator(apiversion, apigroup, arguments.OutputFileBaseName) - g.p = append(g.p, factory.createPackage(gen)) - } - - factory := &packageFactory{apigroup.Pkg.Path, arguments} - gen := CreateUnversionedGenerator(apigroup, arguments.OutputFileBaseName) - g.p = append(g.p, factory.createPackage(gen)) - - factory = &packageFactory{path.Join(apigroup.Pkg.Path, "install"), arguments} - gen = CreateInstallGenerator(apigroup, arguments.OutputFileBaseName) - g.p = append(g.p, factory.createPackage(gen)) - } - - factory := &packageFactory{b.APIs.Pkg.Path, arguments} - gen := CreateApisGenerator(b.APIs, arguments.OutputFileBaseName) - g.p = append(g.p, factory.createPackage(gen)) - - // Add generators for Controllers. - repo := "" - for _, c := range b.Controllers { - repo = c.Repo - factory = &packageFactory{c.Pkg.Path, arguments} - cgen := CreateControllerGenerator(c, arguments.OutputFileBaseName) - g.p = append(g.p, factory.createPackage(cgen)) - } - - if len(b.Controllers) > 0 { - factory = &packageFactory{context.Universe[repo+"/pkg/controller"].Path, arguments} - cgen := CreateAllControllerGenerator(b.Controllers, arguments.OutputFileBaseName) - g.p = append(g.p, factory.createPackage(cgen)) - } - - if len(b.Controllers) > 0 { - factory = &packageFactory{context.Universe[repo+"/pkg/controller/sharedinformers"].Path, arguments} - cgen := CreateInformersGenerator(b.Controllers, arguments.OutputFileBaseName) - g.p = append(g.p, factory.createPackage(cgen)) - } - return g.p -} - -type packageFactory struct { - path string - arguments *args.GeneratorArgs -} - -// Creates a package with a generator -func (f *packageFactory) createPackage(gen generator.Generator) generator.Package { - path := f.path - name := strings.Split(filepath.Base(f.path), ".")[0] - return &generator.DefaultPackage{ - PackageName: name, - PackagePath: path, - HeaderText: f.getHeader(), - GeneratorFunc: func(c *generator.Context) (generators []generator.Generator) { - return []generator.Generator{gen} - }, - FilterFunc: func(c *generator.Context, t *types.Type) bool { - return t.Name.Package == f.path - }, - } -} - -// Returns the header for generated files -func (f *packageFactory) getHeader() []byte { - header := []byte(`/* -Copyright 2017 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// This file was autogenerated by apiregister-gen. Do not edit it manually! - -`) - return header -} diff --git a/vendor/github.com/kubernetes-incubator/apiserver-builder/cmd/apiregister-gen/generators/parser.go b/vendor/github.com/kubernetes-incubator/apiserver-builder/cmd/apiregister-gen/generators/parser.go deleted file mode 100644 index 406cc56bdb..0000000000 --- a/vendor/github.com/kubernetes-incubator/apiserver-builder/cmd/apiregister-gen/generators/parser.go +++ /dev/null @@ -1,663 +0,0 @@ -/* -Copyright 2017 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package generators - -import ( - "fmt" - "log" - "path" - "path/filepath" - "strings" - - "github.com/pkg/errors" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/util/sets" - "k8s.io/gengo/args" - "k8s.io/gengo/generator" - "k8s.io/gengo/types" -) - -type APIs struct { - // Domain is the domain portion of the group - e.g. k8s.io - Domain string - // Package is the name of the go package the api group is under - e.g. github.com/pwittrock/apiserver-helloworld/apis - Package string - Pkg *types.Package - // Groups is a list of API groups - Groups map[string]*APIGroup -} - -type Controller struct { - Target schema.GroupVersionKind - Resource string - Pkg *types.Package - Repo string -} - -type APIGroup struct { - // Package is the name of the go package the api group is under - e.g. github.com/pwittrock/apiserver-helloworld/apis - Package string - // Domain is the domain portion of the group - e.g. k8s.io - Domain string - // Group is the short name of the group - e.g. mushroomkingdom - Group string - GroupTitle string - // Versions is the list of all versions for this group keyed by name - Versions map[string]*APIVersion - - UnversionedResources map[string]*APIResource - - // Structs is a list of unversioned definitions that must be generated - Structs []*Struct - Pkg *types.Package - PkgPath string -} - -type Struct struct { - // Name is the name of the type - Name string - // IsResource - IsResource bool - // Fields is the list of fields appearing in the struct - Fields []*Field -} - -type Field struct { - // Name is the name of the field - Name string - // For versioned Kubernetes types, this is the versioned package - VersionedPackage string - // For versioned Kubernetes types, this is theun versioned package - UnversionedImport string - UnversionedType string -} - -type APIVersion struct { - // Domain is the group domain - e.g. k8s.io - Domain string - // Group is the group name - e.g. mushroomkingdom - Group string - // Version is the api version - e.g. v1beta1 - Version string - // Resources is a list of resources appearing in the API version keyed by name - Resources map[string]*APIResource - // Pkg is the Package object from code-gen - Pkg *types.Package -} - -type APIResource struct { - // Domain is the group domain - e.g. k8s.io - Domain string - // Group is the group name - e.g. mushroomkingdom - Group string - // Version is the api version - e.g. v1beta1 - Version string - // Kind is the resource name - e.g. PeachesCastle - Kind string - // Resource is the resource name - e.g. peachescastles - Resource string - // REST is the rest.Storage implementation used to handle requests - // This field is optional. The standard REST implementation will be used - // by default. - REST string - // Subresources is a map of subresources keyed by name - Subresources map[string]*APISubresource - // Type is the Type object from code-gen - Type *types.Type - // Strategy is name of the struct to use for the strategy - Strategy string - // Strategy is name of the struct to use for the strategy - StatusStrategy string - // NonNamespaced indicates that the resource kind is non namespaced - NonNamespaced bool -} - -type APISubresource struct { - // Domain is the group domain - e.g. k8s.io - Domain string - // Group is the group name - e.g. mushroomkingdom - Group string - // Version is the api version - e.g. v1beta1 - Version string - // Kind is the resource name - e.g. PeachesCastle - Kind string - // Resource is the resource name - e.g. peachescastles - Resource string - // Request is the subresource request type - e.g. ScaleCastle - Request string - // REST is the rest.Storage implementation used to handle requests - REST string - // Path is the subresource path - e.g. scale - Path string - - // ImportPackage is the import statement that must appear for the Request - ImportPackage string - - // RequestType is the type of the request - RequestType *types.Type - - // RESTType is the type of the request handler - RESTType *types.Type -} - -type APIsBuilder struct { - context *generator.Context - arguments *args.GeneratorArgs - Domain string - VersionedPkgs sets.String - UnversionedPkgs sets.String - APIsPkg string - APIsPkgRaw *types.Package - GroupNames sets.String - - APIs *APIs - Controllers []Controller - - ByGroupKindVersion map[string]map[string]map[string]*APIResource - ByGroupVersionKind map[string]map[string]map[string]*APIResource - SubByGroupVersionKind map[string]map[string]map[string]*types.Type - Groups map[string]types.Package -} - -func NewAPIsBuilder(context *generator.Context, arguments *args.GeneratorArgs) *APIsBuilder { - b := &APIsBuilder{ - context: context, - arguments: arguments, - } - b.ParsePackages() - b.ParseDomain() - b.ParseGroupNames() - b.ParseIndex() - b.ParseControllers() - b.ParseAPIs() - - return b -} - -func (b *APIsBuilder) ParseControllers() { - for _, c := range b.context.Order { - if IsController(c) { - tags := ParseControllerTag(b.GetControllerTag(c)) - repo := strings.Split(c.Name.Package, "/pkg/controller")[0] - pkg := b.context.Universe[c.Name.Package] - b.Controllers = append(b.Controllers, Controller{ - tags.gvk, tags.resource, pkg, repo}) - } - } -} - -func (b *APIsBuilder) ParseAPIs() { - apis := &APIs{ - Domain: b.Domain, - Package: b.APIsPkg, - Groups: map[string]*APIGroup{}, - } - - for group, versionMap := range b.ByGroupVersionKind { - apiGroup := &APIGroup{ - Group: group, - GroupTitle: strings.Title(group), - Domain: b.Domain, - Versions: map[string]*APIVersion{}, - UnversionedResources: map[string]*APIResource{}, - } - - for version, kindMap := range versionMap { - apiVersion := &APIVersion{ - Domain: b.Domain, - Group: group, - Version: version, - Resources: map[string]*APIResource{}, - } - for kind, resource := range kindMap { - apiResource := &APIResource{ - Domain: resource.Domain, - Version: resource.Version, - Group: resource.Group, - Resource: resource.Resource, - Type: resource.Type, - REST: resource.REST, - Kind: resource.Kind, - Subresources: resource.Subresources, - StatusStrategy: resource.StatusStrategy, - Strategy: resource.Strategy, - NonNamespaced: resource.NonNamespaced, - } - apiVersion.Resources[kind] = apiResource - // Set the package for the api version - apiVersion.Pkg = b.context.Universe[resource.Type.Name.Package] - // Set the package for the api group - apiGroup.Pkg = b.context.Universe[filepath.Dir(resource.Type.Name.Package)] - apiGroup.PkgPath = apiGroup.Pkg.Path - - apiGroup.UnversionedResources[kind] = apiResource - } - - apiGroup.Versions[version] = apiVersion - } - b.ParseStructs(apiGroup) - apis.Groups[group] = apiGroup - } - apis.Pkg = b.context.Universe[b.APIsPkg] - b.APIs = apis -} - -// ParseIndex indexes all types with the comment "// +resource=RESOURCE" by GroupVersionKind and -// GroupKindVersion -func (b *APIsBuilder) ParseIndex() { - b.ByGroupVersionKind = map[string]map[string]map[string]*APIResource{} - b.ByGroupKindVersion = map[string]map[string]map[string]*APIResource{} - - b.SubByGroupVersionKind = map[string]map[string]map[string]*types.Type{} - for _, c := range b.context.Order { - if IsAPISubresource(c) { - group := GetGroup(c) - version := GetVersion(c, group) - kind := GetKind(c, group) - if _, f := b.SubByGroupVersionKind[group]; !f { - b.SubByGroupVersionKind[group] = map[string]map[string]*types.Type{} - } - if _, f := b.SubByGroupVersionKind[group][version]; !f { - b.SubByGroupVersionKind[group][version] = map[string]*types.Type{} - } - b.SubByGroupVersionKind[group][version][kind] = c - } - - if !IsAPIResource(c) { - continue - } - - r := &APIResource{ - Type: c, - NonNamespaced: IsNonNamespaced(c), - } - r.Group = GetGroup(c) - r.Version = GetVersion(c, r.Group) - r.Kind = GetKind(c, r.Group) - r.Domain = b.Domain - - rt := ParseResourceTag(b.GetResourceTag(c)) - - r.Resource = rt.Resource - r.REST = rt.REST - - r.Strategy = rt.Strategy - - // If not defined, default the strategy to the group strategy for backwards compatibility - if len(r.Strategy) == 0 { - r.Strategy = fmt.Sprintf("%s.%sStrategy", r.Group, r.Kind) - } - - // Copy the Status strategy to mirror the non-status strategy - r.StatusStrategy = strings.TrimSuffix(r.Strategy, "Strategy") - r.StatusStrategy = fmt.Sprintf("%sStatusStrategy", r.StatusStrategy) - - if _, f := b.ByGroupKindVersion[r.Group]; !f { - b.ByGroupKindVersion[r.Group] = map[string]map[string]*APIResource{} - } - if _, f := b.ByGroupKindVersion[r.Group][r.Kind]; !f { - b.ByGroupKindVersion[r.Group][r.Kind] = map[string]*APIResource{} - } - if _, f := b.ByGroupVersionKind[r.Group]; !f { - b.ByGroupVersionKind[r.Group] = map[string]map[string]*APIResource{} - } - if _, f := b.ByGroupVersionKind[r.Group][r.Version]; !f { - b.ByGroupVersionKind[r.Group][r.Version] = map[string]*APIResource{} - } - - b.ByGroupKindVersion[r.Group][r.Kind][r.Version] = r - b.ByGroupVersionKind[r.Group][r.Version][r.Kind] = r - - // Do subresources - if !HasSubresource(c) { - continue - } - r.Type = c - r.Subresources = b.GetSubresources(r) - } -} - -func (b *APIsBuilder) GetSubresources(c *APIResource) map[string]*APISubresource { - r := map[string]*APISubresource{} - subresources := b.GetSubresourceTags(c.Type) - - if len(subresources) == 0 { - // Not a subresource - return r - } - for _, subresource := range subresources { - // Parse the values for each subresource - tags := ParseSubresourceTag(c, subresource) - sr := &APISubresource{ - Kind: tags.Kind, - Request: tags.RequestKind, - Path: tags.Path, - REST: tags.REST, - Domain: b.Domain, - Version: c.Version, - Resource: c.Resource, - Group: c.Group, - } - if !b.IsInPackage(tags) { - // Out of package Request types require an import and are prefixed with the - // package name - e.g. v1.Scale - sr.Request, sr.ImportPackage = b.GetNameAndImport(tags) - } - if v, found := r[sr.Path]; found { - log.Fatalf("Multiple subresources registered for path %s: %v %v", - sr.Path, v, subresource) - } - r[sr.Path] = sr - } - return r -} - -// Returns true if the subresource Request type is in the same package as the resource type -func (b *APIsBuilder) IsInPackage(tags SubresourceTags) bool { - return !strings.Contains(tags.RequestKind, ".") -} - -// GetNameAndImport converts -func (b *APIsBuilder) GetNameAndImport(tags SubresourceTags) (string, string) { - last := strings.LastIndex(tags.RequestKind, ".") - importPackage := tags.RequestKind[:last] - - // Set the request kind to the struct name - tags.RequestKind = tags.RequestKind[last+1:] - // Find the package - pkg := filepath.Base(importPackage) - // Prefix the struct name with the package it is in - return strings.Join([]string{pkg, tags.RequestKind}, "."), importPackage -} - -// ResourceTags contains the tags present in a "+resource=" comment -type ResourceTags struct { - Resource string - REST string - Strategy string -} - -// ParseResourceTag parses the tags in a "+resource=" comment into a ResourceTags struct -func ParseResourceTag(tag string) ResourceTags { - result := ResourceTags{} - for _, elem := range strings.Split(tag, ",") { - kv := strings.Split(elem, "=") - if len(kv) != 2 { - log.Fatalf("// +resource: tags must be key value pairs. Expected "+ - "keys [path=] "+ - "Got string: [%s]", tag) - } - value := kv[1] - switch kv[0] { - case "rest": - result.REST = value - case "path": - result.Resource = value - case "strategy": - result.Strategy = value - } - } - return result -} - -// ResourceTags contains the tags present in a "+resource=" comment -type ControllerTags struct { - gvk schema.GroupVersionKind - resource string -} - -// ParseResourceTag parses the tags in a "+resource=" comment into a ResourceTags struct -func ParseControllerTag(tag string) ControllerTags { - result := ControllerTags{} - for _, elem := range strings.Split(tag, ",") { - kv := strings.Split(elem, "=") - if len(kv) != 2 { - log.Fatalf("// +controller: tags must be key value pairs. Expected "+ - "keys [group=,version=,kind=,resource=] "+ - "Got string: [%s]", tag) - } - value := kv[1] - switch kv[0] { - case "group": - result.gvk.Group = value - case "version": - result.gvk.Version = value - case "kind": - result.gvk.Kind = value - case "resource": - result.resource = value - } - } - return result -} - -// SubresourceTags contains the tags present in a "+subresource=" comment -type SubresourceTags struct { - Path string - Kind string - RequestKind string - REST string -} - -// ParseSubresourceTag parses the tags in a "+subresource=" comment into a SubresourceTags struct -func ParseSubresourceTag(c *APIResource, tag string) SubresourceTags { - result := SubresourceTags{} - for _, elem := range strings.Split(tag, ",") { - kv := strings.Split(elem, "=") - if len(kv) != 2 { - log.Fatalf("// +subresource: tags must be key value pairs. Expected "+ - "keys [request=,rest=,path=] "+ - "Got string: [%s]", tag) - } - value := kv[1] - switch kv[0] { - case "request": - result.RequestKind = value - case "rest": - result.REST = value - case "path": - // Strip the parent resource - result.Path = strings.Replace(value, c.Resource+"/", "", -1) - } - } - return result -} - -// GetResourceTag returns the value of the "+resource=" comment tag -func (b *APIsBuilder) GetResourceTag(c *types.Type) string { - comments := Comments(c.CommentLines) - resource := comments.GetTag("resource", ":") - if len(resource) == 0 { - panic(errors.Errorf("Must specify +resource comment for type %v", c.Name)) - } - return resource -} - -func (b *APIsBuilder) IsResource(c *types.Type) bool { - comments := Comments(c.CommentLines) - resource := comments.GetTag("resource", ":") - return len(resource) > 0 -} - -func (b *APIsBuilder) GetControllerTag(c *types.Type) string { - comments := Comments(c.CommentLines) - resource := comments.GetTag("controller", ":") - if len(resource) == 0 { - panic(errors.Errorf("Must specify +controller comment for type %v", c.Name)) - } - return resource -} - -func (b *APIsBuilder) GetSubresourceTags(c *types.Type) []string { - comments := Comments(c.CommentLines) - return comments.GetTags("subresource", ":") -} - -// ParseGroupNames initializes b.GroupNames with the set of all groups -func (b *APIsBuilder) ParseGroupNames() { - b.GroupNames = sets.String{} - for p := range b.UnversionedPkgs { - pkg := b.context.Universe[p] - if pkg == nil { - // If the input had no Go files, for example. - continue - } - b.GroupNames.Insert(filepath.Base(p)) - } -} - -// ParsePackages parses out the sets of Versioned, Unversioned packages and identifies the root Apis package. -func (b *APIsBuilder) ParsePackages() { - b.VersionedPkgs = sets.NewString() - b.UnversionedPkgs = sets.NewString() - for _, o := range b.context.Order { - if IsAPIResource(o) { - versioned := o.Name.Package - b.VersionedPkgs.Insert(versioned) - - unversioned := filepath.Dir(versioned) - b.UnversionedPkgs.Insert(unversioned) - - if apis := filepath.Dir(unversioned); apis != b.APIsPkg && len(b.APIsPkg) > 0 { - panic(errors.Errorf( - "Found multiple apis directory paths: %v and %v. "+ - "Do you have a +resource tag on a resource that is not in a version "+ - "directory?", b.APIsPkg, apis)) - } else { - b.APIsPkg = apis - } - } - } -} - -// ParseDomain parses the domain from the apis/doc.go file comment "// +domain=YOUR_DOMAIN". -func (b *APIsBuilder) ParseDomain() { - pkg := b.context.Universe[b.APIsPkg] - if pkg == nil { - // If the input had no Go files, for example. - panic(errors.Errorf("Missing apis package.")) - } - comments := Comments(pkg.Comments) - b.Domain = comments.GetTag("domain", "=") - if len(b.Domain) == 0 { - panic("Could not find string matching // +domain=.+ in apis/doc.go") - } -} - -func (b *APIsBuilder) ParseStructs(apigroup *APIGroup) { - remaining := []*types.Type{} - for _, version := range apigroup.Versions { - for _, resource := range version.Resources { - remaining = append(remaining, resource.Type) - } - } - for _, version := range b.SubByGroupVersionKind[apigroup.Group] { - for _, kind := range version { - remaining = append(remaining, kind) - } - } - - done := sets.String{} - for len(remaining) > 0 { - // Pop the next element from the list - next := remaining[0] - remaining[0] = remaining[len(remaining)-1] - remaining = remaining[:len(remaining)-1] - - // Already processed this type. Skip it - if done.Has(next.Name.Name) { - continue - } - done.Insert(next.Name.Name) - - // Generate the struct and append to the list - result, additionalTypes := apigroup.DoType(next) - - // This is a resource, so generate the client - if b.IsResource(next) { - result.IsResource = true - } - apigroup.Structs = append(apigroup.Structs, result) - - // Add the newly discovered subtypes - remaining = append(remaining, additionalTypes...) - } -} - -func (apigroup *APIGroup) DoType(t *types.Type) (*Struct, []*types.Type) { - remaining := []*types.Type{} - s := &Struct{ - Name: t.Name.Name, - IsResource: false, - } - for _, member := range t.Members { - memberGroup := GetGroup(member.Type) - uType := member.Type.Name.Name - memberName := member.Name - uImport := "" - - base := filepath.Base(member.Type.String()) - samepkg := t.Name.Package == member.Type.Name.Package - - // If not in the same package, calculate the import pkg - if !samepkg { - parts := strings.Split(base, ".") - if len(parts) > 1 { - switch member.Type.Name.Package { - case "k8s.io/apimachinery/pkg/apis/meta/v1": - // Use versioned types for meta/v1 - uImport = fmt.Sprintf("%s \"%s\"", "metav1", "k8s.io/apimachinery/pkg/apis/meta/v1") - uType = "metav1." + parts[1] - default: - // Use unversioned types for everything else - t := member.Type - hasElem := false - if t.Elem != nil { - // Handle Pointers, Maps, Slices correctly - t = t.Elem - hasElem = true - } - uImportName := path.Base(path.Dir(t.Name.Package)) - uImport = path.Dir(t.Name.Package) - uType = uImportName + "." + t.Name.Name - if hasElem { - uType = strings.Replace(member.Type.String(), path.Dir(uImport)+"/", "", 1) - uType = strings.Replace(uType, "/"+path.Base(t.Name.Package), "", 1) - } - fmt.Printf("\n%s : %s : %s\n%s : %s\n\n", member.Type.Kind, member.Type.String(), path.Dir(uImport), uImport, uType) - } - } - } - - if member.Embedded { - memberName = "" - } - - s.Fields = append(s.Fields, &Field{ - Name: memberName, - VersionedPackage: member.Type.Name.Package, - UnversionedImport: uImport, - UnversionedType: uType, - }) - - // Add this member Type for processing - if !member.Type.IsPrimitive() && memberGroup == GetGroup(t) { - remaining = append(remaining, member.Type) - } - } - return s, remaining -} diff --git a/vendor/github.com/kubernetes-incubator/apiserver-builder/cmd/apiregister-gen/generators/unversioned_generator.go b/vendor/github.com/kubernetes-incubator/apiserver-builder/cmd/apiregister-gen/generators/unversioned_generator.go deleted file mode 100644 index 2249b2d25c..0000000000 --- a/vendor/github.com/kubernetes-incubator/apiserver-builder/cmd/apiregister-gen/generators/unversioned_generator.go +++ /dev/null @@ -1,280 +0,0 @@ -/* -Copyright 2017 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package generators - -import ( - "io" - "text/template" - - "k8s.io/apimachinery/pkg/util/sets" - "k8s.io/gengo/generator" -) - -type unversionedGenerator struct { - generator.DefaultGen - apigroup *APIGroup -} - -var _ generator.Generator = &unversionedGenerator{} - -func CreateUnversionedGenerator(apigroup *APIGroup, filename string) generator.Generator { - return &unversionedGenerator{ - generator.DefaultGen{OptionalName: filename}, - apigroup, - } -} - -func (d *unversionedGenerator) Imports(c *generator.Context) []string { - imports := sets.NewString( - "fmt", - "github.com/kubernetes-incubator/apiserver-builder/pkg/builders", - "k8s.io/apimachinery/pkg/apis/meta/internalversion", - "k8s.io/apimachinery/pkg/runtime", - "k8s.io/apimachinery/pkg/runtime/schema", - "k8s.io/apiserver/pkg/endpoints/request", - "k8s.io/apiserver/pkg/registry/rest", - "k8s.io/client-go/pkg/api") - - // Get imports for all fields - for _, s := range d.apigroup.Structs { - for _, f := range s.Fields { - if len(f.UnversionedImport) > 0 { - imports.Insert(f.UnversionedImport) - } - } - } - - return imports.List() -} - -func (d *unversionedGenerator) Finalize(context *generator.Context, w io.Writer) error { - temp := template.Must(template.New("unversioned-wiring-template").Parse(UnversionedAPITemplate)) - err := temp.Execute(w, d.apigroup) - if err != nil { - return err - } - return err -} - -var UnversionedAPITemplate = ` -var ( - {{ range $api := .UnversionedResources -}} - Internal{{ $api.Kind }} = builders.NewInternalResource( - "{{ $api.Resource }}", - func() runtime.Object { return &{{ $api.Kind }}{} }, - func() runtime.Object { return &{{ $api.Kind }}List{} }, - ) - Internal{{ $api.Kind }}Status = builders.NewInternalResourceStatus( - "{{ $api.Resource }}", - func() runtime.Object { return &{{ $api.Kind }}{} }, - func() runtime.Object { return &{{ $api.Kind }}List{} }, - ) - {{ range $subresource := .Subresources -}} - Internal{{$subresource.REST}} = builders.NewInternalSubresource( - "{{$subresource.Resource}}", "{{$subresource.Path}}", - func() runtime.Object { return &{{$subresource.Request}}{} }, - ) - {{ end -}} - {{ end -}} - - // Registered resources and subresources - ApiVersion = builders.NewApiGroup("{{.Group}}.{{.Domain}}").WithKinds( - {{ range $api := .UnversionedResources -}} - Internal{{$api.Kind}}, - Internal{{$api.Kind}}Status, - {{ range $subresource := $api.Subresources -}} - Internal{{$subresource.REST}}, - {{ end -}} - {{ end -}} - ) - - // Required by code generated by go2idl - AddToScheme = ApiVersion.SchemaBuilder.AddToScheme - SchemeBuilder = ApiVersion.SchemaBuilder - localSchemeBuilder = &SchemeBuilder - SchemeGroupVersion = ApiVersion.GroupVersion -) - -// Required by code generated by go2idl -// Kind takes an unqualified kind and returns a Group qualified GroupKind -func Kind(kind string) schema.GroupKind { - return SchemeGroupVersion.WithKind(kind).GroupKind() -} - -// Required by code generated by go2idl -// Resource takes an unqualified resource and returns a Group qualified GroupResource -func Resource(resource string) schema.GroupResource { - return SchemeGroupVersion.WithResource(resource).GroupResource() -} - -{{ range $s := .Structs -}} -{{ if $s.IsResource }}// +genclient=true{{end}} - -type {{ $s.Name }} struct { -{{ range $f := $s.Fields -}} - {{ $f.Name }} {{ $f.UnversionedType }} -{{ end -}} -} - -{{ end -}} - -{{ range $api := .UnversionedResources -}} -// -// {{.Kind}} Functions and Structs -// -type {{.Kind}}Strategy struct { - builders.DefaultStorageStrategy -} - -type {{$api.Kind}}StatusStrategy struct { - builders.DefaultStatusStorageStrategy -} - -type {{$api.Kind}}List struct { - metav1.TypeMeta - metav1.ListMeta - Items []{{$api.Kind}} -} - -{{ range $subresource := $api.Subresources -}} -type {{$subresource.Request}}List struct { - metav1.TypeMeta - metav1.ListMeta - Items []{{$subresource.Request}} -} -{{ end -}} - -func ({{$api.Kind}}) NewStatus() interface{} { - return {{$api.Kind}}Status{} -} - -func (pc *{{$api.Kind}}) GetStatus() interface{} { - return pc.Status -} - -func (pc *{{$api.Kind}}) SetStatus(s interface{}) { - pc.Status = s.({{$api.Kind}}Status) -} - -func (pc *{{$api.Kind}}) GetSpec() interface{} { - return pc.Spec -} - -func (pc *{{$api.Kind}}) SetSpec(s interface{}) { - pc.Spec = s.({{$api.Kind}}Spec) -} - -func (pc *{{$api.Kind}}) GetObjectMeta() *metav1.ObjectMeta { - return &pc.ObjectMeta -} - -func (pc *{{$api.Kind}}) SetGeneration(generation int64) { - pc.ObjectMeta.Generation = generation -} - -func (pc {{$api.Kind}}) GetGeneration() int64 { - return pc.ObjectMeta.Generation -} - -// Registry is an interface for things that know how to store {{.Kind}}. -type {{.Kind}}Registry interface { - List{{.Kind}}s(ctx request.Context, options *internalversion.ListOptions) (*{{.Kind}}List, error) - Get{{.Kind}}(ctx request.Context, id string, options *metav1.GetOptions) (*{{.Kind}}, error) - Create{{.Kind}}(ctx request.Context, id *{{.Kind}}) (*{{.Kind}}, error) - Update{{.Kind}}(ctx request.Context, id *{{.Kind}}) (*{{.Kind}}, error) - Delete{{.Kind}}(ctx request.Context, id string) (bool, error) -} - -// NewRegistry returns a new Registry interface for the given Storage. Any mismatched types will panic. -func New{{.Kind}}Registry(sp builders.StandardStorageProvider) {{.Kind}}Registry { - return &storage{{.Kind}}{sp} -} - -// Implement Registry -// storage puts strong typing around storage calls -type storage{{.Kind}} struct { - builders.StandardStorageProvider -} - -func (s *storage{{.Kind}}) List{{.Kind}}s(ctx request.Context, options *internalversion.ListOptions) (*{{.Kind}}List, error) { - if options != nil && options.FieldSelector != nil && !options.FieldSelector.Empty() { - return nil, fmt.Errorf("field selector not supported yet") - } - st := s.GetStandardStorage() - obj, err := st.List(ctx, options) - if err != nil { - return nil, err - } - return obj.(*{{.Kind}}List), err -} - -func (s *storage{{.Kind}}) Get{{.Kind}}(ctx request.Context, id string, options *metav1.GetOptions) (*{{.Kind}}, error) { - st := s.GetStandardStorage() - obj, err := st.Get(ctx, id, options) - if err != nil { - return nil, err - } - return obj.(*{{.Kind}}), nil -} - -func (s *storage{{.Kind}}) Create{{.Kind}}(ctx request.Context, object *{{.Kind}}) (*{{.Kind}}, error) { - st := s.GetStandardStorage() - obj, err := st.Create(ctx, object, false) - if err != nil { - return nil, err - } - return obj.(*{{.Kind}}), nil -} - -func (s *storage{{.Kind}}) Update{{.Kind}}(ctx request.Context, object *{{.Kind}}) (*{{.Kind}}, error) { - st := s.GetStandardStorage() - obj, _, err := st.Update(ctx, object.Name, rest.DefaultUpdatedObjectInfo(object, api.Scheme)) - if err != nil { - return nil, err - } - return obj.(*{{.Kind}}), nil -} - -func (s *storage{{.Kind}}) Delete{{.Kind}}(ctx request.Context, id string) (bool, error) { - st := s.GetStandardStorage() - _, sync, err := st.Delete(ctx, id, nil) - return sync, err -} - -{{ end -}} -` - -var installTemplate = ` -{{.BoilerPlate}} - -package install - -import ( - "github.com/kubernetes-incubator/apiserver-builder/example/pkg/apis" - "k8s.io/apimachinery/pkg/apimachinery/announced" - "k8s.io/apimachinery/pkg/apimachinery/registered" - "k8s.io/apimachinery/pkg/runtime" -) - -func Install( - groupFactoryRegistry announced.APIGroupFactoryRegistry, - registry *registered.APIRegistrationManager, - scheme *runtime.Scheme) { - - apis.{{ title .Group }}APIBuilder().Install(groupFactoryRegistry, registry, scheme) -} -` diff --git a/vendor/github.com/kubernetes-incubator/apiserver-builder/cmd/apiregister-gen/generators/util.go b/vendor/github.com/kubernetes-incubator/apiserver-builder/cmd/apiregister-gen/generators/util.go deleted file mode 100644 index 37ef64c6c8..0000000000 --- a/vendor/github.com/kubernetes-incubator/apiserver-builder/cmd/apiregister-gen/generators/util.go +++ /dev/null @@ -1,152 +0,0 @@ -/* -Copyright 2017 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package generators - -import ( - "fmt" - "path/filepath" - "strings" - - "github.com/pkg/errors" - - "k8s.io/gengo/types" -) - -// IsAPIResource returns true if t has a +resource comment tag -func IsAPIResource(t *types.Type) bool { - for _, c := range t.CommentLines { - if strings.Contains(c, "+resource") { - return true - } - } - return false -} - -// IsNonNamespaced returns true if t has a +nonNamespaced comment tag -func IsNonNamespaced(t *types.Type) bool { - if !IsAPIResource(t) { - return false - } - - // here we check only SecondClosestCommentLines in order to reuse - // the lister-gen's +nonNamespaced tag - v, err := types.ExtractSingleBoolCommentTag("+", "nonNamespaced", - false, t.SecondClosestCommentLines) - if err != nil { - panic(errors.Errorf("Cannot get value for nonNamespaced tag: %v", err)) - } - return v -} - -func IsController(t *types.Type) bool { - for _, c := range t.CommentLines { - if strings.Contains(c, "+controller") { - return true - } - } - return false -} - -// IsAPISubresource returns true if t has a +subresource-request comment tag -func IsAPISubresource(t *types.Type) bool { - for _, c := range t.CommentLines { - if strings.Contains(c, "+subresource-request") { - return true - } - } - return false -} - -// HasSubresource returns true if t is an APIResource with one or more Subresources -func HasSubresource(t *types.Type) bool { - if !IsAPIResource(t) { - return false - } - for _, c := range t.CommentLines { - if strings.Contains(c, "+subresource") { - return true - } - } - return false -} - -func IsUnversioned(t *types.Type, group string) bool { - return IsApisDir(filepath.Base(filepath.Dir(t.Name.Package))) && GetGroup(t) == group -} - -func IsVersioned(t *types.Type, group string) bool { - dir := filepath.Base(filepath.Dir(filepath.Dir(t.Name.Package))) - return IsApisDir(dir) && GetGroup(t) == group -} - -func GetVersion(t *types.Type, group string) string { - if !IsVersioned(t, group) { - panic(errors.Errorf("Cannot get version for unversioned type %v", t.Name)) - } - return filepath.Base(t.Name.Package) -} - -func GetGroup(t *types.Type) string { - return filepath.Base(GetGroupPackage(t)) -} - -func GetGroupPackage(t *types.Type) string { - if IsApisDir(filepath.Base(filepath.Dir(t.Name.Package))) { - return t.Name.Package - } - return filepath.Dir(t.Name.Package) -} - -func GetKind(t *types.Type, group string) string { - if !IsVersioned(t, group) && !IsUnversioned(t, group) { - panic(errors.Errorf("Cannot get kind for type not in group %v", t.Name)) - } - return t.Name.Name -} - -// IsApisDir returns true if a directory path is a Kubernetes api directory -func IsApisDir(dir string) bool { - return dir == "apis" || dir == "api" -} - -// Comments is a structure for using comment tags on go structs and fields -type Comments []string - -// GetTags returns the value for the first comment with a prefix matching "+name=" -// e.g. "+name=foo\n+name=bar" would return "foo" -func (c Comments) GetTag(name, sep string) string { - for _, c := range c { - prefix := fmt.Sprintf("+%s%s", name, sep) - if strings.HasPrefix(c, prefix) { - return strings.Replace(c, prefix, "", 1) - } - } - return "" -} - -// GetTags returns the value for all comments with a prefix and separator. E.g. for "name" and "=" -// "+name=foo\n+name=bar" would return []string{"foo", "bar"} -func (c Comments) GetTags(name, sep string) []string { - tags := []string{} - for _, c := range c { - prefix := fmt.Sprintf("+%s%s", name, sep) - if strings.HasPrefix(c, prefix) { - tags = append(tags, strings.Replace(c, prefix, "", 1)) - } - } - return tags -} diff --git a/vendor/github.com/kubernetes-incubator/apiserver-builder/cmd/apiregister-gen/generators/versioned_generator.go b/vendor/github.com/kubernetes-incubator/apiserver-builder/cmd/apiregister-gen/generators/versioned_generator.go deleted file mode 100644 index 842d6c3fd0..0000000000 --- a/vendor/github.com/kubernetes-incubator/apiserver-builder/cmd/apiregister-gen/generators/versioned_generator.go +++ /dev/null @@ -1,152 +0,0 @@ -/* -Copyright 2017 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package generators - -import ( - "io" - "text/template" - - "k8s.io/gengo/generator" -) - -type versionedGenerator struct { - generator.DefaultGen - apiversion *APIVersion - apigroup *APIGroup -} - -var _ generator.Generator = &versionedGenerator{} - -func CreateVersionedGenerator(apiversion *APIVersion, apigroup *APIGroup, filename string) generator.Generator { - return &versionedGenerator{ - generator.DefaultGen{OptionalName: filename}, - apiversion, - apigroup, - } -} - -func (d *versionedGenerator) Imports(c *generator.Context) []string { - return []string{ - "metav1 \"k8s.io/apimachinery/pkg/apis/meta/v1\"", - "k8s.io/apimachinery/pkg/runtime", - "github.com/kubernetes-incubator/apiserver-builder/pkg/builders", - "k8s.io/apimachinery/pkg/runtime/schema", - d.apigroup.Pkg.Path, - } -} - -func (d *versionedGenerator) Finalize(context *generator.Context, w io.Writer) error { - temp := template.Must(template.New("versioned-template").Parse(VersionedAPITemplate)) - return temp.Execute(w, d.apiversion) -} - -var VersionedAPITemplate = ` -var ( - {{ range $api := .Resources -}} - - {{ if $api.REST -}} - {{$api.Group}}{{$api.Kind}}Storage = builders.NewApiResourceWithStorage( // Resource status endpoint - {{ $api.Group }}.Internal{{ $api.Kind }}, - {{.Kind}}SchemeFns{}, - func() runtime.Object { return &{{ $api.Kind }}{} }, // Register versioned resource - func() runtime.Object { return &{{ $api.Kind }}List{} }, // Register versioned resource list - New{{ $api.REST }}(), - ) - {{ else -}} - {{$api.Group}}{{$api.Kind}}Storage = builders.NewApiResource( // Resource status endpoint - {{ $api.Group }}.Internal{{ $api.Kind }}, - {{.Kind}}SchemeFns{}, - func() runtime.Object { return &{{ $api.Kind }}{} }, // Register versioned resource - func() runtime.Object { return &{{ $api.Kind }}List{} }, // Register versioned resource list - &{{ $api.Strategy }}{builders.StorageStrategySingleton}, - ) - {{ end -}} - {{ end -}} - - ApiVersion = builders.NewApiVersion("{{.Group}}.{{.Domain}}", "{{.Version}}").WithResources( - {{ range $api := .Resources -}} - {{$api.Group}}{{$api.Kind}}Storage, - {{ if $api.REST }}{{ else -}} - builders.NewApiResource( // Resource status endpoint - {{ $api.Group }}.Internal{{ $api.Kind }}Status, - {{.Kind}}SchemeFns{}, - func() runtime.Object { return &{{ $api.Kind }}{} }, // Register versioned resource - func() runtime.Object { return &{{ $api.Kind }}List{} }, // Register versioned resource list - &{{ $api.StatusStrategy }}{builders.StatusStorageStrategySingleton}, - ),{{ end -}} - - {{ range $subresource := $api.Subresources -}} - builders.NewApiResourceWithStorage( - {{ $api.Group }}.Internal{{ $subresource.REST }}, - builders.SchemeFnsSingleton, - func() runtime.Object { return &{{ $subresource.Request }}{} }, // Register versioned resource - nil, - &{{ $subresource.REST }}{ {{$api.Group}}.New{{$api.Kind}}Registry({{$api.Group}}{{$api.Kind}}Storage) }, - ), - {{ end -}} - {{ end -}} - ) - - // Required by code generated by go2idl - AddToScheme = ApiVersion.SchemaBuilder.AddToScheme - SchemeBuilder = ApiVersion.SchemaBuilder - localSchemeBuilder = &SchemeBuilder - SchemeGroupVersion = ApiVersion.GroupVersion -) - -// Required by code generated by go2idl -// Kind takes an unqualified kind and returns a Group qualified GroupKind -func Kind(kind string) schema.GroupKind { - return SchemeGroupVersion.WithKind(kind).GroupKind() -} - -// Required by code generated by go2idl -// Resource takes an unqualified resource and returns a Group qualified GroupResource -func Resource(resource string) schema.GroupResource { - return SchemeGroupVersion.WithResource(resource).GroupResource() -} - -{{ range $api := .Resources -}} -// -// {{.Kind}} Functions and Structs -// -type {{.Kind}}SchemeFns struct { - builders.DefaultSchemeFns -} - -type {{.Kind}}Strategy struct { - builders.DefaultStorageStrategy -} - -type {{$api.Kind}}StatusStrategy struct { - builders.DefaultStatusStorageStrategy -} - - -type {{$api.Kind}}List struct { - metav1.TypeMeta ` + "`json:\",inline\"`" + ` - metav1.ListMeta ` + "`json:\"metadata,omitempty\"`" + ` - Items []{{$api.Kind}} ` + "`json:\"items\"`" + ` -} -{{ range $subresource := $api.Subresources -}} -type {{$subresource.Request}}List struct { - metav1.TypeMeta ` + "`json:\",inline\"`" + ` - metav1.ListMeta ` + "`json:\"metadata,omitempty\"`" + ` - Items []{{$subresource.Request}} ` + "`json:\"items\"`" + ` -} -{{ end -}}{{ end -}} -` diff --git a/vendor/github.com/kubernetes-incubator/apiserver-builder/cmd/apiregister-gen/main.go b/vendor/github.com/kubernetes-incubator/apiserver-builder/cmd/apiregister-gen/main.go deleted file mode 100644 index 3b7ca93b1b..0000000000 --- a/vendor/github.com/kubernetes-incubator/apiserver-builder/cmd/apiregister-gen/main.go +++ /dev/null @@ -1,51 +0,0 @@ -/* -Copyright 2017 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package main - -import ( - "os" - "runtime" - - "github.com/golang/glog" - "github.com/kubernetes-incubator/apiserver-builder/cmd/apiregister-gen/generators" - "k8s.io/apiserver/pkg/util/logs" - "k8s.io/gengo/args" -) - -func main() { - logs.InitLogs() - defer logs.FlushLogs() - - if len(os.Getenv("GOMAXPROCS")) == 0 { - runtime.GOMAXPROCS(runtime.NumCPU()) - } - - arguments := args.Default() - - // Override defaults. - arguments.OutputFileBaseName = "zz_generated.api.register" - - // Custom args. - customArgs := &generators.CustomArgs{} - arguments.CustomArgs = customArgs - - g := generators.Gen{} - if err := g.Execute(arguments); err != nil { - glog.Fatalf("Error: %v", err) - } - glog.V(2).Info("Completed successfully.") -} diff --git a/vendor/github.com/kubernetes-incubator/apiserver-builder/cmd/apiserver-boot/boot/build/build.go b/vendor/github.com/kubernetes-incubator/apiserver-builder/cmd/apiserver-boot/boot/build/build.go deleted file mode 100644 index be451548df..0000000000 --- a/vendor/github.com/kubernetes-incubator/apiserver-builder/cmd/apiserver-boot/boot/build/build.go +++ /dev/null @@ -1,54 +0,0 @@ -/* -Copyright 2017 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package build - -import ( - "github.com/spf13/cobra" -) - -var buildCmd = &cobra.Command{ - Use: "build", - Short: "Command group for building source into artifacts.", - Long: `Command group for building source into artifacts.`, - Example: `# Generate code and build the apiserver and controller-manager binaries into bin/ -apiserver-boot build executables - -# Rebuild generated code -apiserver-boot build generated - -# Build a container with the apiserver and controller-manager executables -apiserver-boot build container --image gcr.io/myrepo/myimage:mytag - -# Build resource config for running an aggregated apiserver in cluster -apiserver-boot build config --name nameofservice --namespace mysystemnamespace --image gcr.io/myrepo/myimage:mytag - `, - Run: RunBuild, -} - -func AddBuild(cmd *cobra.Command) { - cmd.AddCommand(buildCmd) - - AddBuildExecutables(buildCmd) - AddBuildContainer(buildCmd) - AddBuildResourceConfig(buildCmd) - AddDocs(buildCmd) - AddGenerate(buildCmd) -} - -func RunBuild(cmd *cobra.Command, args []string) { - cmd.Help() -} diff --git a/vendor/github.com/kubernetes-incubator/apiserver-builder/cmd/apiserver-boot/boot/build/build_container.go b/vendor/github.com/kubernetes-incubator/apiserver-builder/cmd/apiserver-boot/boot/build/build_container.go deleted file mode 100644 index d416bcc582..0000000000 --- a/vendor/github.com/kubernetes-incubator/apiserver-builder/cmd/apiserver-boot/boot/build/build_container.go +++ /dev/null @@ -1,101 +0,0 @@ -/* -Copyright 2017 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package build - -import ( - "fmt" - "log" - "os" - "os/exec" - "path/filepath" - "strings" - - "github.com/kubernetes-incubator/apiserver-builder/cmd/apiserver-boot/boot/util" - "github.com/spf13/cobra" - "io/ioutil" -) - -var Image string - -var createBuildContainerCmd = &cobra.Command{ - Use: "container", - Short: "Builds a container with the apiserver and controller-manager binaries", - Long: `Builds a container with the apiserver and controller-manager binaries`, - Example: `# Build an image containing the apiserver -# and controller-manager binaries (built for linux:amd64) -apiserver-boot build container --image gcr.io/myrepo/myimage:mytag - -# Push the newly built image to the image repo -docker push gcr.io/myrepo/myimage:mytag`, - Run: RunBuildContainer, -} - -func AddBuildContainer(cmd *cobra.Command) { - cmd.AddCommand(createBuildContainerCmd) - AddBuildContainerFlags(createBuildContainerCmd) -} - -func AddBuildContainerFlags(cmd *cobra.Command) { - cmd.Flags().StringVar(&Image, "image", "", "name of the image with tag") - cmd.Flags().BoolVar(&GenerateForBuild, "generate", true, "if true, generate code before building") -} - -func RunBuildContainer(cmd *cobra.Command, args []string) { - if len(Image) == 0 { - log.Fatalf("Must specify --image") - } - - dir, err := ioutil.TempDir(os.TempDir(), "apiserver-boot-build-container") - if err != nil { - log.Fatalf("failed to create temp directory %s %v", dir, err) - } - log.Printf("Will build docker Image from directory %s", dir) - - log.Printf("Writing the Dockerfile.") - - path := filepath.Join(dir, "Dockerfile") - util.WriteIfNotFound(path, "dockerfile-template", dockerfileTemplate, dockerfileTemplateArguments{}) - - log.Printf("Building binaries for linux amd64.") - - // Set the goos and goarch - goos = "linux" - goarch = "amd64" - outputdir = dir - RunBuildExecutables(cmd, args) - - log.Printf("Building the docker Image.") - - c := exec.Command("docker", "build", "-t", Image, dir) - fmt.Printf("%s\n", strings.Join(c.Args, " ")) - c.Stderr = os.Stderr - c.Stdout = os.Stdout - err = c.Run() - if err != nil { - log.Fatal(err) - } -} - -type dockerfileTemplateArguments struct { -} - -var dockerfileTemplate = ` -FROM ubuntu:14.04 - -ADD apiserver . -ADD controller-manager . -` diff --git a/vendor/github.com/kubernetes-incubator/apiserver-builder/cmd/apiserver-boot/boot/build/build_executables.go b/vendor/github.com/kubernetes-incubator/apiserver-builder/cmd/apiserver-boot/boot/build/build_executables.go deleted file mode 100644 index 4bbbfe2cea..0000000000 --- a/vendor/github.com/kubernetes-incubator/apiserver-builder/cmd/apiserver-boot/boot/build/build_executables.go +++ /dev/null @@ -1,103 +0,0 @@ -/* -Copyright 2017 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package build - -import ( - "fmt" - "log" - "os" - "os/exec" - "path/filepath" - "strings" - - "github.com/spf13/cobra" -) - -var GenerateForBuild bool = true -var goos string = "linux" -var goarch string = "amd64" -var outputdir string = "bin" - -var createBuildExecutablesCmd = &cobra.Command{ - Use: "executables", - Short: "Builds the source into executables to run on the local machine", - Long: `Builds the source into executables to run on the local machine`, - Example: `# Generate code and build the apiserver and controller -# binaries in the bin directory so they can be run locally. -apiserver-boot build executables - -# Build binaries into the linux/ directory using the cross compiler for linux:amd64 -apiserver-boot build --goos linux --goarch amd64 --output linux/`, - Run: RunBuildExecutables, -} - -func AddBuildExecutables(cmd *cobra.Command) { - cmd.AddCommand(createBuildExecutablesCmd) - - createBuildExecutablesCmd.Flags().BoolVar(&GenerateForBuild, "generate", true, "if true, generate code before building") - createBuildExecutablesCmd.Flags().StringVar(&goos, "goos", "", "if specified, set this GOOS") - createBuildExecutablesCmd.Flags().StringVar(&goarch, "goarch", "", "if specified, set this GOARCH") - createBuildExecutablesCmd.Flags().StringVar(&outputdir, "output", "bin", "if set, write the binaries to this directory") -} - -func RunBuildExecutables(cmd *cobra.Command, args []string) { - if GenerateForBuild { - log.Printf("regenerating generated code. To disable regeneration, run with --generate=false.") - RunGenerate(cmd, args) - } - - // Build the apiserver - path := filepath.Join("cmd", "apiserver", "main.go") - c := exec.Command("go", "build", "-o", filepath.Join(outputdir, "apiserver"), path) - c.Env = append(os.Environ(), "CGO_ENABLED=0") - log.Printf("CGO_ENABLED=0") - if len(goos) > 0 { - c.Env = append(c.Env, fmt.Sprintf("GOOS=%s", goos)) - log.Printf(fmt.Sprintf("GOOS=%s", goos)) - } - if len(goarch) > 0 { - c.Env = append(c.Env, fmt.Sprintf("GOARCH=%s", goarch)) - log.Printf(fmt.Sprintf("GOARCH=%s", goarch)) - } - - fmt.Printf("%s\n", strings.Join(c.Args, " ")) - c.Stderr = os.Stderr - c.Stdout = os.Stdout - err := c.Run() - if err != nil { - log.Fatal(err) - } - - // Build the controller manager - path = filepath.Join("cmd", "controller-manager", "main.go") - c = exec.Command("go", "build", "-o", filepath.Join(outputdir, "controller-manager"), path) - c.Env = append(os.Environ(), "CGO_ENABLED=0") - if len(goos) > 0 { - c.Env = append(c.Env, fmt.Sprintf("GOOS=%s", goos)) - } - if len(goarch) > 0 { - c.Env = append(c.Env, fmt.Sprintf("GOARCH=%s", goarch)) - } - - fmt.Println(strings.Join(c.Args, " ")) - c.Stderr = os.Stderr - c.Stdout = os.Stdout - err = c.Run() - if err != nil { - log.Fatal(err) - } -} diff --git a/vendor/github.com/kubernetes-incubator/apiserver-builder/cmd/apiserver-boot/boot/build/build_resource_config.go b/vendor/github.com/kubernetes-incubator/apiserver-builder/cmd/apiserver-boot/boot/build/build_resource_config.go deleted file mode 100644 index 6ee3f059de..0000000000 --- a/vendor/github.com/kubernetes-incubator/apiserver-builder/cmd/apiserver-boot/boot/build/build_resource_config.go +++ /dev/null @@ -1,304 +0,0 @@ -/* -Copyright 2017 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package build - -import ( - "fmt" - "io/ioutil" - "log" - "os" - "path" - "path/filepath" - "regexp" - - "github.com/kubernetes-incubator/apiserver-builder/cmd/apiserver-boot/boot/util" - "github.com/spf13/cobra" - "k8s.io/apimachinery/pkg/runtime/schema" - "os/exec" -) - -var Name, Namespace string -var Versions []schema.GroupVersion -var ResourceConfigDir string - -var buildResourceConfigCmd = &cobra.Command{ - Use: "config", - Short: "Create kubernetes resource config files to launch the apiserver.", - Long: `Create kubernetes resource config files to launch the apiserver.`, - Example: ` -# Build yaml resource config into the config/ directory for running the apiserver and -# controller-manager as an aggregated service in a Kubernetes cluster -# Generates CA and apiserver certificates. -apiserver-boot build config --name nameofservice --namespace mysystemnamespace --image gcr.io/myrepo/myimage:mytag -`, - Run: RunBuildResourceConfig, -} - -func AddBuildResourceConfig(cmd *cobra.Command) { - cmd.AddCommand(buildResourceConfigCmd) - AddBuildResourceConfigFlags(buildResourceConfigCmd) -} - -func AddBuildResourceConfigFlags(cmd *cobra.Command) { - cmd.Flags().StringVar(&Name, "name", "", "") - cmd.Flags().StringVar(&Namespace, "namespace", "", "") - cmd.Flags().StringVar(&Image, "image", "", "name of the apiserver Image with tag") - cmd.Flags().StringVar(&ResourceConfigDir, "output", "config", "directory to output resourceconfig") -} - -func RunBuildResourceConfig(cmd *cobra.Command, args []string) { - if len(Name) == 0 { - log.Fatalf("must specify --name") - } - if len(Namespace) == 0 { - log.Fatalf("must specify --namespace") - } - if len(Image) == 0 { - log.Fatalf("Must specify --image") - } - util.GetDomain() - - if _, err := os.Stat("pkg"); err != nil { - log.Fatalf("could not find 'pkg' directory. must run apiserver-boot init before generating config") - } - - createCerts() - buildResourceConfig() -} - -func getBase64(file string) string { - out, err := exec.Command("bash", "-c", - fmt.Sprintf("base64 %s | awk 'BEGIN{ORS=\"\";} {print}'", file)).CombinedOutput() - if err != nil { - log.Fatalf("Could not base64 encode file: %v", err) - } - return string(out) -} - -func buildResourceConfig() { - initVersionedApis() - - a := resourceConfigTemplateArgs{ - Name: Name, - Namespace: Namespace, - Image: Image, - Domain: util.Domain, - Versions: Versions, - ClientKey: getBase64(filepath.Join("bin", "certificates", "apiserver.key")), - CACert: getBase64(filepath.Join("bin", "certificates", "apiserver_ca.crt")), - ClientCert: getBase64(filepath.Join("bin", "certificates", "apiserver.crt")), - } - path := filepath.Join(ResourceConfigDir, "apiserver.yaml") - - util.DoCmd("mkdir", "-p", ResourceConfigDir) - created := util.WriteIfNotFound(path, "config-template", resourceConfigTemplate, a) - if !created { - log.Fatalf("Resource config already exists.") - } -} - -func createCerts() { - dir, err := os.Getwd() - if err != nil { - log.Fatal(err) - } - dir = filepath.Join(dir, "bin", "certificates") - - util.DoCmd("mkdir", "-p", dir) - - if _, err := os.Stat(filepath.Join(dir, "apiserver_ca.crt")); os.IsNotExist(err) { - util.DoCmd("openssl", "req", "-x509", - "-newkey", "rsa:2048", - "-keyout", filepath.Join(dir, "apiserver_ca.key"), - "-out", filepath.Join(dir, "apiserver_ca.crt"), - "-days", "365", - "-nodes", - "-subj", fmt.Sprintf("/C=/ST=/L=/O=/OU=/CN=%s-certificate-authority", Name), - ) - } else { - log.Printf("Skipping generate CA cert. File already exists.") - } - - if _, err := os.Stat(filepath.Join(dir, "apiserver.csr")); os.IsNotExist(err) { - // Use ..svc as the domain Name for the certificate - util.DoCmd("openssl", "req", - "-out", filepath.Join(dir, "apiserver.csr"), - "-new", - "-newkey", "rsa:2048", - "-nodes", - "-keyout", filepath.Join(dir, "apiserver.key"), - "-subj", fmt.Sprintf("/C=/ST=/L=/O=/OU=/CN=%s.%s.svc", Name, Namespace), - ) - } else { - log.Printf("Skipping generate apiserver csr. File already exists.") - } - - if _, err := os.Stat(filepath.Join(dir, "apiserver.crt")); os.IsNotExist(err) { - util.DoCmd("openssl", "x509", "-req", - "-days", "365", - "-in", filepath.Join(dir, "apiserver.csr"), - "-CA", filepath.Join(dir, "apiserver_ca.crt"), - "-CAkey", filepath.Join(dir, "apiserver_ca.key"), - "-CAcreateserial", - "-out", filepath.Join(dir, "apiserver.crt"), - ) - } else { - log.Printf("Skipping signing apiserver crt. File already exists.") - } -} - -func initVersionedApis() { - groups, err := ioutil.ReadDir(filepath.Join("pkg", "apis")) - if err != nil { - log.Fatalf("could not read pkg/apis directory to find api Versions") - } - log.Printf("Adding APIs:") - for _, g := range groups { - if g.IsDir() { - versionFiles, err := ioutil.ReadDir(filepath.Join("pkg", "apis", g.Name())) - if err != nil { - log.Fatalf("could not read pkg/apis/%s directory to find api Versions", g.Name()) - } - versionMatch := regexp.MustCompile("^v\\d+(alpha\\d+|beta\\d+)*$") - for _, v := range versionFiles { - if v.IsDir() && versionMatch.MatchString(v.Name()) { - log.Printf("\t%s.%s", g.Name(), v.Name()) - Versions = append(Versions, schema.GroupVersion{ - Group: g.Name(), - Version: v.Name(), - }) - } - } - } - } - u := map[string]bool{} - for _, a := range versionedAPIs { - u[path.Dir(a)] = true - } - for a, _ := range u { - unversionedAPIs = append(unversionedAPIs, a) - } -} - -type resourceConfigTemplateArgs struct { - Versions []schema.GroupVersion - CACert string - ClientCert string - ClientKey string - Domain string - Name string - Namespace string - Image string -} - -var resourceConfigTemplate = ` -{{ $config := . -}} -{{ range $api := .Versions -}} -apiVersion: apiregistration.k8s.io/v1beta1 -kind: APIService -metadata: - name: {{ $api.Version }}.{{ $api.Group }}.{{ $config.Domain }} - labels: - api: {{ $config.Name }} - apiserver: "true" -spec: - version: {{ $api.Version }} - group: {{ $api.Group }}.{{ $config.Domain }} - groupPriorityMinimum: 2000 - priority: 200 - service: - name: {{ $config.Name }} - namespace: {{ $config.Namespace }} - versionPriority: 10 - caBundle: "{{ $config.CACert }}" ---- -{{ end -}} -apiVersion: v1 -kind: Service -metadata: - name: {{.Name}} - namespace: {{.Namespace}} - labels: - api: {{.Name}} - apiserver: "true" -spec: - ports: - - port: 443 - protocol: TCP - targetPort: 443 - selector: - api: {{ .Name }} - apiserver: "true" ---- -apiVersion: apps/v1beta1 -kind: Deployment -metadata: - name: {{.Name}} - namespace: {{.Namespace}} - labels: - api: {{.Name}} - apiserver: "true" -spec: - replicas: 1 - template: - metadata: - labels: - api: {{.Name}} - apiserver: "true" - spec: - containers: - - name: apiserver - image: {{.Image}} - volumeMounts: - - name: apiserver-certs - mountPath: /apiserver.local.config/certificates - readOnly: true - command: - - "./apiserver" - args: - - "--etcd-servers=http://localhost:2379" - - "--tls-cert-file=/apiserver.local.config/certificates/tls.crt" - - "--tls-private-key-file=/apiserver.local.config/certificates/tls.key" - - "--audit-log-path=-" - - "--audit-log-maxage=0" - - "--audit-log-maxbackup=0" - - name: controller - image: {{.Image}} - command: - - "./controller-manager" - args: - - name: etcd - image: quay.io/coreos/etcd:v3.0.17 - volumes: - - name: apiserver-certs - secret: - secretName: {{ .Name }} ---- -apiVersion: v1 -kind: Secret -type: kubernetes.io/tls -metadata: - name: {{.Name}} - namespace: {{.Namespace}} - labels: - api: {{.Name}} - apiserver: "true" -data: - tls.crt: {{ .ClientCert }} - tls.key: {{ .ClientKey }} ---- -` diff --git a/vendor/github.com/kubernetes-incubator/apiserver-builder/cmd/apiserver-boot/boot/build/docs.go b/vendor/github.com/kubernetes-incubator/apiserver-builder/cmd/apiserver-boot/boot/build/docs.go deleted file mode 100644 index 1d18792985..0000000000 --- a/vendor/github.com/kubernetes-incubator/apiserver-builder/cmd/apiserver-boot/boot/build/docs.go +++ /dev/null @@ -1,134 +0,0 @@ -/* -Copyright 2017 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package build - -import ( - "fmt" - "io/ioutil" - "log" - "os" - "os/exec" - "path/filepath" - "strings" - - "bytes" - - "github.com/spf13/cobra" -) - -var docsCmd = &cobra.Command{ - Use: "docs", - Short: "Generates docs for types", - Long: `Generates docs for types`, - Run: RunDocs, -} - -var operations bool -var server string - -func AddDocs(cmd *cobra.Command) { - docsCmd.Flags().StringVar(&server, "server", "", "path to apiserver binary to run to get openapi.json") - docsCmd.Flags().BoolVar(&operations, "operations", false, "if true, include operations in docs.") - cmd.AddCommand(docsCmd) - docsCmd.AddCommand(docsCleanCmd) -} - -var docsCleanCmd = &cobra.Command{ - Use: "clean", - Short: "Removes generated docs", - Long: `Removes generated docs`, - Example: `# Run server to get openapi.json and generate docs. Types only. -apiserver-boot build docs --server bin/apiserver - -# Run server to get openapi.json and generate docs. Include operations as well as types. -apiserver-boot build docs --server bin/apiserver --operations=true -`, - Run: RunCleanDocs, -} - -func RunCleanDocs(cmd *cobra.Command, args []string) { - os.RemoveAll(filepath.Join("docs", "build")) - os.RemoveAll(filepath.Join("docs", "includes")) - os.Remove(filepath.Join("docs", "manifest.json")) -} - -func RunDocs(cmd *cobra.Command, args []string) { - if len(server) == 0 { - log.Fatal("apiserver-boot docs requires the --server flag") - } - - c := exec.Command(server, - "--delegated-auth=false", - "--etcd-servers=http://localhost:2379", - "--secure-port=9443", - "--print-openapi", - ) - log.Printf("%s\n", strings.Join(c.Args, " ")) - - var b bytes.Buffer - c.Stdout = &b - c.Stderr = os.Stderr - - err := c.Run() - if err != nil { - log.Fatalf("error: %v\n", err) - } - - err = ioutil.WriteFile(filepath.Join("docs", "openapi-spec", "swagger.json"), b.Bytes(), 0644) - if err != nil { - log.Fatalf("error: %v\n", err) - } - - dir, err := os.Executable() - if err != nil { - log.Fatalf("error: %v\n", err) - } - dir = filepath.Dir(dir) - c = exec.Command(filepath.Join(dir, "gen-apidocs"), - fmt.Sprintf("--build-operations=%v", operations), - "--allow-errors", - "--use-tags", - "--config-dir=docs") - log.Printf("%s\n", strings.Join(c.Args, " ")) - c.Stderr = os.Stderr - c.Stdout = os.Stdout - err = c.Run() - if err != nil { - log.Fatalf("error: %v\n", err) - } - - wd, err := os.Getwd() - if err != nil { - log.Fatalf("error: %v\n", err) - } - - // Run the docker command to build the docs - c = exec.Command("docker", "run", - "-v", fmt.Sprintf("%s:%s", filepath.Join(wd, "docs", "includes"), "/source"), - "-v", fmt.Sprintf("%s:%s", filepath.Join(wd, "docs", "build"), "/build"), - "-v", fmt.Sprintf("%s:%s", filepath.Join(wd, "docs", "build"), "/build"), - "-v", fmt.Sprintf("%s:%s", filepath.Join(wd, "docs"), "/manifest"), - "pwittrock/brodocs", - ) - log.Println(strings.Join(c.Args, " ")) - c.Stderr = os.Stderr - c.Stdout = os.Stdout - err = c.Run() - if err != nil { - log.Fatalf("error: %v\n", err) - } -} diff --git a/vendor/github.com/kubernetes-incubator/apiserver-builder/cmd/apiserver-boot/boot/build/generate.go b/vendor/github.com/kubernetes-incubator/apiserver-builder/cmd/apiserver-boot/boot/build/generate.go deleted file mode 100644 index 38ec9c8bd7..0000000000 --- a/vendor/github.com/kubernetes-incubator/apiserver-builder/cmd/apiserver-boot/boot/build/generate.go +++ /dev/null @@ -1,278 +0,0 @@ -/* -Copyright 2017 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package build - -import ( - "fmt" - "io/ioutil" - "log" - "os" - "os/exec" - "path" - "path/filepath" - "strings" - - "github.com/kubernetes-incubator/apiserver-builder/cmd/apiserver-boot/boot/util" - "github.com/spf13/cobra" - "regexp" -) - -var versionedAPIs []string -var unversionedAPIs []string -var copyright string = "boilerplate.go.txt" - -var generateCmd = &cobra.Command{ - Use: "generated", - Short: "Run code generators against repo.", - Long: `Automatically run by most build commands. Writes generated source code for a repo.`, - Example: `# Run code generators. -apiserver-boot build generated`, - Run: RunGenerate, -} - -var genericAPI = strings.Join([]string{ - "k8s.io/client-go/pkg/api/v1", - "k8s.io/client-go/pkg/apis/apps/v1beta1", - "k8s.io/client-go/pkg/apis/authentication/v1", - "k8s.io/client-go/pkg/apis/authentication/v1beta1", - "k8s.io/client-go/pkg/apis/authorization/v1", - "k8s.io/client-go/pkg/apis/authorization/v1beta1", - "k8s.io/client-go/pkg/apis/autoscaling/v1", - "k8s.io/client-go/pkg/apis/autoscaling/v2alpha1", - "k8s.io/client-go/pkg/apis/batch/v1", - "k8s.io/client-go/pkg/apis/batch/v2alpha1", - "k8s.io/client-go/pkg/apis/certificates/v1beta1", - "k8s.io/client-go/pkg/apis/extensions/v1beta1", - "k8s.io/client-go/pkg/apis/policy/v1beta1", - "k8s.io/client-go/pkg/apis/rbac/v1alpha1", - "k8s.io/client-go/pkg/apis/rbac/v1beta1", - "k8s.io/client-go/pkg/apis/settings/v1alpha1", - "k8s.io/client-go/pkg/apis/storage/v1", - "k8s.io/client-go/pkg/apis/storage/v1beta1", - "k8s.io/apimachinery/pkg/apis/meta/v1", - "k8s.io/apimachinery/pkg/api/resource", - "k8s.io/apimachinery/pkg/version", - "k8s.io/apimachinery/pkg/runtime", - "k8s.io/apimachinery/pkg/util/intstr"}, ",") - -var extraAPI = strings.Join([]string{ - "k8s.io/apimachinery/pkg/apis/meta/v1", - "k8s.io/apimachinery/pkg/conversion", - "k8s.io/apimachinery/pkg/runtime"}, ",") - -func AddGenerate(cmd *cobra.Command) { - cmd.AddCommand(generateCmd) - generateCmd.Flags().StringArrayVar(&versionedAPIs, "api-versions", []string{}, "comma separated list of APIs Versions. e.g. foo/v1beta1,bar/v1 defaults to all directories under pkd/apis/group/version") - generateCmd.AddCommand(generateCleanCmd) -} - -var generateCleanCmd = &cobra.Command{ - Use: "clean", - Short: "Removes generated source code", - Long: `Removes generated source code`, - Run: RunCleanGenerate, -} - -func RunCleanGenerate(cmd *cobra.Command, args []string) { - os.RemoveAll(filepath.Join("pkg", "client", "clientset_generated")) - os.RemoveAll(filepath.Join("pkg", "client", "informers_generated")) - os.RemoveAll(filepath.Join("pkg", "client", "listers_generated")) - os.Remove(filepath.Join("pkg", "openapi", "openapi_generated.go")) - - filepath.Walk("pkg", func(path string, info os.FileInfo, err error) error { - if !info.IsDir() && strings.HasPrefix(info.Name(), "zz_generated.") { - return os.Remove(path) - } - return nil - }) -} - -func RunGenerate(cmd *cobra.Command, args []string) { - initApis() - - util.GetCopyright(copyright) - - root, err := os.Executable() - if err != nil { - log.Fatalf("error: %v", err) - } - root = filepath.Dir(root) - - all := []string{} - versioned := []string{} - for _, v := range versionedAPIs { - v = filepath.Join(util.Repo, "pkg", "apis", v) - versioned = append(versioned, "--input-dirs", v) - all = append(all, "--input-dirs", v) - } - unversioned := []string{} - for _, u := range unversionedAPIs { - u = filepath.Join(util.Repo, "pkg", "apis", u) - unversioned = append(unversioned, "--input-dirs", u) - all = append(all, "--input-dirs", u) - } - - c := exec.Command(filepath.Join(root, "apiregister-gen"), - "--input-dirs", filepath.Join(util.Repo, "pkg", "apis", "..."), - "--input-dirs", filepath.Join(util.Repo, "pkg", "controller", "..."), - ) - fmt.Printf("%s\n", strings.Join(c.Args, " ")) - out, err := c.CombinedOutput() - if err != nil { - log.Fatalf("failed to run apiregister-gen %s %v", out, err) - } - - c = exec.Command(filepath.Join(root, "conversion-gen"), - append(all, - "-o", util.GoSrc, - "--go-header-file", copyright, - "-O", "zz_generated.conversion", - "--extra-peer-dirs", extraAPI)..., - ) - fmt.Printf("%s\n", strings.Join(c.Args, " ")) - out, err = c.CombinedOutput() - if err != nil { - log.Fatalf("failed to run conversion-gen %s %v", out, err) - } - - c = exec.Command(filepath.Join(root, "deepcopy-gen"), - append(all, - "-o", util.GoSrc, - "--go-header-file", copyright, - "-O", "zz_generated.deepcopy")..., - ) - fmt.Printf("%s\n", strings.Join(c.Args, " ")) - out, err = c.CombinedOutput() - if err != nil { - log.Fatalf("failed to run deepcopy-gen %s %v", out, err) - } - - c = exec.Command(filepath.Join(root, "openapi-gen"), - append(all, - "-o", util.GoSrc, - "--go-header-file", copyright, - "-i", genericAPI, - "--output-package", filepath.Join(util.Repo, "pkg", "openapi"))..., - ) - fmt.Printf("%s\n", strings.Join(c.Args, " ")) - out, err = c.CombinedOutput() - if err != nil { - log.Fatalf("failed to run openapi-gen %s %v", out, err) - } - - c = exec.Command(filepath.Join(root, "defaulter-gen"), - append(all, - "-o", util.GoSrc, - "--go-header-file", copyright, - "-O", "zz_generated.defaults", - "--extra-peer-dirs=", extraAPI)..., - ) - fmt.Printf("%s\n", strings.Join(c.Args, " ")) - out, err = c.CombinedOutput() - if err != nil { - log.Fatalf("failed to run defaulter-gen %s %v", out, err) - } - - // Builder the versioned apis client - clientPkg := filepath.Join(util.Repo, "pkg", "client") - clientset := filepath.Join(clientPkg, "clientset_generated") - c = exec.Command(filepath.Join(root, "client-gen"), - "-o", util.GoSrc, - "--go-header-file", copyright, - "--input-base", filepath.Join(util.Repo, "pkg", "apis"), - "--input", strings.Join(versionedAPIs, ","), - "--clientset-path", clientset, - "--clientset-name", "clientset", - ) - fmt.Printf("%s\n", strings.Join(c.Args, " ")) - out, err = c.CombinedOutput() - if err != nil { - log.Fatalf("failed to run client-gen %s %v", out, err) - } - - c = exec.Command(filepath.Join(root, "client-gen"), - "-o", util.GoSrc, - "--go-header-file", copyright, - "--input-base", filepath.Join(util.Repo, "pkg", "apis"), - "--input", strings.Join(unversionedAPIs, ","), - "--clientset-path", clientset, - "--clientset-name", "internalclientset") - fmt.Printf("%s\n", strings.Join(c.Args, " ")) - out, err = c.CombinedOutput() - if err != nil { - log.Fatalf("failed to run client-gen for unversioned APIs %s %v", out, err) - } - - listerPkg := filepath.Join(clientPkg, "listers_generated") - c = exec.Command(filepath.Join(root, "lister-gen"), - append(all, - "-o", util.GoSrc, - "--go-header-file", copyright, - "--output-package", listerPkg)..., - ) - fmt.Printf("%s\n", strings.Join(c.Args, " ")) - out, err = c.CombinedOutput() - if err != nil { - log.Fatalf("failed to run lister-gen %s %v", out, err) - } - - informerPkg := filepath.Join(clientPkg, "informers_generated") - c = exec.Command(filepath.Join(root, "informer-gen"), - append(all, - "-o", util.GoSrc, - "--go-header-file", copyright, - "--output-package", informerPkg, - "--listers-package", listerPkg, - "--versioned-clientset-package", filepath.Join(clientset, "clientset"), - "--internal-clientset-package", filepath.Join(clientset, "internalclientset"))..., - ) - fmt.Printf("%s\n", strings.Join(c.Args, " ")) - out, err = c.CombinedOutput() - if err != nil { - log.Fatalf("failed to run informer-gen %s %v", out, err) - } -} - -func initApis() { - if len(versionedAPIs) == 0 { - groups, err := ioutil.ReadDir(filepath.Join("pkg", "apis")) - if err != nil { - log.Fatalf("could not read pkg/apis directory to find api Versions") - } - for _, g := range groups { - if g.IsDir() { - versionFiles, err := ioutil.ReadDir(filepath.Join("pkg", "apis", g.Name())) - if err != nil { - log.Fatalf("could not read pkg/apis/%s directory to find api Versions", g.Name()) - } - versionMatch := regexp.MustCompile("^v\\d+(alpha\\d+|beta\\d+)*$") - for _, v := range versionFiles { - if v.IsDir() && versionMatch.MatchString(v.Name()) { - versionedAPIs = append(versionedAPIs, filepath.Join(g.Name(), v.Name())) - } - } - } - } - } - u := map[string]bool{} - for _, a := range versionedAPIs { - u[path.Dir(a)] = true - } - for a, _ := range u { - unversionedAPIs = append(unversionedAPIs, a) - } -} diff --git a/vendor/github.com/kubernetes-incubator/apiserver-builder/cmd/apiserver-boot/boot/create/create.go b/vendor/github.com/kubernetes-incubator/apiserver-builder/cmd/apiserver-boot/boot/create/create.go deleted file mode 100644 index 6240499191..0000000000 --- a/vendor/github.com/kubernetes-incubator/apiserver-builder/cmd/apiserver-boot/boot/create/create.go +++ /dev/null @@ -1,49 +0,0 @@ -/* -Copyright 2017 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package create - -import ( - "github.com/spf13/cobra" -) - -var createCmd = &cobra.Command{ - Use: "create", - Short: "Command group for bootstrapping new resources.", - Long: `Command group for bootstrapping new resources.`, - Example: `# Create new resource "Bee" in the "insect" group with version "v1beta" -# Will automatically the group and version if they do not exist -apiserver-boot create group version kind --group insect --version v1beta --kind Bee - -# Create a new group "insect" -apiserver-boot create group --group insect - -# Create a new version "v1beta" of group "insect" -# Will automatically create group if it does not exist -apiserver-boot create group --group insect --version v1beta`, - Run: RunCreate, -} - -var copyright string = "boilerplate.go.txt" - -func AddCreate(cmd *cobra.Command) { - cmd.AddCommand(createCmd) - AddCreateGroup(createCmd) -} - -func RunCreate(cmd *cobra.Command, args []string) { - cmd.Help() -} diff --git a/vendor/github.com/kubernetes-incubator/apiserver-builder/cmd/apiserver-boot/boot/create/group.go b/vendor/github.com/kubernetes-incubator/apiserver-builder/cmd/apiserver-boot/boot/create/group.go deleted file mode 100644 index dbae00642c..0000000000 --- a/vendor/github.com/kubernetes-incubator/apiserver-builder/cmd/apiserver-boot/boot/create/group.go +++ /dev/null @@ -1,108 +0,0 @@ -/* -Copyright 2017 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package create - -import ( - "log" - "os" - "path/filepath" - - "github.com/kubernetes-incubator/apiserver-builder/cmd/apiserver-boot/boot/util" - "github.com/spf13/cobra" - "strings" -) - -var createGroupCmd = &cobra.Command{ - Use: "group", - Short: "Creates an API group", - Long: `Creates an API group.`, - Run: RunCreateGroup, -} - -var groupName string -var ignoreGroupExists bool = false - -func AddCreateGroup(cmd *cobra.Command) { - createGroupCmd.Flags().StringVar(&groupName, "group", "", "name of the API group to create") - - cmd.AddCommand(createGroupCmd) - AddCreateVersion(createGroupCmd) -} - -func RunCreateGroup(cmd *cobra.Command, args []string) { - if _, err := os.Stat("pkg"); err != nil { - log.Fatalf("could not find 'pkg' directory. must run apiserver-boot init before creating resources") - } - - util.GetDomain() - if len(groupName) == 0 { - log.Fatalf("Must specify --group") - } - - if strings.ToLower(groupName) != groupName { - log.Fatalf("--group must be lowercase was (%s)", groupName) - } - - createGroup(util.GetCopyright(copyright)) -} - -func createGroup(boilerplate string) { - dir, err := os.Getwd() - if err != nil { - log.Fatal(err) - } - - a := groupTemplateArgs{ - boilerplate, - util.Domain, - groupName, - } - - path := filepath.Join(dir, "pkg", "apis", groupName, "doc.go") - created := util.WriteIfNotFound(path, "group-template", groupTemplate, a) - - path = filepath.Join(dir, "pkg", "apis", groupName, "install", "doc.go") - created = util.WriteIfNotFound(path, "install-template", installTemplate, a) - if !created && !ignoreGroupExists { - log.Fatalf("API group %s already exists.", groupName) - } -} - -type groupTemplateArgs struct { - BoilerPlate string - Domain string - Name string -} - -var groupTemplate = ` -{{.BoilerPlate}} - - -// +k8s:deepcopy-gen=package,register -// +groupName={{.Name}}.{{.Domain}} - -// Package api is the internal version of the API. -package {{.Name}} - -` - -var installTemplate = ` -{{.BoilerPlate}} - -package install - -` diff --git a/vendor/github.com/kubernetes-incubator/apiserver-builder/cmd/apiserver-boot/boot/create/resource.go b/vendor/github.com/kubernetes-incubator/apiserver-builder/cmd/apiserver-boot/boot/create/resource.go deleted file mode 100644 index 21c933f8d5..0000000000 --- a/vendor/github.com/kubernetes-incubator/apiserver-builder/cmd/apiserver-boot/boot/create/resource.go +++ /dev/null @@ -1,535 +0,0 @@ -/* -Copyright 2017 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package create - -import ( - "fmt" - "log" - "os" - "path/filepath" - "regexp" - "strings" - - "github.com/kubernetes-incubator/apiserver-builder/cmd/apiserver-boot/boot/util" - "github.com/markbates/inflect" - "github.com/spf13/cobra" -) - -var kindName string -var resourceName string -var nonNamespacedKind bool - -var createResourceCmd = &cobra.Command{ - Use: "resource", - Short: "Creates an API group, version and resource", - Long: `Creates an API group, version and resource. Will not recreate group or resource if they already exist.`, - Example: `# Create new resource "Bee" in the "insect" group with version "v1beta" -# Will automatically the group and version if they do not exist -apiserver-boot create group version kind --group insect --version v1beta --kind Bee`, - Run: RunCreateResource, -} - -func AddCreateResource(cmd *cobra.Command) { - createResourceCmd.Flags().StringVar(&groupName, "group", "", "name of the API group to create") - createResourceCmd.Flags().StringVar(&versionName, "version", "", "name of the API version to create") - createResourceCmd.Flags().StringVar(&kindName, "kind", "", "name of the API kind to create") - createResourceCmd.Flags().StringVar(&resourceName, "resource", "", "optional name of the API resource to create, normally the plural name of the kind in lowercase") - createResourceCmd.Flags().BoolVar(&nonNamespacedKind, "non-namespaced", false, "if set, the API kind will be non namespaced") - - cmd.AddCommand(createResourceCmd) -} - -func RunCreateResource(cmd *cobra.Command, args []string) { - if _, err := os.Stat("pkg"); err != nil { - log.Fatalf("could not find 'pkg' directory. must run apiserver-boot init before creating resources") - } - - util.GetDomain() - if len(groupName) == 0 { - log.Fatalf("Must specify --group") - } - if len(versionName) == 0 { - log.Fatalf("Must specify --version") - } - if len(kindName) == 0 { - log.Fatal("Must specify --kind") - } - if len(resourceName) == 0 { - resourceName = inflect.NewDefaultRuleset().Pluralize(strings.ToLower(kindName)) - } - - if strings.ToLower(groupName) != groupName { - log.Fatalf("--group must be lowercase was (%s)", groupName) - } - versionMatch := regexp.MustCompile("^v\\d+(alpha\\d+|beta\\d+)*$") - if !versionMatch.MatchString(versionName) { - log.Fatalf( - "--version has bad format. must match ^v\\d+(alpha\\d+|beta\\d+)*$. "+ - "e.g. v1alpha1,v1beta1,v1 was(%s)", versionName) - } - if string(kindName[0]) != strings.ToUpper(string(kindName[0])) { - log.Fatalf("--kind must start with uppercase letter was (%s)", kindName) - } - - cr := util.GetCopyright(copyright) - - ignoreGroupExists = true - createGroup(cr) - ignoreVersionExists = true - createVersion(cr) - - createResource(cr) -} - -func createResource(boilerplate string) { - dir, err := os.Getwd() - if err != nil { - log.Fatal(err) - } - typesFileName := fmt.Sprintf("%s_types.go", strings.ToLower(kindName)) - path := filepath.Join(dir, "pkg", "apis", groupName, versionName, typesFileName) - a := resourceTemplateArgs{ - boilerplate, - util.Domain, - groupName, - versionName, - kindName, - resourceName, - util.Repo, - inflect.NewDefaultRuleset().Pluralize(kindName), - nonNamespacedKind, - } - - found := false - - created := util.WriteIfNotFound(path, "resource-template", resourceTemplate, a) - if !created { - if !found { - log.Printf("API group version kind %s/%s/%s already exists.", - groupName, versionName, kindName) - found = true - } - } - - // write the suite if it is missing - typesFileName = fmt.Sprintf("%s_suite_test.go", strings.ToLower(versionName)) - path = filepath.Join(dir, "pkg", "apis", groupName, versionName, typesFileName) - util.WriteIfNotFound(path, "version-suite-test-template", resourceSuiteTestTemplate, a) - - typesFileName = fmt.Sprintf("%s_types_test.go", strings.ToLower(kindName)) - path = filepath.Join(dir, "pkg", "apis", groupName, versionName, typesFileName) - created = util.WriteIfNotFound(path, "resource-test-template", resourceTestTemplate, a) - if !created { - if !found { - log.Printf("API group version kind %s/%s/%s test already exists.", - groupName, versionName, kindName) - found = true - } - } - - path = filepath.Join(dir, "pkg", "controller", strings.ToLower(kindName), "controller.go") - created = util.WriteIfNotFound(path, "resource-controller-template", resourceControllerTemplate, a) - if !created { - if !found { - log.Printf("Controller for %s/%s/%s already exists.", - groupName, versionName, kindName) - found = true - } - } - - path = filepath.Join(dir, "pkg", "controller", strings.ToLower(kindName), fmt.Sprintf("%s_suite_test.go", strings.ToLower(kindName))) - util.WriteIfNotFound(path, "resource-controller-suite-test-template", controllerSuiteTestTemplate, a) - - path = filepath.Join(dir, "pkg", "controller", strings.ToLower(kindName), "controller_test.go") - created = util.WriteIfNotFound(path, "controller-test-template", controllerTestTemplate, a) - if !created { - if !found { - log.Printf("Controller test for %s/%s/%s already exists.", - groupName, versionName, kindName) - found = true - } - } - - if found { - os.Exit(-1) - } -} - -type resourceTemplateArgs struct { - BoilerPlate string - Domain string - Group string - Version string - Kind string - Resource string - Repo string - PluralizedKind string - NonNamespacedKind bool -} - -var resourceTemplate = ` -{{.BoilerPlate}} - -package {{.Version}} - -import ( - "log" - - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apiserver/pkg/endpoints/request" - - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/util/validation/field" - - "{{ .Repo }}/pkg/apis/{{.Group}}" -) - -// +genclient=true -{{- if .NonNamespacedKind }} -// +nonNamespaced=true{{ end }} - -// {{.Kind}} -// +k8s:openapi-gen=true -// +resource:path={{.Resource}},strategy={{.Kind}}Strategy -type {{.Kind}} struct { - metav1.TypeMeta ` + "`" + `json:",inline"` + "`" + ` - metav1.ObjectMeta ` + "`" + `json:"metadata,omitempty"` + "`" + ` - - Spec {{.Kind}}Spec ` + "`" + `json:"spec,omitempty"` + "`" + ` - Status {{.Kind}}Status ` + "`" + `json:"status,omitempty"` + "`" + ` -} - -// {{.Kind}}Spec defines the desired state of {{.Kind}} -type {{.Kind}}Spec struct { -} - -// {{.Kind}}Status defines the observed state of {{.Kind}} -type {{.Kind}}Status struct { -} - -// Validate checks that an instance of {{.Kind}} is well formed -func ({{.Kind}}Strategy) Validate(ctx request.Context, obj runtime.Object) field.ErrorList { - o := obj.(*{{.Group}}.{{.Kind}}) - log.Printf("Validating fields for {{.Kind}} %s\n", o.Name) - errors := field.ErrorList{} - // perform validation here and add to errors using field.Invalid - return errors -} - -{{- if .NonNamespacedKind }} - -func ({{.Kind}}Strategy) NamespaceScoped() bool { return false } - -func ({{.Kind}}StatusStrategy) NamespaceScoped() bool { return false } -{{- end }} - -// DefaultingFunction sets default {{.Kind}} field values -func ({{.Kind}}SchemeFns) DefaultingFunction(o interface{}) { - obj := o.(*{{.Kind}}) - // set default field values here - log.Printf("Defaulting fields for {{.Kind}} %s\n", obj.Name) -} -` - -var resourceSuiteTestTemplate = ` -{{.BoilerPlate}} - -package {{.Version}}_test - -import ( - "testing" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - "github.com/kubernetes-incubator/apiserver-builder/pkg/test" - "k8s.io/client-go/rest" - - "{{ .Repo }}/pkg/apis" - "{{ .Repo }}/pkg/client/clientset_generated/clientset" - "{{ .Repo }}/pkg/openapi" -) - -var testenv *test.TestEnvironment -var config *rest.Config -var cs *clientset.Clientset - -func Test{{title .Version}}(t *testing.T) { - RegisterFailHandler(Fail) - RunSpecsWithDefaultAndCustomReporters(t, "v1 Suite", []Reporter{test.NewlineReporter{}}) -} - -var _ = BeforeSuite(func() { - testenv = test.NewTestEnvironment() - config = testenv.Start(apis.GetAllApiBuilders(), openapi.GetOpenAPIDefinitions) - cs = clientset.NewForConfigOrDie(config) -}) - -var _ = AfterSuite(func() { - testenv.Stop() -}) -` - -var resourceTestTemplate = ` -{{.BoilerPlate}} - -package {{.Version}}_test - -import ( - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - - . "{{.Repo}}/pkg/apis/{{.Group}}/{{.Version}}" - . "{{.Repo}}/pkg/client/clientset_generated/clientset/typed/{{.Group}}/{{.Version}}" -) - -var _ = Describe("{{.Kind}}", func() { - var instance {{ .Kind}} - var expected {{ .Kind}} - var client {{ .Kind}}Interface - - BeforeEach(func() { - instance = {{ .Kind}}{} - instance.Name = "instance-1" - - expected = instance - }) - - AfterEach(func() { - client.Delete(instance.Name, &metav1.DeleteOptions{}) - }) - - Describe("when sending a storage request", func() { - Context("for a valid config", func() { - It("should provide CRUD access to the object", func() { - client = cs.{{ title .Group}}{{title .Version}}Client.{{plural .Kind}}({{ if not .NonNamespacedKind }}"{{lower .Kind}}-test-valid"{{ end }}) - - By("returning success from the create request") - actual, err := client.Create(&instance) - Expect(err).ShouldNot(HaveOccurred()) - - By("defaulting the expected fields") - Expect(actual.Spec).To(Equal(expected.Spec)) - - By("returning the item for list requests") - result, err := client.List(metav1.ListOptions{}) - Expect(err).ShouldNot(HaveOccurred()) - Expect(result.Items).To(HaveLen(1)) - Expect(result.Items[0].Spec).To(Equal(expected.Spec)) - - By("returning the item for get requests") - actual, err = client.Get(instance.Name, metav1.GetOptions{}) - Expect(err).ShouldNot(HaveOccurred()) - Expect(actual.Spec).To(Equal(expected.Spec)) - - By("deleting the item for delete requests") - err = client.Delete(instance.Name, &metav1.DeleteOptions{}) - Expect(err).ShouldNot(HaveOccurred()) - result, err = client.List(metav1.ListOptions{}) - Expect(err).ShouldNot(HaveOccurred()) - Expect(result.Items).To(HaveLen(0)) - }) - }) - }) -}) -` - -var resourceControllerTemplate = ` -{{.BoilerPlate}} - -package {{ lower .Kind }} - -import ( - "log" - - "github.com/kubernetes-incubator/apiserver-builder/pkg/controller" - "k8s.io/client-go/rest" - "k8s.io/client-go/tools/cache" - "k8s.io/client-go/util/workqueue" - - "{{.Repo}}/pkg/apis/{{.Group}}/{{.Version}}" - "{{.Repo}}/pkg/controller/sharedinformers" - listers "{{.Repo}}/pkg/client/listers_generated/{{.Group}}/{{.Version}}" -) - -// +controller:group={{ .Group }},version={{ .Version }},kind={{ .Kind}},resource={{ .Resource }} -type {{.Kind}}ControllerImpl struct { - // informer listens for events about {{.Kind}} - informer cache.SharedIndexInformer - - // lister indexes properties about {{.Kind}} - lister listers.{{.Kind}}Lister -} - -// Init initializes the controller and is called by the generated code -// Registers eventhandlers to enqueue events -// config - client configuration for talking to the apiserver -// si - informer factory shared across all controllers for listening to events and indexing resource properties -// queue - message queue for handling new events. unique to this controller. -func (c *{{.Kind}}ControllerImpl) Init( - config *rest.Config, - si *sharedinformers.SharedInformers, - queue workqueue.RateLimitingInterface) { - - // Set the informer and lister for subscribing to events and indexing {{.Resource}} labels - i := si.Factory.{{title .Group}}().{{title .Version}}().{{plural .Kind}}() - c.informer = i.Informer() - c.lister = i.Lister() - - // Add an event handler to enqueue a message for {{.Resource}} adds / updates - c.informer.AddEventHandler(&controller.QueueingEventHandler{queue}) -} - -// Reconcile handles enqueued messages -func (c *{{.Kind}}ControllerImpl) Reconcile(u *{{.Version}}.{{.Kind}}) error { - // Implement controller logic here - log.Printf("Running reconcile {{.Kind}} for %s\n", u.Name) - return nil -} - -func (c *{{.Kind}}ControllerImpl) Get(namespace, name string) (*{{.Version}}.{{.Kind}}, error) { - return c.lister.{{ if not .NonNamespacedKind }}{{ title .Resource }}(namespace).{{ end }}Get(name) -} -` - -var controllerSuiteTestTemplate = ` -{{.BoilerPlate}} - -package {{lower .Kind}}_test - -import ( - "testing" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - "k8s.io/client-go/rest" - "github.com/kubernetes-incubator/apiserver-builder/pkg/test" - - "{{ .Repo }}/pkg/apis" - "{{ .Repo }}/pkg/client/clientset_generated/clientset" - "{{ .Repo }}/pkg/openapi" - "{{ .Repo }}/pkg/controller/sharedinformers" - "{{ .Repo }}/pkg/controller/{{lower .Kind}}" -) - -var testenv *test.TestEnvironment -var config *rest.Config -var cs *clientset.Clientset -var shutdown chan struct{} -var controller *{{ lower .Kind }}.{{ .Kind }}Controller -var si *sharedinformers.SharedInformers - -func Test{{.Kind}}(t *testing.T) { - RegisterFailHandler(Fail) - RunSpecsWithDefaultAndCustomReporters(t, "{{ .Kind }} Suite", []Reporter{test.NewlineReporter{}}) -} - -var _ = BeforeSuite(func() { - testenv = test.NewTestEnvironment() - config = testenv.Start(apis.GetAllApiBuilders(), openapi.GetOpenAPIDefinitions) - cs = clientset.NewForConfigOrDie(config) - - shutdown = make(chan struct{}) - si = sharedinformers.NewSharedInformers(config, shutdown) - controller = {{ lower .Kind }}.New{{ .Kind}}Controller(config, si) - controller.Run(shutdown) -}) - -var _ = AfterSuite(func() { - close(shutdown) - testenv.Stop() -}) -` - -var controllerTestTemplate = ` -{{.BoilerPlate}} - -package {{ lower .Kind }}_test - -import ( - "time" - - . "{{ .Repo }}/pkg/apis/{{ .Group }}/{{ .Version }}" - . "{{ .Repo }}/pkg/client/clientset_generated/clientset/typed/{{ .Group }}/{{ .Version }}" - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -var _ = Describe("{{ .Kind }} controller", func() { - var instance {{ .Kind }} - var expectedKey string - var client {{ .Kind }}Interface - var before chan struct{} - var after chan struct{} - - BeforeEach(func() { - instance = {{ .Kind }}{} - instance.Name = "instance-1" - expectedKey = "{{ if not .NonNamespacedKind }}{{lower .Kind }}-controller-test-handler/{{ end }}instance-1" - }) - - AfterEach(func() { - client.Delete(instance.Name, &metav1.DeleteOptions{}) - }) - - Describe("when creating a new object", func() { - It("invoke the reconcile method", func() { - client = cs.{{title .Group}}{{title .Version}}Client.{{ plural .Kind }}({{ if not .NonNamespacedKind }}"{{lower .Kind }}-controller-test-handler"{{ end }}) - before = make(chan struct{}) - after = make(chan struct{}) - - actualKey := "" - var actualErr error = nil - - // Setup test callbacks to be called when the message is reconciled - controller.BeforeReconcile = func(key string) { - defer close(before) - actualKey = key - } - controller.AfterReconcile = func(key string, err error) { - defer close(after) - actualKey = key - actualErr = err - } - - // Create an instance - _, err := client.Create(&instance) - Expect(err).ShouldNot(HaveOccurred()) - - // Verify reconcile function is called against the correct key - select { - case <-before: - Expect(actualKey).To(Equal(expectedKey)) - Expect(actualErr).ShouldNot(HaveOccurred()) - case <-time.After(time.Second * 2): - Fail("reconcile never called") - } - - select { - case <-after: - Expect(actualKey).To(Equal(expectedKey)) - Expect(actualErr).ShouldNot(HaveOccurred()) - case <-time.After(time.Second * 2): - Fail("reconcile never finished") - } - }) - }) -}) -` diff --git a/vendor/github.com/kubernetes-incubator/apiserver-builder/cmd/apiserver-boot/boot/create/version.go b/vendor/github.com/kubernetes-incubator/apiserver-builder/cmd/apiserver-boot/boot/create/version.go deleted file mode 100644 index 1bacaa0e6a..0000000000 --- a/vendor/github.com/kubernetes-incubator/apiserver-builder/cmd/apiserver-boot/boot/create/version.go +++ /dev/null @@ -1,119 +0,0 @@ -/* -Copyright 2017 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package create - -import ( - "log" - "os" - "path/filepath" - "regexp" - "strings" - - "github.com/kubernetes-incubator/apiserver-builder/cmd/apiserver-boot/boot/util" - "github.com/spf13/cobra" -) - -var versionName string -var ignoreVersionExists bool = false - -var createVersionCmd = &cobra.Command{ - Use: "version", - Short: "Creates an API group and version", - Long: `Creates an API group and version. Will not recreate group if already exists.`, - Run: RunCreateVersion, -} - -func AddCreateVersion(cmd *cobra.Command) { - createVersionCmd.Flags().StringVar(&groupName, "group", "", "name of the API group to create") - createVersionCmd.Flags().StringVar(&versionName, "version", "", "name of the API version to create") - cmd.AddCommand(createVersionCmd) - - AddCreateResource(createVersionCmd) -} - -func RunCreateVersion(cmd *cobra.Command, args []string) { - if _, err := os.Stat("pkg"); err != nil { - log.Fatalf("could not find 'pkg' directory. must run apiserver-boot init before creating resources") - } - - util.GetDomain() - if len(groupName) == 0 { - log.Fatalf("Must specify --group") - } - if len(versionName) == 0 { - log.Fatalf("Must specify --version") - } - - if strings.ToLower(groupName) != groupName { - log.Fatalf("--group must be lowercase was (%s)", groupName) - } - versionMatch := regexp.MustCompile("^v\\d+(alpha\\d+|beta\\d+)*$") - if !versionMatch.MatchString(versionName) { - log.Fatalf( - "--version has bad format. must match ^v\\d+(alpha\\d+|beta\\d+)*$. "+ - "e.g. v1alpha1,v1beta1,v1 was(%s)", versionName) - } - - cr := util.GetCopyright(copyright) - - ignoreGroupExists = true - createGroup(cr) - createVersion(cr) -} - -func createVersion(boilerplate string) { - dir, err := os.Getwd() - if err != nil { - log.Fatalf("%v\n", err) - os.Exit(-1) - } - path := filepath.Join(dir, "pkg", "apis", groupName, versionName, "doc.go") - created := util.WriteIfNotFound(path, "version-template", versionTemplate, versionTemplateArgs{ - boilerplate, - util.Domain, - groupName, - versionName, - util.Repo, - }) - if !created && ignoreVersionExists { - log.Fatalf("API group version %s/%s already exists.", groupName, versionName) - } -} - -type versionTemplateArgs struct { - BoilerPlate string - Domain string - Group string - Version string - Repo string -} - -var versionTemplate = ` -{{.BoilerPlate}} - -// Api versions allow the api contract for a resource to be changed while keeping -// backward compatibility by support multiple concurrent versions -// of the same resource - -// +k8s:openapi-gen=true -// +k8s:deepcopy-gen=package,register -// +k8s:conversion-gen={{.Repo}}/pkg/apis/{{.Group}} -// +k8s:defaulter-gen=TypeMeta -// +groupName={{.Group}}.{{.Domain}} -package {{.Version}} // import "{{.Repo}}/pkg/apis/{{.Group}}/{{.Version}}" - -` diff --git a/vendor/github.com/kubernetes-incubator/apiserver-builder/cmd/apiserver-boot/boot/init_repo/glide.go b/vendor/github.com/kubernetes-incubator/apiserver-builder/cmd/apiserver-boot/boot/init_repo/glide.go deleted file mode 100644 index 612dc110e1..0000000000 --- a/vendor/github.com/kubernetes-incubator/apiserver-builder/cmd/apiserver-boot/boot/init_repo/glide.go +++ /dev/null @@ -1,150 +0,0 @@ -/* -Copyright 2017 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package init_repo - -import ( - "log" - "os" - "os/exec" - "path/filepath" - "strings" - - "github.com/kubernetes-incubator/apiserver-builder/cmd/apiserver-boot/boot/util" - "github.com/spf13/cobra" -) - -var glideInstallCmd = &cobra.Command{ - Use: "glide", - Short: "Install glide.yaml, glide.lock and vendor/.", - Long: `Install glide.yaml, glide.lock and vendor/.`, - Example: `# Bootstrap vendor/ from the src packaged with apiserver-boot -apiserver-boot init glide - -# Install vendor/ from using "glide install --strip-vendor" -apiserver-boot init glide --fetch -`, - Run: RunGlideInstall, -} - -var fetch bool - -func AddGlideInstallCmd(cmd *cobra.Command) { - glideInstallCmd.Flags().BoolVar(&fetch, "fetch", true, "if true, fetch new glide deps instead of copying the ones packaged with the tools") - cmd.AddCommand(glideInstallCmd) -} - -func fetchGlide() { - o, err := exec.Command("glide", "-v").CombinedOutput() - if err != nil { - log.Fatal("must install glide v0.12 or later") - } - if !strings.HasPrefix(string(o), "glide version v0.12") && - !strings.HasPrefix(string(o), "glide version v0.13") { - log.Fatalf("must install glide or later, was %s", o) - } - - c := exec.Command("glide", "install", "--strip-vendor") - c.Stderr = os.Stderr - c.Stdout = os.Stdout - err = c.Run() - if err != nil { - log.Fatalf("failed to run glide install\n%v\n", err) - } -} - -func copyGlide() { - // Move up two directories from the location of the `apiserver-boot` - // executable to find the `vendor` directory we package with our - // releases. TODO(campbellalex@google.com): this doesn't work for people - // who used `go install` to put `apiserver-boot` in their $GOPATH/bin. - e, err := os.Executable() - if err != nil { - log.Fatal("unable to get directory of apiserver-builder tools") - } - - e = filepath.Dir(filepath.Dir(e)) - - doCmd := func(cmd string, args ...string) { - c := exec.Command(cmd, args...) - c.Stderr = os.Stderr - c.Stdout = os.Stdout - err = c.Run() - if err != nil { - log.Fatalf("failed to copy go dependencies %v", err) - } - } - - doCmd("tar", "-xzvf", filepath.Join(e, "bin", "glide.tar.gz")) -} - -func RunGlideInstall(cmd *cobra.Command, args []string) { - createGlide() - if fetch { - fetchGlide() - } else { - copyGlide() - } -} - -type glideTemplateArguments struct { - Repo string -} - -var glideTemplate = ` -package: {{.Repo}} -import: -- package: k8s.io/apimachinery - version: cff8db64dd5b6fb0166dc2cf36e39c7ff4fe48c8 -- package: k8s.io/apiserver - version: 2e70bac0745c7f8e506f7f3e432d040c55d5718a -- package: k8s.io/client-go - version: 36b51953e6efc7779fe27c14258d78573de4e0de -- package: github.com/go-openapi/analysis - version: b44dc874b601d9e4e2f6e19140e794ba24bead3b -- package: github.com/go-openapi/jsonpointer - version: 46af16f9f7b149af66e5d1bd010e3574dc06de98 -- package: github.com/go-openapi/jsonreference - version: 13c6e3589ad90f49bd3e3bbe2c2cb3d7a4142272 -- package: github.com/go-openapi/loads - version: 18441dfa706d924a39a030ee2c3b1d8d81917b38 -- package: github.com/go-openapi/spec - version: 6aced65f8501fe1217321abf0749d354824ba2ff -- package: github.com/go-openapi/swag - version: 1d0bd113de87027671077d3c71eb3ac5d7dbba72 -- package: github.com/golang/glog - version: 44145f04b68cf362d9c4df2182967c2275eaefed -- package: github.com/pkg/errors - version: a22138067af1c4942683050411a841ade67fe1eb -- package: github.com/spf13/cobra - version: 7b1b6e8dc027253d45fc029bc269d1c019f83a34 -- package: github.com/spf13/pflag - version: d90f37a48761fe767528f31db1955e4f795d652f -ignore: -- {{.Repo}} -` - -func createGlide() { - dir, err := os.Getwd() - if err != nil { - log.Fatal(err) - } - path := filepath.Join(dir, "glide.yaml") - util.WriteIfNotFound(path, "glide-template", glideTemplate, - glideTemplateArguments{ - util.Repo, - }) -} diff --git a/vendor/github.com/kubernetes-incubator/apiserver-builder/cmd/apiserver-boot/boot/init_repo/init.go b/vendor/github.com/kubernetes-incubator/apiserver-builder/cmd/apiserver-boot/boot/init_repo/init.go deleted file mode 100644 index c0fbe7b452..0000000000 --- a/vendor/github.com/kubernetes-incubator/apiserver-builder/cmd/apiserver-boot/boot/init_repo/init.go +++ /dev/null @@ -1,42 +0,0 @@ -/* -Copyright 2017 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package init_repo - -import ( - "github.com/spf13/cobra" -) - -var initCmd = &cobra.Command{ - Use: "init", - Short: "Command group for bootstrapping new go projects.", - Long: `Command group for bootstrapping new go projects.`, - Example: ` -# Bootstrap a new repo -apiserver-boot init repo --domain example.com -`, - Run: RunInit, -} - -func AddInit(cmd *cobra.Command) { - cmd.AddCommand(initCmd) - AddInitRepo(initCmd) - AddGlideInstallCmd(initCmd) -} - -func RunInit(cmd *cobra.Command, args []string) { - cmd.Help() -} diff --git a/vendor/github.com/kubernetes-incubator/apiserver-builder/cmd/apiserver-boot/boot/init_repo/repo.go b/vendor/github.com/kubernetes-incubator/apiserver-builder/cmd/apiserver-boot/boot/init_repo/repo.go deleted file mode 100644 index 263111cd4c..0000000000 --- a/vendor/github.com/kubernetes-incubator/apiserver-builder/cmd/apiserver-boot/boot/init_repo/repo.go +++ /dev/null @@ -1,229 +0,0 @@ -/* -Copyright 2017 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package init_repo - -import ( - "log" - "os" - "os/exec" - "path/filepath" - - "github.com/kubernetes-incubator/apiserver-builder/cmd/apiserver-boot/boot/util" - "github.com/spf13/cobra" -) - -var repoCmd = &cobra.Command{ - Use: "repo", - Short: "Initialize a repo with the apiserver scaffolding and glide dependencies", - Long: `Initialize a repo with the apiserver scaffolding and glide dependencies`, - Example: `apiserver-boot init repo --domain mydomain`, - Run: RunInitRepo, -} - -var installDeps bool -var domain string -var copyright string = "boilerplate.go.txt" - -func AddInitRepo(cmd *cobra.Command) { - cmd.AddCommand(repoCmd) - repoCmd.Flags().StringVar(&domain, "domain", "", "domain the api groups live under") - - // Hide this flag by default - repoCmd.Flags(). - BoolVar(&installDeps, "install-deps", true, "if true, install the vendored deps packaged with apiserver-boot.") - repoCmd.Flags().MarkHidden("install-deps") -} - -func RunInitRepo(cmd *cobra.Command, args []string) { - if len(domain) == 0 { - log.Fatal("Must specify --domain") - } - cr := util.GetCopyright(copyright) - - createApiserver(cr) - createControllerManager(cr) - createAPIs(cr) - createDocs() - - createPackage(cr, filepath.Join("pkg")) - createPackage(cr, filepath.Join("pkg", "controller")) - createPackage(cr, filepath.Join("pkg", "controller", "sharedinformers")) - createPackage(cr, filepath.Join("pkg", "openapi")) - - exec.Command("mkdir", "-p", filepath.Join("bin")).CombinedOutput() - - if installDeps { - log.Printf("installing godeps. To disable this, run with --install-deps=false.") - copyGlide() - } -} - -type controllerManagerTemplateArguments struct { - BoilerPlate string - Repo string -} - -var controllerManagerTemplate = ` -{{.BoilerPlate}} - -package main - -import ( - "flag" - "log" - - controllerlib "github.com/kubernetes-incubator/apiserver-builder/pkg/controller" - - "{{ .Repo }}/pkg/controller" -) - -var kubeconfig = flag.String("kubeconfig", "", "path to kubeconfig") - -func main() { - flag.Parse() - config, err := controllerlib.GetConfig(*kubeconfig) - if err != nil { - log.Fatalf("Could not create Config for talking to the apiserver: %v", err) - } - - controllers, _ := controller.GetAllControllers(config) - controllerlib.StartControllerManager(controllers...) - - // Blockforever - select {} -} -` - -func createControllerManager(boilerplate string) { - dir, err := os.Getwd() - if err != nil { - log.Fatal(err) - } - path := filepath.Join(dir, "cmd", "controller-manager", "main.go") - util.WriteIfNotFound(path, "main-template", controllerManagerTemplate, - controllerManagerTemplateArguments{ - boilerplate, - util.Repo, - }) - -} - -type apiserverTemplateArguments struct { - Domain string - BoilerPlate string - Repo string -} - -var apiserverTemplate = ` -{{.BoilerPlate}} - -package main - -import ( - // Make sure glide gets these dependencies - _ "k8s.io/apimachinery/pkg/apis/meta/v1" - _ "github.com/go-openapi/loads" - - "github.com/kubernetes-incubator/apiserver-builder/pkg/cmd/server" - _ "k8s.io/client-go/plugin/pkg/client/auth" // Enable cloud provider auth - - "{{.Repo}}/pkg/apis" - "{{.Repo}}/pkg/openapi" -) - -func main() { - version := "v0" - server.StartApiServer("/registry/{{ .Domain }}", apis.GetAllApiBuilders(), openapi.GetOpenAPIDefinitions, "Api", version) -} -` - -func createApiserver(boilerplate string) { - dir, err := os.Getwd() - if err != nil { - log.Fatal(err) - } - path := filepath.Join(dir, "cmd", "apiserver", "main.go") - util.WriteIfNotFound(path, "apiserver-template", apiserverTemplate, - apiserverTemplateArguments{ - domain, - boilerplate, - util.Repo, - }) - -} - -func createPackage(boilerplate, path string) { - pkg := filepath.Base(path) - dir, err := os.Getwd() - if err != nil { - log.Fatal(err) - } - path = filepath.Join(dir, path, "doc.go") - util.WriteIfNotFound(path, "pkg-template", packageDocTemplate, - packageDocTemplateArguments{ - boilerplate, - pkg, - }) -} - -type packageDocTemplateArguments struct { - BoilerPlate string - Package string -} - -var packageDocTemplate = ` -{{.BoilerPlate}} - - -package {{.Package}} - -` - -func createAPIs(boilerplate string) { - dir, err := os.Getwd() - if err != nil { - log.Fatal(err) - } - path := filepath.Join(dir, "pkg", "apis", "doc.go") - util.WriteIfNotFound(path, "apis-template", apisDocTemplate, - apisDocTemplateArguments{ - boilerplate, - domain, - }) -} - -type apisDocTemplateArguments struct { - BoilerPlate string - Domain string -} - -var apisDocTemplate = ` -{{.BoilerPlate}} - - -// -// +domain={{.Domain}} - -package apis - -` - -func createDocs() { - exec.Command("mkdir", "-p", filepath.Join("docs", "openapi-spec")).CombinedOutput() - exec.Command("mkdir", "-p", filepath.Join("docs", "static_includes")).CombinedOutput() - exec.Command("mkdir", "-p", filepath.Join("docs", "examples")).CombinedOutput() -} diff --git a/vendor/github.com/kubernetes-incubator/apiserver-builder/cmd/apiserver-boot/boot/run/in_cluster.go b/vendor/github.com/kubernetes-incubator/apiserver-builder/cmd/apiserver-boot/boot/run/in_cluster.go deleted file mode 100644 index 95440971f5..0000000000 --- a/vendor/github.com/kubernetes-incubator/apiserver-builder/cmd/apiserver-boot/boot/run/in_cluster.go +++ /dev/null @@ -1,70 +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 run - -import ( - "os" - "path/filepath" - - "github.com/spf13/cobra" - - "github.com/kubernetes-incubator/apiserver-builder/cmd/apiserver-boot/boot/build" - "github.com/kubernetes-incubator/apiserver-builder/cmd/apiserver-boot/boot/util" -) - -var runInClusterCmd = &cobra.Command{ - Use: "in-cluster", - Short: "run the etcd, apiserver and the controller-manager as an aggegrated apiserver in a cluster", - Long: `run the etcd, apiserver and the controller-manager as an aggegrated apiserver in a cluster`, - Example: ` -# Build a new image and run the apiserver and controller-manager in the cluster -apiserver-boot run in-cluster --name example --namespace default --image gcr.io/myrepo/myimage:mytag - -# Clear the discovery cache for kubectl -rm -rf ~/.kube/cache/discovery/ - -# Run kubectl and check for the new version -kubectl api-versions`, - Run: RunInCluster, -} - -var buildImage bool - -func AddInCluster(cmd *cobra.Command) { - cmd.AddCommand(runInClusterCmd) - - build.AddBuildResourceConfigFlags(runInClusterCmd) - runInClusterCmd.Flags().BoolVar(&build.GenerateForBuild, "generate", true, "if true, generate code before building the container image") - runInClusterCmd.Flags().BoolVar(&buildImage, "build-image", true, "if true, build the container image and push it to the image repo.") -} - -func RunInCluster(cmd *cobra.Command, args []string) { - if buildImage { - // Build the container first - build.RunBuildContainer(cmd, args) - - // Push the image - util.DoCmd("docker", "push", build.Image) - } - - // Build the resource config - os.Remove(filepath.Join(build.ResourceConfigDir, "apiserver.yaml")) - build.RunBuildResourceConfig(cmd, args) - - // Apply the new config - util.DoCmd("kubectl", "apply", "-f", filepath.Join(build.ResourceConfigDir, "apiserver.yaml")) -} diff --git a/vendor/github.com/kubernetes-incubator/apiserver-builder/cmd/apiserver-boot/boot/run/local.go b/vendor/github.com/kubernetes-incubator/apiserver-builder/cmd/apiserver-boot/boot/run/local.go deleted file mode 100644 index 0f0fd89499..0000000000 --- a/vendor/github.com/kubernetes-incubator/apiserver-builder/cmd/apiserver-boot/boot/run/local.go +++ /dev/null @@ -1,199 +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 run - -import ( - "fmt" - "log" - "os" - "os/exec" - "path/filepath" - "strings" - "time" - - "github.com/spf13/cobra" - - "github.com/kubernetes-incubator/apiserver-builder/cmd/apiserver-boot/boot/build" - "github.com/kubernetes-incubator/apiserver-builder/cmd/apiserver-boot/boot/util" -) - -var localCmd = &cobra.Command{ - Use: "local", - Short: "run the etcd, apiserver and controller-manager", - Long: `run the etcd, apiserver and controller-manager`, - Example: `# Regenerate code and build binaries. Then run them locally. -apiserver-boot run local - -# Check the api versions of the locally running server -kubectl --kubeconfig kubeconfig api-versions - -# Run locally without rebuilding -apiserver-boot run local --build=false`, - Run: RunLocal, -} - -var etcd string -var config string -var printapiserver bool -var printcontrollermanager bool -var printetcd bool -var buildBin bool - -var server string -var controllermanager string - -func AddLocal(cmd *cobra.Command) { - localCmd.Flags().StringVar(&server, "apiserver", "", "path to apiserver binary to run") - localCmd.Flags().StringVar(&controllermanager, "controller-manager", "", "path to controller-manager binary to run") - localCmd.Flags().StringVar(&etcd, "etcd", "", "if non-empty, use this etcd instead of starting a new one") - - localCmd.Flags().StringVar(&config, "config", "kubeconfig", "path to the kubeconfig to write for using kubectl") - - localCmd.Flags().BoolVar(&printapiserver, "print-apiserver", true, "if true, pipe the apiserver stdout and stderr") - localCmd.Flags().BoolVar(&printcontrollermanager, "print-controller-manager", true, "if true, pipe the controller-manager stdout and stderr") - localCmd.Flags().BoolVar(&printetcd, "printetcd", false, "if true, pipe the etcd stdout and stderr") - localCmd.Flags().BoolVar(&buildBin, "build", true, "if true, build the binaries before running") - - cmd.AddCommand(localCmd) -} - -func RunLocal(cmd *cobra.Command, args []string) { - if buildBin { - build.RunBuildExecutables(cmd, args) - } - - WriteKubeConfig() - - // Start etcd - if len(etcd) == 0 { - etcd = "http://localhost:2379" - etcdCmd := RunEtcd() - defer etcdCmd.Process.Kill() - } - - time.Sleep(time.Second * 2) - - // Start apiserver - go RunApiserver() - - time.Sleep(time.Second * 2) - - // Start controller manager - go RunControllerManager() - - fmt.Printf("to test the server run `kubectl --kubeconfig %s api-versions`\n", config) - select {} // wait forever -} - -func RunEtcd() *exec.Cmd { - etcdCmd := exec.Command("etcd") - if printetcd { - etcdCmd.Stderr = os.Stderr - etcdCmd.Stdout = os.Stdout - } - - fmt.Printf("%s\n", strings.Join(etcdCmd.Args, " ")) - go func() { - err := etcdCmd.Run() - if err != nil { - log.Fatalf("Failed to run etcd %v", err) - os.Exit(-1) - } - }() - return etcdCmd -} - -func RunApiserver() *exec.Cmd { - if len(server) == 0 { - server = "bin/apiserver" - } - - apiserverCmd := exec.Command(server, - "--delegated-auth=false", - fmt.Sprintf("--etcd-servers=%s", etcd), - "--secure-port=9443", - "--print-bearer-token", - ) - fmt.Printf("%s\n", strings.Join(apiserverCmd.Args, " ")) - if printapiserver { - apiserverCmd.Stderr = os.Stderr - apiserverCmd.Stdout = os.Stdout - } - - err := apiserverCmd.Run() - if err != nil { - log.Fatalf("Failed to run apiserver %v", err) - os.Exit(-1) - } - - return apiserverCmd -} - -func RunControllerManager() *exec.Cmd { - if len(controllermanager) == 0 { - controllermanager = "bin/controller-manager" - } - controllerManagerCmd := exec.Command(controllermanager, - fmt.Sprintf("--kubeconfig=%s", config), - ) - fmt.Printf("%s\n", strings.Join(controllerManagerCmd.Args, " ")) - if printcontrollermanager { - controllerManagerCmd.Stderr = os.Stderr - controllerManagerCmd.Stdout = os.Stdout - } - - err := controllerManagerCmd.Run() - if err != nil { - log.Fatalf("Failed to run controller-manager %v", err) - os.Exit(-1) - } - - return controllerManagerCmd -} - -func WriteKubeConfig() { - // Write a kubeconfig - dir, err := os.Getwd() - if err != nil { - log.Fatalf("Cannot get working directory %v", err) - os.Exit(-1) - } - path := filepath.Join(dir, "apiserver.local.config", "certificates", "apiserver") - util.WriteIfNotFound(config, "kubeconfig-template", configTemplate, path) -} - -var configTemplate = ` -apiVersion: v1 -clusters: -- cluster: - certificate-authority: {{ . }}.crt - server: https://localhost:9443 - name: apiserver -contexts: -- context: - cluster: apiserver - user: apiserver - name: apiserver -current-context: apiserver -kind: Config -preferences: {} -users: -- name: apiserver - user: - client-certificate: {{ . }}.crt - client-key: {{ . }}.key -` diff --git a/vendor/github.com/kubernetes-incubator/apiserver-builder/cmd/apiserver-boot/boot/run/run.go b/vendor/github.com/kubernetes-incubator/apiserver-builder/cmd/apiserver-boot/boot/run/run.go deleted file mode 100644 index e5b7aee219..0000000000 --- a/vendor/github.com/kubernetes-incubator/apiserver-builder/cmd/apiserver-boot/boot/run/run.go +++ /dev/null @@ -1,52 +0,0 @@ -/* -Copyright 2017 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package run - -import ( - "github.com/spf13/cobra" -) - -var runCmd = &cobra.Command{ - Use: "run", - Short: "Command group for launching instances.", - Long: `Command group for launching instances.`, - Example: `# Run a local etcd, apiserver and controller-manager. -apiserver-boot run local - -# Check the api versions of the locally running server -kubectl --kubeconfig kubeconfig api-versions - -# Run a etcd, apiserver and controller-manager remotely in a Kubernetes cluster as an aggregated apiserver -apiserver-boot run in-cluster - -# Clear the discovery service cache -rm -rf ~/.kube/cache/discovery/ - -# Check the api versions of the remotely running server -kubectl api-versions`, - Run: RunRun, -} - -func AddRun(cmd *cobra.Command) { - cmd.AddCommand(runCmd) - AddInCluster(runCmd) - AddLocal(runCmd) -} - -func RunRun(cmd *cobra.Command, args []string) { - cmd.Help() -} diff --git a/vendor/github.com/kubernetes-incubator/apiserver-builder/cmd/apiserver-boot/boot/util/util.go b/vendor/github.com/kubernetes-incubator/apiserver-builder/cmd/apiserver-boot/boot/util/util.go deleted file mode 100644 index cc1093a129..0000000000 --- a/vendor/github.com/kubernetes-incubator/apiserver-builder/cmd/apiserver-boot/boot/util/util.go +++ /dev/null @@ -1,135 +0,0 @@ -/* -Copyright 2017 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package util - -import ( - "fmt" - "io/ioutil" - "log" - "os" - "os/exec" - "path/filepath" - "regexp" - "strings" - "text/template" - - "github.com/markbates/inflect" -) - -var Domain string -var Repo string -var GoSrc string - -// writeIfNotFound returns true if the file was created and false if it already exists -func WriteIfNotFound(path, templateName, templateValue string, data interface{}) bool { - // Make sure the directory exists - exec.Command("mkdir", "-p", filepath.Dir(path)).CombinedOutput() - - // Don't create the doc.go if it exists - if _, err := os.Stat(path); err == nil { - return false - } else if !os.IsNotExist(err) { - log.Fatalf("Could not stat %s: %v", path, err) - - } - create(path) - - t := template.Must(template.New(templateName).Funcs( - template.FuncMap{ - "title": strings.Title, - "lower": strings.ToLower, - "plural": inflect.NewDefaultRuleset().Pluralize, - }, - ).Parse(templateValue)) - - f, err := os.OpenFile(path, os.O_WRONLY, 0) - if err != nil { - log.Fatalf("Failed to create %s: %v", path, err) - } - defer f.Close() - - err = t.Execute(f, data) - if err != nil { - log.Fatalf("Failed to create %s: %v", path, err) - } - - return true -} - -func GetCopyright(file string) string { - if len(file) == 0 { - // default to boilerplate.go.txt - if _, err := os.Stat("boilerplate.go.txt"); err == nil { - // Set this because it is passed to generators - file = "boilerplate.go.txt" - cr, err := ioutil.ReadFile(file) - if err != nil { - log.Fatalf("could not read Copyright file %s", file) - } - return string(cr) - } - - log.Fatalf("apiserver-boot create-resource requires the --copyright flag if boilerplate.go.txt does not exist") - } - - if _, err := os.Stat(file); err != nil { - if !os.IsNotExist(err) { - log.Fatalf("Could not stat %s: %v", file, err) - } - return "" - } else { - cr, err := ioutil.ReadFile(file) - if err != nil { - log.Fatalf("could not read Copyright file %s", file) - } - return string(cr) - } -} - -func GetDomain() string { - b, err := ioutil.ReadFile(filepath.Join("pkg", "apis", "doc.go")) - if err != nil { - log.Fatalf("Could not find pkg/apis/doc.go. First run `apiserver-boot init --domain `.") - } - r := regexp.MustCompile("\\+domain=(.*)") - l := r.FindSubmatch(b) - if len(l) < 2 { - log.Fatalf("pkg/apis/doc.go does not contain the domain (// +domain=.*)", l) - } - Domain = string(l[1]) - return Domain -} - -func create(path string) { - f, err := os.Create(path) - if err != nil { - fmt.Println(err) - return - } - defer f.Close() -} - -func DoCmd(cmd string, args ...string) { - c := exec.Command(cmd, args...) - c.Stderr = os.Stderr - c.Stdout = os.Stdout - log.Printf("%s\n", strings.Join(c.Args, " ")) - err := c.Run() - if err != nil { - log.Fatalf("command failed %v", err) - } -} diff --git a/vendor/github.com/kubernetes-incubator/apiserver-builder/cmd/apiserver-boot/main.go b/vendor/github.com/kubernetes-incubator/apiserver-builder/cmd/apiserver-boot/main.go deleted file mode 100644 index 8e45771fa2..0000000000 --- a/vendor/github.com/kubernetes-incubator/apiserver-builder/cmd/apiserver-boot/main.go +++ /dev/null @@ -1,96 +0,0 @@ -/* -Copyright 2017 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package main - -import ( - "log" - "os" - "path/filepath" - "strings" - - "github.com/spf13/cobra" - - "github.com/kubernetes-incubator/apiserver-builder/cmd/apiserver-boot/boot/build" - "github.com/kubernetes-incubator/apiserver-builder/cmd/apiserver-boot/boot/create" - "github.com/kubernetes-incubator/apiserver-builder/cmd/apiserver-boot/boot/init_repo" - "github.com/kubernetes-incubator/apiserver-builder/cmd/apiserver-boot/boot/run" - "github.com/kubernetes-incubator/apiserver-builder/cmd/apiserver-boot/boot/util" -) - -func main() { - gopath := os.Getenv("GOPATH") - if len(gopath) == 0 { - log.Fatal("GOPATH not defined") - } - util.GoSrc = filepath.Join(gopath, "src") - - wd, err := os.Getwd() - if err != nil { - log.Fatal(err) - } - - if !strings.HasPrefix(filepath.Dir(wd), util.GoSrc) { - log.Fatalf("apiserver-boot must be run from the directory containing the go package to "+ - "bootstrap. This must be under $GOPATH/src/. "+ - "\nCurrent GOPATH=%s. \nCurrent directory=%s", gopath, wd) - } - util.Repo = strings.Replace(wd, util.GoSrc+string(filepath.Separator), "", 1) - - init_repo.AddInit(cmd) - create.AddCreate(cmd) - build.AddBuild(cmd) - run.AddRun(cmd) - - if err := cmd.Execute(); err != nil { - log.Fatal(err) - } -} - -var cmd = &cobra.Command{ - Use: "apiserver-boot", - Short: "apiserver-boot development kit for building Kubernetes extensions in go.", - Long: `apiserver-boot development kit for building Kubernetes extensions in go.`, - Example: `# Initialize your repository with scaffolding directories and go files. -apiserver-boot init repo --domain example.com - -# Create new resource "Bee" in the "insect" group with version "v1beta" -apiserver-boot create group version kind --group insect --version v1beta --kind Bee - -# Build the generated code, apiserver and controller-manager so they be run locally. -apiserver-boot build executables - -# Run the tests that were created for your resources -# Requires generated code was already built by "build executables" or "build generated" -go test ./pkg/... - -# Run locally by starting a local etcd, apiserver and controller-manager -# Produces a kubeconfig to talk to the local server -apiserver-boot run local - -# Check the api versions of the locally running server -kubectl --kubeconfig kubeconfig api-versions - -# Build an image and run in a cluster in the default namespace -# Note: after running this you should clear the discovery service -# cache before running kubectl with "rm -rf ~/.kube/cache/discovery/" -apiserver-boot run in-cluster --name creatures --namespace default --image repo/name:tag`, - Run: RunMain, -} - -func RunMain(cmd *cobra.Command, args []string) { - cmd.Help() -} diff --git a/vendor/github.com/kubernetes-incubator/apiserver-builder/cmd/apiserver-builder-release/main.go b/vendor/github.com/kubernetes-incubator/apiserver-builder/cmd/apiserver-builder-release/main.go deleted file mode 100644 index caf7e819a6..0000000000 --- a/vendor/github.com/kubernetes-incubator/apiserver-builder/cmd/apiserver-builder-release/main.go +++ /dev/null @@ -1,434 +0,0 @@ -/* -Copyright 2017 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package main - -import ( - "archive/tar" - "compress/gzip" - "fmt" - "io/ioutil" - "log" - "os" - "os/exec" - "path/filepath" - "strings" - - "github.com/spf13/cobra" -) - -var targets = []string{} -var output string -var dovendor bool -var test bool -var version string - -var cachevendordir string - -var DefaultTargets = []string{"linux:amd64", "darwin:amd64", "windows:amd64"} - -func main() { - buildCmd.Flags().StringSliceVar(&targets, "targets", - DefaultTargets, "GOOS:GOARCH pair. maybe specified multiple times.") - buildCmd.Flags().StringVar(&cachevendordir, "vendordir", "", - "if specified, use this directory for setting up vendor instead of creating a tmp directory.") - buildCmd.Flags().StringVar(&output, "output", "apiserver-builder", - "value name of the tar file to build") - buildCmd.Flags().StringVar(&version, "version", "", "version name") - - buildCmd.Flags().BoolVar(&dovendor, "vendor", true, "if true, fetch packages to vendor") - buildCmd.Flags().BoolVar(&test, "test", true, "if true, run tests") - cmd.AddCommand(buildCmd) - - vendorCmd.Flags().StringVar(&version, "version", "", "version name") - vendorCmd.Flags().StringVar(&cachevendordir, "vendordir", "", - "if specified, use this directory for setting up vendor instead of creating a tmp directory.") - cmd.AddCommand(vendorCmd) - - if err := cmd.Execute(); err != nil { - log.Fatal(err) - } -} - -var cmd = &cobra.Command{ - Use: "apiserver-builder-release", - Short: "apiserver-builder-release builds a .tar.gz release package", - Long: `apiserver-builder-release builds a .tar.gz release package`, - Run: RunMain, -} - -func RunMain(cmd *cobra.Command, args []string) { - cmd.Help() -} - -var buildCmd = &cobra.Command{ - Use: "build", - Short: "build the binaries", - Long: `build the binaries`, - Run: RunBuild, -} - -func TmpDir() string { - dir, err := ioutil.TempDir(os.TempDir(), "apiserver-builder-release") - if err != nil { - log.Fatalf("failed to create temp directory %s %v", dir, err) - } - - dir, err = filepath.EvalSymlinks(dir) - if err != nil { - log.Fatal(err) - } - - err = os.Mkdir(filepath.Join(dir, "src"), 0700) - if err != nil { - log.Fatalf("failed to create directory %s %v", filepath.Join(dir, "src"), err) - } - - err = os.Mkdir(filepath.Join(dir, "bin"), 0700) - if err != nil { - log.Fatalf("failed to create directory %s %v", filepath.Join(dir, "bin"), err) - } - return dir -} - -func RunBuild(cmd *cobra.Command, args []string) { - if len(version) == 0 { - log.Fatal("must specify the --version flag") - } - if len(targets) == 0 { - log.Fatal("must provide at least one --targets flag when building tools") - } - - dir, err := os.Getwd() - if err != nil { - panic(err) - } - dir = filepath.Join(dir, "release", version) - vendor := filepath.Join(dir, "src") - - if _, err := os.Stat(vendor); os.IsNotExist(err) { - log.Fatalf("must first run `apiserver-builder-release vendor`. could not find %s", vendor) - } - - // Build binaries for the targeted platforms in then tar - for _, target := range targets { - // Build binaries for this os:arch - parts := strings.Split(target, ":") - if len(parts) != 2 { - log.Fatalf("--targets flags must be GOOS:GOARCH pairs [%s]", target) - } - goos := parts[0] - goarch := parts[1] - // Cleanup old binaries - os.RemoveAll(filepath.Join(dir, "bin")) - err := os.Mkdir(filepath.Join(dir, "bin"), 0700) - if err != nil { - log.Fatalf("failed to create directory %s %v", filepath.Join(dir, "bin"), err) - } - - BuildVendorTar(dir) - - for _, pkg := range VendoredBuildPackages { - Build(filepath.Join("vendor", pkg, "main.go"), - filepath.Join(dir, "bin", filepath.Base(pkg)), - goos, goarch, - ) - } - for _, pkg := range OwnedBuildPackages { - Build(filepath.Join(pkg, "main.go"), - filepath.Join(dir, "bin", filepath.Base(pkg)), - goos, goarch, - ) - } - PackageTar(goos, goarch, dir, vendor) - } -} - -func RunCmd(cmd *exec.Cmd, gopath string) { - setgopath := len(gopath) > 0 - gopath, err := filepath.Abs(gopath) - if err != nil { - log.Fatal(err) - } - gopath, err = filepath.EvalSymlinks(gopath) - if err != nil { - log.Fatal(err) - } - if setgopath { - cmd.Env = append(cmd.Env, fmt.Sprintf("GOPATH=%s", gopath)) - } - cmd.Env = append(cmd.Env, os.Environ()...) - cmd.Stderr = os.Stderr - cmd.Stdout = os.Stdout - if len(cmd.Dir) == 0 && len(gopath) > 0 { - cmd.Dir = gopath - } - fmt.Printf("%s\n", strings.Join(cmd.Args, " ")) - err = cmd.Run() - if err != nil { - log.Fatal(err) - } -} - -func Build(input, output, goos, goarch string) { - cmd := exec.Command("go", "build", "-o", output, input) - - // CGO_ENABLED=0 for statically compile binaries - cmd.Env = append(cmd.Env, "CGO_ENABLED=0") - if len(goos) > 0 { - cmd.Env = append(cmd.Env, fmt.Sprintf("GOOS=%s", goos)) - } - if len(goarch) > 0 { - cmd.Env = append(cmd.Env, fmt.Sprintf("GOARCH=%s", goarch)) - } - RunCmd(cmd, "") -} - -var VendoredBuildPackages = []string{ - "github.com/kubernetes-incubator/reference-docs/gen-apidocs", - "k8s.io/kubernetes/cmd/libs/go2idl/client-gen", - "k8s.io/kubernetes/cmd/libs/go2idl/conversion-gen", - "k8s.io/kubernetes/cmd/libs/go2idl/deepcopy-gen", - "k8s.io/kubernetes/cmd/libs/go2idl/defaulter-gen", - "k8s.io/kubernetes/cmd/libs/go2idl/informer-gen", - "k8s.io/kubernetes/cmd/libs/go2idl/lister-gen", - "k8s.io/kubernetes/cmd/libs/go2idl/openapi-gen", -} - -var OwnedBuildPackages = []string{ - "cmd/apiregister-gen", - "cmd/apiserver-boot", -} - -func BuildVendorTar(dir string) { - // create the new file - f := filepath.Join(dir, "bin", "glide.tar.gz") - fw, err := os.Create(f) - if err != nil { - log.Fatalf("failed to create vendor tar file %s %v", f, err) - } - defer fw.Close() - - // setup gzip of tar - gw := gzip.NewWriter(fw) - defer gw.Close() - - // setup tar writer - tw := tar.NewWriter(gw) - defer tw.Close() - - srcdir := filepath.Join(dir) - filepath.Walk(srcdir, TarFile{ - tw, - 0555, - filepath.Join(srcdir, "src"), - "", - }.Do) -} - -func PackageTar(goos, goarch, tooldir, vendordir string) { - // create the new file - fw, err := os.Create(fmt.Sprintf("%s-%s-%s-%s.tar.gz", output, version, goos, goarch)) - if err != nil { - log.Fatalf("failed to create output file %s %v", output, err) - } - defer fw.Close() - - // setup gzip of tar - gw := gzip.NewWriter(fw) - defer gw.Close() - - // setup tar writer - tw := tar.NewWriter(gw) - defer tw.Close() - - // Add all of the bin files - // Add all of the bin files - filepath.Walk(filepath.Join(tooldir, "bin"), TarFile{ - tw, - 0555, - tooldir, - "", - }.Do) -} - -type TarFile struct { - Writer *tar.Writer - Mode int64 - Root string - Parent string -} - -func (t TarFile) Do(path string, info os.FileInfo, err error) error { - if info.IsDir() { - return nil - } - - eval, err := filepath.EvalSymlinks(path) - if err != nil { - log.Fatal(err) - } - if eval != path { - name := strings.Replace(path, t.Root, "", -1) - if len(t.Parent) != 0 { - name = filepath.Join(t.Parent, name) - } - linkName := strings.Replace(eval, t.Root, "", -1) - if len(t.Parent) != 0 { - linkName = filepath.Join(t.Parent, linkName) - } - hdr := &tar.Header{ - Name: name, - Mode: t.Mode, - Linkname: linkName, - } - if err := t.Writer.WriteHeader(hdr); err != nil { - log.Fatalf("failed to write output for %s %v", path, err) - } - return nil - } - - return t.Write(path) -} - -func (t TarFile) Write(path string) error { - // Get the relative name of the file - name := strings.Replace(path, t.Root, "", -1) - if len(t.Parent) != 0 { - name = filepath.Join(t.Parent, name) - } - body, err := ioutil.ReadFile(path) - if err != nil { - log.Fatalf("failed to read file %s %v", path, err) - } - if len(body) == 0 { - return nil - } - - hdr := &tar.Header{ - Name: name, - Mode: t.Mode, - Size: int64(len(body)), - } - if err := t.Writer.WriteHeader(hdr); err != nil { - log.Fatalf("failed to write output for %s %v", path, err) - } - if _, err := t.Writer.Write(body); err != nil { - log.Fatalf("failed to write output for %s %v", path, err) - } - return nil -} - -var vendorCmd = &cobra.Command{ - Use: "vendor", - Short: "create vendored libraries for release", - Long: `create vendored libraries for release`, - Run: RunVendor, -} - -func RunVendor(cmd *cobra.Command, args []string) { - if len(version) == 0 { - log.Fatal("must specify the --version flag") - } - - // Create the release directory - dir, err := os.Getwd() - if err != nil { - panic(err) - } - dir = filepath.Join(dir, "release", version) - os.MkdirAll(dir, 0700) - - //Build binaries for the current platform so that we can use them - for _, pkg := range VendoredBuildPackages { - Build(filepath.Join("vendor", pkg, "main.go"), - filepath.Join(dir, "bin", filepath.Base(pkg)), - "", "", - ) - } - for _, pkg := range OwnedBuildPackages { - Build(filepath.Join(pkg, "main.go"), - filepath.Join(dir, "bin", filepath.Base(pkg)), - "", "", - ) - } - BuildVendor(dir) -} - -func BuildVendor(tooldir string) string { - vendordir := cachevendordir - if len(vendordir) == 0 { - vendordir = TmpDir() - fmt.Printf("to rerun with cached glide use `--vendordir %s`\n", vendordir) - } - - vendordir, err := filepath.EvalSymlinks(vendordir) - if err != nil { - log.Fatal(err) - } - - pkgDir := filepath.Join(vendordir, "src", "github.com", "kubernetes-incubator", "test") - bootBin := filepath.Join(tooldir, "bin", "apiserver-boot") - err = os.MkdirAll(pkgDir, 0700) - if err != nil { - log.Fatalf("failed to create directory %s %v", pkgDir, err) - } - - ioutil.WriteFile(filepath.Join(pkgDir, "boilerplate.go.txt"), []byte(""), 0555) - - os.RemoveAll(filepath.Join(pkgDir, "pkg")) - os.RemoveAll(filepath.Join(pkgDir, "docs")) - os.RemoveAll(filepath.Join(pkgDir, "main.go")) - - cmd := exec.Command(bootBin, "init", "repo", "--domain", "k8s.io", "--install-deps=false") - cmd.Dir = pkgDir - RunCmd(cmd, vendordir) - - cmd = exec.Command(bootBin, "create", "group", "version", "resource", "--domain", "k8s.io", "--group", "misk", "--version", "v1beta1", "--kind", "Student") - cmd.Dir = pkgDir - RunCmd(cmd, vendordir) - - cmd = exec.Command(bootBin, "init", "glide", "--fetch") - cmd.Dir = pkgDir - RunCmd(cmd, vendordir) - - // Copy the vendored libraries. This will make it easier to debug if there is a test failure. - os.MkdirAll(filepath.Join(tooldir, "src"), 0700) - c := exec.Command("cp", "-R", "-H", - filepath.Join(pkgDir, "vendor"), - filepath.Join(tooldir, "src", "vendor")) - RunCmd(c, "") - c = exec.Command("cp", "-R", "-H", - filepath.Join(pkgDir, "glide.yaml"), - filepath.Join(tooldir, "src", "glide.yaml")) - RunCmd(c, "") - c = exec.Command("cp", "-R", "-H", - filepath.Join(pkgDir, "glide.lock"), - filepath.Join(tooldir, "src", "glide.lock")) - RunCmd(c, "") - - if test { - cmd = exec.Command(bootBin, "build", "executables") - cmd.Dir = pkgDir - RunCmd(cmd, vendordir) - - cmd = exec.Command("go", "test", "./"+filepath.Join("pkg", "...")) - cmd.Dir = pkgDir - RunCmd(cmd, vendordir) - } - - return pkgDir -} diff --git a/vendor/github.com/kubernetes-incubator/apiserver-builder/docs/adding_custom_rest.md b/vendor/github.com/kubernetes-incubator/apiserver-builder/docs/adding_custom_rest.md deleted file mode 100644 index a44ae1d722..0000000000 --- a/vendor/github.com/kubernetes-incubator/apiserver-builder/docs/adding_custom_rest.md +++ /dev/null @@ -1,30 +0,0 @@ -# Adding resources - -**Important:** Read [this doc](https://github.com/kubernetes-incubator/apiserver-builder/blob/master/docs/adding_resources.md) -first to understand how resources are added - -## Create a resource with custom rest - -You can implement your own REST implementation instead of using the -standard storage by providing the `rest=KindREST` parameter -and providing a `newKindREST() rest.Storage {}` function to return the -storage. - -For more information on custom REST implementations, see the -[subresources doc](https://github.com/kubernetes-incubator/apiserver-builder/blob/master/docs/adding_subresources.md) - -```go -// +genclient=true - -// +resource:path=foos,rest=FooREST -// +k8s:openapi-gen=true -// Foo defines some thing -type Foo struct { - // Your resource definition here -} - -// Custom REST storage -func NewFooREST() rest.Storage { - // Your rest.Storage implementation here -} -``` \ No newline at end of file diff --git a/vendor/github.com/kubernetes-incubator/apiserver-builder/docs/adding_defaulting.md b/vendor/github.com/kubernetes-incubator/apiserver-builder/docs/adding_defaulting.md deleted file mode 100644 index 8a5a9c646c..0000000000 --- a/vendor/github.com/kubernetes-incubator/apiserver-builder/docs/adding_defaulting.md +++ /dev/null @@ -1,44 +0,0 @@ -# Adding a value defaulting to a resources schema - -To add server side field value defaulting for your resource override -the function `func (.SchemeFns) DefaultingFunction(o interface{})` -in the group package. - -**Important:** The validation logic lives in the version package *not* the group package. - -Example: - -File: `pkg/apis///types_bar.go` - -```go -func (BarSchemeFns) DefaultingFunction(o interface{}) { - obj := o.(*Bar) - if obj.Spec.Field == nil { - f := "value" - obj.Spec.Field = &f - } -} -``` - -## Anatomy of defaulting - -A default `.SchemeFns` is generated for each resource with an embedded -empty defaulting function. To specify custom defaulting logic, -override the embedded implementation. - -Cast the object type to your resource Kind - -```go -bar := obj.(*Bar) -``` - ---- - -Update set values for fields with nil values. - -```go - if obj.Spec.Field == nil { - f := "value" - obj.Spec.Field = &f - } -``` \ No newline at end of file diff --git a/vendor/github.com/kubernetes-incubator/apiserver-builder/docs/adding_resources.md b/vendor/github.com/kubernetes-incubator/apiserver-builder/docs/adding_resources.md deleted file mode 100644 index ba4c8445d6..0000000000 --- a/vendor/github.com/kubernetes-incubator/apiserver-builder/docs/adding_resources.md +++ /dev/null @@ -1,236 +0,0 @@ -# Adding resources - -Resources live under `pkg/apis///_types.go`. -It is recommended to use `apiserver-boot` to create new groups, -versions, and resources. - -## Creating a resource with apiserver-boot - -Provide your domain + the api group and version + the resource Kind. -The resource name will be the pluralized lowercased kind. - -`apiserver-boot create group --domain --group --version --kind ` - -## Anatomy of a resource - -A resource has a go struct which defines the *Kind* schema, and is -annotated with comment directives used by the code generator to -wire the storage and REST endpoints. - -Example: - -```go -// +genclient=true - -// +resource:path=foos -// +k8s:openapi-gen=true -// Foo defines some thing -type Foo struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata,omitempty"` - - // spec defines the desired state of Foo - Spec FooSpec `json:"spec,omitempty"` - - // status records the observed state of Foo - Status FooStatus `json:"status,omitempty"` -} - -// FooSpec defines the desired state of Foo -type FooSpec struct { - // some_spec_field defines some desired state about Foo - SomeSpecField int `json:"some_spec_field,omitempty"` -} - -// FooStatus records the observed state of Foo -type FooStatus struct { - // some_status_field records some observed state about Foo - SomeStatusField int `json:"some_status_field,omitempty"` -} -``` - -### Breakdown of example - -```go -// +resource:path=foos -``` - -This tells the code generator to generate the REST -storage endpoints for this resource. - -```go -// +k8s:openapi-gen=true -``` - -This tells the code generator to include this -resource in the openapi spec published by the apiserver - -```go -// Foo defines some thing -``` - -This will appear in the openapi spec and the -generated reference docs as the description of the resource. - -```go -type Foo struct {...} -``` - -This block defines the resource schema - -```go -metav1.TypeMeta `json:",inline"` -metav1.ObjectMeta `json:"metadata,omitempty"` -``` - -These define metadata common to most resources - such as -the name, group/version/kind, annotations, and labels. - -```go -// spec defines the desired state of Foo -Spec FooSpec `json:"spec,omitempty"` -``` - -This field defines the desired state of Foo that the controller loops -will work towards. - -```go -// status records the observed state of Foo -Status FooStatus `json:"status,omitempty"` -``` - -This field records the state of Foo observed by the controller loops -for clients to read. - -```go -// FooSpec defines the desired state of Foo -type FooSpec struct { - // some_spec_field defines some desired state about Foo - SomeSpecField int `json:"some_spec_field,omitempty"` -} - -// FooStatus records the observed state of Foo -type FooStatus struct { - // some_status_field records some observed state about Foo - SomeStatusField int `json:"some_status_field,omitempty"` -} -``` - -These structures define the schema for the desired and observed -state. - -## Controller - -By default, a controller for your resource will also be created under -`pkg/controller//controller.go`. This will listen for creates -or updates to your resource and execute code in response. You can modify -the code to also listen for changes to other resource types that your -kind manages. - -```go -// +controller:group=bar,version=v1beta1,kind=Foo,resource=foos -type FooControllerImpl struct { - // informer listens for events about Foos - informer cache.SharedIndexInformer - - // lister indexes properties about Foos - ulister listers.FooLister -} - -// Init initializes the controller and is called by the generated code -// config - client configuration for talking to the apiserver -// si - informer factory shared across all controllers for listening to events and indexing resource properties -// queue - message queue for handling new events. unique to this controller. -func (c *FooControllerImpl) Init( - config *rest.Config, - si *sharedinformers.SharedInformers, - queue workqueue.RateLimitingInterface) { - - // Get the informer and lister for subscribing to foo events and querying foos from - // the lister cache - i := si.Factory.Bar().V1beta1().Foo() - c.informer = i.Informer() - c.lister = i.Lister() - - // Add an event handler to enqueue a message for foo adds / updates - c.informer.AddEventHandler(&controller.QueueingEventHandler{queue}) -} - -// Reconcile handles enqueued messages -func (c *UniversityControllerImpl) Reconcile(u *v1beta1.Foo) error { - // Put your event handling code here - fmt.Printf("Running reconcile Foo for %s\n", u.Name) - return nil -} - -func (c *FooControllerImpl) Get(namespace, name string) (*v1beta1.Foo, error) { - return c.lister.Foos(namespace).Get(name) -} -``` - -### Breakdown of example - -```go -// +controller:group=bar,version=v1beta1,kind=Foo,resource=foos -type FooControllerImpl struct { - // informer listens for events about Foos - informer cache.SharedIndexInformer - - // lister indexes properties about Foos - ulister listers.FooLister -} -``` - -This declares a new controller that responds to events on Foo resources - -```go -// Init initializes the controller and is called by the generated code -// config - client configuration for talking to the apiserver -// si - informer factory shared across all controllers for listening to events and indexing resource properties -// queue - message queue for handling new events. unique to this controller. -func (c *FooControllerImpl) Init( - config *rest.Config, - si *sharedinformers.SharedInformers, - queue workqueue.RateLimitingInterface) { - - // Get the informer and lister for subscribing to foo events and querying foos from - // the lister cache - i := si.Factory.Bar().V1beta1().Foo() - c.informer = i.Informer() - c.lister = i.Lister() - - // Add an event handler to enqueue a message for foo adds / updates - c.informer.AddEventHandler(&controller.QueueingEventHandler{queue}) -} -``` - -This registers a new EventHandler for Add and Update events to Foo resources -and queues messages in response. - -```go -// Reconcile handles enqueued messages -func (c *UniversityControllerImpl) Reconcile(u *v1beta1.Foo) error { - // Put your event handling code here - fmt.Printf("Running reconcile Foo for %s\n", u.Name) - return nil -} -``` - -This function is called when messages are dequeued. It should read the -actual state and reconcile it with the desired state. - -```go -func (c *FooControllerImpl) Get(namespace, name string) (*v1beta1.Foo, error) { - return c.lister.Foos(namespace).Get(name) -} -``` - -This function looks up a Foo object for a namespace + name. It is executed -just before the Reconcile method to lookup the Foo object. - -## Generating the wiring - -To generate the REST endpoint and storage wiring for your resource, -run `apiserver-boot generate` from the go package root directory. - -This will also generate go client code to read and write your resources under `pkg/client`. \ No newline at end of file diff --git a/vendor/github.com/kubernetes-incubator/apiserver-builder/docs/adding_subresources.md b/vendor/github.com/kubernetes-incubator/apiserver-builder/docs/adding_subresources.md deleted file mode 100644 index e78da91115..0000000000 --- a/vendor/github.com/kubernetes-incubator/apiserver-builder/docs/adding_subresources.md +++ /dev/null @@ -1,190 +0,0 @@ -# Adding a subresource to a resource - -## Create a resource - -Create a resource under `pkg/apis///_types.go` - -```go -// +resource:path=bars -// +subresource:request=Scale,path=scale,rest=ScaleBarREST -// +k8s:openapi-gen=true -type Bar struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata,omitempty"` - - Spec BarSpec `json:"spec,omitempty"` - Status BarStatus `json:"status,omitempty"` -} - -``` - -The following line tells the code generator to generate a subresource for this resource. - -- under the path `bar/scale` -- with request Kind `Scale` -- implemented by the go type `ScaleBarREST` - -Scale and ScaleBarREST live in the versioned package (same as the versioned resource definition) - -```go -// +subresource:request=Scale,path=scale,rest=ScaleBarREST -``` - - - -## Create the subresource request - -Define the request type in the same _types.go file - -```go -// +genclient=true - -// +subresource-request -type Scale struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata,omitempty"` - - Faculty int `json:"faculty,omitempty"` -} - -``` - -Note the line: - -```go -// +subresource-request -``` - -This tells the code generator that this is a subresource type and to -register it in the wiring. - -## Create the REST implementation - -Create the rest implementation in the *versioned* package. - -Example: - -```go -type ScaleBarREST struct { - Registry BarRegistry -} - -// Scale Subresource -var _ rest.CreaterUpdater = &ScaleBarREST{} -var _ rest.Patcher = &ScaleBarREST{} - -func (r *ScaleBarREST) Create(ctx request.Context, obj runtime.Object) (runtime.Object, error) { - scale := obj.(*Scale) - b, err := r.Registry.GetBar(ctx, scale.Name, &metav1.GetOptions{}) - if err != nil { - return nil, err - } - // Do something with b... - - // Save the udpated b - r.Registry.UpdateBar(ctx, b) - return u, nil -} - -// Get retrieves the object from the storage. It is required to support Patch. -func (r *ScaleBarREST) Get(ctx request.Context, name string, options *metav1.GetOptions) (runtime.Object, error) { - return nil, nil -} - -// Update alters the status subset of an object. -func (r *ScaleBarREST) Update(ctx request.Context, name string, objInfo rest.UpdatedObjectInfo) (runtime.Object, bool, error) { - return nil, false, nil -} - -func (r *ScaleBarREST) New() runtime.Object { - return &Scale{} -} - -``` - - -### Anatomy of a REST implementation - -Define the struct type implementing the REST api. The Registry -field is required, and provides a type safe library to read / write -instances of Bar from the storage. - - -```go -type ScaleBarREST struct { - Registry BarRegistry -} -``` - - ---- - -Enforce local compile time checks that the struct implements -the needed REST methods - -```go -// Scale Subresource -var _ rest.CreaterUpdater = &ScaleBarREST{} -var _ rest.Patcher = &ScaleBarREST{} -``` - - ---- - -Implement create and update methods using the Registry to update the parent resource. - -```go -func (r *ScaleBarREST) Create(ctx request.Context, obj runtime.Object) (runtime.Object, error) { - ... -} - -// Update alters the status subset of an object. -func (r *ScaleBarREST) Update(ctx request.Context, name string, objInfo rest.UpdatedObjectInfo) (runtime.Object, bool, error) { - ... -} -``` - ---- - -Implement a read method using the Registry to read the parent resource. - - -```go -// Get retrieves the object from the storage. It is required to support Patch. -func (r *ScaleBarREST) Get(ctx request.Context, name string, options *metav1.GetOptions) (runtime.Object, error) { - ... -} -``` - ---- - -Implement a method that creates new instance of the request. - -```go -func (r *ScaleBarREST) New() runtime.Object { - return &Scale{} -} -``` - - -## Generate the code for your subresource - -Run the code generation command to generate the wiring for your subresource. - -`apiserver-boot generate` - -## Invoke your subresource from a test - -Use the RESTClient to call your subresource. Client go is not generated -for subresources, so you will need to manually invoke the subresource. - -``` -client.RESTClient() - err := restClient.Post().Namespace("default"). - Name("name"). - Resource("bars"). - SubResource("scale"). - Body(scale).Do().Error() - ... -``` - diff --git a/vendor/github.com/kubernetes-incubator/apiserver-builder/docs/adding_validation.md b/vendor/github.com/kubernetes-incubator/apiserver-builder/docs/adding_validation.md deleted file mode 100644 index d5de733bcd..0000000000 --- a/vendor/github.com/kubernetes-incubator/apiserver-builder/docs/adding_validation.md +++ /dev/null @@ -1,51 +0,0 @@ -# Adding a validation to a resources schema - -**Note:** By default, when creating a resource with `apiserver-boot create-resource` a validation -function will be created in the versioned `_types.go` file. - -To add server side validation for your resource override the `Validate` function -on the `Strategy` struct in the version package. - -Example: - -File: `pkg/apis///bar_types.go` - -```go -// Resource Validation -func (BarStrategy) Validate(ctx request.Context, obj runtime.Object) field.ErrorList { - bar := obj.(*Bar) - errors := field.ErrorList{} - if ... { - errors = append(errors, field.Invalid( - field.NewPath("spec", "Field"), - *bar.Spec.Field, - "Error message")) - } - return errors -} -``` - -## Anatomy of validation - -A default `Strategy` is generated for each resource with an embedded -default Validation function. To specify custom validation logic, -override the embedded implementation. - -Cast the object type to your resource Kind - -```go -bar := obj.(*Bar) -``` - ---- - -Use the field.Invalid function to specify errors scoped to fields in the object. - -```go -field.Invalid(field.NewPath("spec", "Field"), *bar.Spec.Field, "Error message") -``` - -**Note:** To specify a different struct type for validation, specify `stragegy` in the resource -comment. e.g. `// +resource:path=,strategy=Strategy`. This struct type must -have a single field of type `builders.DefaultStorageStrategy` for the generated code to correctly -create an pass it into the wiring. diff --git a/vendor/github.com/kubernetes-incubator/apiserver-builder/docs/concepts/README.md b/vendor/github.com/kubernetes-incubator/apiserver-builder/docs/concepts/README.md deleted file mode 100644 index 6f0d19b35b..0000000000 --- a/vendor/github.com/kubernetes-incubator/apiserver-builder/docs/concepts/README.md +++ /dev/null @@ -1,9 +0,0 @@ -API Server Concepts -=================== - -In this directory, you will find documentation on how addon API servers -function, and how they interact with the main Kubernetes API server. - -Currently, the following topics are available: - -- [Authentication, Authorization, and Certificates](./auth.md) diff --git a/vendor/github.com/kubernetes-incubator/apiserver-builder/docs/concepts/auth.md b/vendor/github.com/kubernetes-incubator/apiserver-builder/docs/concepts/auth.md deleted file mode 100644 index a3b88d20e1..0000000000 --- a/vendor/github.com/kubernetes-incubator/apiserver-builder/docs/concepts/auth.md +++ /dev/null @@ -1,252 +0,0 @@ -# Serving Certificates, Authentication, and Authorization - -The apiserver-builder creates API servers that are set up to use a variety -of authentication and authorization options designed for use with an -existing Kubernetes cluster. Together, these options form the *delegated -authentication and authorization* pattern. - -In this document, we'll refer to API servers generated using -apiserver-builder as *addon API servers*. - -## Certificates Overview - -Several of the authentication methods that make up delegated -authentication make use of client and CA certificates. - -CA (Certificate Authority) certificates are used to delegate trust. -Whenever something trusts the CA, it can trust any certificates *signed* -by the CA private key by verifying the signature using the CA public -certificate. - -If a certificate is not signed by a separate CA, it is instead -*self-signed*. A self-signed certificate must either be trusted directly -(instead of being trusted indirectly by trusting a CA), or not trusted at -all. Generally, our client CA certificates will be self-signed, since -they represent the "root" of our trust relationship: clients must -inherently trust the CA. - -For the API servers created by apiserver-builder, there are three -*different* important CAs (and these really should be different): - -1. a serving CA: this CA signs "serving" certificates, which are used to - encrypt communication over HTTPS. The same CA used to sign the main - Kubernetes API server serving certificate pair may also be used to sign - the addon API server serving certificates, but a different CA - may also be used. - - By default, addon API servers automatically generate self-signed - certificates if no serving certificates are passed in, making this CA - optional. However, in a real setup, you'll need this CA so that clients - can easily trust the identity of the addon API server. - -2. a client CA: this CA signs client certificates, and is used by the - addon API server to authenticate users based on the client certificates - they submit. The same client CA may be used for both the main - Kubernetes API server as well as addon API servers, but a different CA - may also be used. Using the same CA ensures that identity trust works - the same way between the main Kubernetes API server and the addon API - servers. - - As an example, the default cluster admin user generated in many - Kubernetes setups uses client certificate authentication. Additionally, - controllers or non-human clients running outside the cluster often use - certificate-based authentication. - -3. a RequestHeader client CA: this special CA signs proxy client - certificates. Clients presenting these certificates are effectively - trusted to masquerade as any other identity. When running behind the - API aggregator, this *must* be the same CA used to sign the - aggregator's proxy client certificate. When not running with an - aggregator (e.g. pre-Kubernetes-1.7, without a separate aggregator - pod), this simply needs to exist. - -### Generating certificates - -The Kubernetes documentation has a [detailed -section](https://kubernetes.io/docs/admin/authentication/#creating-certificates) -on how to create certificates several different ways. For convenience, -we'll reproduce the basics using the `openssl` and `cfssl` commands below -(you can install `cfssl` using `go get -u -github.com/cloudflare/cfssl/cmd/...`). - -In the common case, all three CA certificates referenced above already -exist as part of the main Kubernetes cluster setup. - -In case you need to generate any of the CA certificate pairs mentioned -above yourself, you can do so using the following command (see below for -appropriate values of `$PURPOSE`): - -```shell -export PURPOSE= -openssl req -x509 -sha256 -new -nodes -days 365 -newkey rsa:2048 -keyout ${PURPOSE}-ca.key -out ${PURPOSE}-ca.crt -subj "/CN=ca" -echo '{"signing":{"default":{"expiry":"43800h","usages":["signing","key encipherment","'${PURPOSE}'"]}}}' > "${PURPOSE}-ca-config.json" -``` - -This generates a certificate and private key for the CA, as well as -a signing configuration used by `cfssl` below. `$PURPOSE` should be set to -one of `serving`/`server`, `client`, or `requestheader-client`, as -detailed above in the [certificates overview](#certificates-overview). - -These CA certificates are self-signed; no "higher-level" CAs are signing -these CA certificates, so they represent the "roots" of your trust -relationship. - -To generate a serving certificate keypair (see the [serving -certificates](#serving-certificates) section for more details), you can -use the following commands: - -```shell -export SERVICE_NAME= -export ALT_NAMES='".","..svc"' -echo '{"CN":"'${SERVICE_NAME}'","hosts":['${ALT_NAMES}'],"key":{"algo":"rsa","size":2048}}' | cfssl gencert -ca=server-ca.crt -ca-key=server-ca.key -config=server-ca-config.json - | cfssljson -bare apiserver -``` - -`` should be the name of the Service for the addon API server, -and `` is the name of the namespace in which the server will -run. - -This will create a pair of files named `apiserver-key.pem` and -`apiserver.pem`. These are the private key and public certificate, -respectively. The private key and certificate are commonly referred to -with `.key ` and `.crt` extensions, respectively: `apiserver.key` and -`apiserver.crt`. - -### Serving Certificates - -In order to securely serve your APIs over HTTPS, you'll need serving -certificates. By default, a set of self-signed certificates are generated -by addon API servers. However, clients have no way to trust these (since -they are self-signed, there is no separate CA), so in production -deployments, or deployments running behind an API server aggregator, you -should use manually generated CA certificates. - -By default, addon API servers server looks for these certificates in the -`/var/run/kubernetes` directory, although this may be overridden using the -`--cert-dir` option. The files must be named `apiserver.crt` and -`apiserver.key`. - -## Authentication - -There are three components to the delegated authentication setup, -described below: - -- [Client Certificate Authentication](#client-certificate-authentication) -- [Delegated Token Authentication](#delegated-token-authentication) -- [RequestHeader Authentication](#requestheader-authentication) - -### Client Certificate Authentication - -Client certificate authentication authenticates clients who connect using -certificates signed by a given CA (as specified by the [*client CA -certificate*](#certificates-overview)). This same mechanism is also often -used by the main Kubernetes API server. - -Generally, the default admin user in a cluster connects with client -certificate authentication. Additionally, off-cluster non-human clients -often use client certificate authentication. - -By default, a main Kubernetes API server configured with the -`--client-ca-file` option automatically creates a ConfigMap called -`extension-apiserver-authentication` in the `kube-system` namespace, -populated with the client CA file. Addon API servers use this CA -certificate as the CA used to verify client authentication. This way, -client certificate users who can authenticate with the main Kubernetes -system can also authenticate with addon API servers. - -See the [delegated token authentication](#delegated-token-authentication) -section for more information about how addon API servers contact the main -Kubernetes API server to access this ConfigMap. - -If you wish to use a different client CA certificate to verify client -certificate authentication, you can manually pass the `--client-ca-file` -option to your addon API server. - -See the [x509 client -certificates](https://kubernetes.io/docs/admin/authentication/#x509-client-certs) -section of the Kubernetes documentation for more information. - -### Delegated Token Authentication - -Delegated token authentication authenticates clients who pass in a token -using the `Authorization: Bearer $TOKEN` HTTP header. This is the common -authentication method used by most human Kubernetes clients, as well as -in-cluster non-human clients. - -In this case, addon API servers extract the token from the HTTP request, -and verify it against another API server. In common cases, this is the -main Kubernetes API server. This allows users who are can authentication -with the main Kubernetes system to also authenticate with addon API -servers. - -By default, the addon API servers search for the connection information -and credentials that are automatically injected into every pod running on -a Kubernetes cluster in order to connect to the main Kubernetes API -server. - -If you do not wish to have your addon API server authenticate against the -same cluster that it is running on, or if it is running outside of -a cluster, you can pass the `--authentication-kubeconfig` option to the -service catalog API server to specify a different Kubeconfig file to use to -connect. - -The [Webhook token -authentication](https://kubernetes.io/docs/admin/authentication/#webhook-token-authentication) -method described in the Kubernetes authentication documentation works -similarly in principal to delegated token authentication, except that we -use an existing Kubernetes cluster instead of an external webhook. - -### RequestHeader Authentication - -RequestHeader authentication authenticates connections from API server -proxies, which themselves have already authenticated the client. It works -similarly to [client certificate -authentication](#client-certificate-authentication): it validates the -certificate of the proxy using a CA certificate. However, it then allows -the proxy to masquerade as any other user, by reading a series of headers -set by the proxy. This allows addon API servers to run behind the API -server aggregator. - -By default, addon API servers attempt to pull the requestheader client CA -certificate and appropriate header names from the -`extension-apiserver-authentication` ConfigMap mentioned above in -[client-certificate-authentication](#client-certificate-authentication). -The main Kubernetes API server populates this if it was configured with -the `--requestheader-client-ca-file` option (and optionally associated -`--requestheader-` options). - -However, some API servers are not configured with the -`--requestheader-client-ca-file` option. In these cases, you must pass -the `--requestheader-client-ca-file` option directly to the addon API -server. Any API server proxies (such as the API server aggregator) need to -have client certificates signed by this CA certificate in order to -properly pass their authentication information through to addon API -servers. - -Alternatively, you can pass the `--authentication-skip-lookup` flag to -addon API servers. However, this will *also* disable client certificate -authentication unless you manually pass the corresponding -`--client-ca-file` flag. - -In addition to the CA certificate, you can also configure a number of -additional options. See the [authenticating -proxy](https://kubernetes.io/docs/admin/authentication/#authenticating-proxy) -section of the Kubernetes documentation for more information. - -### Authorization - -Addon API servers use delegated authorization. This means that they query -for authorization against the main Kubernetes API server, allowing cluster -admins to store policy for addon API servers in the same place as the -policy used for the main Kubernetes API server, and in the same format -(e.g. Kubernetes RBAC). - -By default, the addon API servers search for the connection information -and credentials that are automatically injected into every pod running on -a Kubernetes cluster in order to connect to the main Kubernetes API -server. - -If you do not wish to have your addon API server authenticate against the -same cluster that it is running on, or if it is running outside of -a cluster, you can pass the `--authorization-kubeconfig` option to the -service catalog API server to specify a different Kubeconfig file to use to -connect. diff --git a/vendor/github.com/kubernetes-incubator/apiserver-builder/docs/creating_an_api_server.md b/vendor/github.com/kubernetes-incubator/apiserver-builder/docs/creating_an_api_server.md deleted file mode 100644 index 0d11fb0605..0000000000 --- a/vendor/github.com/kubernetes-incubator/apiserver-builder/docs/creating_an_api_server.md +++ /dev/null @@ -1,92 +0,0 @@ -# Creating an API Server - -**Note:** This document explains how to manually create the files generated -by `apiserver-boot`. It is recommended to automatically create these files -instead. See [getting started](https://github.com/kubernetes-incubator/apiserver-builder/blob/master/docs/getting_started.md) -for more details. - -## Create the apiserver command - -Create a file called `main.go` at the root of your project. This -file bootstraps the apiserver by invoking the apiserver start function -with the generated API code. - -*Location:* `GOPATH/src/YOUR/GO/PACKAGE/main.go` - -```go -package main - -import ( - "github.com/kubernetes-incubator/apiserver-builder/pkg/cmd/server" - _ "k8s.io/client-go/plugin/pkg/client/auth" // Enable cloud provider auth - - "YOUR/GO/PACKAGE/pkg/apis" // Change this - "YOUR/GO/PACKAGE/pkg/openapi" // Change this -) - -const storagePath = "/registry/YOUR.DOMAIN" // Change this - -func main() { - server.StartApiServer(storagePath, apis.GetAllApiBuilders(), openapi.GetOpenAPIDefinitions) -} - -``` - -## Create the API root package - -Create your API root under `pkg/apis` - -*Location:* `GOPATH/src/YOUR/GO/PACKAGE/pkg/apis/doc.go` - -- Change `YOUR.DOMAIN` to the domain you want your API groups to appear under. - -```go -// +domain=YOUR.DOMAIN - -package apis -``` - -## Create an API group - -Create your API group under `pkg/apis/GROUP` - -*Location:* `GOPATH/src/YOUR/GO/PACKAGE/pkg/apis/GROUP/doc.go` - -- Change GROUP to be the group name. -- Change YOUR.DOMAIN to be your domain. - -```go -// +k8s:deepcopy-gen=package,register -// +groupName=GROUP.YOUR.DOMAIN - -// Package api is the internal version of the API. -package GROUP -``` - -## Create an API version - -Create your API group under `pkg/apis/GROUP/VERSION` - -*Location:* `GOPATH/src/YOUR/GO/PACKAGE/pkg/apis/GROUP/VERSION/doc.go` - -- Change GROUP to be the group name. -- Change VERSION to the be the api version name. -- Change YOUR/GO/PACKAGE to be the go package of you project. - -```go -// +k8s:openapi-gen=true -// +k8s:deepcopy-gen=package,register -// +k8s:conversion-gen=YOUR/GO/PACKAGE/pkg/apis/GROUP -// +k8s:defaulter-gen=TypeMeta - -// +groupName=GROUP.VERSION -package VERSION // import "YOUR/GO/PACKAGE/pkg/apis/GROUP/VERSION" -``` - -## Create the API type definitions - -## Generate the code - -## Create an integration test - -## Start the server locally \ No newline at end of file diff --git a/vendor/github.com/kubernetes-incubator/apiserver-builder/docs/getting_started.md b/vendor/github.com/kubernetes-incubator/apiserver-builder/docs/getting_started.md deleted file mode 100644 index ce2a08b959..0000000000 --- a/vendor/github.com/kubernetes-incubator/apiserver-builder/docs/getting_started.md +++ /dev/null @@ -1,158 +0,0 @@ -# Getting started (v0.0-alpha.12) - -This document covers building your first apiserver from scratch: - -- Bootstrapping your go dependencies -- Initialize your project directory structure and go packages -- Create an API group, version, resource -- Build the apiserver command -- Write an automated test for the API resource - -## Download the latest release - -Make sure you downloaded and installed the latest release as described -[here](https://github.com/kubernetes-incubator/apiserver-builder/blob/master/docs/installing.md) - -## Create your Go project - -Create a Go project under GOPATH/src/ - -For example - -> GOPATH/src/github.com/my-org/my-project - -## Create a copyright header - -Create a file called `boilerplate.go.txt`. This file will contain the -copyright boilerplate appearing at the top of all generated files. - -Under GOPATH/src/github.com/my-org/my-project: - -- `boilerplate.go.txt` - -e.g. - -```go -/* -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. -*/ -``` - -## Initialize your project - -This will setup the initial file structure for your apiserver, including -vendored go libraries pinned to a set of known working versions. Vendored -libraries are distributed with the apiserver-builder binary tar and copied -from the installation directory. - -Files created under GOPATH/src/github.com/my-org/my-project: - -- `pkg/apis/doc.go` -- `pkg/openapi/doc.go` -- `docs/...` -- `main.go` -- `vendor/...` -- `glide.yaml` -- `glide.lock` - - -Flags: - -- your-domain: unique namespace for your API groups - -At the root of your go package under your GOPATH run the following command: - -```sh -apiserver-boot init --domain -``` - -**Note:** You can skip vendoring by running with `--install-deps=false`, and install -the vendored deps separately with `apiserver-boot glide-install`. - -## Create an API resource - -An API resource provides REST endpoints for CRUD operations on a resource -type. This is what will be used by clients to read and store instances -of the resource kind. - -API resources are defined by a group (like a package), a version (v1alpha1, v1beta1, v1), and a Kind (the type) -Running the `apiserver-boot create-resource` command will create the api group, version and Kind for you. - -Files created under GOPATH/src/github.com/my-org/my-project: - -- `pkg/apis/your-group/doc.go` -- `pkg/apis/your-group/your-version/doc.go` -- `pkg/apis/your-group/your-version/your-kind_types.go` -- `pkg/apis/your-group/your-version/your-kind_types_test.go` - -Flags: - -- your-domain: unique namespace for your API groups. must be the same as used with `init`. -- your-group: name of the API group e.g. `batch` -- your-version: name of the API version e.g. `v1beta1` or `v1` -- your-kind: **Upper CamelCase** name of the type e.g. `MyKind` - -At the root of your go package under your GOPATH run the following command: - -```sh -apiserver-boot create-resource --domain --group --version --kind -``` - -**Note:** The resource name is the lowercase pluralization of the kind e.g. `mykinds` and -generated by default. To directly control the name of the resource, use the `--resource` flag. - -**Note:** If desired, the api group and version maybe created as separate steps with -`apiserver-boot create-group` and `apiserver-boot create-version`. - -## Generate the code and build the apiserver + controller-manager - -Build the apiserver binary - -```sh -apiserver-boot build -``` - -**Note:** This will automatically run the code generators. These maybe -run separate using `apiserver-boot generate`. It is possible to skip running -the generators as part of the build by using the flag `--generate=false`. -Note that the generators must be rerun any time new fields are added to your resources - -## Run the apiserver + controller-manager - -Run an etcd instance and the apiserver + controller-manager. - -**Note:** must have etcd on your PATH - -```sh -apiserver-boot run -``` - -Test with kubectl - -```sh -kubectl --kubeconfig kubeconfig version -``` - -## Run a test - -A placeholder test was created for your resource. The test will -start your apiserver in memory, and allow you to create, read, and write -your resource types. - -This is a good way to test validation and defaulting of your types. - -```sh -go test pkg/apis/your-group/your-version/your-kind_types_test.go -``` diff --git a/vendor/github.com/kubernetes-incubator/apiserver-builder/docs/installing.md b/vendor/github.com/kubernetes-incubator/apiserver-builder/docs/installing.md deleted file mode 100644 index 8f66ee4954..0000000000 --- a/vendor/github.com/kubernetes-incubator/apiserver-builder/docs/installing.md +++ /dev/null @@ -1,9 +0,0 @@ -# Installing the apiserver build tools - -- Download the latest [release](https://github.com/kubernetes-incubator/apiserver-builder/releases) -- Create a new directory for the binaries: - `sudo mkdir /usr/local/apiserver-builder/` -- Unpack the release `tar -xzvf ` into the directory you just created -- Add the binaries to your *PATH* - `export PATH=$PATH:/usr/local/apiserver-builder/bin` -- Test things are working by running `apiserver-boot -h` diff --git a/vendor/github.com/kubernetes-incubator/apiserver-builder/docs/using_minikube.md b/vendor/github.com/kubernetes-incubator/apiserver-builder/docs/using_minikube.md deleted file mode 100644 index 238dc2fb16..0000000000 --- a/vendor/github.com/kubernetes-incubator/apiserver-builder/docs/using_minikube.md +++ /dev/null @@ -1,16 +0,0 @@ -# Running the apiserver with delegated auth against minikube - -- start [minikube](https://github.com/kubernetes/minikube) - - `minikube start` -- copy `~/.kube/config` to `~/.kube/auth_config` - - `kubectl config use-context minikube` - - `cp ~/.kube/config ~/.kube/auth_config` -- add a `~/.kube/config` entry for your apiserver, using the minikube user - - `kubectl config set-cluster mycluster --server=https://localhost:9443 --certificate-authority=/var/run/kubernetes/apiserver.crt` // Use the cluster you created and the minikube user - - `kubectl config set-context mycluster --user=minikube --cluster=mycluster` - - `kubectl config use-context mycluster` -- make the directory `/var/run/kubernetes` if it doesn't exist - - `sudo mkdir /var/run/kubernetes` - - `sudo chown $(whoami) /var/run/kubernetes` -- run the server with ` ./main --authentication-kubeconfig ~/.kube/auth_config --authorization-kubeconfig ~/.kube/auth_config --client-ca-file /var/run/kubernetes/apiserver.crt --requestheader-client-ca-file /var/run/kubernetes/apiserver.crt --requestheader-username-headers=X-Remote-User --requestheader-group-headers=X-Remote-Group --requestheader-extra-headers-prefix=X-Remote-Extra- --etcd-servers=http://localhost:2379 --secure-port=9443 --tls-ca-file /var/run/kubernetes/apiserver.crt --print-bearer-token` - - This will have the server use minikube for delegated auth \ No newline at end of file diff --git a/vendor/github.com/kubernetes-incubator/apiserver-builder/example/.gitignore b/vendor/github.com/kubernetes-incubator/apiserver-builder/example/.gitignore deleted file mode 100644 index deca888ded..0000000000 --- a/vendor/github.com/kubernetes-incubator/apiserver-builder/example/.gitignore +++ /dev/null @@ -1,9 +0,0 @@ -bin/ -default.etcd/ -kubeconfig -apiserver.local.config/ -zz_generated* -pkg/client/*_generated -pkg/openapi/openapi_generated.go -.crt -.key diff --git a/vendor/github.com/kubernetes-incubator/apiserver-builder/example/Makefile b/vendor/github.com/kubernetes-incubator/apiserver-builder/example/Makefile deleted file mode 100644 index bfc544be1b..0000000000 --- a/vendor/github.com/kubernetes-incubator/apiserver-builder/example/Makefile +++ /dev/null @@ -1,42 +0,0 @@ -# Copyright 2017 The Kubernetes Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -.PHONY: all test build generate docs cmds clean cleangenerated cleandocs - -all: test - -test: build - go test ./pkg/... - bash -c "find pkg/apis/ -name apiserver.local.config | xargs rm -rf" - -build: cmds - bin/apiserver-boot build executables - -# Build docs -docs: cleandocs build - bin/apiserver-boot build docs --server bin/apiserver - -# Build the tools -# Note: These are available in the apiserver-builder release tar.gz -cmds: - ./build-tools.sh - -# Clean up functions -clean: cleangenerated cleandocs - -cleangenerated: cmds - bin/apiserver-boot build generated clean - -cleandocs: cmds - bin/apiserver-boot build docs clean diff --git a/vendor/github.com/kubernetes-incubator/apiserver-builder/example/boilerplate.go.txt b/vendor/github.com/kubernetes-incubator/apiserver-builder/example/boilerplate.go.txt deleted file mode 100644 index 59e740c1ee..0000000000 --- a/vendor/github.com/kubernetes-incubator/apiserver-builder/example/boilerplate.go.txt +++ /dev/null @@ -1,16 +0,0 @@ -/* -Copyright YEAR 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. -*/ - diff --git a/vendor/github.com/kubernetes-incubator/apiserver-builder/example/build-tools.sh b/vendor/github.com/kubernetes-incubator/apiserver-builder/example/build-tools.sh deleted file mode 100755 index 13895b29a1..0000000000 --- a/vendor/github.com/kubernetes-incubator/apiserver-builder/example/build-tools.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/usr/bin/env bash - -# NOTE: Do not copy this file unless you need to use apiserver-builder at HEAD. -# Otherwise, download the pre-built apiserver-builder tar release from -# https://github.com/kubernetes-incubator/apiserver-builder/releases instead. - -# Install generators from other repos -if [ ! -f bin/client-gen ] ; then - go build -o bin/client-gen ../vendor/k8s.io/kubernetes/cmd/libs/go2idl/client-gen -fi -if [ ! -f bin/bin/conversion-gen ] ; then - go build -o bin/conversion-gen ../vendor/k8s.io/kubernetes/cmd/libs/go2idl/conversion-gen -fi -if [ ! -f bin/bin/deepcopy-gen ] ; then - go build -o bin/deepcopy-gen ../vendor/k8s.io/kubernetes/cmd/libs/go2idl/deepcopy-gen -fi -if [ ! -f bin/openapi-gen ] ; then - go build -o bin/openapi-gen ../vendor/k8s.io/kubernetes/cmd/libs/go2idl/openapi-gen -fi -if [ ! -f bin/defaulter-gen ] ; then - go build -o bin/defaulter-gen ../vendor/k8s.io/kubernetes/cmd/libs/go2idl/defaulter-gen -fi -if [ ! -f bin/lister-gen ] ; then - go build -o bin/lister-gen ../vendor/k8s.io/kubernetes/cmd/libs/go2idl/lister-gen -fi -if [ ! -f bin/informer-gen ] ; then - go build -o bin/informer-gen ../vendor/k8s.io/kubernetes/cmd/libs/go2idl/informer-gen -fi -if [ ! -f bin/gen-apidocs ] ; then - go build -o bin/gen-apidocs ../vendor/github.com/kubernetes-incubator/reference-docs/gen-apidocs -fi - -# Install generators from this repo -go build -o bin/apiserver-boot ../cmd/apiserver-boot/main.go -go build -o bin/apiregister-gen ../cmd/apiregister-gen/main.go diff --git a/vendor/github.com/kubernetes-incubator/apiserver-builder/example/cmd/apiserver/main.go b/vendor/github.com/kubernetes-incubator/apiserver-builder/example/cmd/apiserver/main.go deleted file mode 100644 index e36b79708c..0000000000 --- a/vendor/github.com/kubernetes-incubator/apiserver-builder/example/cmd/apiserver/main.go +++ /dev/null @@ -1,29 +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 ( - "github.com/kubernetes-incubator/apiserver-builder/pkg/cmd/server" - _ "k8s.io/client-go/plugin/pkg/client/auth" // Enable cloud provider auth - - "github.com/kubernetes-incubator/apiserver-builder/example/pkg/apis" - "github.com/kubernetes-incubator/apiserver-builder/example/pkg/openapi" -) - -func main() { - server.StartApiServer("/registry/sample.kubernetes.io", apis.GetAllApiBuilders(), openapi.GetOpenAPIDefinitions, "Api", "v0") -} diff --git a/vendor/github.com/kubernetes-incubator/apiserver-builder/example/cmd/controller-manager/main.go b/vendor/github.com/kubernetes-incubator/apiserver-builder/example/cmd/controller-manager/main.go deleted file mode 100644 index 1f9ee5a76c..0000000000 --- a/vendor/github.com/kubernetes-incubator/apiserver-builder/example/cmd/controller-manager/main.go +++ /dev/null @@ -1,41 +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" - "log" - - examplecontroller "github.com/kubernetes-incubator/apiserver-builder/example/pkg/controller" - "github.com/kubernetes-incubator/apiserver-builder/pkg/controller" -) - -var kubeconfig = flag.String("kubeconfig", "", "path to kubeconfig") - -func main() { - flag.Parse() - config, err := controller.GetConfig(*kubeconfig) - if err != nil { - log.Fatalf("Could not create Config for talking to the apiserver: %v\n", err) - } - - controllers, _ := examplecontroller.GetAllControllers(config) - controller.StartControllerManager(controllers...) - - // Blockforever - select {} -} diff --git a/vendor/github.com/kubernetes-incubator/apiserver-builder/example/pkg/apis/doc.go b/vendor/github.com/kubernetes-incubator/apiserver-builder/example/pkg/apis/doc.go deleted file mode 100644 index 5fb642a807..0000000000 --- a/vendor/github.com/kubernetes-incubator/apiserver-builder/example/pkg/apis/doc.go +++ /dev/null @@ -1,19 +0,0 @@ -/* -Copyright 2017 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// +domain=k8s.io - -package apis diff --git a/vendor/github.com/kubernetes-incubator/apiserver-builder/example/pkg/apis/innsmouth/doc.go b/vendor/github.com/kubernetes-incubator/apiserver-builder/example/pkg/apis/innsmouth/doc.go deleted file mode 100644 index ca4a9f3bfb..0000000000 --- a/vendor/github.com/kubernetes-incubator/apiserver-builder/example/pkg/apis/innsmouth/doc.go +++ /dev/null @@ -1,21 +0,0 @@ -/* -Copyright 2017 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// +k8s:deepcopy-gen=package,register -// +groupName=innsmouth.k8s.io - -// Package api is the internal version of the API. -package innsmouth diff --git a/vendor/github.com/kubernetes-incubator/apiserver-builder/example/pkg/apis/innsmouth/install/doc.go b/vendor/github.com/kubernetes-incubator/apiserver-builder/example/pkg/apis/innsmouth/install/doc.go deleted file mode 100644 index a1fb52f7a5..0000000000 --- a/vendor/github.com/kubernetes-incubator/apiserver-builder/example/pkg/apis/innsmouth/install/doc.go +++ /dev/null @@ -1,17 +0,0 @@ -/* -Copyright 2017 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package install diff --git a/vendor/github.com/kubernetes-incubator/apiserver-builder/example/pkg/apis/innsmouth/v1/deepone_types.go b/vendor/github.com/kubernetes-incubator/apiserver-builder/example/pkg/apis/innsmouth/v1/deepone_types.go deleted file mode 100644 index b57a3f3790..0000000000 --- a/vendor/github.com/kubernetes-incubator/apiserver-builder/example/pkg/apis/innsmouth/v1/deepone_types.go +++ /dev/null @@ -1,46 +0,0 @@ -/* -Copyright 2017 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package v1 - -import ( - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -// +genclient=true - -// +k8s:openapi-gen=true -// +resource:path=deepones -// DeepOne defines a resident of innsmouth -type DeepOne struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata,omitempty"` - - Spec DeepOneSpec `json:"spec,omitempty"` - Status DeepOneStatus `json:"status,omitempty"` -} - -// DeepOnesSpec defines the desired state of DeepOne -type DeepOneSpec struct { - // fish_required defines the number of fish required by the DeepOne. - FishRequired int `json:"fish_required,omitempty"` -} - -// DeepOneStatus defines the observed state of DeepOne -type DeepOneStatus struct { - // actual_fish defines the number of fish caught by the DeepOne. - ActualFish int `json:"actual_fish,omitempty"` -} diff --git a/vendor/github.com/kubernetes-incubator/apiserver-builder/example/pkg/apis/innsmouth/v1/doc.go b/vendor/github.com/kubernetes-incubator/apiserver-builder/example/pkg/apis/innsmouth/v1/doc.go deleted file mode 100644 index be222e22f8..0000000000 --- a/vendor/github.com/kubernetes-incubator/apiserver-builder/example/pkg/apis/innsmouth/v1/doc.go +++ /dev/null @@ -1,27 +0,0 @@ -/* -Copyright 2017 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Api versions allow the api contract for a resource to be changed while keeping -// backward compatibility by support multiple concurrent versions -// of the same resource - -// +k8s:openapi-gen=true -// +k8s:deepcopy-gen=package,register -// +k8s:conversion-gen=github.com/kubernetes-incubator/apiserver-builder/example/pkg/apis/innsmouth -// +k8s:defaulter-gen=TypeMeta - -// +groupName=innsmouth.k8s.io -package v1 // import "github.com/kubernetes-incubator/apiserver-builder/example/pkg/apis/innsmouth/v1" diff --git a/vendor/github.com/kubernetes-incubator/apiserver-builder/example/pkg/apis/kingsport/doc.go b/vendor/github.com/kubernetes-incubator/apiserver-builder/example/pkg/apis/kingsport/doc.go deleted file mode 100644 index 001a8d5637..0000000000 --- a/vendor/github.com/kubernetes-incubator/apiserver-builder/example/pkg/apis/kingsport/doc.go +++ /dev/null @@ -1,26 +0,0 @@ - -/* -Copyright YEAR The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - - - - -// +k8s:deepcopy-gen=package,register -// +groupName=kingsport.k8s.io - -// Package api is the internal version of the API. -package kingsport - diff --git a/vendor/github.com/kubernetes-incubator/apiserver-builder/example/pkg/apis/kingsport/install/doc.go b/vendor/github.com/kubernetes-incubator/apiserver-builder/example/pkg/apis/kingsport/install/doc.go deleted file mode 100644 index 755b647cf3..0000000000 --- a/vendor/github.com/kubernetes-incubator/apiserver-builder/example/pkg/apis/kingsport/install/doc.go +++ /dev/null @@ -1,21 +0,0 @@ - -/* -Copyright YEAR The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - - - -package install - diff --git a/vendor/github.com/kubernetes-incubator/apiserver-builder/example/pkg/apis/kingsport/v1/doc.go b/vendor/github.com/kubernetes-incubator/apiserver-builder/example/pkg/apis/kingsport/v1/doc.go deleted file mode 100644 index dbe850e583..0000000000 --- a/vendor/github.com/kubernetes-incubator/apiserver-builder/example/pkg/apis/kingsport/v1/doc.go +++ /dev/null @@ -1,30 +0,0 @@ - -/* -Copyright YEAR 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. -*/ - - - -// Api versions allow the api contract for a resource to be changed while keeping -// backward compatibility by support multiple concurrent versions -// of the same resource - -// +k8s:openapi-gen=true -// +k8s:deepcopy-gen=package,register -// +k8s:conversion-gen=github.com/kubernetes-incubator/apiserver-builder/example/pkg/apis/kingsport -// +k8s:defaulter-gen=TypeMeta -// +groupName=kingsport.k8s.io -package v1 // import "github.com/kubernetes-incubator/apiserver-builder/example/pkg/apis/kingsport/v1" - diff --git a/vendor/github.com/kubernetes-incubator/apiserver-builder/example/pkg/apis/kingsport/v1/festival_types.go b/vendor/github.com/kubernetes-incubator/apiserver-builder/example/pkg/apis/kingsport/v1/festival_types.go deleted file mode 100644 index 1310f19380..0000000000 --- a/vendor/github.com/kubernetes-incubator/apiserver-builder/example/pkg/apis/kingsport/v1/festival_types.go +++ /dev/null @@ -1,80 +0,0 @@ - -/* -Copyright 2017 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - - - -package v1 - -import ( - "log" - - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apiserver/pkg/endpoints/request" - - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/util/validation/field" - - "github.com/kubernetes-incubator/apiserver-builder/example/pkg/apis/kingsport" -) - -// +genclient=true -// +nonNamespaced=true - -// Festival -// +k8s:openapi-gen=true -// +resource:path=festivals,strategy=FestivalStrategy -type Festival struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata,omitempty"` - - Spec FestivalSpec `json:"spec,omitempty"` - Status FestivalStatus `json:"status,omitempty"` -} - -// FestivalSpec defines the desired state of Festival -type FestivalSpec struct { - // Year when the festival was held, may be negative (BC) - Year int `json:"year,omitempty"` - // Invited holds the number of invited attendees - Invited uint `json:"invited,omitempty"` -} - -// FestivalStatus defines the observed state of Festival -type FestivalStatus struct { - // Attended holds the actual number of attendees - Attended uint `json:"attended,omitempty"` -} - -// Validate checks that an instance of Festival is well formed -func (FestivalStrategy) Validate(ctx request.Context, obj runtime.Object) field.ErrorList { - o := obj.(*kingsport.Festival) - log.Printf("Validating fields for Festival %s\n", o.Name) - errors := field.ErrorList{} - // perform validation here and add to errors using field.Invalid - return errors -} - -func (FestivalStrategy) NamespaceScoped() bool { return false } - -func (FestivalStatusStrategy) NamespaceScoped() bool { return false } - -// DefaultingFunction sets default Festival field values -func (FestivalSchemeFns) DefaultingFunction(o interface{}) { - obj := o.(*Festival) - // set default field values here - log.Printf("Defaulting fields for Festival %s\n", obj.Name) -} diff --git a/vendor/github.com/kubernetes-incubator/apiserver-builder/example/pkg/apis/miskatonic/doc.go b/vendor/github.com/kubernetes-incubator/apiserver-builder/example/pkg/apis/miskatonic/doc.go deleted file mode 100644 index b71cfc53de..0000000000 --- a/vendor/github.com/kubernetes-incubator/apiserver-builder/example/pkg/apis/miskatonic/doc.go +++ /dev/null @@ -1,21 +0,0 @@ -/* -Copyright 2017 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// +k8s:deepcopy-gen=package,register -// +groupName=miskatonic.k8s.io - -// Package api is the internal version of the API. -package miskatonic diff --git a/vendor/github.com/kubernetes-incubator/apiserver-builder/example/pkg/apis/miskatonic/install/doc.go b/vendor/github.com/kubernetes-incubator/apiserver-builder/example/pkg/apis/miskatonic/install/doc.go deleted file mode 100644 index a1fb52f7a5..0000000000 --- a/vendor/github.com/kubernetes-incubator/apiserver-builder/example/pkg/apis/miskatonic/install/doc.go +++ /dev/null @@ -1,17 +0,0 @@ -/* -Copyright 2017 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package install diff --git a/vendor/github.com/kubernetes-incubator/apiserver-builder/example/pkg/apis/miskatonic/student.go b/vendor/github.com/kubernetes-incubator/apiserver-builder/example/pkg/apis/miskatonic/student.go deleted file mode 100644 index ae47f58370..0000000000 --- a/vendor/github.com/kubernetes-incubator/apiserver-builder/example/pkg/apis/miskatonic/student.go +++ /dev/null @@ -1,54 +0,0 @@ -/* -Copyright 2017 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package miskatonic - -import ( - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apiserver/pkg/endpoints/request" - "k8s.io/apiserver/pkg/registry/rest" -) - -//var _ rest.CreaterUpdater = NewStudentREST() -//var _ rest.Patcher = NewStudentREST() - -var _ rest.CreaterUpdater = &StudentREST{} -var _ rest.Patcher = &StudentREST{} - -type StudentREST struct { - Registry StudentRegistry -} - -func (r *StudentREST) Create(ctx request.Context, obj runtime.Object, includeUninitialized bool) (runtime.Object, error) { - s := obj.(*Student) - s.Spec.ID = s.Spec.ID + 1 - return s, nil -} - -// Get retrieves the object from the storage. It is required to support Patch. -func (r *StudentREST) Get(ctx request.Context, name string, options *metav1.GetOptions) (runtime.Object, error) { - return &Student{}, nil -} - -// Update alters the status subset of an object. -func (r *StudentREST) Update(ctx request.Context, name string, objInfo rest.UpdatedObjectInfo) (runtime.Object, bool, error) { - return nil, false, nil -} - -func (r *StudentREST) New() runtime.Object { - return &Student{} -} diff --git a/vendor/github.com/kubernetes-incubator/apiserver-builder/example/pkg/apis/miskatonic/v1beta1/doc.go b/vendor/github.com/kubernetes-incubator/apiserver-builder/example/pkg/apis/miskatonic/v1beta1/doc.go deleted file mode 100644 index 759a28c266..0000000000 --- a/vendor/github.com/kubernetes-incubator/apiserver-builder/example/pkg/apis/miskatonic/v1beta1/doc.go +++ /dev/null @@ -1,26 +0,0 @@ -/* -Copyright 2017 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Api versions allow the api contract for a resource to be changed while keeping -// backward compatibility by support multiple concurrent versions -// of the same resource - -// +k8s:openapi-gen=true -// +k8s:deepcopy-gen=package,register -// +k8s:conversion-gen=github.com/kubernetes-incubator/apiserver-builder/example/pkg/apis/miskatonic -// +k8s:defaulter-gen=TypeMeta -// +groupName=miskatonic.k8s.io -package v1beta1 // import "github.com/kubernetes-incubator/apiserver-builder/example/pkg/apis/miskatonic/v1beta1" diff --git a/vendor/github.com/kubernetes-incubator/apiserver-builder/example/pkg/apis/miskatonic/v1beta1/student_types.go b/vendor/github.com/kubernetes-incubator/apiserver-builder/example/pkg/apis/miskatonic/v1beta1/student_types.go deleted file mode 100644 index 6f80c9fa96..0000000000 --- a/vendor/github.com/kubernetes-incubator/apiserver-builder/example/pkg/apis/miskatonic/v1beta1/student_types.go +++ /dev/null @@ -1,54 +0,0 @@ -/* -Copyright 2017 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package v1beta1 - -import ( - "github.com/kubernetes-incubator/apiserver-builder/example/pkg/apis/miskatonic" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apiserver/pkg/registry/rest" -) - -// Generating code from student_types.go file will generate storage and status REST endpoints for -// Student. - -// +genclient=true - -// +k8s:openapi-gen=true -// +resource:path=students,rest=StudentREST -type Student struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata,omitempty"` - - Spec StudentSpec `json:"spec,omitempty"` - Status StudentStatus `json:"status,omitempty"` -} - -// StudentSpec defines the desired state of Student -type StudentSpec struct { - ID int `json:"id,omitempty"` -} - -// StudentStatus defines the observed state of Student -type StudentStatus struct { - // GPA is the GPA of the student. - GPA float64 `json:"GPA,omitempty"` -} - -// Custom REST storage that delegates to the generated standard Registry -func NewStudentREST() rest.Storage { - return &miskatonic.StudentREST{miskatonic.NewStudentRegistry(nil)} -} diff --git a/vendor/github.com/kubernetes-incubator/apiserver-builder/example/pkg/apis/miskatonic/v1beta1/university_types.go b/vendor/github.com/kubernetes-incubator/apiserver-builder/example/pkg/apis/miskatonic/v1beta1/university_types.go deleted file mode 100644 index a55ef1d1e3..0000000000 --- a/vendor/github.com/kubernetes-incubator/apiserver-builder/example/pkg/apis/miskatonic/v1beta1/university_types.go +++ /dev/null @@ -1,155 +0,0 @@ -/* -Copyright 2017 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package v1beta1 - -import ( - "log" - - "github.com/kubernetes-incubator/apiserver-builder/example/pkg/apis/miskatonic" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/util/validation/field" - "k8s.io/apiserver/pkg/endpoints/request" - "k8s.io/apiserver/pkg/registry/rest" - apiv1 "k8s.io/client-go/pkg/api/v1" - //extensionsv1beta1 "k8s.io/client-go/pkg/apis/extensions/v1beta1" -) - -// Generating code from university_types.go file will generate storage and status REST endpoints for -// University. - -// +genclient=true - -// +k8s:openapi-gen=true -// +resource:path=universities,strategy=UniversityStrategy -// +subresource:request=Scale,path=scale,rest=ScaleUniversityREST -type University struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata,omitempty"` - - Spec UniversitySpec `json:"spec,omitempty"` - Status UniversityStatus `json:"status,omitempty"` -} - -// UniversitySpec defines the desired state of University -type UniversitySpec struct { - // faculty_size defines the desired faculty size of the university. Defaults to 15. - FacultySize int `json:"faculty_size,omitempty"` - - // max_students defines the maximum number of enrolled students. Defaults to 300. - // +optional - MaxStudents *int `json:"max_students,omitempty"` - - //// WARNING: Using types from client-go as fields does not work outside this example - //// This example hacked the vendored client-go to add the openapi generation directives - //// to make this work - //Template *apiv1.PodSpec `json:"template,omitempty"` - // - //// WARNING: Using types from client-go as fields does not work outside this example - //// This example hacked the vendored client-go to add the openapi generation directives - //// to make this work - //ServiceSpec apiv1.ServiceSpec `json:"service_spec,omitempty"` - // - //// WARNING: Using types from client-go as fields does not work outside this example - //// This example hacked the vendored client-go to add the openapi generation directives - //// to make this work - //Rollout []extensionsv1beta1.Deployment `json:"rollout,omitempty"` -} - -// UniversityStatus defines the observed state of University -type UniversityStatus struct { - // enrolled_students is the number of currently enrolled students - EnrolledStudents []string `json:"enrolled_students,omitempty"` - - // statusfield provides status information about University - FacultyEmployed []string `json:"faculty_employed,omitempty"` -} - -// Resource Validation -func (UniversityStrategy) Validate(ctx request.Context, obj runtime.Object) field.ErrorList { - university := obj.(*miskatonic.University) - log.Printf("Validating University %s\n", university.Name) - errors := field.ErrorList{} - if university.Spec.MaxStudents == nil || *university.Spec.MaxStudents < 1 || *university.Spec.MaxStudents > 150 { - errors = append(errors, field.Invalid( - field.NewPath("spec", "MaxStudents"), - *university.Spec.MaxStudents, - "Must be between 1 and 150")) - } - return errors -} - -// GetDefaultingFunctions returns functions for defaulting v1beta1.University values -func (UniversitySchemeFns) DefaultingFunction(o interface{}) { - obj := o.(*University) - log.Printf("Defaulting University %s\n", obj.Name) - if obj.Spec.MaxStudents == nil { - n := 15 - obj.Spec.MaxStudents = &n - } -} - -// GetConversionFunctions returns functions for converting resource versions to override the -// conversion functions -func (UniversitySchemeFns) GetConversionFunctions() []interface{} { - return []interface{}{ - apiv1.Convert_api_PodSpec_To_v1_PodSpec, - apiv1.Convert_v1_PodSpec_To_api_PodSpec, - } -} - -// +genclient=true - -// +subresource-request -type Scale struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata,omitempty"` - - Faculty int `json:"faculty,omitempty"` -} - -var _ rest.CreaterUpdater = &ScaleUniversityREST{} -var _ rest.Patcher = &ScaleUniversityREST{} - -type ScaleUniversityREST struct { - Registry miskatonic.UniversityRegistry -} - -func (r *ScaleUniversityREST) Create(ctx request.Context, obj runtime.Object, includeUninitialized bool) (runtime.Object, error) { - scale := obj.(*Scale) - u, err := r.Registry.GetUniversity(ctx, scale.Name, &metav1.GetOptions{}) - if err != nil { - return nil, err - } - u.Spec.FacultySize = scale.Faculty - r.Registry.UpdateUniversity(ctx, u) - return u, nil -} - -// Get retrieves the object from the storage. It is required to support Patch. -func (r *ScaleUniversityREST) Get(ctx request.Context, name string, options *metav1.GetOptions) (runtime.Object, error) { - return nil, nil -} - -// Update alters the status subset of an object. -func (r *ScaleUniversityREST) Update(ctx request.Context, name string, objInfo rest.UpdatedObjectInfo) (runtime.Object, bool, error) { - return nil, false, nil -} - -func (r *ScaleUniversityREST) New() runtime.Object { - return &Scale{} -} diff --git a/vendor/github.com/kubernetes-incubator/apiserver-builder/example/pkg/controller/doc.go b/vendor/github.com/kubernetes-incubator/apiserver-builder/example/pkg/controller/doc.go deleted file mode 100644 index e150354dd7..0000000000 --- a/vendor/github.com/kubernetes-incubator/apiserver-builder/example/pkg/controller/doc.go +++ /dev/null @@ -1,17 +0,0 @@ -/* -Copyright 2017 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package controller diff --git a/vendor/github.com/kubernetes-incubator/apiserver-builder/example/pkg/controller/festival/controller.go b/vendor/github.com/kubernetes-incubator/apiserver-builder/example/pkg/controller/festival/controller.go deleted file mode 100644 index 98e6a5010a..0000000000 --- a/vendor/github.com/kubernetes-incubator/apiserver-builder/example/pkg/controller/festival/controller.go +++ /dev/null @@ -1,72 +0,0 @@ - -/* -Copyright YEAR 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 festival - -import ( - "log" - - "github.com/kubernetes-incubator/apiserver-builder/pkg/controller" - "k8s.io/client-go/rest" - "k8s.io/client-go/tools/cache" - "k8s.io/client-go/util/workqueue" - - "github.com/kubernetes-incubator/apiserver-builder/example/pkg/apis/kingsport/v1" - "github.com/kubernetes-incubator/apiserver-builder/example/pkg/controller/sharedinformers" - listers "github.com/kubernetes-incubator/apiserver-builder/example/pkg/client/listers_generated/kingsport/v1" -) - -// +controller:group=kingsport,version=v1,kind=Festival,resource=festivals -type FestivalControllerImpl struct { - // informer listens for events about Festival - informer cache.SharedIndexInformer - - // lister indexes properties about Festival - lister listers.FestivalLister -} - -// Init initializes the controller and is called by the generated code -// Registers eventhandlers to enqueue events -// config - client configuration for talking to the apiserver -// si - informer factory shared across all controllers for listening to events and indexing resource properties -// queue - message queue for handling new events. unique to this controller. -func (c *FestivalControllerImpl) Init( - config *rest.Config, - si *sharedinformers.SharedInformers, - queue workqueue.RateLimitingInterface) { - - // Set the informer and lister for subscribing to events and indexing festivals labels - i := si.Factory.Kingsport().V1().Festivals() - c.informer = i.Informer() - c.lister = i.Lister() - - // Add an event handler to enqueue a message for festivals adds / updates - c.informer.AddEventHandler(&controller.QueueingEventHandler{queue}) -} - -// Reconcile handles enqueued messages -func (c *FestivalControllerImpl) Reconcile(u *v1.Festival) error { - // Implement controller logic here - log.Printf("Running reconcile Festival for %s\n", u.Name) - return nil -} - -func (c *FestivalControllerImpl) Get(namespace, name string) (*v1.Festival, error) { - return c.lister.Get(name) -} diff --git a/vendor/github.com/kubernetes-incubator/apiserver-builder/example/pkg/controller/university/university_controller.go b/vendor/github.com/kubernetes-incubator/apiserver-builder/example/pkg/controller/university/university_controller.go deleted file mode 100644 index 38a00bc0c9..0000000000 --- a/vendor/github.com/kubernetes-incubator/apiserver-builder/example/pkg/controller/university/university_controller.go +++ /dev/null @@ -1,68 +0,0 @@ -/* -Copyright 2017 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package university - -import ( - "fmt" - - "github.com/kubernetes-incubator/apiserver-builder/pkg/controller" - "k8s.io/client-go/rest" - "k8s.io/client-go/tools/cache" - "k8s.io/client-go/util/workqueue" - - "github.com/kubernetes-incubator/apiserver-builder/example/pkg/apis/miskatonic/v1beta1" - listers "github.com/kubernetes-incubator/apiserver-builder/example/pkg/client/listers_generated/miskatonic/v1beta1" - "github.com/kubernetes-incubator/apiserver-builder/example/pkg/controller/sharedinformers" -) - -// +controller:group=miskatonic,version=v1beta1,kind=University,resource=universities -type UniversityControllerImpl struct { - // universityinformer listens for events about Universities - universityinformer cache.SharedIndexInformer - - // universitylister indexes properties about Universities - universitylister listers.UniversityLister -} - -// Init initializes the controller and is called by the generated code -// config - client configuration for talking to the apiserver -// si - informer factory shared across all controllers for listening to events and indexing resource properties -// queue - message queue for handling new events. unique to this controller. -func (c *UniversityControllerImpl) Init( - config *rest.Config, - si *sharedinformers.SharedInformers, - queue workqueue.RateLimitingInterface) { - - // Get the informer and lister for subscribing to university events and querying universities from - // the lister cache - i := si.Factory.Miskatonic().V1beta1().Universities() - c.universityinformer = i.Informer() - c.universitylister = i.Lister() - - // Add an event handler to enqueue a message for university adds / updates - c.universityinformer.AddEventHandler(&controller.QueueingEventHandler{queue}) -} - -// Reconcile handles enqueued messages -func (c *UniversityControllerImpl) Reconcile(u *v1beta1.University) error { - fmt.Printf("Running reconcile University for %s\n", u.Name) - return nil -} - -func (c *UniversityControllerImpl) Get(namespace, name string) (*v1beta1.University, error) { - return c.universitylister.Universities(namespace).Get(name) -} diff --git a/vendor/github.com/kubernetes-incubator/apiserver-builder/example/pkg/openapi/doc.go b/vendor/github.com/kubernetes-incubator/apiserver-builder/example/pkg/openapi/doc.go deleted file mode 100644 index bdf1e20d70..0000000000 --- a/vendor/github.com/kubernetes-incubator/apiserver-builder/example/pkg/openapi/doc.go +++ /dev/null @@ -1,15 +0,0 @@ -/* -Copyright 2017 The Kubernetes Authors. -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Package openapi exists to hold generated openapi code -package openapi diff --git a/vendor/github.com/kubernetes-incubator/apiserver-builder/example/sampleconfig/university.yaml b/vendor/github.com/kubernetes-incubator/apiserver-builder/example/sampleconfig/university.yaml deleted file mode 100644 index d6b4e21068..0000000000 --- a/vendor/github.com/kubernetes-incubator/apiserver-builder/example/sampleconfig/university.yaml +++ /dev/null @@ -1,5 +0,0 @@ -apiVersion: miskatonic.k8s.io/v1beta1 -kind: University -metadata: - name: u2 -spec: diff --git a/vendor/github.com/kubernetes-incubator/apiserver-builder/glide.lock b/vendor/github.com/kubernetes-incubator/apiserver-builder/glide.lock deleted file mode 100644 index e4691645c0..0000000000 --- a/vendor/github.com/kubernetes-incubator/apiserver-builder/glide.lock +++ /dev/null @@ -1,608 +0,0 @@ -hash: 3b3bb4360bb2822bf60033a34ec38af64a8cd80a0122e3941a466c033f7c480a -updated: 2017-06-23T10:04:30.800062909-07:00 -imports: -- name: bitbucket.org/ww/goautoneg - version: 75cd24fc2f2c2a2088577d12123ddee5f54e0675 -- name: cloud.google.com/go - version: 3b1ae45394a234c385be014e9a488f2bb6eef821 - subpackages: - - compute/metadata - - internal -- name: github.com/Azure/go-autorest - version: d7c034a8af24eda120dd6460bfcd6d9ed14e43ca - subpackages: - - autorest - - autorest/azure - - autorest/date -- name: github.com/beorn7/perks - version: 3ac7bf7a47d159a033b107610db8a1b6575507a4 - subpackages: - - quantile -- name: github.com/coreos/etcd - version: 20490caaf0dcd96bb4a95e40625559def8ef5b04 - subpackages: - - alarm - - auth - - auth/authpb - - client - - clientv3 - - compactor - - discovery - - error - - etcdserver - - etcdserver/api - - etcdserver/api/v2http - - etcdserver/api/v2http/httptypes - - etcdserver/api/v3rpc - - etcdserver/api/v3rpc/rpctypes - - etcdserver/auth - - etcdserver/etcdserverpb - - etcdserver/membership - - etcdserver/stats - - integration - - lease - - lease/leasehttp - - lease/leasepb - - mvcc - - mvcc/backend - - mvcc/mvccpb - - pkg/adt - - pkg/contention - - pkg/cpuutil - - pkg/crc - - pkg/fileutil - - pkg/httputil - - pkg/idutil - - pkg/ioutil - - pkg/logutil - - pkg/monotime - - pkg/netutil - - pkg/pathutil - - pkg/pbutil - - pkg/runtime - - pkg/schedule - - pkg/testutil - - pkg/tlsutil - - pkg/transport - - pkg/types - - pkg/wait - - proxy/grpcproxy - - proxy/grpcproxy/cache - - raft - - raft/raftpb - - rafthttp - - snap - - snap/snappb - - store - - version - - wal - - wal/walpb -- name: github.com/coreos/go-systemd - version: 48702e0da86bd25e76cfef347e2adeb434a0d0a6 - subpackages: - - daemon - - journal -- name: github.com/coreos/pkg - version: fa29b1d70f0beaddd4c7021607cc3c3be8ce94b8 - subpackages: - - capnslog - - health - - httputil - - timeutil -- name: github.com/davecgh/go-spew - version: 5215b55f46b2b919f50a1df0eaa5886afe4e3b3d - subpackages: - - spew -- name: github.com/dgrijalva/jwt-go - version: 01aeca54ebda6e0fbfafd0a524d234159c05ec20 -- name: github.com/docker/distribution - version: cd27f179f2c10c5d300e6d09025b538c475b0d51 - subpackages: - - digest - - reference -- name: github.com/elazarl/go-bindata-assetfs - version: 3dcc96556217539f50599357fb481ac0dc7439b9 -- name: github.com/emicklei/go-restful - version: ff4f55a206334ef123e4f79bbf348980da81ca46 - subpackages: - - log -- name: github.com/emicklei/go-restful-swagger12 - version: dcef7f55730566d41eae5db10e7d6981829720f6 -- name: github.com/evanphx/json-patch - version: ba18e35c5c1b36ef6334cad706eb681153d2d379 -- name: github.com/ghodss/yaml - version: 73d445a93680fa1a78ae23a5839bad48f32ba1ee -- name: github.com/go-openapi/analysis - version: b44dc874b601d9e4e2f6e19140e794ba24bead3b -- name: github.com/go-openapi/jsonpointer - version: 46af16f9f7b149af66e5d1bd010e3574dc06de98 -- name: github.com/go-openapi/jsonreference - version: 13c6e3589ad90f49bd3e3bbe2c2cb3d7a4142272 -- name: github.com/go-openapi/loads - version: 18441dfa706d924a39a030ee2c3b1d8d81917b38 -- name: github.com/go-openapi/spec - version: 6aced65f8501fe1217321abf0749d354824ba2ff -- name: github.com/go-openapi/swag - version: 1d0bd113de87027671077d3c71eb3ac5d7dbba72 -- name: github.com/gogo/protobuf - version: c0656edd0d9eab7c66d1eb0c568f9039345796f7 - subpackages: - - proto - - sortkeys -- name: github.com/golang/glog - version: 44145f04b68cf362d9c4df2182967c2275eaefed -- name: github.com/golang/protobuf - version: 4bd1920723d7b7c925de087aa32e2187708897f7 - subpackages: - - jsonpb - - proto - - ptypes - - ptypes/any - - ptypes/duration - - ptypes/timestamp -- name: github.com/google/gofuzz - version: 44d81051d367757e1c7c6a5a86423ece9afcf63c -- name: github.com/googleapis/gnostic - version: 68f4ded48ba9414dab2ae69b3f0d69971da73aa5 - subpackages: - - OpenAPIv2 - - compiler - - extensions -- name: github.com/grpc-ecosystem/go-grpc-prometheus - version: 2500245aa6110c562d17020fb31a2c133d737799 -- name: github.com/grpc-ecosystem/grpc-gateway - version: 84398b94e188ee336f307779b57b3aa91af7063c - subpackages: - - runtime - - runtime/internal - - utilities -- name: github.com/hashicorp/golang-lru - version: a0d98a5f288019575c6d1f4bb1573fef2d1fcdc4 - subpackages: - - simplelru -- name: github.com/howeyc/gopass - version: bf9dde6d0d2c004a008c27aaee91170c786f6db8 -- name: github.com/imdario/mergo - version: 6633656539c1639d9d78127b7d47c622b5d7b6dc -- name: github.com/inconshreveable/mousetrap - version: 76626ae9c91c4f2a10f34cad8ce83ea42c93bb75 -- name: github.com/juju/ratelimit - version: 5b9ff866471762aa2ab2dced63c9fb6f53921342 -- name: github.com/kubernetes-incubator/reference-docs - version: cf773b839413d2419c2476257fb0200fdad86b3a - subpackages: - - gen-apidocs -- name: github.com/mailru/easyjson - version: d5b7844b561a7bc640052f1b935f7b800330d7e0 - subpackages: - - buffer - - jlexer - - jwriter -- name: github.com/markbates/inflect - version: 6cacb66d100482ef7cc366289ccb156020e57e76 -- name: github.com/matttproud/golang_protobuf_extensions - version: fc2b8d3a73c4867e51861bbdd5ae3c1f0869dd6a - subpackages: - - pbutil -- name: github.com/onsi/ginkgo - version: 77a8c1e5c40d6bb6c5eb4dd4bdce9763564f6298 - subpackages: - - config - - internal/codelocation - - internal/containernode - - internal/failer - - internal/leafnodes - - internal/remote - - internal/spec - - internal/spec_iterator - - internal/specrunner - - internal/suite - - internal/testingtproxy - - internal/writer - - reporters - - reporters/stenographer - - reporters/stenographer/support/go-colorable - - reporters/stenographer/support/go-isatty - - types -- name: github.com/onsi/gomega - version: 334b8f472b3af5d541c5642701c1e29e2126f486 - subpackages: - - format - - internal/assertion - - internal/asyncassertion - - internal/oraclematcher - - internal/testingtsupport - - matchers - - matchers/support/goraph/bipartitegraph - - matchers/support/goraph/edge - - matchers/support/goraph/node - - matchers/support/goraph/util - - types -- name: github.com/pborman/uuid - version: ca53cad383cad2479bbba7f7a1a05797ec1386e4 -- name: github.com/pkg/errors - version: a22138067af1c4942683050411a841ade67fe1eb -- name: github.com/prometheus/client_golang - version: e7e903064f5e9eb5da98208bae10b475d4db0f8c - subpackages: - - prometheus -- name: github.com/prometheus/client_model - version: fa8ad6fec33561be4280a8f0514318c79d7f6cb6 - subpackages: - - go -- name: github.com/prometheus/common - version: 13ba4ddd0caa9c28ca7b7bffe1dfa9ed8d5ef207 - subpackages: - - expfmt - - internal/bitbucket.org/ww/goautoneg - - model -- name: github.com/prometheus/procfs - version: 65c1f6f8f0fc1e2185eb9863a3bc751496404259 - subpackages: - - xfs -- name: github.com/PuerkitoBio/purell - version: 8a290539e2e8629dbc4e6bad948158f790ec31f4 -- name: github.com/PuerkitoBio/urlesc - version: 5bd2802263f21d8788851d5305584c82a5c75d7e -- name: github.com/spf13/cobra - version: 7b1b6e8dc027253d45fc029bc269d1c019f83a34 -- name: github.com/spf13/pflag - version: d90f37a48761fe767528f31db1955e4f795d652f -- name: github.com/ugorji/go - version: ded73eae5db7e7a0ef6f55aace87a2873c5d2b74 - subpackages: - - codec -- name: golang.org/x/crypto - version: d172538b2cfce0c13cee31e647d0367aa8cd2486 - subpackages: - - bcrypt - - blowfish - - nacl/secretbox - - poly1305 - - salsa20/salsa - - ssh/terminal -- name: golang.org/x/net - version: f2499483f923065a842d38eb4c7f1927e6fc6e6d - subpackages: - - context - - context/ctxhttp - - html - - html/atom - - http2 - - http2/hpack - - idna - - internal/timeseries - - lex/httplex - - trace - - websocket -- name: golang.org/x/oauth2 - version: a6bd8cefa1811bd24b86f8902872e4e8225f74c4 - subpackages: - - google - - internal - - jws - - jwt -- name: golang.org/x/sys - version: 8f0908ab3b2457e2e15403d3697c9ef5cb4b57a9 - subpackages: - - unix -- name: golang.org/x/text - version: 2910a502d2bf9e43193af9d68ca516529614eed3 - subpackages: - - cases - - internal/tag - - language - - runes - - secure/bidirule - - secure/precis - - transform - - unicode/bidi - - unicode/norm - - width -- name: google.golang.org/appengine - version: 12d5545dc1cfa6047a286d5e853841b6471f4c19 - subpackages: - - internal - - internal/app_identity - - internal/base - - internal/datastore - - internal/log - - internal/modules - - internal/remote_api - - internal/urlfetch - - urlfetch -- name: google.golang.org/grpc - version: 777daa17ff9b5daef1cfdf915088a2ada3332bf0 - subpackages: - - codes - - credentials - - grpclog - - internal - - metadata - - naming - - peer - - transport -- name: gopkg.in/inf.v0 - version: 3887ee99ecf07df5b447e9b00d9c0b2adaa9f3e4 -- name: gopkg.in/natefinch/lumberjack.v2 - version: 20b71e5b60d756d3d2f80def009790325acc2b23 -- name: gopkg.in/yaml.v2 - version: 53feefa2559fb8dfa8d81baad31be332c97d6c77 -- name: k8s.io/apimachinery - version: cff8db64dd5b6fb0166dc2cf36e39c7ff4fe48c8 - subpackages: - - pkg/api/equality - - pkg/api/errors - - pkg/api/meta - - pkg/api/resource - - pkg/api/validation - - pkg/api/validation/path - - pkg/apimachinery - - pkg/apimachinery/announced - - pkg/apimachinery/registered - - pkg/apis/meta/internalversion - - pkg/apis/meta/v1 - - pkg/apis/meta/v1/unstructured - - pkg/apis/meta/v1/validation - - pkg/apis/meta/v1alpha1 - - pkg/conversion - - pkg/conversion/queryparams - - pkg/conversion/unstructured - - pkg/fields - - pkg/labels - - pkg/openapi - - pkg/runtime - - pkg/runtime/schema - - pkg/runtime/serializer - - pkg/runtime/serializer/json - - pkg/runtime/serializer/protobuf - - pkg/runtime/serializer/recognizer - - pkg/runtime/serializer/streaming - - pkg/runtime/serializer/versioning - - pkg/selection - - pkg/types - - pkg/util/cache - - pkg/util/clock - - pkg/util/diff - - pkg/util/errors - - pkg/util/framer - - pkg/util/httpstream - - pkg/util/intstr - - pkg/util/json - - pkg/util/mergepatch - - pkg/util/net - - pkg/util/rand - - pkg/util/runtime - - pkg/util/sets - - pkg/util/strategicpatch - - pkg/util/uuid - - pkg/util/validation - - pkg/util/validation/field - - pkg/util/wait - - pkg/util/yaml - - pkg/version - - pkg/watch - - third_party/forked/golang/json - - third_party/forked/golang/netutil - - third_party/forked/golang/reflect -- name: k8s.io/apiserver - version: 2e70bac0745c7f8e506f7f3e432d040c55d5718a - subpackages: - - pkg/admission - - pkg/admission/initializer - - pkg/admission/plugin/namespace/lifecycle - - pkg/apis/apiserver - - pkg/apis/apiserver/install - - pkg/apis/apiserver/v1alpha1 - - pkg/apis/audit - - pkg/apis/audit/install - - pkg/apis/audit/v1alpha1 - - pkg/apis/audit/validation - - pkg/audit - - pkg/audit/policy - - pkg/authentication/authenticator - - pkg/authentication/authenticatorfactory - - pkg/authentication/group - - pkg/authentication/request/anonymous - - pkg/authentication/request/bearertoken - - pkg/authentication/request/headerrequest - - pkg/authentication/request/union - - pkg/authentication/request/x509 - - pkg/authentication/serviceaccount - - pkg/authentication/token/tokenfile - - pkg/authentication/user - - pkg/authorization/authorizer - - pkg/authorization/authorizerfactory - - pkg/authorization/union - - pkg/endpoints - - pkg/endpoints/discovery - - pkg/endpoints/filters - - pkg/endpoints/handlers - - pkg/endpoints/handlers/negotiation - - pkg/endpoints/handlers/responsewriters - - pkg/endpoints/metrics - - pkg/endpoints/openapi - - pkg/endpoints/request - - pkg/features - - pkg/registry/generic - - pkg/registry/generic/registry - - pkg/registry/rest - - pkg/server - - pkg/server/filters - - pkg/server/healthz - - pkg/server/httplog - - pkg/server/mux - - pkg/server/openapi - - pkg/server/options - - pkg/server/routes - - pkg/server/routes/data/swagger - - pkg/server/storage - - pkg/storage - - pkg/storage/errors - - pkg/storage/etcd - - pkg/storage/etcd/metrics - - pkg/storage/etcd/util - - pkg/storage/etcd3 - - pkg/storage/names - - pkg/storage/storagebackend - - pkg/storage/storagebackend/factory - - pkg/storage/value - - pkg/util/feature - - pkg/util/flag - - pkg/util/flushwriter - - pkg/util/logs - - pkg/util/proxy - - pkg/util/trace - - pkg/util/trie - - pkg/util/webhook - - pkg/util/wsstream - - plugin/pkg/audit/log - - plugin/pkg/audit/webhook - - plugin/pkg/authenticator/token/webhook - - plugin/pkg/authorizer/webhook -- name: k8s.io/client-go - version: 36b51953e6efc7779fe27c14258d78573de4e0de - subpackages: - - discovery - - discovery/fake - - informers - - informers/admissionregistration - - informers/admissionregistration/v1alpha1 - - informers/apps - - informers/apps/v1beta1 - - informers/autoscaling - - informers/autoscaling/v1 - - informers/autoscaling/v2alpha1 - - informers/batch - - informers/batch/v1 - - informers/batch/v2alpha1 - - informers/certificates - - informers/certificates/v1beta1 - - informers/core - - informers/core/v1 - - informers/extensions - - informers/extensions/v1beta1 - - informers/internalinterfaces - - informers/networking - - informers/networking/v1 - - informers/policy - - informers/policy/v1beta1 - - informers/rbac - - informers/rbac/v1alpha1 - - informers/rbac/v1beta1 - - informers/settings - - informers/settings/v1alpha1 - - informers/storage - - informers/storage/v1 - - informers/storage/v1beta1 - - kubernetes - - kubernetes/scheme - - kubernetes/typed/admissionregistration/v1alpha1 - - kubernetes/typed/apps/v1beta1 - - kubernetes/typed/authentication/v1 - - kubernetes/typed/authentication/v1beta1 - - kubernetes/typed/authorization/v1 - - kubernetes/typed/authorization/v1beta1 - - kubernetes/typed/autoscaling/v1 - - kubernetes/typed/autoscaling/v2alpha1 - - kubernetes/typed/batch/v1 - - kubernetes/typed/batch/v2alpha1 - - kubernetes/typed/certificates/v1beta1 - - kubernetes/typed/core/v1 - - kubernetes/typed/extensions/v1beta1 - - kubernetes/typed/networking/v1 - - kubernetes/typed/policy/v1beta1 - - kubernetes/typed/rbac/v1alpha1 - - kubernetes/typed/rbac/v1beta1 - - kubernetes/typed/settings/v1alpha1 - - kubernetes/typed/storage/v1 - - kubernetes/typed/storage/v1beta1 - - listers/admissionregistration/v1alpha1 - - listers/apps/v1beta1 - - listers/autoscaling/v1 - - listers/autoscaling/v2alpha1 - - listers/batch/v1 - - listers/batch/v2alpha1 - - listers/certificates/v1beta1 - - listers/core/v1 - - listers/extensions/v1beta1 - - listers/networking/v1 - - listers/policy/v1beta1 - - listers/rbac/v1alpha1 - - listers/rbac/v1beta1 - - listers/settings/v1alpha1 - - listers/storage/v1 - - listers/storage/v1beta1 - - pkg/api - - pkg/api/v1 - - pkg/api/v1/ref - - pkg/apis/admissionregistration - - pkg/apis/admissionregistration/v1alpha1 - - pkg/apis/apps - - pkg/apis/apps/v1beta1 - - pkg/apis/authentication - - pkg/apis/authentication/v1 - - pkg/apis/authentication/v1beta1 - - pkg/apis/authorization - - pkg/apis/authorization/v1 - - pkg/apis/authorization/v1beta1 - - pkg/apis/autoscaling - - pkg/apis/autoscaling/v1 - - pkg/apis/autoscaling/v2alpha1 - - pkg/apis/batch - - pkg/apis/batch/v1 - - pkg/apis/batch/v2alpha1 - - pkg/apis/certificates - - pkg/apis/certificates/v1beta1 - - pkg/apis/extensions - - pkg/apis/extensions/v1beta1 - - pkg/apis/networking - - pkg/apis/networking/v1 - - pkg/apis/policy - - pkg/apis/policy/v1beta1 - - pkg/apis/rbac - - pkg/apis/rbac/v1alpha1 - - pkg/apis/rbac/v1beta1 - - pkg/apis/settings - - pkg/apis/settings/v1alpha1 - - pkg/apis/storage - - pkg/apis/storage/v1 - - pkg/apis/storage/v1beta1 - - pkg/util - - pkg/util/parsers - - pkg/version - - plugin/pkg/client/auth - - plugin/pkg/client/auth/azure - - plugin/pkg/client/auth/gcp - - plugin/pkg/client/auth/oidc - - rest - - rest/watch - - testing - - third_party/forked/golang/template - - tools/auth - - tools/cache - - tools/clientcmd - - tools/clientcmd/api - - tools/clientcmd/api/latest - - tools/clientcmd/api/v1 - - tools/metrics - - transport - - util/cert - - util/flowcontrol - - util/homedir - - util/integer - - util/jsonpath - - util/workqueue -- name: k8s.io/gengo - version: c79c13d131b0a8f42d05faa6491c12e94ccc6f30 - subpackages: - - args - - generator - - namer - - parser - - types -- name: k8s.io/kubernetes - version: 227f52e0cb142f5658598e3c981e0e637f8d9c08 - subpackages: - - cmd/libs/go2idl -testImports: [] diff --git a/vendor/github.com/kubernetes-incubator/apiserver-builder/glide.yaml b/vendor/github.com/kubernetes-incubator/apiserver-builder/glide.yaml deleted file mode 100644 index 08ab6cba39..0000000000 --- a/vendor/github.com/kubernetes-incubator/apiserver-builder/glide.yaml +++ /dev/null @@ -1,44 +0,0 @@ -package: github.com/kubernetes-incubator/apiserver-builder -ignore: -- github.com/kubernetes-incubator/apiserver-builder -import: -- package: github.com/go-openapi/analysis - version: b44dc874b601d9e4e2f6e19140e794ba24bead3b -- package: github.com/go-openapi/jsonpointer - version: 46af16f9f7b149af66e5d1bd010e3574dc06de98 -- package: github.com/go-openapi/jsonreference - version: 13c6e3589ad90f49bd3e3bbe2c2cb3d7a4142272 -- package: github.com/go-openapi/loads - version: 18441dfa706d924a39a030ee2c3b1d8d81917b38 -- package: github.com/go-openapi/spec - version: 6aced65f8501fe1217321abf0749d354824ba2ff -- package: github.com/go-openapi/swag - version: 1d0bd113de87027671077d3c71eb3ac5d7dbba72 -- package: github.com/golang/glog - version: 44145f04b68cf362d9c4df2182967c2275eaefed -- package: github.com/pkg/errors - version: a22138067af1c4942683050411a841ade67fe1eb -- package: github.com/spf13/cobra - version: 7b1b6e8dc027253d45fc029bc269d1c019f83a34 -- package: github.com/spf13/pflag - version: d90f37a48761fe767528f31db1955e4f795d652f -- package: github.com/markbates/inflect - version: 6cacb66d100482ef7cc366289ccb156020e57e76 -- package: k8s.io/apimachinery - version: cff8db64dd5b6fb0166dc2cf36e39c7ff4fe48c8 -- package: k8s.io/apiserver - version: 2e70bac0745c7f8e506f7f3e432d040c55d5718a -- package: k8s.io/client-go - version: 36b51953e6efc7779fe27c14258d78573de4e0de -- package: k8s.io/gengo -- package: github.com/onsi/ginkgo - version: ~1.3.1 -- package: github.com/onsi/gomega - version: ~1.1.0 -- package: k8s.io/kubernetes - version: ~1.8.0-alpha.1 - subpackages: - - cmd/libs/go2idl -- package: github.com/kubernetes-incubator/reference-docs - subpackages: - - gen-apidocs diff --git a/vendor/github.com/kubernetes-incubator/apiserver-builder/pkg/apiserver/apiserver.go b/vendor/github.com/kubernetes-incubator/apiserver-builder/pkg/apiserver/apiserver.go deleted file mode 100644 index a48d653bb8..0000000000 --- a/vendor/github.com/kubernetes-incubator/apiserver-builder/pkg/apiserver/apiserver.go +++ /dev/null @@ -1,114 +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 apiserver - -import ( - "k8s.io/apimachinery/pkg/apimachinery/announced" - "k8s.io/apimachinery/pkg/apimachinery/registered" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/version" - genericapiserver "k8s.io/apiserver/pkg/server" - - "github.com/kubernetes-incubator/apiserver-builder/pkg/builders" - "k8s.io/client-go/pkg/api" -) - -type Installer struct { - GroupFactoryRegistry announced.APIGroupFactoryRegistry - Registry *registered.APIRegistrationManager - Scheme *runtime.Scheme -} - -func (c *Config) Init() *Config { - for _, builder := range builders.APIGroupBuilders { - builder.Announce() - } - - // we need to add the options to empty v1 - // TODO fix the server code to avoid this - metav1.AddToGroupVersion(api.Scheme, schema.GroupVersion{Version: "v1"}) - - // TODO: keep the generic ResourceDefinition server from wanting this - unversioned := schema.GroupVersion{Group: "", Version: "v1"} - api.Scheme.AddUnversionedTypes(unversioned, - &metav1.Status{}, - &metav1.APIVersions{}, - &metav1.APIGroupList{}, - &metav1.APIGroup{}, - &metav1.APIResourceList{}, - ) - - return c -} - -type Config struct { - GenericConfig *genericapiserver.Config -} - -// Server contains state for a Kubernetes cluster master/api server. -type Server struct { - GenericAPIServer *genericapiserver.GenericAPIServer -} - -type completedConfig struct { - *Config -} - -// Complete fills in any fields not set that are required to have valid data. It's mutating the receiver. -func (c *Config) Complete() completedConfig { - c.GenericConfig.Complete() - - c.GenericConfig.Version = &version.Info{ - Major: "1", - Minor: "0", - } - - return completedConfig{c} -} - -func (c *Config) AddApi(builder *builders.APIGroupBuilder) *Config { - builders.APIGroupBuilders = append(builders.APIGroupBuilders, builder) - return c -} - -// SkipComplete provides a way to construct a server instance without config completion. -func (c *Config) SkipComplete() completedConfig { - return completedConfig{c} -} - -// NewFunc returns a new instance of Server from the given config. -func (c completedConfig) New() (*Server, error) { - genericServer, err := c.Config.GenericConfig.SkipComplete(). - New("aggregated-apiserver", genericapiserver.EmptyDelegate) // completion is done in Complete, no need for a second time - if err != nil { - return nil, err - } - - s := &Server{ - GenericAPIServer: genericServer, - } - - for _, builder := range builders.APIGroupBuilders { - group := builder.Build(c.GenericConfig.RESTOptionsGetter) - if err := s.GenericAPIServer.InstallAPIGroup(group); err != nil { - return nil, err - } - } - return s, nil -} diff --git a/vendor/github.com/kubernetes-incubator/apiserver-builder/pkg/builders/api_group_builder.go b/vendor/github.com/kubernetes-incubator/apiserver-builder/pkg/builders/api_group_builder.go deleted file mode 100644 index 2f71ecc793..0000000000 --- a/vendor/github.com/kubernetes-incubator/apiserver-builder/pkg/builders/api_group_builder.go +++ /dev/null @@ -1,145 +0,0 @@ -/* -Copyright 2017 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package builders - -import ( - "k8s.io/apimachinery/pkg/apimachinery/announced" - "k8s.io/apimachinery/pkg/apimachinery/registered" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/util/sets" - "k8s.io/apiserver/pkg/registry/generic" - "k8s.io/apiserver/pkg/registry/rest" - genericapiserver "k8s.io/apiserver/pkg/server" - "k8s.io/client-go/pkg/api" -) - -// Global registry of API groups -var APIGroupBuilders = []*APIGroupBuilder{} - -type APIGroupBuilder struct { - UnVersioned *UnVersionedApiBuilder - Versions []*VersionedApiBuilder - Name string - ImportPrefix string - RootScopedKinds []string -} - -func NewApiGroupBuilder(name, prefix string) *APIGroupBuilder { - g := &APIGroupBuilder{ - Name: name, - ImportPrefix: prefix, - } - return g -} - -func (g *APIGroupBuilder) WithUnVersionedApi(unversioned *UnVersionedApiBuilder) *APIGroupBuilder { - g.UnVersioned = unversioned - return g -} - -func (g *APIGroupBuilder) WithVersionedApis(versions ...*VersionedApiBuilder) *APIGroupBuilder { - g.Versions = append(g.Versions, versions...) - return g -} - -func (g *APIGroupBuilder) WithRootScopedKinds(kinds ...string) *APIGroupBuilder { - g.RootScopedKinds = append(g.RootScopedKinds, kinds...) - return g -} - -// GetVersionPreferenceOrder returns the preferred ordering of versions for this api group -func (g *APIGroupBuilder) GetVersionPreferenceOrder() []string { - order := []string{} - for _, v := range g.Versions { - order = append(order, v.GroupVersion.Version) - } - return order -} - -// VersionToSchemeFunc returns a map of version to AddToScheme function for all versioned Schemes -func (g *APIGroupBuilder) VersionToSchemeFunc() announced.VersionToSchemeFunc { - f := announced.VersionToSchemeFunc{} - for _, v := range g.Versions { - v.registerVersionToScheme(f) - } - return f -} - -func (g *APIGroupBuilder) GetLegacyCodec() []schema.GroupVersion { - versions := []schema.GroupVersion{} - for _, v := range g.Versions { - versions = append(versions, v.GroupVersion) - } - return versions -} - -func (g *APIGroupBuilder) registerEndpoints( - optionsGetter generic.RESTOptionsGetter, - registry map[string]map[string]rest.Storage) { - - // Register the endpoints for each version - for _, v := range g.Versions { - v.registerEndpoints(optionsGetter, registry) - } -} - -// Build returns a new NewDefaultAPIGroupInfo to install into a GenericApiServer -func (g *APIGroupBuilder) Build(optionsGetter generic.RESTOptionsGetter) *genericapiserver.APIGroupInfo { - - // Build a new group - i := genericapiserver.NewDefaultAPIGroupInfo( - g.Name, - api.Registry, - api.Scheme, - metav1.ParameterCodec, - api.Codecs) - - // First group version is preferred - i.GroupMeta.GroupVersion = g.Versions[0].GroupVersion - - // Register the endpoints with the group - g.registerEndpoints(optionsGetter, i.VersionedResourcesStorageMap) - - return &i - -} - -func (g *APIGroupBuilder) Install( - groupFactoryRegistry announced.APIGroupFactoryRegistry, - registry *registered.APIRegistrationManager, - scheme *runtime.Scheme) { - if err := announced.NewGroupMetaFactory( - &announced.GroupMetaFactoryArgs{ - GroupName: g.Name, - RootScopedKinds: sets.NewString(append(g.RootScopedKinds, "APIService")...), - VersionPreferenceOrder: g.GetVersionPreferenceOrder(), - ImportPrefix: g.ImportPrefix, - AddInternalObjectsToScheme: g.UnVersioned.SchemaBuilder.AddToScheme, - }, - g.VersionToSchemeFunc(), - ).Announce(groupFactoryRegistry).RegisterAndEnable(registry, scheme); err != nil { - panic(err) - } - -} - -// Announce installs the API group for an api server -func (g *APIGroupBuilder) Announce() { - g.Install(api.GroupFactoryRegistry, api.Registry, api.Scheme) -} diff --git a/vendor/github.com/kubernetes-incubator/apiserver-builder/pkg/builders/api_unversioned_resource_builder.go b/vendor/github.com/kubernetes-incubator/apiserver-builder/pkg/builders/api_unversioned_resource_builder.go deleted file mode 100644 index d9c181e6de..0000000000 --- a/vendor/github.com/kubernetes-incubator/apiserver-builder/pkg/builders/api_unversioned_resource_builder.go +++ /dev/null @@ -1,116 +0,0 @@ -/* -Copyright 2017 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package builders - -import ( - "k8s.io/apimachinery/pkg/runtime" -) - -// NewInternalResource creates a new strategy for a resource -// name - name of the resource - e.g. "deployments" -// new - function for creating new empty UNVERSIONED instances - e.g. func() runtime.Object { return &Deployment{} } -// newList - function for creating an empty list of UNVERSIONED instances - e.g. func() runtime.Object { return &DeploymentList{} } -func NewInternalResource(name string, new, newList func() runtime.Object) UnversionedResourceBuilder { - return NewBuilder(name, "", new, newList, true) -} - -// NewInternalResourceStatus returns a new strategy for the status subresource of an object -// name - name of the resource - e.g. "deployments" -// new - function for creating new empty UNVERSIONED instances - e.g. func() runtime.Object { return &Deployment{} } -// newList - function for creating an empty list of UNVERSIONED instances - e.g. func() runtime.Object { return &DeploymentList{} } -func NewInternalResourceStatus(name string, new, newList func() runtime.Object) UnversionedResourceBuilder { - return NewBuilder( - name, - "status", - new, newList, - true) -} - -// NewInternalSubresource returns a new strategy for a subresource -// name - name of the resource - e.g. "deployments" -// path - path to the subresource - e.g. "scale" -// new - function for creating new empty UNVERSIONED instances - e.g. func() runtime.Object { return &Deployment{} } -func NewInternalSubresource(name, path string, new func() runtime.Object) UnversionedResourceBuilder { - return NewBuilder( - name, - path, - new, - nil, // Don't provide a list function - false, // Don't create a full storage rest interface, just use the provide methods - ) -} - -func NewBuilder( - name, path string, - new, newList func() runtime.Object, - useRegistryStore bool) UnversionedResourceBuilder { - - return &UnversionedResourceBuilderImpl{ - path, - name, - new, - newList, - useRegistryStore, - } -} - -type WithList interface { - NewList() runtime.Object -} - -type UnversionedResourceBuilder interface { - WithList - New() runtime.Object - - GetPath() string - GetName() string - ShouldUseRegistryStore() bool -} - -type UnversionedResourceBuilderImpl struct { - Path string - Name string - NewFunc func() runtime.Object - NewListFunc func() runtime.Object - UseRegistryStore bool -} - -func (b *UnversionedResourceBuilderImpl) GetPath() string { - return b.Path -} - -func (b *UnversionedResourceBuilderImpl) GetName() string { - return b.Name -} - -func (b *UnversionedResourceBuilderImpl) ShouldUseRegistryStore() bool { - return b.UseRegistryStore -} - -func (b *UnversionedResourceBuilderImpl) New() runtime.Object { - if b.NewFunc == nil { - return nil - } - return b.NewFunc() -} - -func (b *UnversionedResourceBuilderImpl) NewList() runtime.Object { - if b.NewListFunc == nil { - return nil - } - return b.NewListFunc() -} diff --git a/vendor/github.com/kubernetes-incubator/apiserver-builder/pkg/builders/api_version_builder.go b/vendor/github.com/kubernetes-incubator/apiserver-builder/pkg/builders/api_version_builder.go deleted file mode 100644 index 8e70489805..0000000000 --- a/vendor/github.com/kubernetes-incubator/apiserver-builder/pkg/builders/api_version_builder.go +++ /dev/null @@ -1,156 +0,0 @@ -/* -Copyright 2017 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package builders - -import ( - "github.com/golang/glog" - "k8s.io/apimachinery/pkg/apimachinery/announced" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apiserver/pkg/registry/generic" - "k8s.io/apiserver/pkg/registry/rest" - "reflect" -) - -type VersionedApiBuilder struct { - Kinds []*versionedResourceBuilder - GroupVersion schema.GroupVersion - SchemaBuilder runtime.SchemeBuilder -} - -func NewApiVersion(group, version string) *VersionedApiBuilder { - b := &VersionedApiBuilder{ - GroupVersion: schema.GroupVersion{group, version}, - } - b.SchemaBuilder = runtime.NewSchemeBuilder(b.registerTypes, b.registerDefaults, b.registerConversions) - return b -} - -// WithResources adds new resource types and subresources to the API versions -// resourceBuilders is a list of *versionedResourceBuilder -func (s *VersionedApiBuilder) WithResources(resourceBuilders ...*versionedResourceBuilder) *VersionedApiBuilder { - s.Kinds = append(s.Kinds, resourceBuilders...) - for _, b := range resourceBuilders { - s.SchemaBuilder.Register(b.SchemeFns.Register) - } - return s -} - -// registerVersionToScheme registers the version to scheme mapping -func (s *VersionedApiBuilder) registerVersionToScheme(to announced.VersionToSchemeFunc) { - to[s.GroupVersion.Version] = s.SchemaBuilder.AddToScheme -} - -// registerTypes registers all of the types in this API version -func (s *VersionedApiBuilder) registerTypes(scheme *runtime.Scheme) error { - for _, k := range s.Kinds { - // RegisterTypes type - if t := k.New(); t != nil { - scheme.AddKnownTypes(s.GroupVersion, t) // Register the versioned type - } - - // RegisterTypes list type if it exists - if l := k.NewList(); l != nil { - scheme.AddKnownTypes(s.GroupVersion, l) // Register the versioned type - } - } - metav1.AddToGroupVersion(scheme, s.GroupVersion) - return nil -} - -func (s *VersionedApiBuilder) registerDefaults(scheme *runtime.Scheme) error { - for _, k := range s.Kinds { - scheme.AddTypeDefaultingFunc(k.New(), k.SchemeFns.DefaultingFunction) - } - return nil -} - -func (s *VersionedApiBuilder) registerConversions(scheme *runtime.Scheme) error { - for _, k := range s.Kinds { - err := scheme.AddConversionFuncs(k.SchemeFns.GetConversionFunctions()...) - if err != nil { - glog.Errorf("Failed to add conversion functions %v", err) - return err - } - } - return nil -} - -// registerEndpoints registers the REST endpoints for all resources in this API group version -// group is the group to register the resources under -// optionsGetter is the RESTOptionsGetter provided by a server.Config -// registry is the server.APIGroupInfo VersionedResourcesStorageMap used to register REST endpoints -func (s *VersionedApiBuilder) registerEndpoints( - optionsGetter generic.RESTOptionsGetter, - registry map[string]map[string]rest.Storage) { - - // Register the endpoints for each kind - for _, k := range s.Kinds { - if _, found := registry[s.GroupVersion.Version]; !found { - // Initialize the version if missing - registry[s.GroupVersion.Version] = map[string]rest.Storage{} - } - // Register each of the endpoints in this version - k.registerEndpoints(s.GroupVersion.Group, optionsGetter, registry[s.GroupVersion.Version]) - } -} - -type UnVersionedApiBuilder struct { - Kinds []UnversionedResourceBuilder - GroupVersion schema.GroupVersion - SchemaBuilder runtime.SchemeBuilder -} - -func NewApiGroup(group string) *UnVersionedApiBuilder { - b := &UnVersionedApiBuilder{ - GroupVersion: schema.GroupVersion{group, runtime.APIVersionInternal}, - } - b.SchemaBuilder = runtime.NewSchemeBuilder(b.registerTypes) - return b -} - -func (s *UnVersionedApiBuilder) WithKinds(kinds ...UnversionedResourceBuilder) *UnVersionedApiBuilder { - s.Kinds = append(s.Kinds, kinds...) - return s -} - -func (s *UnVersionedApiBuilder) registerTypes(scheme *runtime.Scheme) error { - // Make sure we only each type once - typesToRegister := map[reflect.Type]runtime.Object{} - for _, k := range s.Kinds { - // RegisterTypes type - if t := k.New(); t != nil { - // Register the unversioned type - typesToRegister[reflect.TypeOf(t)] = t - } - - // RegisterTypes list type if it exists - if i, ok := k.(WithList); ok && i.NewList() != nil { - // Register the unversioned type - l := i.NewList() - typesToRegister[reflect.TypeOf(l)] = l - } - } - for _, t := range typesToRegister { - scheme.AddKnownTypes(s.GroupVersion, t) - } - - //fmt.Printf("Registering for group %v\n", s.GroupVersion) - //metav1.AddToGroupVersion(scheme, s.GroupVersion) - return nil -} diff --git a/vendor/github.com/kubernetes-incubator/apiserver-builder/pkg/builders/api_versioned_resource_builder.go b/vendor/github.com/kubernetes-incubator/apiserver-builder/pkg/builders/api_versioned_resource_builder.go deleted file mode 100644 index b557c3f9ae..0000000000 --- a/vendor/github.com/kubernetes-incubator/apiserver-builder/pkg/builders/api_versioned_resource_builder.go +++ /dev/null @@ -1,184 +0,0 @@ -/* -Copyright 2017 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package builders - -import ( - "fmt" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apiserver/pkg/endpoints/request" - "k8s.io/apiserver/pkg/registry/generic" - "k8s.io/apiserver/pkg/registry/generic/registry" - "k8s.io/apiserver/pkg/registry/rest" - "k8s.io/client-go/pkg/api" -) - -// -// Versioned Kind Builder builds a versioned resource using unversioned strategy -// - -// NewApiResource returns a new versionedResourceBuilder for registering endpoints for -// resources that are persisted to storage. -// strategy - unversionedBuilder from calling NewUnversionedXXX() -// new - function for creating new empty VERSIONED instances - e.g. func() runtime.Object { return &Deployment{} } -// newList - function for creating an empty list of VERSIONED instances - e.g. func() runtime.Object { return &DeploymentList{} } -// storeBuilder - builder for creating the store -func NewApiResource( - unversionedBuilder UnversionedResourceBuilder, - schemeFns SchemeFns, - new, newList func() runtime.Object, - storeBuilder StorageBuilder) *versionedResourceBuilder { - - if storeBuilder == nil { - storeBuilder = StorageStrategySingleton - } - - return &versionedResourceBuilder{ - unversionedBuilder, schemeFns, new, newList, storeBuilder, nil, nil, - } -} - -// NewApiResourceWithStorage returns a new versionedResourceBuilder for registering endpoints that -// does not require standard storage (e.g. subresources reuses the storage for the parent resource). -// strategy - unversionedBuilder from calling NewUnversionedXXX() -// new - function for creating new empty VERSIONED instances - e.g. func() runtime.Object { return &Deployment{} } -// storage - storage for manipulating the resource -func NewApiResourceWithStorage( - unversionedBuilder UnversionedResourceBuilder, - schemeFns SchemeFns, - new, newList func() runtime.Object, - storage rest.Storage) *versionedResourceBuilder { - v := &versionedResourceBuilder{ - unversionedBuilder, schemeFns, new, newList, nil, storage, nil, - } - if new == nil { - panic(fmt.Errorf("Cannot call NewApiResourceWithStorage with nil new function.")) - } - if storage == nil { - panic(fmt.Errorf("Cannot call NewApiResourceWithStorage with nil new storage.")) - } - return v -} - -type versionedResourceBuilder struct { - Unversioned UnversionedResourceBuilder - SchemeFns SchemeFns - - // NewFunc returns an empty unversioned instance of a resource - NewFunc func() runtime.Object - - // NewListFunc returns and empty unversioned instance of a resource List - NewListFunc func() runtime.Object - - // Store is used to modify the default storage, mutually exclusive with RESTFunc - StorageBuilder StorageBuilder - - // REST a rest.Store implementation, mutually exclusive with StoreFunc - REST rest.Storage - - Storage rest.StandardStorage -} - -func (b *versionedResourceBuilder) New() runtime.Object { - if b.NewFunc == nil { - return nil - } - return b.NewFunc() -} - -func (b *versionedResourceBuilder) NewList() runtime.Object { - if b.NewListFunc == nil { - return nil - } - return b.NewListFunc() -} - -type StorageWrapper struct { - registry.Store -} - -func (s StorageWrapper) Create(ctx request.Context, obj runtime.Object, includeUninitialized bool) (runtime.Object, error) { - return s.Store.Create(ctx, obj, false) -} - -func (b *versionedResourceBuilder) Build( - group string, - optionsGetter generic.RESTOptionsGetter) rest.StandardStorage { - - // Set a default strategy - wcs := 1000 - store := &StorageWrapper{registry.Store{ - Copier: api.Scheme, - NewFunc: b.Unversioned.New, // Use the unversioned type - NewListFunc: b.Unversioned.NewList, // Use the unversioned type - QualifiedResource: b.getGroupResource(group), - WatchCacheSize: &wcs, - }} - - // Use default, requires - options := &generic.StoreOptions{RESTOptions: optionsGetter} - - if b.StorageBuilder != nil { - // Allow overriding the storage defaults - b.StorageBuilder.Build(b.StorageBuilder, store, options) - } - - if err := store.CompleteWithOptions(options); err != nil { - panic(err) // TODO: Propagate error up - } - b.Storage = store - return store -} - -func (b *versionedResourceBuilder) GetStandardStorage() rest.StandardStorage { - return b.Storage -} - -// getGroupResource returns the GroupResource for this Resource and the provided Group -// group is the group the resource belongs to -func (b *versionedResourceBuilder) getGroupResource(group string) schema.GroupResource { - return schema.GroupResource{group, b.Unversioned.GetName()} - -} - -// registerEndpoints registers the REST endpoints for this resource in the registry -// group is the group to register the resource under -// optionsGetter is the RESTOptionsGetter provided by a server.Config -// registry is the server.APIGroupInfo VersionedResourcesStorageMap used to register REST endpoints -func (b *versionedResourceBuilder) registerEndpoints( - group string, - optionsGetter generic.RESTOptionsGetter, - registry map[string]rest.Storage) { - - // Register the endpoint - path := b.Unversioned.GetPath() - if len(path) > 0 { - // Subresources appear after the resource - path = b.Unversioned.GetName() + "/" + path - } else { - path = b.Unversioned.GetName() - } - - if b.REST != nil { - // Use the REST implementation directly. - registry[path] = b.REST - } else { - // Create a new REST implementation wired to storage. - registry[path] = b. - Build(group, optionsGetter) - } -} diff --git a/vendor/github.com/kubernetes-incubator/apiserver-builder/pkg/builders/default_scheme_fns.go b/vendor/github.com/kubernetes-incubator/apiserver-builder/pkg/builders/default_scheme_fns.go deleted file mode 100644 index 8aed5c862a..0000000000 --- a/vendor/github.com/kubernetes-incubator/apiserver-builder/pkg/builders/default_scheme_fns.go +++ /dev/null @@ -1,34 +0,0 @@ -/* -Copyright 2017 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package builders - -import ( - "k8s.io/apimachinery/pkg/runtime" -) - -var _ SchemeFns = &DefaultSchemeFns{} - -var SchemeFnsSingleton = DefaultSchemeFns{} - -type DefaultSchemeFns struct { -} - -func (DefaultSchemeFns) DefaultingFunction(interface{}) {} - -func (DefaultSchemeFns) GetConversionFunctions() []interface{} { return []interface{}{} } - -func (DefaultSchemeFns) Register(scheme *runtime.Scheme) error { return nil } diff --git a/vendor/github.com/kubernetes-incubator/apiserver-builder/pkg/builders/default_storage_strategy.go b/vendor/github.com/kubernetes-incubator/apiserver-builder/pkg/builders/default_storage_strategy.go deleted file mode 100644 index 53bb6fa8cf..0000000000 --- a/vendor/github.com/kubernetes-incubator/apiserver-builder/pkg/builders/default_storage_strategy.go +++ /dev/null @@ -1,159 +0,0 @@ -/* -Copyright 2017 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package builders - -import ( - "fmt" - "reflect" - - "k8s.io/apimachinery/pkg/fields" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/util/validation/field" - "k8s.io/apiserver/pkg/endpoints/request" - "k8s.io/apiserver/pkg/registry/generic" - "k8s.io/apiserver/pkg/registry/rest" - "k8s.io/apiserver/pkg/storage" - "k8s.io/apiserver/pkg/storage/names" - "k8s.io/client-go/pkg/api" -) - -var _ rest.RESTCreateStrategy = &DefaultStorageStrategy{} -var _ rest.RESTDeleteStrategy = &DefaultStorageStrategy{} -var _ rest.RESTUpdateStrategy = &DefaultStorageStrategy{} - -var StorageStrategySingleton = DefaultStorageStrategy{ - api.Scheme, - names.SimpleNameGenerator, -} - -type DefaultStorageStrategy struct { - runtime.ObjectTyper - names.NameGenerator -} - -func (DefaultStorageStrategy) ObjectNameFunc(obj runtime.Object) (string, error) { - switch obj := obj.(type) { - default: - return "", fmt.Errorf( - "Cannot get name for object type %T. Must implement HasObjectMeta or define "+ - "its own ObjectNameFunc in its storage strategy.", obj) - case HasObjectMeta: - // Get the name from the metadata - return obj.GetObjectMeta().Name, nil - } -} - -// Build sets the strategy for the store -func (DefaultStorageStrategy) Build(builder StorageBuilder, store *StorageWrapper, options *generic.StoreOptions) { - store.PredicateFunc = builder.BasicMatch - store.ObjectNameFunc = builder.ObjectNameFunc - store.CreateStrategy = builder - store.UpdateStrategy = builder - store.DeleteStrategy = builder - - options.AttrFunc = builder.GetAttrs -} - -func (DefaultStorageStrategy) NamespaceScoped() bool { return true } - -func (DefaultStorageStrategy) AllowCreateOnUpdate() bool { return true } - -func (DefaultStorageStrategy) AllowUnconditionalUpdate() bool { return true } - -func (DefaultStorageStrategy) Canonicalize(obj runtime.Object) {} - -func (DefaultStorageStrategy) PrepareForCreate(ctx request.Context, obj runtime.Object) { - switch t := obj.(type) { - default: - case HasObjectMetaSpecStatus: - // Clear the status if the resource has a Status - t.GetObjectMeta().Generation = 1 - t.SetStatus(t.NewStatus()) - } -} - -func (DefaultStorageStrategy) PrepareForUpdate(ctx request.Context, obj, old runtime.Object) { - // Don't update the status if the resource has a Status - switch n := obj.(type) { - default: - case HasObjectMetaSpecStatus: - o := old.(HasObjectMetaSpecStatus) - n.SetStatus(o.GetStatus()) - - // Spec and annotation updates bump the generation. - if !reflect.DeepEqual(n.GetSpec(), o.GetSpec()) || - !reflect.DeepEqual(n.GetObjectMeta().Annotations, o.GetObjectMeta().Annotations) { - n.GetObjectMeta().Generation = o.GetObjectMeta().Generation + 1 - } - } -} - -func (DefaultStorageStrategy) Validate(ctx request.Context, obj runtime.Object) field.ErrorList { - return field.ErrorList{} -} - -func (DefaultStorageStrategy) ValidateUpdate(ctx request.Context, obj, old runtime.Object) field.ErrorList { - return field.ErrorList{} -} - -func (b DefaultStorageStrategy) GetAttrs(obj runtime.Object) (labels.Set, fields.Set, bool, error) { - switch t := obj.(type) { - case HasObjectMeta: - apiserver := obj.(HasObjectMeta) - return labels.Set(apiserver.GetObjectMeta().Labels), b.GetSelectableFields(apiserver), false, nil - default: - return nil, nil, false, fmt.Errorf( - "Cannot get attributes for object type %v which does not implement HasObjectMeta.", t) - } -} - -// GetSelectableFields returns a field set that represents the object. -func (DefaultStorageStrategy) GetSelectableFields(obj HasObjectMeta) fields.Set { - return generic.ObjectMetaFieldsSet(obj.GetObjectMeta(), true) -} - -// MatchResource is the filter used by the generic etcd backend to watch events -// from etcd to clients of the apiserver only interested in specific labels/fields. -func (b DefaultStorageStrategy) BasicMatch(label labels.Selector, field fields.Selector) storage.SelectionPredicate { - return storage.SelectionPredicate{ - Label: label, - Field: field, - GetAttrs: b.GetAttrs, - } -} - -// -// Status Strategies -// - -var StatusStorageStrategySingleton = DefaultStatusStorageStrategy{StorageStrategySingleton} - -type DefaultStatusStorageStrategy struct { - DefaultStorageStrategy -} - -func (DefaultStatusStorageStrategy) PrepareForUpdate(ctx request.Context, obj, old runtime.Object) { - switch n := obj.(type) { - default: - case HasObjectMetaSpecStatus: - // Only update the Status - o := old.(HasObjectMetaSpecStatus) - n.SetSpec(o.GetSpec()) - n.GetObjectMeta().Labels = o.GetObjectMeta().Labels - } -} diff --git a/vendor/github.com/kubernetes-incubator/apiserver-builder/pkg/builders/resource_interfaces.go b/vendor/github.com/kubernetes-incubator/apiserver-builder/pkg/builders/resource_interfaces.go deleted file mode 100644 index 8807004a88..0000000000 --- a/vendor/github.com/kubernetes-incubator/apiserver-builder/pkg/builders/resource_interfaces.go +++ /dev/null @@ -1,81 +0,0 @@ -/* -Copyright 2017 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package builders - -import ( - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/fields" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/util/validation/field" - "k8s.io/apiserver/pkg/endpoints/request" - "k8s.io/apiserver/pkg/registry/generic" - "k8s.io/apiserver/pkg/registry/rest" - "k8s.io/apiserver/pkg/storage" - "k8s.io/apiserver/pkg/storage/names" -) - -type HasObjectMetaSpecStatus interface { - HasObjectMeta - HasSpec - HasStatus -} - -type HasStatus interface { - NewStatus() interface{} - GetStatus() interface{} - SetStatus(status interface{}) -} - -type HasSpec interface { - GetSpec() interface{} - SetSpec(spec interface{}) -} - -type HasObjectMeta interface { - GetObjectMeta() *metav1.ObjectMeta -} - -type StorageBuilder interface { - Build(builder StorageBuilder, store *StorageWrapper, options *generic.StoreOptions) - - names.NameGenerator - runtime.ObjectTyper - - ObjectNameFunc(obj runtime.Object) (string, error) - NamespaceScoped() bool - AllowCreateOnUpdate() bool - AllowUnconditionalUpdate() bool - Canonicalize(obj runtime.Object) - PrepareForCreate(ctx request.Context, obj runtime.Object) - PrepareForUpdate(ctx request.Context, obj, old runtime.Object) - Validate(ctx request.Context, obj runtime.Object) field.ErrorList - ValidateUpdate(ctx request.Context, obj, old runtime.Object) field.ErrorList - GetAttrs(obj runtime.Object) (labels.Set, fields.Set, bool, error) - GetSelectableFields(obj HasObjectMeta) fields.Set - BasicMatch(label labels.Selector, field fields.Selector) storage.SelectionPredicate -} - -type SchemeFns interface { - DefaultingFunction(obj interface{}) - GetConversionFunctions() []interface{} - Register(scheme *runtime.Scheme) error -} - -type StandardStorageProvider interface { - GetStandardStorage() rest.StandardStorage -} diff --git a/vendor/github.com/kubernetes-incubator/apiserver-builder/pkg/cmd/server/start.go b/vendor/github.com/kubernetes-incubator/apiserver-builder/pkg/cmd/server/start.go deleted file mode 100644 index acf8aa7baa..0000000000 --- a/vendor/github.com/kubernetes-incubator/apiserver-builder/pkg/cmd/server/start.go +++ /dev/null @@ -1,242 +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 server - -import ( - "fmt" - "io" - - "github.com/spf13/cobra" - flag "github.com/spf13/pflag" - - "github.com/kubernetes-incubator/apiserver-builder/pkg/apiserver" - "github.com/kubernetes-incubator/apiserver-builder/pkg/builders" - "k8s.io/apimachinery/pkg/runtime/schema" - genericapiserver "k8s.io/apiserver/pkg/server" - genericoptions "k8s.io/apiserver/pkg/server/options" - - "bytes" - "net/http" - "os" - - "github.com/golang/glog" - "github.com/kubernetes-incubator/apiserver-builder/pkg/validators" - "k8s.io/apimachinery/pkg/openapi" - "k8s.io/apimachinery/pkg/util/wait" - "k8s.io/apiserver/pkg/util/logs" - "k8s.io/client-go/pkg/api" -) - -var GetOpenApiDefinition openapi.GetOpenAPIDefinitions - -type ServerOptions struct { - RecommendedOptions *genericoptions.RecommendedOptions - APIBuilders []*builders.APIGroupBuilder - - PrintBearerToken bool - PrintOpenapi bool - RunDelegatedAuth bool - BearerToken string - PostStartHooks []PostStartHook -} - -type PostStartHook struct { - Fn genericapiserver.PostStartHookFunc - Name string -} - -// StartApiServer starts an apiserver hosting the provider apis and openapi definitions. -func StartApiServer(etcdPath string, apis []*builders.APIGroupBuilder, openapidefs openapi.GetOpenAPIDefinitions, title, version string) { - logs.InitLogs() - defer logs.FlushLogs() - - GetOpenApiDefinition = openapidefs - - // To disable providers, manually specify the list provided by getKnownProviders() - cmd, _ := NewCommandStartServer(etcdPath, os.Stdout, os.Stderr, apis, wait.NeverStop, title, version) - cmd.Flags().AddFlagSet(flag.CommandLine) - if err := cmd.Execute(); err != nil { - panic(err) - } -} - -func NewServerOptions(etcdPath string, out, errOut io.Writer, builders []*builders.APIGroupBuilder) *ServerOptions { - versions := []schema.GroupVersion{} - for _, b := range builders { - versions = append(versions, b.GetLegacyCodec()...) - } - - o := &ServerOptions{ - RecommendedOptions: genericoptions.NewRecommendedOptions(etcdPath, api.Scheme, api.Codecs.LegacyCodec(versions...)), - APIBuilders: builders, - RunDelegatedAuth: true, - } - o.RecommendedOptions.SecureServing.BindPort = 443 - - return o -} - -// NewCommandStartMaster provides a CLI handler for 'start master' command -func NewCommandStartServer(etcdPath string, out, errOut io.Writer, builders []*builders.APIGroupBuilder, - stopCh <-chan struct{}, title, version string) (*cobra.Command, *ServerOptions) { - o := NewServerOptions(etcdPath, out, errOut, builders) - - // Support overrides - cmd := &cobra.Command{ - Short: "Launch an API server", - Long: "Launch an API server", - RunE: func(c *cobra.Command, args []string) error { - if err := o.Complete(); err != nil { - return err - } - if err := o.Validate(args); err != nil { - return err - } - if err := o.RunServer(stopCh, title, version); err != nil { - return err - } - return nil - }, - } - - flags := cmd.Flags() - flags.BoolVar(&o.PrintBearerToken, "print-bearer-token", false, - "Print a curl command with the bearer token to test the server") - flags.BoolVar(&o.PrintOpenapi, "print-openapi", false, - "Print the openapi json and exit") - flags.BoolVar(&o.RunDelegatedAuth, "delegated-auth", true, - "Setup delegated auth") - o.RecommendedOptions.AddFlags(flags) - return cmd, o -} - -func (o ServerOptions) Validate(args []string) error { - return nil -} - -func (o *ServerOptions) Complete() error { - return nil -} - -func applyOptions(config *genericapiserver.Config, applyTo ...func(*genericapiserver.Config) error) error { - for _, fn := range applyTo { - if err := fn(config); err != nil { - return err - } - } - return nil -} - -func (o ServerOptions) Config() (*apiserver.Config, error) { - // TODO have a "real" external address - if err := o.RecommendedOptions.SecureServing.MaybeDefaultWithSelfSignedCerts( - "localhost", nil, nil); err != nil { - - return nil, fmt.Errorf("error creating self-signed certificates: %v", err) - } - - serverConfig := genericapiserver.NewConfig(api.Codecs) - - err := applyOptions( - serverConfig, - o.RecommendedOptions.Etcd.ApplyTo, - o.RecommendedOptions.SecureServing.ApplyTo, - o.RecommendedOptions.Audit.ApplyTo, - o.RecommendedOptions.Features.ApplyTo, - ) - if err != nil { - return nil, err - } - - if o.RunDelegatedAuth { - err := applyOptions( - serverConfig, - o.RecommendedOptions.Authentication.ApplyTo, - o.RecommendedOptions.Authorization.ApplyTo, - ) - if err != nil { - return nil, err - } - } - - config := &apiserver.Config{GenericConfig: serverConfig} - return config, nil -} - -func (o *ServerOptions) RunServer(stopCh <-chan struct{}, title, version string) error { - config, err := o.Config() - if err != nil { - return err - } - - config.GenericConfig.OpenAPIConfig = genericapiserver.DefaultOpenAPIConfig(GetOpenApiDefinition, api.Scheme) - config.GenericConfig.OpenAPIConfig.Info.Title = title - config.GenericConfig.OpenAPIConfig.Info.Version = version - - if o.PrintBearerToken { - glog.Infof("Serving on loopback...") - glog.Infof("\n\n********************************\nTo test the server run:\n"+ - "curl -k -H \"Authorization: Bearer %s\" %s\n********************************\n\n", - config.GenericConfig.LoopbackClientConfig.BearerToken, - config.GenericConfig.LoopbackClientConfig.Host) - } - o.BearerToken = config.GenericConfig.LoopbackClientConfig.BearerToken - - for _, provider := range o.APIBuilders { - config.AddApi(provider) - } - - server, err := config.Init().Complete().New() - if err != nil { - return err - } - - for _, h := range o.PostStartHooks { - server.GenericAPIServer.AddPostStartHook(h.Name, h.Fn) - } - - s := server.GenericAPIServer.PrepareRun() - err = validators.OpenAPI.SetSchema(readOpenapi(server.GenericAPIServer.Handler)) - if o.PrintOpenapi { - fmt.Printf("%s", validators.OpenAPI.OpenApi) - os.Exit(0) - } - if err != nil { - return err - } - - s.Run(stopCh) - - return nil -} - -func readOpenapi(handler *genericapiserver.APIServerHandler) string { - req, err := http.NewRequest("GET", "/swagger.json", nil) - if err != nil { - panic(fmt.Errorf("Could not create openapi request %v", err)) - } - resp := &BufferedResponse{} - handler.ServeHTTP(resp, req) - return resp.String() -} - -type BufferedResponse struct { - bytes.Buffer -} - -func (BufferedResponse) Header() http.Header { return http.Header{} } -func (BufferedResponse) WriteHeader(int) {} diff --git a/vendor/github.com/kubernetes-incubator/apiserver-builder/pkg/controller/controller.go b/vendor/github.com/kubernetes-incubator/apiserver-builder/pkg/controller/controller.go deleted file mode 100644 index 88084586fb..0000000000 --- a/vendor/github.com/kubernetes-incubator/apiserver-builder/pkg/controller/controller.go +++ /dev/null @@ -1,141 +0,0 @@ -/* -Copyright 2017 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package controller - -import ( - "time" - - "github.com/golang/glog" - "k8s.io/apimachinery/pkg/util/runtime" - "k8s.io/apimachinery/pkg/util/wait" - "k8s.io/client-go/rest" - "k8s.io/client-go/tools/cache" - "k8s.io/client-go/tools/clientcmd" - "k8s.io/client-go/util/workqueue" -) - -// QueueingEventHandler queues the key for the object on add and update events -type QueueingEventHandler struct { - Queue workqueue.RateLimitingInterface -} - -func (c *QueueingEventHandler) enqueue(obj interface{}) { - key, err := cache.DeletionHandlingMetaNamespaceKeyFunc(obj) - if err != nil { - glog.Errorf("Couldn't get key for object %+v: %v", obj, err) - return - } - c.Queue.Add(key) -} - -func (c *QueueingEventHandler) OnAdd(obj interface{}) { - glog.V(6).Infof("Add event for %+v\n", obj) - c.enqueue(obj) -} - -func (c *QueueingEventHandler) OnUpdate(oldObj, newObj interface{}) { - glog.V(6).Infof("Update event for %+v\n", newObj) - c.enqueue(newObj) -} - -func (c *QueueingEventHandler) OnDelete(obj interface{}) { - glog.V(6).Infof("Delete event for %+v\n", obj) -} - -// QueueWorker continuously runs a Reconcile function against a message Queue -type QueueWorker struct { - Queue workqueue.RateLimitingInterface - MaxRetries int - Name string - Reconcile func(key string) error -} - -// Run schedules a routine to continuously process Queue messages -// until shutdown is closed -func (q *QueueWorker) Run(shutdown <-chan struct{}) { - defer runtime.HandleCrash() - - // Every second, process all messages in the Queue until it is time to shutdown - go wait.Until(q.ProcessAllMessages, time.Second, shutdown) - - go func() { - <-shutdown - - // Stop accepting messages into the Queue - glog.V(1).Infof("Shutting down %s Queue\n", q.Name) - q.Queue.ShutDown() - }() -} - -// ProcessAllMessages tries to process all messages in the Queue -func (q *QueueWorker) ProcessAllMessages() { - for done := false; !done; { - // Process all messages in the Queue - done = q.ProcessMessage() - } -} - -// ProcessMessage tries to process the next message in the Queue, and requeues on an error -func (q *QueueWorker) ProcessMessage() bool { - key, quit := q.Queue.Get() - if quit { - // Queue is empty - return true - } - defer q.Queue.Done(key) - - // Do the work - err := q.Reconcile(key.(string)) - if err == nil { - // Success. Clear the requeue count for this key. - q.Queue.Forget(key) - return false - } - - // Error. Maybe retry if haven't hit the limit. - if q.Queue.NumRequeues(key) < q.MaxRetries { - glog.V(4).Infof("Error handling %s Queue message %v: %v", q.Name, key, err) - q.Queue.AddRateLimited(key) - return false - } - - glog.V(4).Infof("Too many retries for %s Queue message %v: %v", q.Name, key, err) - q.Queue.Forget(key) - return false -} - -type Controller interface { - Run(stopCh <-chan struct{}) - GetName() string -} - -// StartControllerManager -func StartControllerManager(controllers ...Controller) <-chan struct{} { - shutdown := make(chan struct{}) - for _, c := range controllers { - c.Run(shutdown) - } - return shutdown -} - -func GetConfig(kubeconfig string) (*rest.Config, error) { - if len(kubeconfig) > 0 { - return clientcmd.BuildConfigFromFlags("", kubeconfig) - } else { - return rest.InClusterConfig() - } -} diff --git a/vendor/github.com/kubernetes-incubator/apiserver-builder/pkg/test/client.go b/vendor/github.com/kubernetes-incubator/apiserver-builder/pkg/test/client.go deleted file mode 100644 index ec5251d5a4..0000000000 --- a/vendor/github.com/kubernetes-incubator/apiserver-builder/pkg/test/client.go +++ /dev/null @@ -1,17 +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 test diff --git a/vendor/github.com/kubernetes-incubator/apiserver-builder/pkg/test/ginkgo.go b/vendor/github.com/kubernetes-incubator/apiserver-builder/pkg/test/ginkgo.go deleted file mode 100644 index 3b01fe11e5..0000000000 --- a/vendor/github.com/kubernetes-incubator/apiserver-builder/pkg/test/ginkgo.go +++ /dev/null @@ -1,41 +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 test - -import ( - "fmt" - - . "github.com/onsi/ginkgo/config" - . "github.com/onsi/ginkgo/types" -) - -// Print a newline after the default Reporter due to issue -// https://github.com/jstemmer/go-junit-report/issues/31 -type NewlineReporter struct{} - -func (NewlineReporter) SpecSuiteWillBegin(config GinkgoConfigType, summary *SuiteSummary) {} - -func (NewlineReporter) BeforeSuiteDidRun(setupSummary *SetupSummary) {} - -func (NewlineReporter) AfterSuiteDidRun(setupSummary *SetupSummary) {} - -func (NewlineReporter) SpecWillRun(specSummary *SpecSummary) {} - -func (NewlineReporter) SpecDidComplete(specSummary *SpecSummary) {} - -// SpecSuiteDidEnd Prints a newline between "35 Passed | 0 Failed | 0 Pending | 0 Skipped" and "--- PASS:" -func (NewlineReporter) SpecSuiteDidEnd(summary *SuiteSummary) { fmt.Printf("\n") } diff --git a/vendor/github.com/kubernetes-incubator/apiserver-builder/pkg/test/server.go b/vendor/github.com/kubernetes-incubator/apiserver-builder/pkg/test/server.go deleted file mode 100644 index f90bf0e741..0000000000 --- a/vendor/github.com/kubernetes-incubator/apiserver-builder/pkg/test/server.go +++ /dev/null @@ -1,196 +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 test - -import ( - "bufio" - "fmt" - "io" - "io/ioutil" - "net" - "os/exec" - "regexp" - "strconv" - "strings" - "time" - - "github.com/kubernetes-incubator/apiserver-builder/pkg/builders" - "github.com/kubernetes-incubator/apiserver-builder/pkg/cmd/server" - openapi "k8s.io/apimachinery/pkg/openapi" - genericapiserver "k8s.io/apiserver/pkg/server" - genericoptions "k8s.io/apiserver/pkg/server/options" - "k8s.io/client-go/rest" -) - -type TestEnvironment struct { - StopServer chan struct{} - ServerOuput *io.PipeWriter - ApiserverPort int - BearerToken string - EtcdClientPort int - EtcdPeerPort int - EtcdPath string - EtcdCmd *exec.Cmd - Done bool -} - -func NewTestEnvironment() *TestEnvironment { - return &TestEnvironment{ - EtcdPath: "/registry/test.kubernetes.io", - } -} - -func (te *TestEnvironment) getPort() int { - l, _ := net.Listen("tcp", ":0") - defer l.Close() - println(l.Addr().String()) - pieces := strings.Split(l.Addr().String(), ":") - i, err := strconv.Atoi(pieces[len(pieces)-1]) - if err != nil { - panic(err) - } - return i -} - -// Stop stops a running server -func (te *TestEnvironment) Stop() { - te.Done = true - te.StopServer <- struct{}{} - te.EtcdCmd.Process.Kill() -} - -// Start starts a local Kubernetes server and updates te.ApiserverPort with the port it is listening on -func (te *TestEnvironment) Start( - apis []*builders.APIGroupBuilder, openapidefs openapi.GetOpenAPIDefinitions) *rest.Config { - - te.EtcdClientPort = te.getPort() - te.EtcdPeerPort = te.getPort() - te.ApiserverPort = te.getPort() - - etcdready := make(chan string) - go te.startEtcd(etcdready) - - // Wait for etcd to start - // TODO: Poll the /health address to wait for etcd to become healthy - time.Sleep(time.Second * 1) - - apiserverready := make(chan *rest.Config) - go te.startApiserver(apiserverready, apis, openapidefs) - - // Wait for everything to be ready - loopback := <-apiserverready - <-etcdready - return loopback -} - -func (te *TestEnvironment) startApiserver( - ready chan *rest.Config, apis []*builders.APIGroupBuilder, openapidefs openapi.GetOpenAPIDefinitions) { - te.StopServer = make(chan struct{}) - _, te.ServerOuput = io.Pipe() - server.GetOpenApiDefinition = openapidefs - cmd, options := server.NewCommandStartServer( - te.EtcdPath, - te.ServerOuput, te.ServerOuput, apis, te.StopServer, "API", "v0") - - options.RecommendedOptions.SecureServing.BindPort = te.ApiserverPort - options.RunDelegatedAuth = false - options.RecommendedOptions.Etcd.StorageConfig.ServerList = []string{ - fmt.Sprintf("http://localhost:%d", te.EtcdClientPort), - } - tmpdir, err := ioutil.TempDir("", "apiserver-test") - if err != nil { - panic(fmt.Sprintf("Could not create temp dir for testing: %v", err)) - } - options.RecommendedOptions.SecureServing.ServerCert = genericoptions.GeneratableKeyCert{ - CertDirectory: tmpdir, - } - - // Notify once the apiserver is ready to serve traffic - options.PostStartHooks = []server.PostStartHook{ - { - func(context genericapiserver.PostStartHookContext) error { - // Let the test know the server is ready - ready <- context.LoopbackClientConfig - return nil - }, - "apiserver-ready", - }, - } - - if err := cmd.Execute(); err != nil { - panic(err) - } -} - -// startEtcd starts a new etcd process using a random temp data directory and random free port -func (te *TestEnvironment) startEtcd(ready chan string) { - dirname, err := ioutil.TempDir("/tmp", "apiserver-test") - if err != nil { - panic(err) - } - - clientAddr := fmt.Sprintf("http://localhost:%d", te.EtcdClientPort) - peerAddr := fmt.Sprintf("http://localhost:%d", te.EtcdPeerPort) - cmd := exec.Command( - "etcd", - "--data-dir", dirname, - "--listen-client-urls", clientAddr, - "--listen-peer-urls", peerAddr, - "--advertise-client-urls", clientAddr, - ) - te.EtcdCmd = cmd - stdout, err := cmd.StdoutPipe() - if err != nil { - panic(err) - } - stderr, err := cmd.StderrPipe() - if err != nil { - panic(err) - } - - err = cmd.Start() - if err != nil { - panic(err) - } - - go te.waitForEtcdReady(ready, stdout) - go te.waitForEtcdReady(ready, stderr) - - err = cmd.Wait() - if err != nil && !te.Done { - panic(err) - } -} - -// waitForEtcdReady notify's read once the etcd instances is ready to receive traffic -func (te *TestEnvironment) waitForEtcdReady(ready chan string, reader io.Reader) { - started := regexp.MustCompile("serving insecure client requests on (.+), this is strongly discouraged!") - buffered := bufio.NewReader(reader) - for { - l, _, err := buffered.ReadLine() - if err != nil { - time.Sleep(time.Second * 5) - } - line := string(l) - if started.MatchString(line) { - addr := started.FindStringSubmatch(line)[1] - // etcd is ready - ready <- addr - return - } - } -} diff --git a/vendor/github.com/kubernetes-incubator/apiserver-builder/pkg/validators/openapi.go b/vendor/github.com/kubernetes-incubator/apiserver-builder/pkg/validators/openapi.go deleted file mode 100644 index bcf4b6c3b8..0000000000 --- a/vendor/github.com/kubernetes-incubator/apiserver-builder/pkg/validators/openapi.go +++ /dev/null @@ -1,29 +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 validators - -var OpenAPI = OpenAPIValidator{} - -type OpenAPIValidator struct { - OpenApi string -} - -func (o *OpenAPIValidator) SetSchema(openapi string) error { - var err error - o.OpenApi = openapi - return err -} diff --git a/vendor/github.com/kubernetes-incubator/apiserver-builder/scripts/install_etcd.sh b/vendor/github.com/kubernetes-incubator/apiserver-builder/scripts/install_etcd.sh deleted file mode 100755 index 4d0d39682a..0000000000 --- a/vendor/github.com/kubernetes-incubator/apiserver-builder/scripts/install_etcd.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env bash - -# Copied from https://github.com/coreos/etcd/releases instructions - -ETCD_VER=v3.2.0 - -# choose either URL -GOOGLE_URL=https://storage.googleapis.com/etcd -GITHUB_URL=https://github.com/coreos/etcd/releases/download -DOWNLOAD_URL=${GOOGLE_URL} - -rm -f /tmp/etcd-${ETCD_VER}-linux-amd64.tar.gz -rm -rf /tmp/test-etcd && mkdir -p /tmp/test-etcd - -curl -L ${DOWNLOAD_URL}/${ETCD_VER}/etcd-${ETCD_VER}-linux-amd64.tar.gz -o /tmp/etcd-${ETCD_VER}-linux-amd64.tar.gz -tar xzvf /tmp/etcd-${ETCD_VER}-linux-amd64.tar.gz -C /tmp/test-etcd --strip-components=1 diff --git a/vendor/k8s.io/klog/.travis.yml b/vendor/k8s.io/klog/.travis.yml new file mode 100644 index 0000000000..fc0d2caf33 --- /dev/null +++ b/vendor/k8s.io/klog/.travis.yml @@ -0,0 +1,14 @@ +language: go +dist: xenial +go: + - 1.9.x + - 1.10.x + - 1.11.x +script: + - go get -t -v ./... + - diff -u <(echo -n) <(gofmt -d .) + - diff -u <(echo -n) <(golint $(go list -e ./...)) + - go tool vet . + - go test -v -race ./... +install: + - go get golang.org/x/lint/golint diff --git a/vendor/k8s.io/klog/CONTRIBUTING.md b/vendor/k8s.io/klog/CONTRIBUTING.md new file mode 100644 index 0000000000..de47115137 --- /dev/null +++ b/vendor/k8s.io/klog/CONTRIBUTING.md @@ -0,0 +1,31 @@ +# Contributing Guidelines + +Welcome to Kubernetes. We are excited about the prospect of you joining our [community](https://github.com/kubernetes/community)! The Kubernetes community abides by the CNCF [code of conduct](code-of-conduct.md). Here is an excerpt: + +_As contributors and maintainers of this project, and in the interest of fostering an open and welcoming community, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities._ + +## Getting Started + +We have full documentation on how to get started contributing here: + + + +- [Contributor License Agreement](https://git.k8s.io/community/CLA.md) Kubernetes projects require that you sign a Contributor License Agreement (CLA) before we can accept your pull requests +- [Kubernetes Contributor Guide](http://git.k8s.io/community/contributors/guide) - Main contributor documentation, or you can just jump directly to the [contributing section](http://git.k8s.io/community/contributors/guide#contributing) +- [Contributor Cheat Sheet](https://git.k8s.io/community/contributors/guide/contributor-cheatsheet.md) - Common resources for existing developers + +## Mentorship + +- [Mentoring Initiatives](https://git.k8s.io/community/mentoring) - We have a diverse set of mentorship programs available that are always looking for volunteers! + + diff --git a/vendor/k8s.io/klog/LICENSE b/vendor/k8s.io/klog/LICENSE new file mode 100644 index 0000000000..37ec93a14f --- /dev/null +++ b/vendor/k8s.io/klog/LICENSE @@ -0,0 +1,191 @@ +Apache License +Version 2.0, January 2004 +http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + +"License" shall mean the terms and conditions for use, reproduction, and +distribution as defined by Sections 1 through 9 of this document. + +"Licensor" shall mean the copyright owner or entity authorized by the copyright +owner that is granting the License. + +"Legal Entity" shall mean the union of the acting entity and all other entities +that control, are controlled by, or are under common control with that entity. +For the purposes of this definition, "control" means (i) the power, direct or +indirect, to cause the direction or management of such entity, whether by +contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the +outstanding shares, or (iii) beneficial ownership of such entity. + +"You" (or "Your") shall mean an individual or Legal Entity exercising +permissions granted by this License. + +"Source" form shall mean the preferred form for making modifications, including +but not limited to software source code, documentation source, and configuration +files. + +"Object" form shall mean any form resulting from mechanical transformation or +translation of a Source form, including but not limited to compiled object code, +generated documentation, and conversions to other media types. + +"Work" shall mean the work of authorship, whether in Source or Object form, made +available under the License, as indicated by a copyright notice that is included +in or attached to the work (an example is provided in the Appendix below). + +"Derivative Works" shall mean any work, whether in Source or Object form, that +is based on (or derived from) the Work and for which the editorial revisions, +annotations, elaborations, or other modifications represent, as a whole, an +original work of authorship. For the purposes of this License, Derivative Works +shall not include works that remain separable from, or merely link (or bind by +name) to the interfaces of, the Work and Derivative Works thereof. + +"Contribution" shall mean any work of authorship, including the original version +of the Work and any modifications or additions to that Work or Derivative Works +thereof, that is intentionally submitted to Licensor for inclusion in the Work +by the copyright owner or by an individual or Legal Entity authorized to submit +on behalf of the copyright owner. For the purposes of this definition, +"submitted" means any form of electronic, verbal, or written communication sent +to the Licensor or its representatives, including but not limited to +communication on electronic mailing lists, source code control systems, and +issue tracking systems that are managed by, or on behalf of, the Licensor for +the purpose of discussing and improving the Work, but excluding communication +that is conspicuously marked or otherwise designated in writing by the copyright +owner as "Not a Contribution." + +"Contributor" shall mean Licensor and any individual or Legal Entity on behalf +of whom a Contribution has been received by Licensor and subsequently +incorporated within the Work. + +2. Grant of Copyright License. + +Subject to the terms and conditions of this License, each Contributor hereby +grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, +irrevocable copyright license to reproduce, prepare Derivative Works of, +publicly display, publicly perform, sublicense, and distribute the Work and such +Derivative Works in Source or Object form. + +3. Grant of Patent License. + +Subject to the terms and conditions of this License, each Contributor hereby +grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, +irrevocable (except as stated in this section) patent license to make, have +made, use, offer to sell, sell, import, and otherwise transfer the Work, where +such license applies only to those patent claims licensable by such Contributor +that are necessarily infringed by their Contribution(s) alone or by combination +of their Contribution(s) with the Work to which such Contribution(s) was +submitted. If You institute patent litigation against any entity (including a +cross-claim or counterclaim in a lawsuit) alleging that the Work or a +Contribution incorporated within the Work constitutes direct or contributory +patent infringement, then any patent licenses granted to You under this License +for that Work shall terminate as of the date such litigation is filed. + +4. Redistribution. + +You may reproduce and distribute copies of the Work or Derivative Works thereof +in any medium, with or without modifications, and in Source or Object form, +provided that You meet the following conditions: + +You must give any other recipients of the Work or Derivative Works a copy of +this License; and +You must cause any modified files to carry prominent notices stating that You +changed the files; and +You must retain, in the Source form of any Derivative Works that You distribute, +all copyright, patent, trademark, and attribution notices from the Source form +of the Work, excluding those notices that do not pertain to any part of the +Derivative Works; and +If the Work includes a "NOTICE" text file as part of its distribution, then any +Derivative Works that You distribute must include a readable copy of the +attribution notices contained within such NOTICE file, excluding those notices +that do not pertain to any part of the Derivative Works, in at least one of the +following places: within a NOTICE text file distributed as part of the +Derivative Works; within the Source form or documentation, if provided along +with the Derivative Works; or, within a display generated by the Derivative +Works, if and wherever such third-party notices normally appear. The contents of +the NOTICE file are for informational purposes only and do not modify the +License. You may add Your own attribution notices within Derivative Works that +You distribute, alongside or as an addendum to the NOTICE text from the Work, +provided that such additional attribution notices cannot be construed as +modifying the License. +You may add Your own copyright statement to Your modifications and may provide +additional or different license terms and conditions for use, reproduction, or +distribution of Your modifications, or for any such Derivative Works as a whole, +provided Your use, reproduction, and distribution of the Work otherwise complies +with the conditions stated in this License. + +5. Submission of Contributions. + +Unless You explicitly state otherwise, any Contribution intentionally submitted +for inclusion in the Work by You to the Licensor shall be under the terms and +conditions of this License, without any additional terms or conditions. +Notwithstanding the above, nothing herein shall supersede or modify the terms of +any separate license agreement you may have executed with Licensor regarding +such Contributions. + +6. Trademarks. + +This License does not grant permission to use the trade names, trademarks, +service marks, or product names of the Licensor, except as required for +reasonable and customary use in describing the origin of the Work and +reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. + +Unless required by applicable law or agreed to in writing, Licensor provides the +Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, +including, without limitation, any warranties or conditions of TITLE, +NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are +solely responsible for determining the appropriateness of using or +redistributing the Work and assume any risks associated with Your exercise of +permissions under this License. + +8. Limitation of Liability. + +In no event and under no legal theory, whether in tort (including negligence), +contract, or otherwise, unless required by applicable law (such as deliberate +and grossly negligent acts) or agreed to in writing, shall any Contributor be +liable to You for damages, including any direct, indirect, special, incidental, +or consequential damages of any character arising as a result of this License or +out of the use or inability to use the Work (including but not limited to +damages for loss of goodwill, work stoppage, computer failure or malfunction, or +any and all other commercial damages or losses), even if such Contributor has +been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. + +While redistributing the Work or Derivative Works thereof, You may choose to +offer, and charge a fee for, acceptance of support, warranty, indemnity, or +other liability obligations and/or rights consistent with this License. However, +in accepting such obligations, You may act only on Your own behalf and on Your +sole responsibility, not on behalf of any other Contributor, and only if You +agree to indemnify, defend, and hold each Contributor harmless for any liability +incurred by, or claims asserted against, such Contributor by reason of your +accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work + +To apply the Apache License to your work, attach the following boilerplate +notice, with the fields enclosed by brackets "[]" replaced with your own +identifying information. (Don't include the brackets!) The text should be +enclosed in the appropriate comment syntax for the file format. We also +recommend that a file or class name and description of purpose be included on +the same "printed page" as the copyright notice for easier identification within +third-party archives. + + 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. + 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. diff --git a/vendor/k8s.io/klog/OWNERS b/vendor/k8s.io/klog/OWNERS new file mode 100644 index 0000000000..56b0eb044f --- /dev/null +++ b/vendor/k8s.io/klog/OWNERS @@ -0,0 +1,11 @@ +# See the OWNERS docs: https://git.k8s.io/community/contributors/guide/owners.md + +approvers: + - dims + - thockin + - justinsb + - tallclair + - piosz + - brancz + - DirectXMan12 + - lavalamp diff --git a/vendor/k8s.io/klog/README.md b/vendor/k8s.io/klog/README.md new file mode 100644 index 0000000000..a747f538a8 --- /dev/null +++ b/vendor/k8s.io/klog/README.md @@ -0,0 +1,51 @@ +klog +==== + +klog is a permanant fork of https://github.com/golang/glog. original README from glog is below + +---- + +glog +==== + +Leveled execution logs for Go. + +This is an efficient pure Go implementation of leveled logs in the +manner of the open source C++ package + https://github.com/google/glog + +By binding methods to booleans it is possible to use the log package +without paying the expense of evaluating the arguments to the log. +Through the -vmodule flag, the package also provides fine-grained +control over logging at the file level. + +The comment from glog.go introduces the ideas: + + Package glog implements logging analogous to the Google-internal + C++ INFO/ERROR/V setup. It provides functions Info, Warning, + Error, Fatal, plus formatting variants such as Infof. It + also provides V-style logging controlled by the -v and + -vmodule=file=2 flags. + + Basic examples: + + glog.Info("Prepare to repel boarders") + + glog.Fatalf("Initialization failed: %s", err) + + See the documentation for the V function for an explanation + of these examples: + + if glog.V(2) { + glog.Info("Starting transaction...") + } + + glog.V(2).Infoln("Processed", nItems, "elements") + + +The repository contains an open source version of the log package +used inside Google. The master copy of the source lives inside +Google, not here. The code in this repo is for export only and is not itself +under development. Feature requests will be ignored. + +Send bug reports to golang-nuts@googlegroups.com. diff --git a/vendor/k8s.io/klog/RELEASE.md b/vendor/k8s.io/klog/RELEASE.md new file mode 100644 index 0000000000..b53eb960ce --- /dev/null +++ b/vendor/k8s.io/klog/RELEASE.md @@ -0,0 +1,9 @@ +# Release Process + +The `klog` is released on an as-needed basis. The process is as follows: + +1. An issue is proposing a new release with a changelog since the last release +1. All [OWNERS](OWNERS) must LGTM this release +1. An OWNER runs `git tag -s $VERSION` and inserts the changelog and pushes the tag with `git push $VERSION` +1. The release issue is closed +1. An announcement email is sent to `kubernetes-dev@googlegroups.com` with the subject `[ANNOUNCE] kubernetes-template-project $VERSION is released` diff --git a/vendor/k8s.io/klog/SECURITY_CONTACTS b/vendor/k8s.io/klog/SECURITY_CONTACTS new file mode 100644 index 0000000000..520ddb5257 --- /dev/null +++ b/vendor/k8s.io/klog/SECURITY_CONTACTS @@ -0,0 +1,20 @@ +# Defined below are the security contacts for this repo. +# +# They are the contact point for the Product Security Team to reach out +# to for triaging and handling of incoming issues. +# +# The below names agree to abide by the +# [Embargo Policy](https://github.com/kubernetes/sig-release/blob/master/security-release-process-documentation/security-release-process.md#embargo-policy) +# and will be removed and replaced if they violate that agreement. +# +# DO NOT REPORT SECURITY VULNERABILITIES DIRECTLY TO THESE NAMES, FOLLOW THE +# INSTRUCTIONS AT https://kubernetes.io/security/ + +dims +thockin +justinsb +tallclair +piosz +brancz +DirectXMan12 +lavalamp diff --git a/vendor/k8s.io/klog/examples/coexist_glog/coexist_glog.go b/vendor/k8s.io/klog/examples/coexist_glog/coexist_glog.go new file mode 100644 index 0000000000..71087bc0c6 --- /dev/null +++ b/vendor/k8s.io/klog/examples/coexist_glog/coexist_glog.go @@ -0,0 +1,28 @@ +package main + +import ( + "flag" + "github.com/golang/glog" + "k8s.io/klog" +) + +type glogWriter struct{} + +func (file *glogWriter) Write(data []byte) (n int, err error) { + glog.InfoDepth(0, string(data)) + return len(data), nil +} + +func main() { + flag.Set("alsologtostderr", "true") + + var flags flag.FlagSet + klog.InitFlags(&flags) + flags.Set("skip_headers", "true") + flag.Parse() + + klog.SetOutput(&glogWriter{}) + klog.Info("nice to meet you") + glog.Flush() + klog.Flush() +} diff --git a/vendor/k8s.io/klog/examples/log_file/usage_log_file.go b/vendor/k8s.io/klog/examples/log_file/usage_log_file.go new file mode 100644 index 0000000000..42b7d89906 --- /dev/null +++ b/vendor/k8s.io/klog/examples/log_file/usage_log_file.go @@ -0,0 +1,14 @@ +package main + +import ( + "flag" + "k8s.io/klog" +) + +func main() { + klog.InitFlags(nil) + flag.Set("log_file", "myfile.log") + flag.Parse() + klog.Info("nice to meet you") + klog.Flush() +} diff --git a/vendor/k8s.io/klog/examples/set_output/usage_set_output.go b/vendor/k8s.io/klog/examples/set_output/usage_set_output.go new file mode 100644 index 0000000000..6d4d5c5435 --- /dev/null +++ b/vendor/k8s.io/klog/examples/set_output/usage_set_output.go @@ -0,0 +1,22 @@ +package main + +import ( + "bytes" + "flag" + "fmt" + "k8s.io/klog" +) + +func main() { + klog.InitFlags(nil) + flag.Set("logtostderr", "false") + flag.Set("alsologtostderr", "false") + flag.Parse() + + buf := new(bytes.Buffer) + klog.SetOutput(buf) + klog.Info("nice to meet you") + klog.Flush() + + fmt.Printf("LOGGED: %s", buf.String()) +} diff --git a/vendor/k8s.io/klog/glog/README.md b/vendor/k8s.io/klog/glog/README.md new file mode 100644 index 0000000000..f1b7ccddbb --- /dev/null +++ b/vendor/k8s.io/klog/glog/README.md @@ -0,0 +1,9 @@ +# glog + +This repo contains a package that exposes an API subset of the [glog](https://github.com/golang/glog) package. +All logging state delivered to this package is shunted to the global [klog logger](https://github.com/kubernetes/klog). + +This package makes it so we can intercept the calls to glog and redirect them to klog and thus produce +a consistent log for our processes. + +This code was inspired by https://github.com/istio/glog/ diff --git a/vendor/k8s.io/klog/glog/glog.go b/vendor/k8s.io/klog/glog/glog.go new file mode 100644 index 0000000000..f4c0c1ff21 --- /dev/null +++ b/vendor/k8s.io/klog/glog/glog.go @@ -0,0 +1,160 @@ +// Copyright 2017 Istio 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 glog exposes an API subset of the [glog](https://github.com/golang/glog) package. +// All logging state delivered to this package is shunted to the global [klog logger](ttps://github.com/kubernetes/klog). +// +// We depend on some downstream components that use glog for logging. This package makes it so we can intercept +// the calls to glog and redirect them to klog and thus produce a consistent log for our processes. +package glog + +import ( + "k8s.io/klog" +) + +// Level is a shim +type Level int32 + +// Verbose is a shim +type Verbose bool + +// Flush is a shim +func Flush() { +} + +// V is a shim +func V(level Level) Verbose { + return Verbose(bool(klog.V(klog.Level(int32(level))))) +} + +// Info is a shim +func (v Verbose) Info(args ...interface{}) { + if v { + klog.Info(args...) + } +} + +// Infoln is a shim +func (v Verbose) Infoln(args ...interface{}) { + if v { + klog.Infoln(args...) + } +} + +// Infof is a shim +func (v Verbose) Infof(format string, args ...interface{}) { + if v { + klog.Infof(format, args...) + } +} + +// Info is a shim +func Info(args ...interface{}) { + klog.Info(args...) +} + +// InfoDepth is a shim +func InfoDepth(depth int, args ...interface{}) { + klog.InfoDepth(depth, args...) +} + +// Infoln is a shim +func Infoln(args ...interface{}) { + klog.Infoln(args...) +} + +// Infof is a shim +func Infof(format string, args ...interface{}) { + klog.Infof(format, args...) +} + +// Warning is a shim +func Warning(args ...interface{}) { + klog.Warning(args...) +} + +// WarningDepth is a shim +func WarningDepth(depth int, args ...interface{}) { + klog.WarningDepth(depth, args...) +} + +// Warningln is a shim +func Warningln(args ...interface{}) { + klog.Warningln(args...) +} + +// Warningf is a shim +func Warningf(format string, args ...interface{}) { + klog.Warningf(format, args...) +} + +// Error is a shim +func Error(args ...interface{}) { + klog.Error(args...) +} + +// ErrorDepth is a shim +func ErrorDepth(depth int, args ...interface{}) { + klog.ErrorDepth(depth, args...) +} + +// Errorln is a shim +func Errorln(args ...interface{}) { + klog.Errorln(args...) +} + +// Errorf is a shim +func Errorf(format string, args ...interface{}) { + klog.Errorf(format, args...) +} + +// Fatal is a shim +func Fatal(args ...interface{}) { + klog.Fatal(args...) +} + +// FatalDepth is a shim +func FatalDepth(depth int, args ...interface{}) { + klog.FatalDepth(depth, args...) +} + +// Fatalln is a shim +func Fatalln(args ...interface{}) { + klog.Fatalln(args...) +} + +// Fatalf is a shim +func Fatalf(format string, args ...interface{}) { + klog.Fatalf(format, args...) +} + +// Exit is a shim +func Exit(args ...interface{}) { + klog.Exit(args...) +} + +// ExitDepth is a shim +func ExitDepth(depth int, args ...interface{}) { + klog.ExitDepth(depth, args...) +} + +// Exitln is a shim +func Exitln(args ...interface{}) { + klog.Exitln(args...) +} + +// Exitf is a shim +func Exitf(format string, args ...interface{}) { + klog.Exitf(format, args...) +} diff --git a/vendor/k8s.io/klog/klog.go b/vendor/k8s.io/klog/klog.go new file mode 100644 index 0000000000..13bcc81a75 --- /dev/null +++ b/vendor/k8s.io/klog/klog.go @@ -0,0 +1,1239 @@ +// Go support for leveled logs, analogous to https://code.google.com/p/google-glog/ +// +// Copyright 2013 Google Inc. All Rights Reserved. +// +// 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 klog implements logging analogous to the Google-internal C++ INFO/ERROR/V setup. +// It provides functions Info, Warning, Error, Fatal, plus formatting variants such as +// Infof. It also provides V-style logging controlled by the -v and -vmodule=file=2 flags. +// +// Basic examples: +// +// glog.Info("Prepare to repel boarders") +// +// glog.Fatalf("Initialization failed: %s", err) +// +// See the documentation for the V function for an explanation of these examples: +// +// if glog.V(2) { +// glog.Info("Starting transaction...") +// } +// +// glog.V(2).Infoln("Processed", nItems, "elements") +// +// Log output is buffered and written periodically using Flush. Programs +// should call Flush before exiting to guarantee all log output is written. +// +// By default, all log statements write to files in a temporary directory. +// This package provides several flags that modify this behavior. +// As a result, flag.Parse must be called before any logging is done. +// +// -logtostderr=false +// Logs are written to standard error instead of to files. +// -alsologtostderr=false +// Logs are written to standard error as well as to files. +// -stderrthreshold=ERROR +// Log events at or above this severity are logged to standard +// error as well as to files. +// -log_dir="" +// Log files will be written to this directory instead of the +// default temporary directory. +// +// Other flags provide aids to debugging. +// +// -log_backtrace_at="" +// When set to a file and line number holding a logging statement, +// such as +// -log_backtrace_at=gopherflakes.go:234 +// a stack trace will be written to the Info log whenever execution +// hits that statement. (Unlike with -vmodule, the ".go" must be +// present.) +// -v=0 +// Enable V-leveled logging at the specified level. +// -vmodule="" +// The syntax of the argument is a comma-separated list of pattern=N, +// where pattern is a literal file name (minus the ".go" suffix) or +// "glob" pattern and N is a V level. For instance, +// -vmodule=gopher*=3 +// sets the V level to 3 in all Go files whose names begin "gopher". +// +package klog + +import ( + "bufio" + "bytes" + "errors" + "flag" + "fmt" + "io" + stdLog "log" + "os" + "path/filepath" + "runtime" + "strconv" + "strings" + "sync" + "sync/atomic" + "time" +) + +// severity identifies the sort of log: info, warning etc. It also implements +// the flag.Value interface. The -stderrthreshold flag is of type severity and +// should be modified only through the flag.Value interface. The values match +// the corresponding constants in C++. +type severity int32 // sync/atomic int32 + +// These constants identify the log levels in order of increasing severity. +// A message written to a high-severity log file is also written to each +// lower-severity log file. +const ( + infoLog severity = iota + warningLog + errorLog + fatalLog + numSeverity = 4 +) + +const severityChar = "IWEF" + +var severityName = []string{ + infoLog: "INFO", + warningLog: "WARNING", + errorLog: "ERROR", + fatalLog: "FATAL", +} + +// get returns the value of the severity. +func (s *severity) get() severity { + return severity(atomic.LoadInt32((*int32)(s))) +} + +// set sets the value of the severity. +func (s *severity) set(val severity) { + atomic.StoreInt32((*int32)(s), int32(val)) +} + +// String is part of the flag.Value interface. +func (s *severity) String() string { + return strconv.FormatInt(int64(*s), 10) +} + +// Get is part of the flag.Value interface. +func (s *severity) Get() interface{} { + return *s +} + +// Set is part of the flag.Value interface. +func (s *severity) Set(value string) error { + var threshold severity + // Is it a known name? + if v, ok := severityByName(value); ok { + threshold = v + } else { + v, err := strconv.Atoi(value) + if err != nil { + return err + } + threshold = severity(v) + } + logging.stderrThreshold.set(threshold) + return nil +} + +func severityByName(s string) (severity, bool) { + s = strings.ToUpper(s) + for i, name := range severityName { + if name == s { + return severity(i), true + } + } + return 0, false +} + +// OutputStats tracks the number of output lines and bytes written. +type OutputStats struct { + lines int64 + bytes int64 +} + +// Lines returns the number of lines written. +func (s *OutputStats) Lines() int64 { + return atomic.LoadInt64(&s.lines) +} + +// Bytes returns the number of bytes written. +func (s *OutputStats) Bytes() int64 { + return atomic.LoadInt64(&s.bytes) +} + +// Stats tracks the number of lines of output and number of bytes +// per severity level. Values must be read with atomic.LoadInt64. +var Stats struct { + Info, Warning, Error OutputStats +} + +var severityStats = [numSeverity]*OutputStats{ + infoLog: &Stats.Info, + warningLog: &Stats.Warning, + errorLog: &Stats.Error, +} + +// Level is exported because it appears in the arguments to V and is +// the type of the v flag, which can be set programmatically. +// It's a distinct type because we want to discriminate it from logType. +// Variables of type level are only changed under logging.mu. +// The -v flag is read only with atomic ops, so the state of the logging +// module is consistent. + +// Level is treated as a sync/atomic int32. + +// Level specifies a level of verbosity for V logs. *Level implements +// flag.Value; the -v flag is of type Level and should be modified +// only through the flag.Value interface. +type Level int32 + +// get returns the value of the Level. +func (l *Level) get() Level { + return Level(atomic.LoadInt32((*int32)(l))) +} + +// set sets the value of the Level. +func (l *Level) set(val Level) { + atomic.StoreInt32((*int32)(l), int32(val)) +} + +// String is part of the flag.Value interface. +func (l *Level) String() string { + return strconv.FormatInt(int64(*l), 10) +} + +// Get is part of the flag.Value interface. +func (l *Level) Get() interface{} { + return *l +} + +// Set is part of the flag.Value interface. +func (l *Level) Set(value string) error { + v, err := strconv.Atoi(value) + if err != nil { + return err + } + logging.mu.Lock() + defer logging.mu.Unlock() + logging.setVState(Level(v), logging.vmodule.filter, false) + return nil +} + +// moduleSpec represents the setting of the -vmodule flag. +type moduleSpec struct { + filter []modulePat +} + +// modulePat contains a filter for the -vmodule flag. +// It holds a verbosity level and a file pattern to match. +type modulePat struct { + pattern string + literal bool // The pattern is a literal string + level Level +} + +// match reports whether the file matches the pattern. It uses a string +// comparison if the pattern contains no metacharacters. +func (m *modulePat) match(file string) bool { + if m.literal { + return file == m.pattern + } + match, _ := filepath.Match(m.pattern, file) + return match +} + +func (m *moduleSpec) String() string { + // Lock because the type is not atomic. TODO: clean this up. + logging.mu.Lock() + defer logging.mu.Unlock() + var b bytes.Buffer + for i, f := range m.filter { + if i > 0 { + b.WriteRune(',') + } + fmt.Fprintf(&b, "%s=%d", f.pattern, f.level) + } + return b.String() +} + +// Get is part of the (Go 1.2) flag.Getter interface. It always returns nil for this flag type since the +// struct is not exported. +func (m *moduleSpec) Get() interface{} { + return nil +} + +var errVmoduleSyntax = errors.New("syntax error: expect comma-separated list of filename=N") + +// Syntax: -vmodule=recordio=2,file=1,gfs*=3 +func (m *moduleSpec) Set(value string) error { + var filter []modulePat + for _, pat := range strings.Split(value, ",") { + if len(pat) == 0 { + // Empty strings such as from a trailing comma can be ignored. + continue + } + patLev := strings.Split(pat, "=") + if len(patLev) != 2 || len(patLev[0]) == 0 || len(patLev[1]) == 0 { + return errVmoduleSyntax + } + pattern := patLev[0] + v, err := strconv.Atoi(patLev[1]) + if err != nil { + return errors.New("syntax error: expect comma-separated list of filename=N") + } + if v < 0 { + return errors.New("negative value for vmodule level") + } + if v == 0 { + continue // Ignore. It's harmless but no point in paying the overhead. + } + // TODO: check syntax of filter? + filter = append(filter, modulePat{pattern, isLiteral(pattern), Level(v)}) + } + logging.mu.Lock() + defer logging.mu.Unlock() + logging.setVState(logging.verbosity, filter, true) + return nil +} + +// isLiteral reports whether the pattern is a literal string, that is, has no metacharacters +// that require filepath.Match to be called to match the pattern. +func isLiteral(pattern string) bool { + return !strings.ContainsAny(pattern, `\*?[]`) +} + +// traceLocation represents the setting of the -log_backtrace_at flag. +type traceLocation struct { + file string + line int +} + +// isSet reports whether the trace location has been specified. +// logging.mu is held. +func (t *traceLocation) isSet() bool { + return t.line > 0 +} + +// match reports whether the specified file and line matches the trace location. +// The argument file name is the full path, not the basename specified in the flag. +// logging.mu is held. +func (t *traceLocation) match(file string, line int) bool { + if t.line != line { + return false + } + if i := strings.LastIndex(file, "/"); i >= 0 { + file = file[i+1:] + } + return t.file == file +} + +func (t *traceLocation) String() string { + // Lock because the type is not atomic. TODO: clean this up. + logging.mu.Lock() + defer logging.mu.Unlock() + return fmt.Sprintf("%s:%d", t.file, t.line) +} + +// Get is part of the (Go 1.2) flag.Getter interface. It always returns nil for this flag type since the +// struct is not exported +func (t *traceLocation) Get() interface{} { + return nil +} + +var errTraceSyntax = errors.New("syntax error: expect file.go:234") + +// Syntax: -log_backtrace_at=gopherflakes.go:234 +// Note that unlike vmodule the file extension is included here. +func (t *traceLocation) Set(value string) error { + if value == "" { + // Unset. + t.line = 0 + t.file = "" + } + fields := strings.Split(value, ":") + if len(fields) != 2 { + return errTraceSyntax + } + file, line := fields[0], fields[1] + if !strings.Contains(file, ".") { + return errTraceSyntax + } + v, err := strconv.Atoi(line) + if err != nil { + return errTraceSyntax + } + if v <= 0 { + return errors.New("negative or zero value for level") + } + logging.mu.Lock() + defer logging.mu.Unlock() + t.line = v + t.file = file + return nil +} + +// flushSyncWriter is the interface satisfied by logging destinations. +type flushSyncWriter interface { + Flush() error + Sync() error + io.Writer +} + +func init() { + // Default stderrThreshold is ERROR. + logging.stderrThreshold = errorLog + + logging.setVState(0, nil, false) + go logging.flushDaemon() +} + +// InitFlags is for explicitly initializing the flags +func InitFlags(flagset *flag.FlagSet) { + if flagset == nil { + flagset = flag.CommandLine + } + flagset.StringVar(&logging.logDir, "log_dir", "", "If non-empty, write log files in this directory") + flagset.StringVar(&logging.logFile, "log_file", "", "If non-empty, use this log file") + flagset.BoolVar(&logging.toStderr, "logtostderr", false, "log to standard error instead of files") + flagset.BoolVar(&logging.alsoToStderr, "alsologtostderr", false, "log to standard error as well as files") + flagset.Var(&logging.verbosity, "v", "log level for V logs") + flagset.BoolVar(&logging.skipHeaders, "skip_headers", false, "If true, avoid header prefixes in the log messages") + flagset.Var(&logging.stderrThreshold, "stderrthreshold", "logs at or above this threshold go to stderr") + flagset.Var(&logging.vmodule, "vmodule", "comma-separated list of pattern=N settings for file-filtered logging") + flagset.Var(&logging.traceLocation, "log_backtrace_at", "when logging hits line file:N, emit a stack trace") +} + +// Flush flushes all pending log I/O. +func Flush() { + logging.lockAndFlushAll() +} + +// loggingT collects all the global state of the logging setup. +type loggingT struct { + // Boolean flags. Not handled atomically because the flag.Value interface + // does not let us avoid the =true, and that shorthand is necessary for + // compatibility. TODO: does this matter enough to fix? Seems unlikely. + toStderr bool // The -logtostderr flag. + alsoToStderr bool // The -alsologtostderr flag. + + // Level flag. Handled atomically. + stderrThreshold severity // The -stderrthreshold flag. + + // freeList is a list of byte buffers, maintained under freeListMu. + freeList *buffer + // freeListMu maintains the free list. It is separate from the main mutex + // so buffers can be grabbed and printed to without holding the main lock, + // for better parallelization. + freeListMu sync.Mutex + + // mu protects the remaining elements of this structure and is + // used to synchronize logging. + mu sync.Mutex + // file holds writer for each of the log types. + file [numSeverity]flushSyncWriter + // pcs is used in V to avoid an allocation when computing the caller's PC. + pcs [1]uintptr + // vmap is a cache of the V Level for each V() call site, identified by PC. + // It is wiped whenever the vmodule flag changes state. + vmap map[uintptr]Level + // filterLength stores the length of the vmodule filter chain. If greater + // than zero, it means vmodule is enabled. It may be read safely + // using sync.LoadInt32, but is only modified under mu. + filterLength int32 + // traceLocation is the state of the -log_backtrace_at flag. + traceLocation traceLocation + // These flags are modified only under lock, although verbosity may be fetched + // safely using atomic.LoadInt32. + vmodule moduleSpec // The state of the -vmodule flag. + verbosity Level // V logging level, the value of the -v flag/ + + // If non-empty, overrides the choice of directory in which to write logs. + // See createLogDirs for the full list of possible destinations. + logDir string + + // If non-empty, specifies the path of the file to write logs. mutually exclusive + // with the log-dir option. + logFile string + + // If true, do not add the prefix headers, useful when used with SetOutput + skipHeaders bool +} + +// buffer holds a byte Buffer for reuse. The zero value is ready for use. +type buffer struct { + bytes.Buffer + tmp [64]byte // temporary byte array for creating headers. + next *buffer +} + +var logging loggingT + +// setVState sets a consistent state for V logging. +// l.mu is held. +func (l *loggingT) setVState(verbosity Level, filter []modulePat, setFilter bool) { + // Turn verbosity off so V will not fire while we are in transition. + logging.verbosity.set(0) + // Ditto for filter length. + atomic.StoreInt32(&logging.filterLength, 0) + + // Set the new filters and wipe the pc->Level map if the filter has changed. + if setFilter { + logging.vmodule.filter = filter + logging.vmap = make(map[uintptr]Level) + } + + // Things are consistent now, so enable filtering and verbosity. + // They are enabled in order opposite to that in V. + atomic.StoreInt32(&logging.filterLength, int32(len(filter))) + logging.verbosity.set(verbosity) +} + +// getBuffer returns a new, ready-to-use buffer. +func (l *loggingT) getBuffer() *buffer { + l.freeListMu.Lock() + b := l.freeList + if b != nil { + l.freeList = b.next + } + l.freeListMu.Unlock() + if b == nil { + b = new(buffer) + } else { + b.next = nil + b.Reset() + } + return b +} + +// putBuffer returns a buffer to the free list. +func (l *loggingT) putBuffer(b *buffer) { + if b.Len() >= 256 { + // Let big buffers die a natural death. + return + } + l.freeListMu.Lock() + b.next = l.freeList + l.freeList = b + l.freeListMu.Unlock() +} + +var timeNow = time.Now // Stubbed out for testing. + +/* +header formats a log header as defined by the C++ implementation. +It returns a buffer containing the formatted header and the user's file and line number. +The depth specifies how many stack frames above lives the source line to be identified in the log message. + +Log lines have this form: + Lmmdd hh:mm:ss.uuuuuu threadid file:line] msg... +where the fields are defined as follows: + L A single character, representing the log level (eg 'I' for INFO) + mm The month (zero padded; ie May is '05') + dd The day (zero padded) + hh:mm:ss.uuuuuu Time in hours, minutes and fractional seconds + threadid The space-padded thread ID as returned by GetTID() + file The file name + line The line number + msg The user-supplied message +*/ +func (l *loggingT) header(s severity, depth int) (*buffer, string, int) { + _, file, line, ok := runtime.Caller(3 + depth) + if !ok { + file = "???" + line = 1 + } else { + slash := strings.LastIndex(file, "/") + if slash >= 0 { + file = file[slash+1:] + } + } + return l.formatHeader(s, file, line), file, line +} + +// formatHeader formats a log header using the provided file name and line number. +func (l *loggingT) formatHeader(s severity, file string, line int) *buffer { + now := timeNow() + if line < 0 { + line = 0 // not a real line number, but acceptable to someDigits + } + if s > fatalLog { + s = infoLog // for safety. + } + buf := l.getBuffer() + if l.skipHeaders { + return buf + } + + // Avoid Fprintf, for speed. The format is so simple that we can do it quickly by hand. + // It's worth about 3X. Fprintf is hard. + _, month, day := now.Date() + hour, minute, second := now.Clock() + // Lmmdd hh:mm:ss.uuuuuu threadid file:line] + buf.tmp[0] = severityChar[s] + buf.twoDigits(1, int(month)) + buf.twoDigits(3, day) + buf.tmp[5] = ' ' + buf.twoDigits(6, hour) + buf.tmp[8] = ':' + buf.twoDigits(9, minute) + buf.tmp[11] = ':' + buf.twoDigits(12, second) + buf.tmp[14] = '.' + buf.nDigits(6, 15, now.Nanosecond()/1000, '0') + buf.tmp[21] = ' ' + buf.nDigits(7, 22, pid, ' ') // TODO: should be TID + buf.tmp[29] = ' ' + buf.Write(buf.tmp[:30]) + buf.WriteString(file) + buf.tmp[0] = ':' + n := buf.someDigits(1, line) + buf.tmp[n+1] = ']' + buf.tmp[n+2] = ' ' + buf.Write(buf.tmp[:n+3]) + return buf +} + +// Some custom tiny helper functions to print the log header efficiently. + +const digits = "0123456789" + +// twoDigits formats a zero-prefixed two-digit integer at buf.tmp[i]. +func (buf *buffer) twoDigits(i, d int) { + buf.tmp[i+1] = digits[d%10] + d /= 10 + buf.tmp[i] = digits[d%10] +} + +// nDigits formats an n-digit integer at buf.tmp[i], +// padding with pad on the left. +// It assumes d >= 0. +func (buf *buffer) nDigits(n, i, d int, pad byte) { + j := n - 1 + for ; j >= 0 && d > 0; j-- { + buf.tmp[i+j] = digits[d%10] + d /= 10 + } + for ; j >= 0; j-- { + buf.tmp[i+j] = pad + } +} + +// someDigits formats a zero-prefixed variable-width integer at buf.tmp[i]. +func (buf *buffer) someDigits(i, d int) int { + // Print into the top, then copy down. We know there's space for at least + // a 10-digit number. + j := len(buf.tmp) + for { + j-- + buf.tmp[j] = digits[d%10] + d /= 10 + if d == 0 { + break + } + } + return copy(buf.tmp[i:], buf.tmp[j:]) +} + +func (l *loggingT) println(s severity, args ...interface{}) { + buf, file, line := l.header(s, 0) + fmt.Fprintln(buf, args...) + l.output(s, buf, file, line, false) +} + +func (l *loggingT) print(s severity, args ...interface{}) { + l.printDepth(s, 1, args...) +} + +func (l *loggingT) printDepth(s severity, depth int, args ...interface{}) { + buf, file, line := l.header(s, depth) + fmt.Fprint(buf, args...) + if buf.Bytes()[buf.Len()-1] != '\n' { + buf.WriteByte('\n') + } + l.output(s, buf, file, line, false) +} + +func (l *loggingT) printf(s severity, format string, args ...interface{}) { + buf, file, line := l.header(s, 0) + fmt.Fprintf(buf, format, args...) + if buf.Bytes()[buf.Len()-1] != '\n' { + buf.WriteByte('\n') + } + l.output(s, buf, file, line, false) +} + +// printWithFileLine behaves like print but uses the provided file and line number. If +// alsoLogToStderr is true, the log message always appears on standard error; it +// will also appear in the log file unless --logtostderr is set. +func (l *loggingT) printWithFileLine(s severity, file string, line int, alsoToStderr bool, args ...interface{}) { + buf := l.formatHeader(s, file, line) + fmt.Fprint(buf, args...) + if buf.Bytes()[buf.Len()-1] != '\n' { + buf.WriteByte('\n') + } + l.output(s, buf, file, line, alsoToStderr) +} + +// redirectBuffer is used to set an alternate destination for the logs +type redirectBuffer struct { + w io.Writer +} + +func (rb *redirectBuffer) Sync() error { + return nil +} + +func (rb *redirectBuffer) Flush() error { + return nil +} + +func (rb *redirectBuffer) Write(bytes []byte) (n int, err error) { + return rb.w.Write(bytes) +} + +// SetOutput sets the output destination for all severities +func SetOutput(w io.Writer) { + for s := fatalLog; s >= infoLog; s-- { + rb := &redirectBuffer{ + w: w, + } + logging.file[s] = rb + } +} + +// SetOutputBySeverity sets the output destination for specific severity +func SetOutputBySeverity(name string, w io.Writer) { + sev, ok := severityByName(name) + if !ok { + panic(fmt.Sprintf("SetOutputBySeverity(%q): unrecognized severity name", name)) + } + rb := &redirectBuffer{ + w: w, + } + logging.file[sev] = rb +} + +// output writes the data to the log files and releases the buffer. +func (l *loggingT) output(s severity, buf *buffer, file string, line int, alsoToStderr bool) { + l.mu.Lock() + if l.traceLocation.isSet() { + if l.traceLocation.match(file, line) { + buf.Write(stacks(false)) + } + } + data := buf.Bytes() + if l.toStderr { + os.Stderr.Write(data) + } else { + if alsoToStderr || l.alsoToStderr || s >= l.stderrThreshold.get() { + os.Stderr.Write(data) + } + if l.file[s] == nil { + if err := l.createFiles(s); err != nil { + os.Stderr.Write(data) // Make sure the message appears somewhere. + l.exit(err) + } + } + switch s { + case fatalLog: + l.file[fatalLog].Write(data) + fallthrough + case errorLog: + l.file[errorLog].Write(data) + fallthrough + case warningLog: + l.file[warningLog].Write(data) + fallthrough + case infoLog: + l.file[infoLog].Write(data) + } + } + if s == fatalLog { + // If we got here via Exit rather than Fatal, print no stacks. + if atomic.LoadUint32(&fatalNoStacks) > 0 { + l.mu.Unlock() + timeoutFlush(10 * time.Second) + os.Exit(1) + } + // Dump all goroutine stacks before exiting. + // First, make sure we see the trace for the current goroutine on standard error. + // If -logtostderr has been specified, the loop below will do that anyway + // as the first stack in the full dump. + if !l.toStderr { + os.Stderr.Write(stacks(false)) + } + // Write the stack trace for all goroutines to the files. + trace := stacks(true) + logExitFunc = func(error) {} // If we get a write error, we'll still exit below. + for log := fatalLog; log >= infoLog; log-- { + if f := l.file[log]; f != nil { // Can be nil if -logtostderr is set. + f.Write(trace) + } + } + l.mu.Unlock() + timeoutFlush(10 * time.Second) + os.Exit(255) // C++ uses -1, which is silly because it's anded with 255 anyway. + } + l.putBuffer(buf) + l.mu.Unlock() + if stats := severityStats[s]; stats != nil { + atomic.AddInt64(&stats.lines, 1) + atomic.AddInt64(&stats.bytes, int64(len(data))) + } +} + +// timeoutFlush calls Flush and returns when it completes or after timeout +// elapses, whichever happens first. This is needed because the hooks invoked +// by Flush may deadlock when glog.Fatal is called from a hook that holds +// a lock. +func timeoutFlush(timeout time.Duration) { + done := make(chan bool, 1) + go func() { + Flush() // calls logging.lockAndFlushAll() + done <- true + }() + select { + case <-done: + case <-time.After(timeout): + fmt.Fprintln(os.Stderr, "glog: Flush took longer than", timeout) + } +} + +// stacks is a wrapper for runtime.Stack that attempts to recover the data for all goroutines. +func stacks(all bool) []byte { + // We don't know how big the traces are, so grow a few times if they don't fit. Start large, though. + n := 10000 + if all { + n = 100000 + } + var trace []byte + for i := 0; i < 5; i++ { + trace = make([]byte, n) + nbytes := runtime.Stack(trace, all) + if nbytes < len(trace) { + return trace[:nbytes] + } + n *= 2 + } + return trace +} + +// logExitFunc provides a simple mechanism to override the default behavior +// of exiting on error. Used in testing and to guarantee we reach a required exit +// for fatal logs. Instead, exit could be a function rather than a method but that +// would make its use clumsier. +var logExitFunc func(error) + +// exit is called if there is trouble creating or writing log files. +// It flushes the logs and exits the program; there's no point in hanging around. +// l.mu is held. +func (l *loggingT) exit(err error) { + fmt.Fprintf(os.Stderr, "log: exiting because of error: %s\n", err) + // If logExitFunc is set, we do that instead of exiting. + if logExitFunc != nil { + logExitFunc(err) + return + } + l.flushAll() + os.Exit(2) +} + +// syncBuffer joins a bufio.Writer to its underlying file, providing access to the +// file's Sync method and providing a wrapper for the Write method that provides log +// file rotation. There are conflicting methods, so the file cannot be embedded. +// l.mu is held for all its methods. +type syncBuffer struct { + logger *loggingT + *bufio.Writer + file *os.File + sev severity + nbytes uint64 // The number of bytes written to this file +} + +func (sb *syncBuffer) Sync() error { + return sb.file.Sync() +} + +func (sb *syncBuffer) Write(p []byte) (n int, err error) { + if sb.nbytes+uint64(len(p)) >= MaxSize { + if err := sb.rotateFile(time.Now()); err != nil { + sb.logger.exit(err) + } + } + n, err = sb.Writer.Write(p) + sb.nbytes += uint64(n) + if err != nil { + sb.logger.exit(err) + } + return +} + +// rotateFile closes the syncBuffer's file and starts a new one. +func (sb *syncBuffer) rotateFile(now time.Time) error { + if sb.file != nil { + sb.Flush() + sb.file.Close() + } + var err error + sb.file, _, err = create(severityName[sb.sev], now) + sb.nbytes = 0 + if err != nil { + return err + } + + sb.Writer = bufio.NewWriterSize(sb.file, bufferSize) + + // Write header. + var buf bytes.Buffer + fmt.Fprintf(&buf, "Log file created at: %s\n", now.Format("2006/01/02 15:04:05")) + fmt.Fprintf(&buf, "Running on machine: %s\n", host) + fmt.Fprintf(&buf, "Binary: Built with %s %s for %s/%s\n", runtime.Compiler, runtime.Version(), runtime.GOOS, runtime.GOARCH) + fmt.Fprintf(&buf, "Log line format: [IWEF]mmdd hh:mm:ss.uuuuuu threadid file:line] msg\n") + n, err := sb.file.Write(buf.Bytes()) + sb.nbytes += uint64(n) + return err +} + +// bufferSize sizes the buffer associated with each log file. It's large +// so that log records can accumulate without the logging thread blocking +// on disk I/O. The flushDaemon will block instead. +const bufferSize = 256 * 1024 + +// createFiles creates all the log files for severity from sev down to infoLog. +// l.mu is held. +func (l *loggingT) createFiles(sev severity) error { + now := time.Now() + // Files are created in decreasing severity order, so as soon as we find one + // has already been created, we can stop. + for s := sev; s >= infoLog && l.file[s] == nil; s-- { + sb := &syncBuffer{ + logger: l, + sev: s, + } + if err := sb.rotateFile(now); err != nil { + return err + } + l.file[s] = sb + } + return nil +} + +const flushInterval = 30 * time.Second + +// flushDaemon periodically flushes the log file buffers. +func (l *loggingT) flushDaemon() { + for range time.NewTicker(flushInterval).C { + l.lockAndFlushAll() + } +} + +// lockAndFlushAll is like flushAll but locks l.mu first. +func (l *loggingT) lockAndFlushAll() { + l.mu.Lock() + l.flushAll() + l.mu.Unlock() +} + +// flushAll flushes all the logs and attempts to "sync" their data to disk. +// l.mu is held. +func (l *loggingT) flushAll() { + // Flush from fatal down, in case there's trouble flushing. + for s := fatalLog; s >= infoLog; s-- { + file := l.file[s] + if file != nil { + file.Flush() // ignore error + file.Sync() // ignore error + } + } +} + +// CopyStandardLogTo arranges for messages written to the Go "log" package's +// default logs to also appear in the Google logs for the named and lower +// severities. Subsequent changes to the standard log's default output location +// or format may break this behavior. +// +// Valid names are "INFO", "WARNING", "ERROR", and "FATAL". If the name is not +// recognized, CopyStandardLogTo panics. +func CopyStandardLogTo(name string) { + sev, ok := severityByName(name) + if !ok { + panic(fmt.Sprintf("log.CopyStandardLogTo(%q): unrecognized severity name", name)) + } + // Set a log format that captures the user's file and line: + // d.go:23: message + stdLog.SetFlags(stdLog.Lshortfile) + stdLog.SetOutput(logBridge(sev)) +} + +// logBridge provides the Write method that enables CopyStandardLogTo to connect +// Go's standard logs to the logs provided by this package. +type logBridge severity + +// Write parses the standard logging line and passes its components to the +// logger for severity(lb). +func (lb logBridge) Write(b []byte) (n int, err error) { + var ( + file = "???" + line = 1 + text string + ) + // Split "d.go:23: message" into "d.go", "23", and "message". + if parts := bytes.SplitN(b, []byte{':'}, 3); len(parts) != 3 || len(parts[0]) < 1 || len(parts[2]) < 1 { + text = fmt.Sprintf("bad log format: %s", b) + } else { + file = string(parts[0]) + text = string(parts[2][1:]) // skip leading space + line, err = strconv.Atoi(string(parts[1])) + if err != nil { + text = fmt.Sprintf("bad line number: %s", b) + line = 1 + } + } + // printWithFileLine with alsoToStderr=true, so standard log messages + // always appear on standard error. + logging.printWithFileLine(severity(lb), file, line, true, text) + return len(b), nil +} + +// setV computes and remembers the V level for a given PC +// when vmodule is enabled. +// File pattern matching takes the basename of the file, stripped +// of its .go suffix, and uses filepath.Match, which is a little more +// general than the *? matching used in C++. +// l.mu is held. +func (l *loggingT) setV(pc uintptr) Level { + fn := runtime.FuncForPC(pc) + file, _ := fn.FileLine(pc) + // The file is something like /a/b/c/d.go. We want just the d. + if strings.HasSuffix(file, ".go") { + file = file[:len(file)-3] + } + if slash := strings.LastIndex(file, "/"); slash >= 0 { + file = file[slash+1:] + } + for _, filter := range l.vmodule.filter { + if filter.match(file) { + l.vmap[pc] = filter.level + return filter.level + } + } + l.vmap[pc] = 0 + return 0 +} + +// Verbose is a boolean type that implements Infof (like Printf) etc. +// See the documentation of V for more information. +type Verbose bool + +// V reports whether verbosity at the call site is at least the requested level. +// The returned value is a boolean of type Verbose, which implements Info, Infoln +// and Infof. These methods will write to the Info log if called. +// Thus, one may write either +// if glog.V(2) { glog.Info("log this") } +// or +// glog.V(2).Info("log this") +// The second form is shorter but the first is cheaper if logging is off because it does +// not evaluate its arguments. +// +// Whether an individual call to V generates a log record depends on the setting of +// the -v and --vmodule flags; both are off by default. If the level in the call to +// V is at least the value of -v, or of -vmodule for the source file containing the +// call, the V call will log. +func V(level Level) Verbose { + // This function tries hard to be cheap unless there's work to do. + // The fast path is two atomic loads and compares. + + // Here is a cheap but safe test to see if V logging is enabled globally. + if logging.verbosity.get() >= level { + return Verbose(true) + } + + // It's off globally but it vmodule may still be set. + // Here is another cheap but safe test to see if vmodule is enabled. + if atomic.LoadInt32(&logging.filterLength) > 0 { + // Now we need a proper lock to use the logging structure. The pcs field + // is shared so we must lock before accessing it. This is fairly expensive, + // but if V logging is enabled we're slow anyway. + logging.mu.Lock() + defer logging.mu.Unlock() + if runtime.Callers(2, logging.pcs[:]) == 0 { + return Verbose(false) + } + v, ok := logging.vmap[logging.pcs[0]] + if !ok { + v = logging.setV(logging.pcs[0]) + } + return Verbose(v >= level) + } + return Verbose(false) +} + +// Info is equivalent to the global Info function, guarded by the value of v. +// See the documentation of V for usage. +func (v Verbose) Info(args ...interface{}) { + if v { + logging.print(infoLog, args...) + } +} + +// Infoln is equivalent to the global Infoln function, guarded by the value of v. +// See the documentation of V for usage. +func (v Verbose) Infoln(args ...interface{}) { + if v { + logging.println(infoLog, args...) + } +} + +// Infof is equivalent to the global Infof function, guarded by the value of v. +// See the documentation of V for usage. +func (v Verbose) Infof(format string, args ...interface{}) { + if v { + logging.printf(infoLog, format, args...) + } +} + +// Info logs to the INFO log. +// Arguments are handled in the manner of fmt.Print; a newline is appended if missing. +func Info(args ...interface{}) { + logging.print(infoLog, args...) +} + +// InfoDepth acts as Info but uses depth to determine which call frame to log. +// InfoDepth(0, "msg") is the same as Info("msg"). +func InfoDepth(depth int, args ...interface{}) { + logging.printDepth(infoLog, depth, args...) +} + +// Infoln logs to the INFO log. +// Arguments are handled in the manner of fmt.Println; a newline is appended if missing. +func Infoln(args ...interface{}) { + logging.println(infoLog, args...) +} + +// Infof logs to the INFO log. +// Arguments are handled in the manner of fmt.Printf; a newline is appended if missing. +func Infof(format string, args ...interface{}) { + logging.printf(infoLog, format, args...) +} + +// Warning logs to the WARNING and INFO logs. +// Arguments are handled in the manner of fmt.Print; a newline is appended if missing. +func Warning(args ...interface{}) { + logging.print(warningLog, args...) +} + +// WarningDepth acts as Warning but uses depth to determine which call frame to log. +// WarningDepth(0, "msg") is the same as Warning("msg"). +func WarningDepth(depth int, args ...interface{}) { + logging.printDepth(warningLog, depth, args...) +} + +// Warningln logs to the WARNING and INFO logs. +// Arguments are handled in the manner of fmt.Println; a newline is appended if missing. +func Warningln(args ...interface{}) { + logging.println(warningLog, args...) +} + +// Warningf logs to the WARNING and INFO logs. +// Arguments are handled in the manner of fmt.Printf; a newline is appended if missing. +func Warningf(format string, args ...interface{}) { + logging.printf(warningLog, format, args...) +} + +// Error logs to the ERROR, WARNING, and INFO logs. +// Arguments are handled in the manner of fmt.Print; a newline is appended if missing. +func Error(args ...interface{}) { + logging.print(errorLog, args...) +} + +// ErrorDepth acts as Error but uses depth to determine which call frame to log. +// ErrorDepth(0, "msg") is the same as Error("msg"). +func ErrorDepth(depth int, args ...interface{}) { + logging.printDepth(errorLog, depth, args...) +} + +// Errorln logs to the ERROR, WARNING, and INFO logs. +// Arguments are handled in the manner of fmt.Println; a newline is appended if missing. +func Errorln(args ...interface{}) { + logging.println(errorLog, args...) +} + +// Errorf logs to the ERROR, WARNING, and INFO logs. +// Arguments are handled in the manner of fmt.Printf; a newline is appended if missing. +func Errorf(format string, args ...interface{}) { + logging.printf(errorLog, format, args...) +} + +// Fatal logs to the FATAL, ERROR, WARNING, and INFO logs, +// including a stack trace of all running goroutines, then calls os.Exit(255). +// Arguments are handled in the manner of fmt.Print; a newline is appended if missing. +func Fatal(args ...interface{}) { + logging.print(fatalLog, args...) +} + +// FatalDepth acts as Fatal but uses depth to determine which call frame to log. +// FatalDepth(0, "msg") is the same as Fatal("msg"). +func FatalDepth(depth int, args ...interface{}) { + logging.printDepth(fatalLog, depth, args...) +} + +// Fatalln logs to the FATAL, ERROR, WARNING, and INFO logs, +// including a stack trace of all running goroutines, then calls os.Exit(255). +// Arguments are handled in the manner of fmt.Println; a newline is appended if missing. +func Fatalln(args ...interface{}) { + logging.println(fatalLog, args...) +} + +// Fatalf logs to the FATAL, ERROR, WARNING, and INFO logs, +// including a stack trace of all running goroutines, then calls os.Exit(255). +// Arguments are handled in the manner of fmt.Printf; a newline is appended if missing. +func Fatalf(format string, args ...interface{}) { + logging.printf(fatalLog, format, args...) +} + +// fatalNoStacks is non-zero if we are to exit without dumping goroutine stacks. +// It allows Exit and relatives to use the Fatal logs. +var fatalNoStacks uint32 + +// Exit logs to the FATAL, ERROR, WARNING, and INFO logs, then calls os.Exit(1). +// Arguments are handled in the manner of fmt.Print; a newline is appended if missing. +func Exit(args ...interface{}) { + atomic.StoreUint32(&fatalNoStacks, 1) + logging.print(fatalLog, args...) +} + +// ExitDepth acts as Exit but uses depth to determine which call frame to log. +// ExitDepth(0, "msg") is the same as Exit("msg"). +func ExitDepth(depth int, args ...interface{}) { + atomic.StoreUint32(&fatalNoStacks, 1) + logging.printDepth(fatalLog, depth, args...) +} + +// Exitln logs to the FATAL, ERROR, WARNING, and INFO logs, then calls os.Exit(1). +func Exitln(args ...interface{}) { + atomic.StoreUint32(&fatalNoStacks, 1) + logging.println(fatalLog, args...) +} + +// Exitf logs to the FATAL, ERROR, WARNING, and INFO logs, then calls os.Exit(1). +// Arguments are handled in the manner of fmt.Printf; a newline is appended if missing. +func Exitf(format string, args ...interface{}) { + atomic.StoreUint32(&fatalNoStacks, 1) + logging.printf(fatalLog, format, args...) +} diff --git a/vendor/k8s.io/klog/klog_file.go b/vendor/k8s.io/klog/klog_file.go new file mode 100644 index 0000000000..b76a4e10be --- /dev/null +++ b/vendor/k8s.io/klog/klog_file.go @@ -0,0 +1,126 @@ +// Go support for leveled logs, analogous to https://code.google.com/p/google-glog/ +// +// Copyright 2013 Google Inc. All Rights Reserved. +// +// 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. + +// File I/O for logs. + +package klog + +import ( + "errors" + "fmt" + "os" + "os/user" + "path/filepath" + "strings" + "sync" + "time" +) + +// MaxSize is the maximum size of a log file in bytes. +var MaxSize uint64 = 1024 * 1024 * 1800 + +// logDirs lists the candidate directories for new log files. +var logDirs []string + +func createLogDirs() { + if logging.logDir != "" { + logDirs = append(logDirs, logging.logDir) + } + logDirs = append(logDirs, os.TempDir()) +} + +var ( + pid = os.Getpid() + program = filepath.Base(os.Args[0]) + host = "unknownhost" + userName = "unknownuser" +) + +func init() { + h, err := os.Hostname() + if err == nil { + host = shortHostname(h) + } + + current, err := user.Current() + if err == nil { + userName = current.Username + } + + // Sanitize userName since it may contain filepath separators on Windows. + userName = strings.Replace(userName, `\`, "_", -1) +} + +// shortHostname returns its argument, truncating at the first period. +// For instance, given "www.google.com" it returns "www". +func shortHostname(hostname string) string { + if i := strings.Index(hostname, "."); i >= 0 { + return hostname[:i] + } + return hostname +} + +// logName returns a new log file name containing tag, with start time t, and +// the name for the symlink for tag. +func logName(tag string, t time.Time) (name, link string) { + name = fmt.Sprintf("%s.%s.%s.log.%s.%04d%02d%02d-%02d%02d%02d.%d", + program, + host, + userName, + tag, + t.Year(), + t.Month(), + t.Day(), + t.Hour(), + t.Minute(), + t.Second(), + pid) + return name, program + "." + tag +} + +var onceLogDirs sync.Once + +// create creates a new log file and returns the file and its filename, which +// contains tag ("INFO", "FATAL", etc.) and t. If the file is created +// successfully, create also attempts to update the symlink for that tag, ignoring +// errors. +func create(tag string, t time.Time) (f *os.File, filename string, err error) { + if logging.logFile != "" { + f, err := os.Create(logging.logFile) + if err == nil { + return f, logging.logFile, nil + } + return nil, "", fmt.Errorf("log: unable to create log: %v", err) + } + onceLogDirs.Do(createLogDirs) + if len(logDirs) == 0 { + return nil, "", errors.New("log: no log dirs") + } + name, link := logName(tag, t) + var lastErr error + for _, dir := range logDirs { + fname := filepath.Join(dir, name) + f, err := os.Create(fname) + if err == nil { + symlink := filepath.Join(dir, link) + os.Remove(symlink) // ignore err + os.Symlink(name, symlink) // ignore err + return f, fname, nil + } + lastErr = err + } + return nil, "", fmt.Errorf("log: cannot create log: %v", lastErr) +} diff --git a/vendor/sigs.k8s.io/cluster-api/.github/ISSUE_TEMPLATE/bug_report.md b/vendor/sigs.k8s.io/cluster-api/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000000..3a7d08c612 --- /dev/null +++ b/vendor/sigs.k8s.io/cluster-api/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,24 @@ +--- +name: Bug report +about: Tell us about a problem you are experiencing + +--- + +/kind bug + +**What steps did you take and what happened:** +[A clear and concise description of what the bug is.] + + +**What did you expect to happen:** + + +**Anything else you would like to add:** +[Miscellaneous information that will assist in solving the issue.] + + +**Environment:** + +- Cluster-api version: +- Kubernetes version: (use `kubectl version`): +- OS (e.g. from `/etc/os-release`): diff --git a/vendor/sigs.k8s.io/cluster-api/.github/ISSUE_TEMPLATE/feature_request.md b/vendor/sigs.k8s.io/cluster-api/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 0000000000..fc06aa7128 --- /dev/null +++ b/vendor/sigs.k8s.io/cluster-api/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,21 @@ +--- +name: Feature enhancement request +about: Suggest an idea for this project + +--- + +/kind feature + +**Describe the solution you'd like** +[A clear and concise description of what you want to happen.] + + +**Anything else you would like to add:** +[Miscellaneous information that will assist in solving the issue.] + + +**Environment:** + +- Cluster-api version: +- Kubernetes version: (use `kubectl version`): +- OS (e.g. from `/etc/os-release`): diff --git a/vendor/sigs.k8s.io/cluster-api/.gitignore b/vendor/sigs.k8s.io/cluster-api/.gitignore index a5e270388b..ce5a81a10d 100644 --- a/vendor/sigs.k8s.io/cluster-api/.gitignore +++ b/vendor/sigs.k8s.io/cluster-api/.gitignore @@ -32,3 +32,6 @@ minikube.kubeconfig # GitBook - do not check in node_modules for a specific arch and os. docs/book/node_modules/ + +# Common editor / temporary files +*~ diff --git a/vendor/sigs.k8s.io/cluster-api/BUILD.bazel b/vendor/sigs.k8s.io/cluster-api/BUILD.bazel new file mode 100644 index 0000000000..8f39d36c94 --- /dev/null +++ b/vendor/sigs.k8s.io/cluster-api/BUILD.bazel @@ -0,0 +1,7 @@ +load("@bazel_gazelle//:def.bzl", "gazelle") + +# gazelle:prefix sigs.k8s.io/cluster-api +gazelle( + name = "gazelle", + external = "vendored", +) diff --git a/vendor/sigs.k8s.io/cluster-api/CONTRIBUTING.md b/vendor/sigs.k8s.io/cluster-api/CONTRIBUTING.md index 628d62a121..a635b9d7ee 100644 --- a/vendor/sigs.k8s.io/cluster-api/CONTRIBUTING.md +++ b/vendor/sigs.k8s.io/cluster-api/CONTRIBUTING.md @@ -101,7 +101,7 @@ for machine in machines: upgrade machine ``` -The specific upgrade logic will be implement as part of the machine controller, and is specific to the provider. The user provided provider config will be in `machine.Spec.ProviderConfig`. +The specific upgrade logic will be implement as part of the machine controller, and is specific to the provider. The user provided provider config will be in `machine.Spec.ProviderSpec`. Discussion around in-place vs replace upgrades [is here](https://github.com/kubernetes/community/blob/master/keps/sig-cluster-lifecycle/0003-cluster-api.md#in-place-vs-replace). diff --git a/vendor/sigs.k8s.io/cluster-api/Dockerfile b/vendor/sigs.k8s.io/cluster-api/Dockerfile index 6edacc769e..3555795986 100644 --- a/vendor/sigs.k8s.io/cluster-api/Dockerfile +++ b/vendor/sigs.k8s.io/cluster-api/Dockerfile @@ -27,6 +27,6 @@ RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o manager sigs.k8s.io/clu # Copy the controller-manager into a thin image # TODO: Build this on scratch FROM debian:latest -WORKDIR /root/ +WORKDIR / COPY --from=builder /go/src/sigs.k8s.io/cluster-api/manager . -ENTRYPOINT ["./manager"] +ENTRYPOINT ["/manager"] diff --git a/vendor/sigs.k8s.io/cluster-api/Gopkg.lock b/vendor/sigs.k8s.io/cluster-api/Gopkg.lock index 4435aa716d..8df1de4f87 100644 --- a/vendor/sigs.k8s.io/cluster-api/Gopkg.lock +++ b/vendor/sigs.k8s.io/cluster-api/Gopkg.lock @@ -2,29 +2,29 @@ [[projects]] - digest = "1:5849d8fb74a3464195e7fb187ea0d2bfb85731172e37f17726f24fd6919a9f8e" + digest = "1:5c3894b2aa4d6bead0ceeea6831b305d62879c871780e7b76296ded1b004bc57" name = "cloud.google.com/go" packages = ["compute/metadata"] - pruneopts = "T" + pruneopts = "UT" revision = "97efc2c9ffd9fe8ef47f7f3203dc60bbca547374" version = "v0.28.0" [[projects]] - digest = "1:9f42202ac457c462ad8bb9642806d275af9ab4850cf0b1960b9c6f083d4a309a" + digest = "1:ffe9824d294da03b391f44e1ae8281281b4afc1bdaa9588c9097785e3af10cec" name = "github.com/davecgh/go-spew" packages = ["spew"] - pruneopts = "T" + pruneopts = "UT" revision = "8991bc29aa16c548c550c7ff78260e27b9ab7c73" version = "v1.1.1" [[projects]] - digest = "1:0ffd93121f3971aea43f6a26b3eaaa64c8af20fb0ff0731087d8dab7164af5a8" + digest = "1:899234af23e5793c34e06fd397f86ba33af5307b959b6a7afd19b63db065a9d7" name = "github.com/emicklei/go-restful" packages = [ ".", "log", ] - pruneopts = "T" + pruneopts = "UT" revision = "3eb9738c1697594ea6e71a7156a9bb32ed216cf0" version = "v2.8.0" @@ -32,16 +32,16 @@ digest = "1:2cd7915ab26ede7d95b8749e6b1f933f1c6d5398030684e6505940a10f31cfda" name = "github.com/ghodss/yaml" packages = ["."] - pruneopts = "T" + pruneopts = "UT" revision = "0ca9ea5df5451ffdf184b4428c902747c2c11cd7" version = "v1.0.0" [[projects]] branch = "master" - digest = "1:65587005c6fa4293c0b8a2e457e689df7fda48cc5e1f5449ea2c1e7784551558" + digest = "1:edd2fa4578eb086265db78a9201d15e76b298dfd0d5c379da83e9c61712cf6df" name = "github.com/go-logr/logr" packages = ["."] - pruneopts = "T" + pruneopts = "UT" revision = "9fb12b3b21c5415d16ac18dc5cd42c1cfdd40c4e" [[projects]] @@ -49,25 +49,25 @@ digest = "1:ce43ad4015e7cdad3f0e8f2c8339439dd4470859a828d2a6988b0f713699e94a" name = "github.com/go-logr/zapr" packages = ["."] - pruneopts = "T" + pruneopts = "UT" revision = "7536572e8d55209135cd5e7ccf7fce43dca217ab" [[projects]] - digest = "1:011e8eca01fb5af3497e6f1b79d670bb6b8519b4b0c287b710f984b364aaafb8" + digest = "1:38101365bdbea4ca2746cf7bac064b3f18d6a5561787d653a54f80c7afb4b513" name = "github.com/gobuffalo/envy" packages = ["."] - pruneopts = "T" + pruneopts = "UT" revision = "3c96536452167a705ca5a70b831d3810e1e10452" version = "v1.6.4" [[projects]] - digest = "1:da39f4a22829ca95e63566208e0ea42d6f055f41dff1b14fdab88d88f62df653" + digest = "1:34e709f36fd4f868fb00dbaf8a6cab4c1ae685832d392874ba9d7c5dec2429d1" name = "github.com/gogo/protobuf" packages = [ "proto", "sortkeys", ] - pruneopts = "T" + pruneopts = "UT" revision = "636bf0302bc95575d69441b25a2603156ffdddf1" version = "v1.1.1" @@ -76,19 +76,19 @@ digest = "1:1ba1d79f2810270045c328ae5d674321db34e3aae468eb4233883b473c5c0467" name = "github.com/golang/glog" packages = ["."] - pruneopts = "T" + pruneopts = "UT" revision = "23def4e6c14b4da8ac2ed8007337bc5eb5007998" [[projects]] branch = "master" - digest = "1:29342f636f875ca5478b6fd926212c37d89ae3c858ab3ec4680ee1eed7d32945" + digest = "1:3fb07f8e222402962fa190eb060608b34eddfb64562a18e2167df2de0ece85d8" name = "github.com/golang/groupcache" packages = ["lru"] - pruneopts = "T" + pruneopts = "UT" revision = "6f2cf27854a4a29e3811b0371547be335d411b8b" [[projects]] - digest = "1:a2ecb56e5053d942aafc86738915fb94c9131bac848c543b8b6764365fd69080" + digest = "1:4c0989ca0bcd10799064318923b9bc2db6b4d6338dd75f3f2d86c3511aaaf5cf" name = "github.com/golang/protobuf" packages = [ "proto", @@ -97,7 +97,7 @@ "ptypes/duration", "ptypes/timestamp", ] - pruneopts = "T" + pruneopts = "UT" revision = "aa810b61a9c79d51363740d207bb46cf8e620ed5" version = "v1.2.0" @@ -106,7 +106,7 @@ digest = "1:0bfbe13936953a98ae3cfe8ed6670d396ad81edf069a806d2f6515d7bb6950df" name = "github.com/google/btree" packages = ["."] - pruneopts = "T" + pruneopts = "UT" revision = "4030bb1f1f0c35b30ca7009e9ebd06849dd45306" [[projects]] @@ -114,38 +114,38 @@ digest = "1:3ee90c0d94da31b442dde97c99635aaafec68d0b8a3c12ee2075c6bdabeec6bb" name = "github.com/google/gofuzz" packages = ["."] - pruneopts = "T" + pruneopts = "UT" revision = "24818f796faf91cd76ec7bddd72458fbced7a6c1" [[projects]] digest = "1:3a26588bc48b96825977c1b3df964f8fd842cd6860cc26370588d3563433cf11" name = "github.com/google/uuid" packages = ["."] - pruneopts = "T" + pruneopts = "UT" revision = "d460ce9f8df2e77fb1ba55ca87fafed96c607494" version = "v1.0.0" [[projects]] - digest = "1:35735e2255fa34521c2a1355fb2a3a2300bc9949f487be1c1ce8ee8efcfa2d04" + digest = "1:65c4414eeb350c47b8de71110150d0ea8a281835b1f386eacaa3ad7325929c21" name = "github.com/googleapis/gnostic" packages = [ "OpenAPIv2", "compiler", "extensions", ] - pruneopts = "T" + pruneopts = "UT" revision = "7c663266750e7d82587642f65e60bc4083f1f84e" version = "v0.2.0" [[projects]] branch = "master" - digest = "1:4607fd19c69c3deee61840fca759fedb3908e4fcb09385e2f3783b93e0035c73" + digest = "1:86c1210529e69d69860f2bb3ee9ccce0b595aa3f9165e7dd1388e5c612915888" name = "github.com/gregjones/httpcache" packages = [ ".", "diskcache", ] - pruneopts = "T" + pruneopts = "UT" revision = "9cad4c3443a7200dd6400aef47183728de563a38" [[projects]] @@ -155,12 +155,12 @@ ".", "simplelru", ] - pruneopts = "T" + pruneopts = "UT" revision = "20f1fb78b0740ba8c3cb143a61e86ba5c8669768" version = "v0.5.0" [[projects]] - digest = "1:8f20c8dd713564fa97299fbcb77d729c6de9c33f3222812a76e6ecfaef80fd61" + digest = "1:a1038ef593beb4771c8f0f9c26e8b00410acd800af5c6864651d9bf160ea1813" name = "github.com/hpcloud/tail" packages = [ ".", @@ -169,15 +169,15 @@ "watch", "winfile", ] - pruneopts = "T" + pruneopts = "UT" revision = "a30252cb686a21eb2d0b98132633053ec2f7f1e5" version = "v1.0.0" [[projects]] - digest = "1:3477d9dd8c135faab978bac762eaeafb31f28d6da97ef500d5c271966f74140a" + digest = "1:8eb1de8112c9924d59bf1d3e5c26f5eaa2bfc2a5fcbb92dc1c2e4546d695f277" name = "github.com/imdario/mergo" packages = ["."] - pruneopts = "T" + pruneopts = "UT" revision = "9f23e2d6bd2a77f959b2bf6acdbefd708a83a4a4" version = "v0.3.6" @@ -185,23 +185,23 @@ digest = "1:870d441fe217b8e689d7949fef6e43efbc787e50f200cb1e70dbca9204a1d6be" name = "github.com/inconshreveable/mousetrap" packages = ["."] - pruneopts = "T" + pruneopts = "UT" revision = "76626ae9c91c4f2a10f34cad8ce83ea42c93bb75" version = "v1.0" [[projects]] - digest = "1:ee5840274624ad20cac08227aeca582fbdaf3727ef9dd37ae935706240679e09" + digest = "1:ecd9aa82687cf31d1585d4ac61d0ba180e42e8a6182b85bd785fcca8dfeefc1b" name = "github.com/joho/godotenv" packages = ["."] - pruneopts = "T" + pruneopts = "UT" revision = "23d116af351c84513e1946b527c88823e476be13" version = "v1.3.0" [[projects]] - digest = "1:5d713dbcad44f3358fec51fd5573d4f733c02cac5a40dcb177787ad5ffe9272f" + digest = "1:3e551bbb3a7c0ab2a2bf4660e7fcad16db089fdcfbb44b0199e62838038623ea" name = "github.com/json-iterator/go" packages = ["."] - pruneopts = "T" + pruneopts = "UT" revision = "1624edc4454b8682399def8740d46db5e4362ba4" version = "v1.1.5" @@ -209,7 +209,7 @@ digest = "1:e60b8e2ad986a90b522fd74a87c4f5b3bb173c6a6bc5d88744d70cb0c760afdd" name = "github.com/markbates/inflect" packages = ["."] - pruneopts = "T" + pruneopts = "UT" revision = "dd7de90c06bca70f18136e59dec2270c19a401e7" version = "v1.0.0" @@ -218,14 +218,14 @@ digest = "1:fc2b04b0069d6b10bdef96d278fe20c345794009685ed3c8c7f1a6dc023eefec" name = "github.com/mattbaird/jsonpatch" packages = ["."] - pruneopts = "T" + pruneopts = "UT" revision = "81af80346b1a01caae0cbc27fd3c1ba5b11e189f" [[projects]] digest = "1:33422d238f147d247752996a26574ac48dcf472976eda7f5134015f06bf16563" name = "github.com/modern-go/concurrent" packages = ["."] - pruneopts = "T" + pruneopts = "UT" revision = "bacd9c7ef1dd9b15be4a9909b8ac7a4e313eec94" version = "1.0.3" @@ -233,12 +233,12 @@ digest = "1:e32bdbdb7c377a07a9a46378290059822efdce5c8d96fe71940d87cb4f918855" name = "github.com/modern-go/reflect2" packages = ["."] - pruneopts = "T" + pruneopts = "UT" revision = "4b7aa43c6742a2c18fdef89dd197aaae7dac7ccd" version = "1.0.1" [[projects]] - digest = "1:99ec7b4370b05816679fe9ae77f1f8af4eae3df0abaeef8c3d2d42d86f55f549" + digest = "1:42e29deef12327a69123b9cb2cb45fee4af5c12c2a23c6e477338279a052703f" name = "github.com/onsi/ginkgo" packages = [ ".", @@ -260,12 +260,12 @@ "reporters/stenographer/support/go-isatty", "types", ] - pruneopts = "T" + pruneopts = "UT" revision = "3774a09d95489ccaa16032e0770d08ea77ba6184" version = "v1.6.0" [[projects]] - digest = "1:8dd7bb91b515b86408de9c0d553f14e97ffa21c65c643976242e63d11a28999a" + digest = "1:d6d3014e71a3504f7fda993889cfdc09ef5b70b46b00dd6bd078943585944352" name = "github.com/onsi/gomega" packages = [ ".", @@ -283,7 +283,7 @@ "matchers/support/goraph/util", "types", ] - pruneopts = "T" + pruneopts = "UT" revision = "7615b9433f86a8bdf29709bf288bc4fd0636a369" version = "v1.4.2" @@ -291,23 +291,23 @@ digest = "1:e5d0bd87abc2781d14e274807a470acd180f0499f8bf5bb18606e9ec22ad9de9" name = "github.com/pborman/uuid" packages = ["."] - pruneopts = "T" + pruneopts = "UT" revision = "adf5a7427709b9deb95d29d3fa8a2bf9cfd388f1" version = "v1.2" [[projects]] branch = "master" - digest = "1:0c29d499ffc3b9f33e7136444575527d0c3a9463a89b3cbeda0523b737f910b3" + digest = "1:3bf17a6e6eaa6ad24152148a631d18662f7212e21637c2699bff3369b7f00fa2" name = "github.com/petar/GoLLRB" packages = ["llrb"] - pruneopts = "T" + pruneopts = "UT" revision = "53be0d36a84c2a886ca057d34b6aa4468df9ccb4" [[projects]] - digest = "1:598241bd36d3a5f6d9102a306bd9bf78f3bc253672460d92ac70566157eae648" + digest = "1:0e7775ebbcf00d8dd28ac663614af924411c868dca3d5aa762af0fae3808d852" name = "github.com/peterbourgon/diskv" packages = ["."] - pruneopts = "T" + pruneopts = "UT" revision = "5f041e8faa004a95c88a202771f4cc3e991971e6" version = "v2.0.1" @@ -315,55 +315,55 @@ digest = "1:40e195917a951a8bf867cd05de2a46aaf1806c50cf92eebf4c16f78cd196f747" name = "github.com/pkg/errors" packages = ["."] - pruneopts = "T" + pruneopts = "UT" revision = "645ef00459ed84a119197bfb8d8205042c6df63d" version = "v0.8.0" [[projects]] - digest = "1:b7bf9fd95d38ebe6726a63b7d0320611f7c920c64e2c8313eba0cec51926bf55" + digest = "1:6a4a11ba764a56d2758899ec6f3848d24698d48442ebce85ee7a3f63284526cd" name = "github.com/spf13/afero" packages = [ ".", "mem", ] - pruneopts = "T" + pruneopts = "UT" revision = "d40851caa0d747393da1ffb28f7f9d8b4eeffebd" version = "v1.1.2" [[projects]] - digest = "1:8be8b3743fc9795ec21bbd3e0fc28ff6234018e1a269b0a7064184be95ac13e0" + digest = "1:645cabccbb4fa8aab25a956cbcbdf6a6845ca736b2c64e197ca7cbb9d210b939" name = "github.com/spf13/cobra" packages = ["."] - pruneopts = "T" + pruneopts = "UT" revision = "ef82de70bb3f60c65fb8eebacbb2d122ef517385" version = "v0.0.3" [[projects]] - digest = "1:9ba911fe3884995431690e7eb180cf848da0d637ba5f61711783b795d031793f" + digest = "1:dab83a1bbc7ad3d7a6ba1a1cc1760f25ac38cdf7d96a5cdd55cd915a4f5ceaf9" name = "github.com/spf13/pflag" packages = ["."] - pruneopts = "T" + pruneopts = "UT" revision = "9a97c102cda95a86cec2345a6f09f55a939babf5" version = "v1.0.2" [[projects]] - digest = "1:365b8ecb35a5faf5aa0ee8d798548fc9cd4200cb95d77a5b0b285ac881bae499" + digest = "1:3c1a69cdae3501bf75e76d0d86dc6f2b0a7421bc205c0cb7b96b19eed464a34d" name = "go.uber.org/atomic" packages = ["."] - pruneopts = "T" + pruneopts = "UT" revision = "1ea20fb1cbb1cc08cbd0d913a96dead89aa18289" version = "v1.3.2" [[projects]] - digest = "1:8da5d356e645cc806b953f35966e9185e9f3817c6cee54f9b33ca602544ee434" + digest = "1:60bf2a5e347af463c42ed31a493d817f8a72f102543060ed992754e689805d1a" name = "go.uber.org/multierr" packages = ["."] - pruneopts = "T" + pruneopts = "UT" revision = "3c4937480c32f4c13a875a1829af76c98ca3d40a" version = "v1.1.0" [[projects]] - digest = "1:c57d4b95825e74f8eb3b0c851d04aac3626a602de613f8702c0de41de26856b6" + digest = "1:c52caf7bd44f92e54627a31b85baf06a68333a196b3d8d241480a774733dcf8b" name = "go.uber.org/zap" packages = [ ".", @@ -373,21 +373,21 @@ "internal/exit", "zapcore", ] - pruneopts = "T" + pruneopts = "UT" revision = "ff33455a0e382e8a81d14dd7c922020b6b5e7982" version = "v1.9.1" [[projects]] branch = "master" - digest = "1:62fac8c414ce3fb59b87102ebebb04edd0287a721c0cd6b36f4dc866a42cf772" + digest = "1:3f3a05ae0b95893d90b9b3b5afdb79a9b3d96e4e36e099d841ae602e4aca0da8" name = "golang.org/x/crypto" packages = ["ssh/terminal"] - pruneopts = "T" + pruneopts = "UT" revision = "0e37d006457bf46f9e6692014ba72ef82c33022c" [[projects]] branch = "master" - digest = "1:0d3b3ce2b76e0d10fc5e804e51a92c4466b05a92de06e61e96d7035deab04c41" + digest = "1:169b5e9a5bdb701a74d083ae0d836d3ee5038f036fb945bacc997b2777691d7b" name = "golang.org/x/net" packages = [ "context", @@ -400,12 +400,12 @@ "http2/hpack", "idna", ] - pruneopts = "T" + pruneopts = "UT" revision = "2f5d2388922f370f4355f327fcf4cfe9f5583908" [[projects]] branch = "master" - digest = "1:b532962365df3c36d313cb4a9c0551523b1ed562b9e5736780577b02835086f7" + digest = "1:f645667d687fc8bf228865a2c5455824ef05bad08841e673673ef2bb89ac5b90" name = "golang.org/x/oauth2" packages = [ ".", @@ -414,22 +414,22 @@ "jws", "jwt", ] - pruneopts = "T" + pruneopts = "UT" revision = "d2e6202438beef2727060aa7cabdd924d92ebfd9" [[projects]] branch = "master" - digest = "1:153c61460456a812f7d45cb6834d348a3d4b5f377f1381d659c9be1d34090218" + digest = "1:75cb7164c3c9e028922e69b10842159549ab96ffc4800ea189c4a6865dc3bc08" name = "golang.org/x/sys" packages = [ "unix", "windows", ] - pruneopts = "T" + pruneopts = "UT" revision = "90868a75fefd03942536221d7c0e2f84ec62a668" [[projects]] - digest = "1:6164911cb5e94e8d8d5131d646613ff82c14f5a8ce869de2f6d80d9889df8c5a" + digest = "1:436b24586f8fee329e0dd65fd67c817681420cda1d7f934345c13fe78c212a73" name = "golang.org/x/text" packages = [ "collate", @@ -459,32 +459,32 @@ "unicode/norm", "unicode/rangetable", ] - pruneopts = "T" + pruneopts = "UT" revision = "f21a4dfb5e38f5895301dc265a8def02365cc3d0" version = "v0.3.0" [[projects]] branch = "master" - digest = "1:59a73243379bd5412feb268ec3d9ec0c55acb596ce15fdf937ec29ea6dab441f" + digest = "1:c9e7a4b4d47c0ed205d257648b0e5b0440880cb728506e318f8ac7cd36270bc4" name = "golang.org/x/time" packages = ["rate"] - pruneopts = "T" + pruneopts = "UT" revision = "fbb02b2291d28baffd63558aa44b4b56f178d650" [[projects]] branch = "master" - digest = "1:e6bdc146e4f8ef85e7c0666f55185eda9044e25d052e8d8ee922c532763a9f80" + digest = "1:45751dc3302c90ea55913674261b2d74286b05cdd8e3ae9606e02e4e77f4353f" name = "golang.org/x/tools" packages = [ "go/ast/astutil", "imports", "internal/fastwalk", ] - pruneopts = "T" + pruneopts = "UT" revision = "e93be7f42f9fcac2c537bcd78bab08e6e63ed5bf" [[projects]] - digest = "1:193075fba81bbed6bbb7909249582de60770f5e67ed1c9321f4eeb2d9b56c7a4" + digest = "1:193950893ea275f89ed92e5da11ed8fa1436872f755a9ea5d4afa83dc9d9c3a8" name = "google.golang.org/appengine" packages = [ ".", @@ -498,15 +498,15 @@ "internal/urlfetch", "urlfetch", ] - pruneopts = "T" + pruneopts = "UT" revision = "ae0ab99deb4dc413a2b4bd6c8bdd0eb67f1e4d06" version = "v1.2.0" [[projects]] - digest = "1:7fc160b460a6fc506b37fcca68332464c3f2cd57b6e3f111f26c5bbfd2d5518e" + digest = "1:abeb38ade3f32a92943e5be54f55ed6d6e3b6602761d74b4aab4c9dd45c18abd" name = "gopkg.in/fsnotify.v1" packages = ["."] - pruneopts = "T" + pruneopts = "UT" revision = "c2828203cd70a50dcccfb2761f8b1f8ceef9a8e9" source = "https://github.com/fsnotify/fsnotify.git" version = "v1.4.7" @@ -515,7 +515,7 @@ digest = "1:2d1fbdc6777e5408cabeb02bf336305e724b925ff4546ded0fa8715a7267922a" name = "gopkg.in/inf.v0" packages = ["."] - pruneopts = "T" + pruneopts = "UT" revision = "d2d2541c53f18d2a059457998ce2876cc8e67cbf" version = "v0.9.1" @@ -524,19 +524,19 @@ digest = "1:0caa92e17bc0b65a98c63e5bc76a9e844cd5e56493f8fdbb28fad101a16254d9" name = "gopkg.in/tomb.v1" packages = ["."] - pruneopts = "T" + pruneopts = "UT" revision = "dd632973f1e7218eb1089048e0798ec9ae7dceb8" [[projects]] digest = "1:342378ac4dcb378a5448dd723f0784ae519383532f5e70ade24132c4c8693202" name = "gopkg.in/yaml.v2" packages = ["."] - pruneopts = "T" + pruneopts = "UT" revision = "5420a8b6744d3b0345ab293f6fcba19c978f1183" version = "v2.2.1" [[projects]] - digest = "1:75905606c2db8d9526ccff0acf5655759afe3d901d1d64868bd87985b4a46e36" + digest = "1:728c0c37966b7a6c8980fab69a3d690cc0996e206804a55052318858d00f1e17" name = "k8s.io/api" packages = [ "admission/v1beta1", @@ -570,12 +570,12 @@ "storage/v1alpha1", "storage/v1beta1", ] - pruneopts = "T" + pruneopts = "UT" revision = "2d6f90ab1293a1fb871cf149423ebb72aa7423aa" version = "kubernetes-1.11.2" [[projects]] - digest = "1:3fe3cb0c5e5a140f0b40c18796b884d3432efbd690b0bda8cbd838d38a3ea585" + digest = "1:145647b653ff6a6882bbc2c4701ebcbce7be643007231d545560e4ce612ad5cb" name = "k8s.io/apiextensions-apiserver" packages = [ "pkg/apis/apiextensions", @@ -584,12 +584,12 @@ "pkg/client/clientset/clientset/scheme", "pkg/client/clientset/clientset/typed/apiextensions/v1beta1", ] - pruneopts = "T" + pruneopts = "UT" revision = "408db4a50408e2149acbd657bceb2480c13cb0a4" version = "kubernetes-1.11.2" [[projects]] - digest = "1:e2035d60919705a125feeb8b13926383aff8817634b2c4550743c19ca21f3b08" + digest = "1:6a8fca786f4e263fac02cb6cfe8f0decfee526aede3969d301e18fcef167cd38" name = "k8s.io/apimachinery" packages = [ "pkg/api/equality", @@ -638,20 +638,20 @@ "third_party/forked/golang/json", "third_party/forked/golang/reflect", ] - pruneopts = "T" + pruneopts = "UT" revision = "103fd098999dc9c0c88536f5c9ad2e5da39373ae" version = "kubernetes-1.11.2" [[projects]] branch = "master" - digest = "1:74fe93fed4d79058e3107aa9cd48da81a5b3ec50460b41d34bfc29df369e7584" + digest = "1:f4399da66c191adee58287b4069dbd3f040c4b42c7050e426b9b906c263c65b6" name = "k8s.io/apiserver" packages = ["pkg/storage/names"] - pruneopts = "T" + pruneopts = "UT" revision = "cf5eff4f5e8f6019796cb18c69918b9f2f09e6db" [[projects]] - digest = "1:0a19f9bf56ecc683569299c8c2282ee3ac70d4e32eeb170d3265761bff8d5e12" + digest = "1:2094148c7308a9ddab4ad3c355c343a55d8b6c265417cebe42e74a594916dd9d" name = "k8s.io/client-go" packages = [ "discovery", @@ -722,25 +722,39 @@ "util/retry", "util/workqueue", ] - pruneopts = "T" + pruneopts = "UT" revision = "1f13a808da65775f22cbf47862c4e5898d8f4ca1" version = "kubernetes-1.11.2" [[projects]] branch = "master" - digest = "1:4e2addcdbe0330f43800c1fcb905fc7a21b86415dfcca619e5c606c87257af1b" + digest = "1:aa0d5fbf4eb99ae4cfaf645d4ffdef921777a5b761a28ee0a2cd5e9754ba130e" name = "k8s.io/code-generator" packages = [ + "cmd/client-gen", + "cmd/client-gen/args", + "cmd/client-gen/generators", + "cmd/client-gen/generators/fake", + "cmd/client-gen/generators/scheme", + "cmd/client-gen/generators/util", + "cmd/client-gen/path", + "cmd/client-gen/types", "cmd/deepcopy-gen", "cmd/deepcopy-gen/args", + "cmd/informer-gen", + "cmd/informer-gen/args", + "cmd/informer-gen/generators", + "cmd/lister-gen", + "cmd/lister-gen/args", + "cmd/lister-gen/generators", "pkg/util", ] - pruneopts = "T" + pruneopts = "UT" revision = "aae79feb89bdded3679da91fd8c19b6dfcbdb79a" [[projects]] branch = "master" - digest = "1:f58422ce44ba581f34423e12c951061d139fa3518441b0e791b1f57a6494d603" + digest = "1:63d18b00923c8c3b9b230b752bf0ab6da6bfdd02ca029c49455bfda97f3e0c26" name = "k8s.io/gengo" packages = [ "args", @@ -751,19 +765,27 @@ "parser", "types", ] - pruneopts = "T" + pruneopts = "UT" revision = "4242d8e6c5dba56827bb7bcf14ad11cda38f3991" +[[projects]] + digest = "1:e2999bf1bb6eddc2a6aa03fe5e6629120a53088926520ca3b4765f77d7ff7eab" + name = "k8s.io/klog" + packages = ["."] + pruneopts = "UT" + revision = "a5bc97fbc634d635061f3146511332c7e313a55a" + version = "v0.1.0" + [[projects]] branch = "master" - digest = "1:38bc6f751116369b8f6752fed062e36c56564cfaca0318b3a71caf3b05329d7c" + digest = "1:a2c842a1e0aed96fd732b535514556323a6f5edfded3b63e5e0ab1bce188aa54" name = "k8s.io/kube-openapi" packages = ["pkg/util/proto"] - pruneopts = "T" + pruneopts = "UT" revision = "e3762e86a74c878ffed47484592986685639c2cd" [[projects]] - digest = "1:ca3f51201a90f3a23bf35938ee910d2fb3095ece453cf56c8b723e935c194ebd" + digest = "1:264a5cbd8f1975842b856e8a590e2c54eaffb087c8bfa130d338eb07c7325a87" name = "sigs.k8s.io/controller-runtime" packages = [ "pkg/cache", @@ -771,6 +793,7 @@ "pkg/client", "pkg/client/apiutil", "pkg/client/config", + "pkg/client/fake", "pkg/controller", "pkg/envtest", "pkg/envtest/printer", @@ -794,12 +817,12 @@ "pkg/webhook/admission/types", "pkg/webhook/types", ] - pruneopts = "T" + pruneopts = "UT" revision = "5fd1e9e9fac5261e9ad9d47c375afc014fc31d21" version = "v0.1.7" [[projects]] - digest = "1:92290e452e328ffe6bd62f969e51d3aadd57a30a68b5fcf31ccdeda62068bb5d" + digest = "1:41e7c89bdceb653e2235a7b5627d23af65fa22fb4dad368bf49eb2857e23bac2" name = "sigs.k8s.io/controller-tools" packages = [ "cmd/controller-gen", @@ -810,26 +833,26 @@ "pkg/internal/codegen/parse", "pkg/util", ] - pruneopts = "T" + pruneopts = "UT" revision = "38b2f3f497ed6b8ea5d2844ecf00c28ac4b5c2c4" version = "v0.1.6" [[projects]] branch = "master" - digest = "1:fd7fb0f1f6e3259ec03c9730c675f7c97bcbd9d2a1037364734b197eaa76eee7" + digest = "1:fcda4907e877328a34cafaa567073836809d79f43027d6ed9a036758affdcb6c" name = "sigs.k8s.io/testing_frameworks" packages = [ "integration", "integration/internal", ] - pruneopts = "T" + pruneopts = "UT" revision = "5818a3a284a11812aaed11d5ca0bcadec2c50e83" [[projects]] digest = "1:7719608fe0b52a4ece56c2dde37bedd95b938677d1ab0f84b8a7852e4c59f849" name = "sigs.k8s.io/yaml" packages = ["."] - pruneopts = "T" + pruneopts = "UT" revision = "fd68e9863619f6ec2fdd8625fe1f02e7c877e480" version = "v1.1.0" @@ -839,7 +862,6 @@ input-imports = [ "github.com/davecgh/go-spew/spew", "github.com/emicklei/go-restful", - "github.com/golang/glog", "github.com/spf13/cobra", "github.com/spf13/pflag", "golang.org/x/net/context", @@ -877,9 +899,14 @@ "k8s.io/client-go/util/flowcontrol", "k8s.io/client-go/util/integer", "k8s.io/client-go/util/retry", + "k8s.io/code-generator/cmd/client-gen", "k8s.io/code-generator/cmd/deepcopy-gen", + "k8s.io/code-generator/cmd/informer-gen", + "k8s.io/code-generator/cmd/lister-gen", + "k8s.io/klog", "sigs.k8s.io/controller-runtime/pkg/client", "sigs.k8s.io/controller-runtime/pkg/client/config", + "sigs.k8s.io/controller-runtime/pkg/client/fake", "sigs.k8s.io/controller-runtime/pkg/controller", "sigs.k8s.io/controller-runtime/pkg/envtest", "sigs.k8s.io/controller-runtime/pkg/handler", diff --git a/vendor/sigs.k8s.io/cluster-api/Gopkg.toml b/vendor/sigs.k8s.io/cluster-api/Gopkg.toml index 429ae95891..2bb33e5dd9 100644 --- a/vendor/sigs.k8s.io/cluster-api/Gopkg.toml +++ b/vendor/sigs.k8s.io/cluster-api/Gopkg.toml @@ -2,6 +2,9 @@ required = [ "github.com/emicklei/go-restful", "k8s.io/client-go/plugin/pkg/client/auth/gcp", # for development against gcp "k8s.io/code-generator/cmd/deepcopy-gen", # for go generate + "k8s.io/code-generator/cmd/client-gen", # for go generate + "k8s.io/code-generator/cmd/informer-gen", # for go generate + "k8s.io/code-generator/cmd/lister-gen", # for go generate "sigs.k8s.io/controller-tools/cmd/controller-gen", # for crd/rbac generation "sigs.k8s.io/controller-runtime/pkg/client/config", "sigs.k8s.io/controller-runtime/pkg/controller", @@ -15,6 +18,7 @@ required = [ [prune] go-tests = true + unused-packages = true # STANZAS BELOW ARE GENERATED AND MAY BE WRITTEN - DO NOT MODIFY BELOW THIS LINE. diff --git a/vendor/sigs.k8s.io/cluster-api/Makefile b/vendor/sigs.k8s.io/cluster-api/Makefile index 7c4cd3df44..7c9031d12a 100644 --- a/vendor/sigs.k8s.io/cluster-api/Makefile +++ b/vendor/sigs.k8s.io/cluster-api/Makefile @@ -12,6 +12,11 @@ # See the License for the specific language governing permissions and # limitations under the License. +# If you update this file, please follow +# https://suva.sh/posts/well-documented-makefiles + +.DEFAULT_GOAL:=help + # Default timeout for starting/stopping the Kubebuilder test controlplane export KUBEBUILDER_CONTROLPLANE_START_TIMEOUT ?=60s export KUBEBUILDER_CONTROLPLANE_STOP_TIMEOUT ?=60s @@ -21,49 +26,56 @@ IMG ?= gcr.io/k8s-cluster-api/cluster-api-controller:latest all: test manager clusterctl -# Run tests -test: generate fmt vet manifests verify +help: ## Display this help + @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m\033[0m\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) + +.PHONY: gazelle +gazelle: ## Run Bazel Gazelle + (which bazel && ./hack/update-bazel.sh) || true + +.PHONY: test +test: verify generate fmt vet manifests ## Run tests go test -v -tags=integration ./pkg/... ./cmd/... -# go test -v -tags=integration ./pkg/... ./cmd/... -coverprofile cover.out -# Build manager binary -manager: generate fmt vet +.PHONY: manager +manager: generate fmt vet ## Build manager binary go build -o bin/manager sigs.k8s.io/cluster-api/cmd/manager -# Build clusterctl binary -clusterctl: generate fmt vet +.PHONY: clusterctl +clusterctl: generate fmt vet ## Build clusterctl binary go build -o bin/clusterctl sigs.k8s.io/cluster-api/cmd/clusterctl -# Run against the configured Kubernetes cluster in ~/.kube/config -run: generate fmt vet +.PHONY: run +run: generate fmt vet ## Run against the configured Kubernetes cluster in ~/.kube/config go run ./cmd/manager/main.go -# Deploy controller in the configured Kubernetes cluster in ~/.kube/config -deploy: manifests +.PHONY: deploy +deploy: manifests ## Deploy controller in the configured Kubernetes cluster in ~/.kube/config kustomize build config/default | kubectl apply -f - -# Generate manifests e.g. CRD, RBAC etc. -manifests: + +.PHONY: manifests +manifests: ## Generate manifests e.g. CRD, RBAC etc. go run vendor/sigs.k8s.io/controller-tools/cmd/controller-gen/main.go all @# Kubebuilder CRD generation can't handle intstr.IntOrString properly: @# https://github.com/kubernetes-sigs/kubebuilder/issues/442 sed -i -e 's/maxSurge:/maxSurge: {}/g' -e '/maxSurge:/{n;d};' config/crds/cluster_v1alpha1_machinedeployment.yaml sed -i -e 's/maxUnavailable:/maxUnavailable: {}/g' -e '/maxUnavailable:/{n;d};' config/crds/cluster_v1alpha1_machinedeployment.yaml -# Run go fmt against code -fmt: +.PHONY: fmt +fmt: ## Run go fmt against code go fmt ./pkg/... ./cmd/... -# Run go vet against code -vet: +.PHONY: vet +vet: ## Run go vet against code go vet ./pkg/... ./cmd/... -# Generate code -generate: clientset +.PHONY: generate +generate: clientset gazelle ## Generate code go generate ./pkg/... ./cmd/... -# Generate a typed clientset -clientset: +.PHONY: clientset +clientset: ## Generate a typed clientset rm -rf pkg/client cd ./vendor/k8s.io/code-generator/cmd && go install ./client-gen ./lister-gen ./informer-gen $$GOPATH/bin/client-gen --clientset-name clientset --input-base sigs.k8s.io/cluster-api/pkg/apis \ @@ -78,16 +90,18 @@ clientset: --output-package sigs.k8s.io/cluster-api/pkg/client/informers_generated \ --go-header-file=./hack/boilerplate.go.txt -# Build the docker image -docker-build: generate fmt vet manifests +.PHONY: docker-build +docker-build: generate fmt vet manifests ## Build the docker image docker build . -t ${IMG} @echo "updating kustomize image patch file for manager resource" sed -i'' -e 's@image: .*@image: '"${IMG}"'@' ./config/default/manager_image_patch.yaml +.PHONY: docker-push +docker-push: ## Push the docker image + docker push ${IMG} + +.PHONY: verify verify: ./hack/verify_boilerplate.py ./hack/verify_clientset.sh - -# Push the docker image -docker-push: - docker push ${IMG} + ./hack/verify-bazel.sh diff --git a/vendor/sigs.k8s.io/cluster-api/README.md b/vendor/sigs.k8s.io/cluster-api/README.md index 6ca3ac75b2..c2b54c22ac 100644 --- a/vendor/sigs.k8s.io/cluster-api/README.md +++ b/vendor/sigs.k8s.io/cluster-api/README.md @@ -38,18 +38,20 @@ are also sponsored by SIG-cluster-lifecycle: * AWS, https://github.com/kubernetes-sigs/cluster-api-provider-aws * AWS/Openshift, https://github.com/openshift/cluster-operator * Azure, https://github.com/platform9/azure-provider + * Baidu Cloud, https://github.com/baidu/cluster-api-provider-baiducloud * DigitalOcean, https://github.com/kubernetes-sigs/cluster-api-provider-digitalocean * GCE, https://github.com/kubernetes-sigs/cluster-api-provider-gcp * OpenStack, https://github.com/kubernetes-sigs/cluster-api-provider-openstack - * vSphere, https://github.com/kubernetes-sigs/cluster-api-provider-vsphere * Tencent Cloud, https://github.com/TencentCloud/cluster-api-provider-tencent + * vSphere, https://github.com/kubernetes-sigs/cluster-api-provider-vsphere ## API Adoption Following are the implementations managed by third-parties adopting the standard cluster-api and/or machine-api being developed here. - * Machine-controller-manager, https://github.com/gardener/machine-controller-manager/tree/cluster-api * Kubermatic machine-controller, https://github.com/kubermatic/machine-controller/tree/master + * Machine API Operator, https://github.com/openshift/machine-api-operator/tree/master + * Machine-controller-manager, https://github.com/gardener/machine-controller-manager/tree/cluster-api ## Getting Started ### Prerequisites diff --git a/vendor/sigs.k8s.io/cluster-api/WORKSPACE b/vendor/sigs.k8s.io/cluster-api/WORKSPACE new file mode 100644 index 0000000000..27dbf6850c --- /dev/null +++ b/vendor/sigs.k8s.io/cluster-api/WORKSPACE @@ -0,0 +1,31 @@ +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") + +http_archive( + name = "io_bazel_rules_go", + url = "https://github.com/bazelbuild/rules_go/releases/download/0.16.5/rules_go-0.16.5.tar.gz", + sha256 = "7be7dc01f1e0afdba6c8eb2b43d2fa01c743be1b9273ab1eaf6c233df078d705", +) + +http_archive( + name = "bazel_gazelle", + sha256 = "6e875ab4b6bf64a38c352887760f21203ab054676d9c1b274963907e0768740d", + urls = ["https://github.com/bazelbuild/bazel-gazelle/releases/download/0.15.0/bazel-gazelle-0.15.0.tar.gz"], +) + +load("@io_bazel_rules_go//go:def.bzl", "go_rules_dependencies", "go_register_toolchains") + +go_rules_dependencies() + +go_register_toolchains( + go_version = "1.11.4", +) + +load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies", "go_repository") + +gazelle_dependencies() + +go_repository( + name = "io_k8s_sigs_kustomize", + commit = "58492e2d83c59ed63881311f46ad6251f77dabc3", + importpath = "sigs.k8s.io/kustomize", +) diff --git a/vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/BUILD.bazel b/vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/BUILD.bazel new file mode 100644 index 0000000000..5344a11d3a --- /dev/null +++ b/vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/BUILD.bazel @@ -0,0 +1,15 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") + +go_library( + name = "go_default_library", + srcs = ["main.go"], + importpath = "sigs.k8s.io/cluster-api/cmd/clusterctl", + visibility = ["//visibility:private"], + deps = ["//cmd/clusterctl/cmd:go_default_library"], +) + +go_binary( + name = "clusterctl", + embed = [":go_default_library"], + visibility = ["//visibility:public"], +) diff --git a/vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/clientcmd/BUILD.bazel b/vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/clientcmd/BUILD.bazel new file mode 100644 index 0000000000..45af598ffe --- /dev/null +++ b/vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/clientcmd/BUILD.bazel @@ -0,0 +1,15 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +go_library( + name = "go_default_library", + srcs = ["configutil.go"], + importpath = "sigs.k8s.io/cluster-api/cmd/clusterctl/clientcmd", + visibility = ["//visibility:public"], + deps = [ + "//pkg/client/clientset_generated/clientset:go_default_library", + "//vendor/k8s.io/client-go/kubernetes:go_default_library", + "//vendor/k8s.io/client-go/rest:go_default_library", + "//vendor/k8s.io/client-go/tools/clientcmd:go_default_library", + "//vendor/k8s.io/client-go/tools/clientcmd/api:go_default_library", + ], +) diff --git a/vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/clusterdeployer/BUILD.bazel b/vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/clusterdeployer/BUILD.bazel new file mode 100644 index 0000000000..5686e5600a --- /dev/null +++ b/vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/clusterdeployer/BUILD.bazel @@ -0,0 +1,34 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") + +go_library( + name = "go_default_library", + srcs = [ + "clusterdeployer.go", + "providercomponentsstorefactory.go", + ], + importpath = "sigs.k8s.io/cluster-api/cmd/clusterctl/clusterdeployer", + visibility = ["//visibility:public"], + deps = [ + "//cmd/clusterctl/clusterdeployer/bootstrap:go_default_library", + "//cmd/clusterctl/clusterdeployer/clusterclient:go_default_library", + "//cmd/clusterctl/phases:go_default_library", + "//cmd/clusterctl/providercomponents:go_default_library", + "//pkg/apis/cluster/v1alpha1:go_default_library", + "//pkg/util:go_default_library", + "//vendor/k8s.io/client-go/kubernetes:go_default_library", + "//vendor/k8s.io/klog:go_default_library", + ], +) + +go_test( + name = "go_default_test", + srcs = ["clusterdeployer_test.go"], + embed = [":go_default_library"], + deps = [ + "//cmd/clusterctl/clusterdeployer/clusterclient:go_default_library", + "//pkg/apis/cluster/v1alpha1:go_default_library", + "//vendor/k8s.io/api/core/v1:go_default_library", + "//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library", + "//vendor/k8s.io/client-go/kubernetes:go_default_library", + ], +) diff --git a/vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/clusterdeployer/bootstrap/BUILD.bazel b/vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/clusterdeployer/bootstrap/BUILD.bazel new file mode 100644 index 0000000000..b5f66c2d09 --- /dev/null +++ b/vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/clusterdeployer/bootstrap/BUILD.bazel @@ -0,0 +1,8 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +go_library( + name = "go_default_library", + srcs = ["provisioner.go"], + importpath = "sigs.k8s.io/cluster-api/cmd/clusterctl/clusterdeployer/bootstrap", + visibility = ["//visibility:public"], +) diff --git a/vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/clusterdeployer/bootstrap/existing/BUILD.bazel b/vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/clusterdeployer/bootstrap/existing/BUILD.bazel new file mode 100644 index 0000000000..1eaa6f4dba --- /dev/null +++ b/vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/clusterdeployer/bootstrap/existing/BUILD.bazel @@ -0,0 +1,14 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") + +go_library( + name = "go_default_library", + srcs = ["existingcluster.go"], + importpath = "sigs.k8s.io/cluster-api/cmd/clusterctl/clusterdeployer/bootstrap/existing", + visibility = ["//visibility:public"], +) + +go_test( + name = "go_default_test", + srcs = ["existingcluster_test.go"], + embed = [":go_default_library"], +) diff --git a/vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/clusterdeployer/bootstrap/existing/exisingcluster.go b/vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/clusterdeployer/bootstrap/existing/existingcluster.go similarity index 100% rename from vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/clusterdeployer/bootstrap/existing/exisingcluster.go rename to vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/clusterdeployer/bootstrap/existing/existingcluster.go diff --git a/vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/clusterdeployer/bootstrap/minikube/BUILD.bazel b/vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/clusterdeployer/bootstrap/minikube/BUILD.bazel new file mode 100644 index 0000000000..0386d9ff20 --- /dev/null +++ b/vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/clusterdeployer/bootstrap/minikube/BUILD.bazel @@ -0,0 +1,15 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") + +go_library( + name = "go_default_library", + srcs = ["minikube.go"], + importpath = "sigs.k8s.io/cluster-api/cmd/clusterctl/clusterdeployer/bootstrap/minikube", + visibility = ["//visibility:public"], + deps = ["//vendor/k8s.io/klog:go_default_library"], +) + +go_test( + name = "go_default_test", + srcs = ["minikube_test.go"], + embed = [":go_default_library"], +) diff --git a/vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/clusterdeployer/bootstrap/minikube/minikube.go b/vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/clusterdeployer/bootstrap/minikube/minikube.go index e5ae03ca8c..2c5a73f528 100644 --- a/vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/clusterdeployer/bootstrap/minikube/minikube.go +++ b/vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/clusterdeployer/bootstrap/minikube/minikube.go @@ -23,7 +23,7 @@ import ( "os/exec" "strings" - "github.com/golang/glog" + "k8s.io/klog" ) type Minikube struct { @@ -55,11 +55,11 @@ func WithOptionsAndKubeConfigPath(options []string, kubeconfigpath string) *Mini var minikubeExec = func(env []string, args ...string) (string, error) { const executable = "minikube" - glog.V(3).Infof("Running: %v %v", executable, args) + klog.V(3).Infof("Running: %v %v", executable, args) cmd := exec.Command(executable, args...) cmd.Env = env cmdOut, err := cmd.CombinedOutput() - glog.V(2).Infof("Ran: %v %v Output: %v", executable, args, string(cmdOut)) + klog.V(2).Infof("Ran: %v %v Output: %v", executable, args, string(cmdOut)) if err != nil { err = fmt.Errorf("error running command '%v %v': %v", executable, strings.Join(args, " "), err) } diff --git a/vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/clusterdeployer/clusterclient/BUILD.bazel b/vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/clusterdeployer/clusterclient/BUILD.bazel index ba825d8110..6a60489cc9 100644 --- a/vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/clusterdeployer/clusterclient/BUILD.bazel +++ b/vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/clusterdeployer/clusterclient/BUILD.bazel @@ -6,19 +6,19 @@ go_library( "clientfactory.go", "clusterclient.go", ], - importpath = "sigs.k8s.io/cluster-api/clusterctl/clusterdeployer/clusterclient", + importpath = "sigs.k8s.io/cluster-api/cmd/clusterctl/clusterdeployer/clusterclient", visibility = ["//visibility:public"], deps = [ + "//cmd/clusterctl/clientcmd:go_default_library", "//pkg/apis/cluster/v1alpha1:go_default_library", "//pkg/client/clientset_generated/clientset:go_default_library", - "//pkg/clientcmd:go_default_library", "//pkg/util:go_default_library", - "//vendor/github.com/golang/glog:go_default_library", "//vendor/k8s.io/api/core/v1: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/client-go/kubernetes:go_default_library", "//vendor/k8s.io/client-go/tools/clientcmd:go_default_library", + "//vendor/k8s.io/klog:go_default_library", ], ) diff --git a/vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/clusterdeployer/clusterclient/clusterclient.go b/vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/clusterdeployer/clusterclient/clusterclient.go index 2328814051..bac8268257 100644 --- a/vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/clusterdeployer/clusterclient/clusterclient.go +++ b/vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/clusterdeployer/clusterclient/clusterclient.go @@ -34,7 +34,7 @@ import ( "sigs.k8s.io/cluster-api/pkg/client/clientset_generated/clientset" "sigs.k8s.io/cluster-api/pkg/util" - "github.com/golang/glog" + "k8s.io/klog" ) const ( @@ -87,7 +87,7 @@ type client struct { closeFn func() error } -// New creates and returns a Client, the kubeconfig argument is expected to be the string represenation +// New creates and returns a Client, the kubeconfig argument is expected to be the string representation // of a valid kubeconfig. func New(kubeconfig string) (*client, error) { f, err := createTempFile(kubeconfig) @@ -221,7 +221,7 @@ func (c *client) GetMachineDeploymentObjectsInNamespace(namespace string) ([]*cl // Deprecated API. Please do not extend or use. func (c *client) GetMachineDeploymentObjects() ([]*clusterv1.MachineDeployment, error) { - glog.V(2).Info("GetMachineDeploymentObjects API is deprecated, use GetMachineDeploymentObjectsInNamespace instead") + klog.V(2).Info("GetMachineDeploymentObjects API is deprecated, use GetMachineDeploymentObjectsInNamespace instead") return c.GetMachineDeploymentObjectsInNamespace(apiv1.NamespaceDefault) } @@ -239,7 +239,7 @@ func (c *client) GetMachineSetObjectsInNamespace(namespace string) ([]*clusterv1 // Deprecated API. Please do not extend or use. func (c *client) GetMachineSetObjects() ([]*clusterv1.MachineSet, error) { - glog.V(2).Info("GetMachineSetObjects API is deprecated, use GetMachineSetObjectsInNamespace instead") + klog.V(2).Info("GetMachineSetObjects API is deprecated, use GetMachineSetObjectsInNamespace instead") return c.GetMachineSetObjectsInNamespace(apiv1.NamespaceDefault) } @@ -258,7 +258,7 @@ func (c *client) GetMachineObjectsInNamespace(namespace string) ([]*clusterv1.Ma // Deprecated API. Please do not extend or use. func (c *client) GetMachineObjects() ([]*clusterv1.Machine, error) { - glog.V(2).Info("GetMachineObjects API is deprecated, use GetMachineObjectsInNamespace instead") + klog.V(2).Info("GetMachineObjects API is deprecated, use GetMachineObjectsInNamespace instead") return c.GetMachineObjectsInNamespace(apiv1.NamespaceDefault) } @@ -329,7 +329,7 @@ func (c *client) CreateMachineObjects(machines []*clusterv1.Machine, namespace s // Deprecated API. Please do not extend or use. func (c *client) DeleteClusterObjects() error { - glog.V(2).Info("DeleteClusterObjects API is deprecated, use DeleteClusterObjectsInNamespace instead") + klog.V(2).Info("DeleteClusterObjects API is deprecated, use DeleteClusterObjectsInNamespace instead") return c.DeleteClusterObjectsInNamespace(apiv1.NamespaceDefault) } @@ -347,7 +347,7 @@ func (c *client) DeleteClusterObjectsInNamespace(namespace string) error { // Deprecated API. Please do not extend or use. func (c *client) DeleteMachineDeploymentObjects() error { - glog.V(2).Info("DeleteMachineDeploymentObjects API is deprecated, use DeleteMachineDeploymentObjectsInNamespace instead") + klog.V(2).Info("DeleteMachineDeploymentObjects API is deprecated, use DeleteMachineDeploymentObjectsInNamespace instead") return c.DeleteMachineDeploymentObjectsInNamespace(apiv1.NamespaceDefault) } @@ -365,7 +365,7 @@ func (c *client) DeleteMachineDeploymentObjectsInNamespace(namespace string) err // Deprecated API. Please do not extend or use. func (c *client) DeleteMachineSetObjects() error { - glog.V(2).Info("DeleteMachineSetObjects API is deprecated, use DeleteMachineSetObjectsInNamespace instead") + klog.V(2).Info("DeleteMachineSetObjects API is deprecated, use DeleteMachineSetObjectsInNamespace instead") return c.DeleteMachineSetObjectsInNamespace(apiv1.NamespaceDefault) } @@ -383,7 +383,7 @@ func (c *client) DeleteMachineSetObjectsInNamespace(namespace string) error { // Deprecated API. Please do not extend or use. func (c *client) DeleteMachineObjects() error { - glog.V(2).Info("DeleteMachineObjects API is deprecated, use DeleteMachineObjectsInNamespace instead") + klog.V(2).Info("DeleteMachineObjects API is deprecated, use DeleteMachineObjectsInNamespace instead") return c.DeleteMachineObjectsInNamespace(apiv1.NamespaceDefault) } @@ -427,7 +427,7 @@ func (c *client) WaitForClusterV1alpha1Ready() error { func (c *client) waitForClusterDelete(namespace string) error { return util.PollImmediate(retryIntervalResourceDelete, timeoutResourceDelete, func() (bool, error) { - glog.V(2).Infof("Waiting for cluster objects to be deleted...") + klog.V(2).Infof("Waiting for cluster objects to be deleted...") response, err := c.clientSet.ClusterV1alpha1().Clusters(namespace).List(metav1.ListOptions{}) if err != nil { return false, nil @@ -441,7 +441,7 @@ func (c *client) waitForClusterDelete(namespace string) error { func (c *client) waitForMachineDeploymentsDelete(namespace string) error { return util.PollImmediate(retryIntervalResourceDelete, timeoutResourceDelete, func() (bool, error) { - glog.V(2).Infof("Waiting for machine deployment objects to be deleted...") + klog.V(2).Infof("Waiting for machine deployment objects to be deleted...") response, err := c.clientSet.ClusterV1alpha1().MachineDeployments(namespace).List(metav1.ListOptions{}) if err != nil { return false, nil @@ -455,7 +455,7 @@ func (c *client) waitForMachineDeploymentsDelete(namespace string) error { func (c *client) waitForMachineSetsDelete(namespace string) error { return util.PollImmediate(retryIntervalResourceDelete, timeoutResourceDelete, func() (bool, error) { - glog.V(2).Infof("Waiting for machine set objects to be deleted...") + klog.V(2).Infof("Waiting for machine set objects to be deleted...") response, err := c.clientSet.ClusterV1alpha1().MachineSets(namespace).List(metav1.ListOptions{}) if err != nil { return false, nil @@ -469,7 +469,7 @@ func (c *client) waitForMachineSetsDelete(namespace string) error { func (c *client) waitForMachinesDelete(namespace string) error { return util.PollImmediate(retryIntervalResourceDelete, timeoutResourceDelete, func() (bool, error) { - glog.V(2).Infof("Waiting for machine objects to be deleted...") + klog.V(2).Infof("Waiting for machine objects to be deleted...") response, err := c.clientSet.ClusterV1alpha1().Machines(namespace).List(metav1.ListOptions{}) if err != nil { return false, nil @@ -518,22 +518,23 @@ func (c *client) buildKubectlArgs(commandName string) []string { func (c *client) waitForKubectlApply(manifest string) error { err := util.PollImmediate(retryIntervalKubectlApply, timeoutKubectlApply, func() (bool, error) { - glog.V(2).Infof("Waiting for kubectl apply...") + klog.V(2).Infof("Waiting for kubectl apply...") err := c.kubectlApply(manifest) if err != nil { if strings.Contains(err.Error(), "refused") { // Connection was refused, probably because the API server is not ready yet. - glog.V(4).Infof("Waiting for kubectl apply... server not yet available: %v", err) + klog.V(4).Infof("Waiting for kubectl apply... server not yet available: %v", err) return false, nil } if strings.Contains(err.Error(), "unable to recognize") { - glog.V(4).Infof("Waiting for kubectl apply... api not yet available: %v", err) + klog.V(4).Infof("Waiting for kubectl apply... api not yet available: %v", err) return false, nil } if strings.Contains(err.Error(), "namespaces \"default\" not found") { - glog.V(4).Infof("Waiting for kubectl apply... default namespace not yet available: %v", err) + klog.V(4).Infof("Waiting for kubectl apply... default namespace not yet available: %v", err) return false, nil } + klog.Warningf("Waiting for kubectl apply... unknown error %v", err) return false, err } @@ -546,7 +547,7 @@ func (c *client) waitForKubectlApply(manifest string) error { func waitForClusterResourceReady(cs clientset.Interface) error { deadline := time.Now().Add(timeoutResourceReady) err := util.PollImmediate(retryIntervalResourceReady, timeoutResourceReady, func() (bool, error) { - glog.V(2).Info("Waiting for Cluster v1alpha resources to become available...") + klog.V(2).Info("Waiting for Cluster v1alpha resources to become available...") _, err := cs.Discovery().ServerResourcesForGroupVersion("cluster.k8s.io/v1alpha1") if err == nil { return true, nil @@ -559,7 +560,7 @@ func waitForClusterResourceReady(cs clientset.Interface) error { } timeout := time.Until(deadline) return util.PollImmediate(retryIntervalResourceReady, timeout, func() (bool, error) { - glog.V(2).Info("Waiting for Cluster v1alpha resources to be listable...") + klog.V(2).Info("Waiting for Cluster v1alpha resources to be listable...") _, err := cs.ClusterV1alpha1().Clusters(apiv1.NamespaceDefault).List(metav1.ListOptions{}) if err == nil { return true, nil @@ -570,7 +571,7 @@ func waitForClusterResourceReady(cs clientset.Interface) error { func waitForMachineReady(cs clientset.Interface, machine *clusterv1.Machine) error { err := util.PollImmediate(retryIntervalResourceReady, timeoutMachineReady, func() (bool, error) { - glog.V(2).Infof("Waiting for Machine %v to become ready...", machine.Name) + klog.V(2).Infof("Waiting for Machine %v to become ready...", machine.Name) m, err := cs.ClusterV1alpha1().Machines(machine.Namespace).Get(machine.Name, metav1.GetOptions{}) if err != nil { return false, nil @@ -605,7 +606,7 @@ func createTempFile(contents string) (string, error) { func ifErrRemove(pErr *error, path string) { if *pErr != nil { if err := os.Remove(path); err != nil { - glog.Warningf("Error removing file '%s': %v", path, err) + klog.Warningf("Error removing file '%s': %v", path, err) } } } diff --git a/vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/clusterdeployer/clusterdeployer.go b/vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/clusterdeployer/clusterdeployer.go index 0a0e7a8a20..b1c444f839 100644 --- a/vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/clusterdeployer/clusterdeployer.go +++ b/vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/clusterdeployer/clusterdeployer.go @@ -23,8 +23,8 @@ import ( "strings" "time" - "github.com/golang/glog" "k8s.io/client-go/kubernetes" + "k8s.io/klog" "sigs.k8s.io/cluster-api/cmd/clusterctl/clusterdeployer/bootstrap" "sigs.k8s.io/cluster-api/cmd/clusterctl/clusterdeployer/clusterclient" "sigs.k8s.io/cluster-api/cmd/clusterctl/phases" @@ -92,12 +92,12 @@ func (d *ClusterDeployer) Create(cluster *clusterv1.Cluster, machines []*cluster } defer closeClient(bootstrapClient, "bootstrap") - glog.Info("Applying Cluster API stack to bootstrap cluster") + klog.Info("Applying Cluster API stack to bootstrap cluster") if err := phases.ApplyClusterAPIComponents(bootstrapClient, d.providerComponents); err != nil { return fmt.Errorf("unable to apply cluster api stack to bootstrap cluster: %v", err) } - glog.Info("Provisioning target cluster via bootstrap cluster") + klog.Info("Provisioning target cluster via bootstrap cluster") if err := phases.ApplyCluster(bootstrapClient, cluster); err != nil { return fmt.Errorf("unable to create cluster %q in bootstrap cluster: %v", cluster.Name, err) } @@ -106,17 +106,17 @@ func (d *ClusterDeployer) Create(cluster *clusterv1.Cluster, machines []*cluster cluster.Namespace = bootstrapClient.GetContextNamespace() } - glog.Infof("Creating master %v in namespace %q", master.Name, cluster.Namespace) + klog.Infof("Creating master %v in namespace %q", master.Name, cluster.Namespace) if err := phases.ApplyMachines(bootstrapClient, cluster.Namespace, []*clusterv1.Machine{master}); err != nil { return fmt.Errorf("unable to create master machine: %v", err) } - glog.Infof("Updating bootstrap cluster object for cluster %v in namespace %q with master (%s) endpoint", cluster.Name, cluster.Namespace, master.Name) + klog.Infof("Updating bootstrap cluster object for cluster %v in namespace %q with master (%s) endpoint", cluster.Name, cluster.Namespace, master.Name) if err := d.updateClusterEndpoint(bootstrapClient, provider, cluster.Name, cluster.Namespace); err != nil { return fmt.Errorf("unable to update bootstrap cluster endpoint: %v", err) } - glog.Info("Creating target cluster") + klog.Info("Creating target cluster") targetClient, err := d.createTargetClusterClient(bootstrapClient, provider, kubeconfigOutput, cluster.Name, cluster.Namespace) if err != nil { return fmt.Errorf("unable to create target cluster: %v", err) @@ -129,12 +129,12 @@ func (d *ClusterDeployer) Create(cluster *clusterv1.Cluster, machines []*cluster } } - glog.Info("Applying Cluster API stack to target cluster") + klog.Info("Applying Cluster API stack to target cluster") if err := d.applyClusterAPIComponentsWithPivoting(targetClient, bootstrapClient, cluster.Namespace); err != nil { return fmt.Errorf("unable to apply cluster api stack to target cluster: %v", err) } - glog.Info("Saving provider components to the target cluster") + klog.Info("Saving provider components to the target cluster") err = d.saveProviderComponentsToCluster(providerComponentsStoreFactory, kubeconfigOutput) if err != nil { return fmt.Errorf("unable to save provider components to target cluster: %v", err) @@ -147,23 +147,23 @@ func (d *ClusterDeployer) Create(cluster *clusterv1.Cluster, machines []*cluster // For some reason, endpoint doesn't get updated in bootstrap cluster sometimes. So we // update the target cluster endpoint as well to be sure. - glog.Infof("Updating target cluster object with master (%s) endpoint", master.Name) + klog.Infof("Updating target cluster object with master (%s) endpoint", master.Name) if err := d.updateClusterEndpoint(targetClient, provider, cluster.Name, cluster.Namespace); err != nil { return fmt.Errorf("unable to update target cluster endpoint: %v", err) } - glog.Info("Creating node machines in target cluster.") + klog.Info("Creating node machines in target cluster.") if err := phases.ApplyMachines(targetClient, cluster.Namespace, nodes); err != nil { return fmt.Errorf("unable to create node machines: %v", err) } - glog.Infof("Done provisioning cluster. You can now access your cluster with kubectl --kubeconfig %v", kubeconfigOutput) + klog.Infof("Done provisioning cluster. You can now access your cluster with kubectl --kubeconfig %v", kubeconfigOutput) return nil } func (d *ClusterDeployer) Delete(targetClient clusterclient.Client, namespace string) error { - glog.Info("Creating bootstrap cluster") + klog.Info("Creating bootstrap cluster") bootstrapClient, cleanupBootstrapCluster, err := phases.CreateBootstrapCluster(d.bootstrapProvisioner, d.cleanupBootstrapCluster, d.clientFactory) defer cleanupBootstrapCluster() if err != nil { @@ -171,28 +171,28 @@ func (d *ClusterDeployer) Delete(targetClient clusterclient.Client, namespace st } defer closeClient(bootstrapClient, "bootstrap") - glog.Info("Applying Cluster API stack to bootstrap cluster") + klog.Info("Applying Cluster API stack to bootstrap cluster") if err := phases.ApplyClusterAPIComponents(bootstrapClient, d.providerComponents); err != nil { return fmt.Errorf("unable to apply cluster api stack to bootstrap cluster: %v", err) } - glog.Info("Deleting Cluster API Provider Components from target cluster") + klog.Info("Deleting Cluster API Provider Components from target cluster") if err = targetClient.Delete(d.providerComponents); err != nil { - glog.Infof("error while removing provider components from target cluster: %v", err) - glog.Infof("Continuing with a best effort delete") + klog.Infof("error while removing provider components from target cluster: %v", err) + klog.Infof("Continuing with a best effort delete") } - glog.Info("Copying objects from target cluster to bootstrap cluster") + klog.Info("Copying objects from target cluster to bootstrap cluster") if err = pivotNamespace(targetClient, bootstrapClient, namespace); err != nil { return fmt.Errorf("unable to copy objects from target to bootstrap cluster: %v", err) } - glog.Info("Deleting objects from bootstrap cluster") + klog.Info("Deleting objects from bootstrap cluster") if err = deleteObjectsInNamespace(bootstrapClient, namespace); err != nil { return fmt.Errorf("unable to finish deleting objects in bootstrap cluster, resources may have been leaked: %v", err) } - glog.Info("Deletion of cluster complete") + klog.Info("Deletion of cluster complete") return nil } @@ -203,7 +203,7 @@ func (d *ClusterDeployer) createTargetClusterClient(bootstrapClient clusterclien return nil, err } - glog.V(1).Info("Getting target cluster kubeconfig.") + klog.V(1).Info("Getting target cluster kubeconfig.") targetKubeconfig, err := waitForKubeconfigReady(provider, cluster, master) if err != nil { return nil, fmt.Errorf("unable to get target cluster kubeconfig: %v", err) @@ -257,12 +257,12 @@ func (d *ClusterDeployer) saveProviderComponentsToCluster(factory ProviderCompon } func (d *ClusterDeployer) applyClusterAPIComponentsWithPivoting(client, source clusterclient.Client, namespace string) error { - glog.Info("Applying Cluster API Provider Components") + klog.Info("Applying Cluster API Provider Components") if err := client.Apply(d.providerComponents); err != nil { return fmt.Errorf("unable to apply cluster api controllers: %v", err) } - glog.Info("Pivoting Cluster API objects from bootstrap to target cluster.") + klog.Info("Pivoting Cluster API objects from bootstrap to target cluster.") err := pivotNamespace(source, client, namespace) if err != nil { return fmt.Errorf("unable to pivot cluster API objects: %v", err) @@ -280,10 +280,10 @@ func (d *ClusterDeployer) writeKubeconfig(kubeconfig string, kubeconfigOutput st func waitForKubeconfigReady(provider ProviderDeployer, cluster *clusterv1.Cluster, machine *clusterv1.Machine) (string, error) { kubeconfig := "" err := util.PollImmediate(retryKubeConfigReady, timeoutKubeconfigReady, func() (bool, error) { - glog.V(2).Infof("Waiting for kubeconfig on %v to become ready...", machine.Name) + klog.V(2).Infof("Waiting for kubeconfig on %v to become ready...", machine.Name) k, err := provider.GetKubeConfig(cluster, machine) if err != nil { - glog.V(4).Infof("error getting kubeconfig: %v", err) + klog.V(4).Infof("error getting kubeconfig: %v", err) return false, nil } if k == "" { @@ -316,7 +316,7 @@ func pivotNamespace(from, to clusterclient.Client, namespace string) error { if err = to.CreateClusterObject(cluster); err != nil { return fmt.Errorf("error moving Cluster '%v': %v", cluster.GetName(), err) } - glog.Infof("Moved Cluster '%s'", cluster.GetName()) + klog.Infof("Moved Cluster '%s'", cluster.GetName()) } fromDeployments, err := from.GetMachineDeploymentObjectsInNamespace(namespace) @@ -329,7 +329,7 @@ func pivotNamespace(from, to clusterclient.Client, namespace string) error { if err = to.CreateMachineDeploymentObjects([]*clusterv1.MachineDeployment{deployment}, namespace); err != nil { return fmt.Errorf("error moving MachineDeployment '%v': %v", deployment.GetName(), err) } - glog.Infof("Moved MachineDeployment %v", deployment.GetName()) + klog.Infof("Moved MachineDeployment %v", deployment.GetName()) } fromMachineSets, err := from.GetMachineSetObjectsInNamespace(namespace) @@ -342,7 +342,7 @@ func pivotNamespace(from, to clusterclient.Client, namespace string) error { if err := to.CreateMachineSetObjects([]*clusterv1.MachineSet{machineSet}, namespace); err != nil { return fmt.Errorf("error moving MachineSet '%v': %v", machineSet.GetName(), err) } - glog.Infof("Moved MachineSet %v", machineSet.GetName()) + klog.Infof("Moved MachineSet %v", machineSet.GetName()) } machines, err := from.GetMachineObjectsInNamespace(namespace) @@ -356,34 +356,34 @@ func pivotNamespace(from, to clusterclient.Client, namespace string) error { if err = to.CreateMachineObjects([]*clusterv1.Machine{machine}, namespace); err != nil { return fmt.Errorf("error moving Machine '%v': %v", machine.GetName(), err) } - glog.Infof("Moved Machine '%s'", machine.GetName()) + klog.Infof("Moved Machine '%s'", machine.GetName()) } return nil } func deleteObjectsInNamespace(client clusterclient.Client, namespace string) error { var errors []string - glog.Infof("Deleting machine deployments in namespace %q", namespace) + klog.Infof("Deleting machine deployments in namespace %q", namespace) if err := client.DeleteMachineDeploymentObjectsInNamespace(namespace); err != nil { err = fmt.Errorf("error deleting machine deployments: %v", err) errors = append(errors, err.Error()) } - glog.Infof("Deleting machine sets in namespace %q", namespace) + klog.Infof("Deleting machine sets in namespace %q", namespace) if err := client.DeleteMachineSetObjectsInNamespace(namespace); err != nil { err = fmt.Errorf("error deleting machine sets: %v", err) errors = append(errors, err.Error()) } - glog.Infof("Deleting machines in namespace %q", namespace) + klog.Infof("Deleting machines in namespace %q", namespace) if err := client.DeleteMachineObjectsInNamespace(namespace); err != nil { err = fmt.Errorf("error deleting machines: %v", err) errors = append(errors, err.Error()) } - glog.Infof("Deleting clusters in namespace %q", namespace) + klog.Infof("Deleting clusters in namespace %q", namespace) if err := client.DeleteClusterObjectsInNamespace(namespace); err != nil { err = fmt.Errorf("error deleting clusters: %v", err) errors = append(errors, err.Error()) } - glog.Infof("Deleting namespace %q", namespace) + klog.Infof("Deleting namespace %q", namespace) if err := client.DeleteNamespace(namespace); err != nil { err = fmt.Errorf("error deleting namespace: %v", err) errors = append(errors, err.Error()) @@ -432,6 +432,6 @@ func extractMasterMachine(machines []*clusterv1.Machine) (*clusterv1.Machine, [] func closeClient(client clusterclient.Client, name string) { if err := client.Close(); err != nil { - glog.Errorf("Could not close %v client: %v", name, err) + klog.Errorf("Could not close %v client: %v", name, err) } } diff --git a/vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/cmd/BUILD.bazel b/vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/cmd/BUILD.bazel new file mode 100644 index 0000000000..946d098a90 --- /dev/null +++ b/vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/cmd/BUILD.bazel @@ -0,0 +1,53 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") + +go_library( + name = "go_default_library", + srcs = [ + "alpha.go", + "alpha_phase_apply_addons.go", + "alpha_phase_apply_cluster.go", + "alpha_phase_apply_cluster_api_components.go", + "alpha_phase_apply_machines.go", + "alpha_phase_create_bootstrap_cluster.go", + "alpha_phases.go", + "create.go", + "create_cluster.go", + "delete.go", + "delete_cluster.go", + "logutil.go", + "root.go", + "validate.go", + "validate_cluster.go", + ], + importpath = "sigs.k8s.io/cluster-api/cmd/clusterctl/cmd", + visibility = ["//visibility:public"], + deps = [ + "//cmd/clusterctl/clientcmd:go_default_library", + "//cmd/clusterctl/clusterdeployer:go_default_library", + "//cmd/clusterctl/clusterdeployer/bootstrap:go_default_library", + "//cmd/clusterctl/clusterdeployer/bootstrap/existing:go_default_library", + "//cmd/clusterctl/clusterdeployer/bootstrap/minikube:go_default_library", + "//cmd/clusterctl/clusterdeployer/clusterclient:go_default_library", + "//cmd/clusterctl/phases:go_default_library", + "//cmd/clusterctl/providercomponents:go_default_library", + "//cmd/clusterctl/validation:go_default_library", + "//pkg/apis:go_default_library", + "//pkg/apis/cluster/common:go_default_library", + "//pkg/util:go_default_library", + "//vendor/github.com/spf13/cobra:go_default_library", + "//vendor/github.com/spf13/pflag:go_default_library", + "//vendor/k8s.io/api/core/v1:go_default_library", + "//vendor/k8s.io/apimachinery/pkg/util/wait:go_default_library", + "//vendor/k8s.io/client-go/tools/clientcmd:go_default_library", + "//vendor/k8s.io/klog:go_default_library", + "//vendor/sigs.k8s.io/controller-runtime/pkg/client:go_default_library", + "//vendor/sigs.k8s.io/controller-runtime/pkg/client/config:go_default_library", + "//vendor/sigs.k8s.io/controller-runtime/pkg/manager:go_default_library", + ], +) + +go_test( + name = "go_default_test", + srcs = ["create_cluster_test.go"], + embed = [":go_default_library"], +) diff --git a/vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/cmd/alpha_phase_apply_addons.go b/vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/cmd/alpha_phase_apply_addons.go index fe1af04a07..d4f7f1ed24 100644 --- a/vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/cmd/alpha_phase_apply_addons.go +++ b/vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/cmd/alpha_phase_apply_addons.go @@ -20,8 +20,8 @@ import ( "fmt" "io/ioutil" - "github.com/golang/glog" "github.com/spf13/cobra" + "k8s.io/klog" "sigs.k8s.io/cluster-api/cmd/clusterctl/clusterdeployer/clusterclient" "sigs.k8s.io/cluster-api/cmd/clusterctl/phases" ) @@ -47,7 +47,7 @@ var alphaPhaseApplyAddonsCmd = &cobra.Command{ } if err := RunAlphaPhaseApplyAddons(paao); err != nil { - glog.Exit(err) + klog.Exit(err) } }, } diff --git a/vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/cmd/alpha_phase_apply_cluster.go b/vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/cmd/alpha_phase_apply_cluster.go index 4df1bfd622..4197ffc8e5 100644 --- a/vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/cmd/alpha_phase_apply_cluster.go +++ b/vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/cmd/alpha_phase_apply_cluster.go @@ -20,8 +20,8 @@ import ( "fmt" "io/ioutil" - "github.com/golang/glog" "github.com/spf13/cobra" + "k8s.io/klog" "sigs.k8s.io/cluster-api/cmd/clusterctl/clusterdeployer/clusterclient" "sigs.k8s.io/cluster-api/cmd/clusterctl/phases" "sigs.k8s.io/cluster-api/pkg/util" @@ -48,7 +48,7 @@ var alphaPhaseApplyClusterCmd = &cobra.Command{ } if err := RunAlphaPhaseApplyCluster(paco); err != nil { - glog.Exit(err) + klog.Exit(err) } }, } diff --git a/vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/cmd/alpha_phase_apply_cluster_api_components.go b/vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/cmd/alpha_phase_apply_cluster_api_components.go index 7717f94f39..9bd767afd4 100644 --- a/vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/cmd/alpha_phase_apply_cluster_api_components.go +++ b/vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/cmd/alpha_phase_apply_cluster_api_components.go @@ -20,8 +20,8 @@ import ( "fmt" "io/ioutil" - "github.com/golang/glog" "github.com/spf13/cobra" + "k8s.io/klog" "sigs.k8s.io/cluster-api/cmd/clusterctl/clusterdeployer/clusterclient" "sigs.k8s.io/cluster-api/cmd/clusterctl/phases" ) @@ -47,7 +47,7 @@ var alphaPhaseApplyClusterAPIComponentsCmd = &cobra.Command{ } if err := RunAlphaPhaseApplyClusterAPIComponents(pacaso); err != nil { - glog.Exit(err) + klog.Exit(err) } }, } diff --git a/vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/cmd/alpha_phase_apply_machines.go b/vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/cmd/alpha_phase_apply_machines.go index b7bb0e224c..4fd9d5d5c2 100644 --- a/vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/cmd/alpha_phase_apply_machines.go +++ b/vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/cmd/alpha_phase_apply_machines.go @@ -20,8 +20,8 @@ import ( "fmt" "io/ioutil" - "github.com/golang/glog" "github.com/spf13/cobra" + "k8s.io/klog" "sigs.k8s.io/cluster-api/cmd/clusterctl/clusterdeployer/clusterclient" "sigs.k8s.io/cluster-api/cmd/clusterctl/phases" "sigs.k8s.io/cluster-api/pkg/util" @@ -49,7 +49,7 @@ var alphaPhaseApplyMachinesCmd = &cobra.Command{ } if err := RunAlphaPhaseApplyMachines(pamo); err != nil { - glog.Exit(err) + klog.Exit(err) } }, } diff --git a/vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/cmd/alpha_phase_create_bootstrap_cluster.go b/vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/cmd/alpha_phase_create_bootstrap_cluster.go index 782581a8e7..cd6346cde1 100644 --- a/vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/cmd/alpha_phase_create_bootstrap_cluster.go +++ b/vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/cmd/alpha_phase_create_bootstrap_cluster.go @@ -19,8 +19,8 @@ package cmd import ( "fmt" - "github.com/golang/glog" "github.com/spf13/cobra" + "k8s.io/klog" "sigs.k8s.io/cluster-api/cmd/clusterctl/clusterdeployer/bootstrap/minikube" "sigs.k8s.io/cluster-api/cmd/clusterctl/clusterdeployer/clusterclient" "sigs.k8s.io/cluster-api/cmd/clusterctl/phases" @@ -40,7 +40,7 @@ var alphaPhaseCreateBootstrapClusterCmd = &cobra.Command{ Long: `Create a bootstrap cluster`, Run: func(cmd *cobra.Command, args []string) { if err := RunAlphaPhaseCreateBootstrapCluster(pcbco); err != nil { - glog.Exit(err) + klog.Exit(err) } }, } @@ -57,7 +57,7 @@ func RunAlphaPhaseCreateBootstrapCluster(pcbco *AlphaPhaseCreateBootstrapCluster return fmt.Errorf("failed to create bootstrap cluster: %v", err) } - glog.Infof("Created bootstrap cluster, path to kubeconfig: %q", pcbco.KubeconfigOutput) + klog.Infof("Created bootstrap cluster, path to kubeconfig: %q", pcbco.KubeconfigOutput) return nil } diff --git a/vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/cmd/create_cluster.go b/vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/cmd/create_cluster.go index b94aec5ff1..cecaa4a679 100644 --- a/vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/cmd/create_cluster.go +++ b/vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/cmd/create_cluster.go @@ -20,8 +20,8 @@ import ( "fmt" "io/ioutil" - "github.com/golang/glog" "github.com/spf13/cobra" + "k8s.io/klog" "sigs.k8s.io/cluster-api/cmd/clusterctl/clusterdeployer" "sigs.k8s.io/cluster-api/cmd/clusterctl/clusterdeployer/bootstrap" "sigs.k8s.io/cluster-api/cmd/clusterctl/clusterdeployer/bootstrap/existing" @@ -61,7 +61,7 @@ var createClusterCmd = &cobra.Command{ exitWithHelp(cmd, "Please provide yaml file for provider component definition.") } if err := RunCreate(co); err != nil { - glog.Exit(err) + klog.Exit(err) } }, } diff --git a/vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/cmd/delete_cluster.go b/vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/cmd/delete_cluster.go index 6af723bafe..2435713c69 100644 --- a/vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/cmd/delete_cluster.go +++ b/vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/cmd/delete_cluster.go @@ -29,8 +29,8 @@ import ( "sigs.k8s.io/cluster-api/cmd/clusterctl/clusterdeployer/clusterclient" "sigs.k8s.io/cluster-api/cmd/clusterctl/providercomponents" - "github.com/golang/glog" "github.com/spf13/cobra" + "k8s.io/klog" ) type DeleteOptions struct { @@ -58,7 +58,7 @@ var deleteClusterCmd = &cobra.Command{ exitWithHelp(cmd, "Please provide yaml file for provider component definition.") } if err := RunDelete(); err != nil { - glog.Exit(err) + klog.Exit(err) } }, } diff --git a/vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/cmd/logutil.go b/vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/cmd/logutil.go index 9ed1b87a5c..90b79071de 100644 --- a/vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/cmd/logutil.go +++ b/vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/cmd/logutil.go @@ -21,9 +21,9 @@ import ( "log" "time" - "github.com/golang/glog" "github.com/spf13/pflag" "k8s.io/apimachinery/pkg/util/wait" + "k8s.io/klog" ) var logFlushFreq = pflag.Duration("log-flush-frequency", 5*time.Second, "Maximum number of seconds between log flushes") @@ -33,19 +33,19 @@ func init() { flag.Set("logtostderr", "true") } -// GlogWriter serves as a bridge between the standard log package and the glog package. -type GlogWriter struct{} +// KlogWriter serves as a bridge between the standard log package and the klog package. +type KlogWriter struct{} // Write implements the io.Writer interface. -func (writer GlogWriter) Write(data []byte) (n int, err error) { - glog.Info(string(data)) +func (writer KlogWriter) Write(data []byte) (n int, err error) { + klog.Info(string(data)) return len(data), nil } // InitLogs initializes logs the way we want for kubernetes. func InitLogs() { - log.SetOutput(GlogWriter{}) + log.SetOutput(KlogWriter{}) log.SetFlags(0) - // The default glog flush interval is 30 seconds, which is frighteningly long. - go wait.Until(glog.Flush, *logFlushFreq, wait.NeverStop) + // The default klog flush interval is 30 seconds, which is frighteningly long. + go wait.Until(klog.Flush, *logFlushFreq, wait.NeverStop) } diff --git a/vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/cmd/root.go b/vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/cmd/root.go index a4a7048549..c0a39184df 100644 --- a/vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/cmd/root.go +++ b/vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/cmd/root.go @@ -23,12 +23,31 @@ import ( "github.com/spf13/cobra" "github.com/spf13/pflag" + "k8s.io/klog" ) var RootCmd = &cobra.Command{ Use: "clusterctl", Short: "cluster management", Long: `Simple kubernetes cluster management`, + PersistentPreRun: func(cmd *cobra.Command, args []string) { + // Glog requires this otherwise it complains. + flag.CommandLine.Parse(nil) + + // This is a temporary hack to enable proper logging until upstream dependencies + // are migrated to fully utilize klog instead of glog. + klogFlags := flag.NewFlagSet("klog", flag.ExitOnError) + klog.InitFlags(klogFlags) + + // Sync the glog and klog flags. + cmd.Flags().VisitAll(func(f1 *pflag.Flag) { + f2 := klogFlags.Lookup(f1.Name) + if f2 != nil { + value := f1.Value.String() + f2.Value.Set(value) + } + }) + }, Run: func(cmd *cobra.Command, args []string) { // Do Stuff Here cmd.Help() @@ -49,10 +68,6 @@ func exitWithHelp(cmd *cobra.Command, err string) { } func init() { - flag.CommandLine.Parse([]string{}) - - // Honor glog flags for verbosity control - pflag.CommandLine.AddGoFlagSet(flag.CommandLine) - + RootCmd.PersistentFlags().AddGoFlagSet(flag.CommandLine) InitLogs() } diff --git a/vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/phases/BUILD.bazel b/vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/phases/BUILD.bazel new file mode 100644 index 0000000000..accc177fc5 --- /dev/null +++ b/vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/phases/BUILD.bazel @@ -0,0 +1,20 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +go_library( + name = "go_default_library", + srcs = [ + "applyaddons.go", + "applycluster.go", + "applyclusterapicomponents.go", + "applymachines.go", + "createbootstrapcluster.go", + ], + importpath = "sigs.k8s.io/cluster-api/cmd/clusterctl/phases", + visibility = ["//visibility:public"], + deps = [ + "//cmd/clusterctl/clusterdeployer/bootstrap:go_default_library", + "//cmd/clusterctl/clusterdeployer/clusterclient:go_default_library", + "//pkg/apis/cluster/v1alpha1:go_default_library", + "//vendor/k8s.io/klog:go_default_library", + ], +) diff --git a/vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/phases/applyaddons.go b/vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/phases/applyaddons.go index 421ddd09c5..dec8422d29 100644 --- a/vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/phases/applyaddons.go +++ b/vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/phases/applyaddons.go @@ -17,11 +17,11 @@ limitations under the License. package phases import ( - "github.com/golang/glog" + "k8s.io/klog" "sigs.k8s.io/cluster-api/cmd/clusterctl/clusterdeployer/clusterclient" ) func ApplyAddons(client clusterclient.Client, addons string) error { - glog.Info("Applying Addons") + klog.Info("Applying Addons") return client.Apply(addons) } diff --git a/vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/phases/applycluster.go b/vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/phases/applycluster.go index 567ea7120f..7c46a03ced 100644 --- a/vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/phases/applycluster.go +++ b/vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/phases/applycluster.go @@ -19,7 +19,7 @@ package phases import ( "fmt" - "github.com/golang/glog" + "k8s.io/klog" "sigs.k8s.io/cluster-api/cmd/clusterctl/clusterdeployer/clusterclient" clusterv1 "sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1" ) @@ -34,7 +34,7 @@ func ApplyCluster(client clusterclient.Client, cluster *clusterv1.Cluster) error return fmt.Errorf("unable to ensure namespace %q: %v", cluster.Namespace, err) } - glog.Infof("Creating cluster object %v in namespace %q", cluster.Name, cluster.Namespace) + klog.Infof("Creating cluster object %v in namespace %q", cluster.Name, cluster.Namespace) if err := client.CreateClusterObject(cluster); err != nil { return err } diff --git a/vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/phases/applyclusterapicomponents.go b/vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/phases/applyclusterapicomponents.go index 2827036a40..e5e0e01bec 100644 --- a/vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/phases/applyclusterapicomponents.go +++ b/vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/phases/applyclusterapicomponents.go @@ -19,12 +19,12 @@ package phases import ( "fmt" - "github.com/golang/glog" + "k8s.io/klog" "sigs.k8s.io/cluster-api/cmd/clusterctl/clusterdeployer/clusterclient" ) func ApplyClusterAPIComponents(client clusterclient.Client, providerComponents string) error { - glog.Info("Applying Cluster API Provider Components") + klog.Info("Applying Cluster API Provider Components") if err := client.Apply(providerComponents); err != nil { return fmt.Errorf("unable to apply cluster api controllers: %v", err) } diff --git a/vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/phases/applymachines.go b/vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/phases/applymachines.go index b14e362af3..232c8db784 100644 --- a/vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/phases/applymachines.go +++ b/vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/phases/applymachines.go @@ -19,7 +19,7 @@ package phases import ( "fmt" - "github.com/golang/glog" + "k8s.io/klog" "sigs.k8s.io/cluster-api/cmd/clusterctl/clusterdeployer/clusterclient" clusterv1 "sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1" ) @@ -34,7 +34,7 @@ func ApplyMachines(client clusterclient.Client, namespace string, machines []*cl return fmt.Errorf("unable to ensure namespace %q: %v", namespace, err) } - glog.Infof("Creating machines in namespace %q", namespace) + klog.Infof("Creating machines in namespace %q", namespace) if err := client.CreateMachineObjects(machines, namespace); err != nil { return err } diff --git a/vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/phases/createbootstrapcluster.go b/vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/phases/createbootstrapcluster.go index 4bd684fcd4..4a3fefa63c 100644 --- a/vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/phases/createbootstrapcluster.go +++ b/vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/phases/createbootstrapcluster.go @@ -19,13 +19,13 @@ package phases import ( "fmt" - "github.com/golang/glog" + "k8s.io/klog" "sigs.k8s.io/cluster-api/cmd/clusterctl/clusterdeployer/bootstrap" "sigs.k8s.io/cluster-api/cmd/clusterctl/clusterdeployer/clusterclient" ) func CreateBootstrapCluster(provisioner bootstrap.ClusterProvisioner, cleanupBootstrapCluster bool, clientFactory clusterclient.Factory) (clusterclient.Client, func(), error) { - glog.Info("Creating bootstrap cluster") + klog.Info("Creating bootstrap cluster") cleanupFn := func() {} if err := provisioner.Create(); err != nil { @@ -34,7 +34,7 @@ func CreateBootstrapCluster(provisioner bootstrap.ClusterProvisioner, cleanupBoo if cleanupBootstrapCluster { cleanupFn = func() { - glog.Info("Cleaning up bootstrap cluster.") + klog.Info("Cleaning up bootstrap cluster.") provisioner.Delete() } } diff --git a/vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/providercomponents/BUILD.bazel b/vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/providercomponents/BUILD.bazel new file mode 100644 index 0000000000..6583bd1c48 --- /dev/null +++ b/vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/providercomponents/BUILD.bazel @@ -0,0 +1,29 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") + +go_library( + name = "go_default_library", + srcs = ["providercomponents.go"], + importpath = "sigs.k8s.io/cluster-api/cmd/clusterctl/providercomponents", + visibility = ["//visibility:public"], + deps = [ + "//vendor/k8s.io/api/core/v1: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/client-go/kubernetes:go_default_library", + "//vendor/k8s.io/client-go/kubernetes/typed/core/v1:go_default_library", + ], +) + +go_test( + name = "go_default_test", + srcs = ["providercomponents_test.go"], + embed = [":go_default_library"], + deps = [ + "//pkg/apis/cluster/v1alpha1:go_default_library", + "//vendor/k8s.io/api/core/v1: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/types:go_default_library", + "//vendor/k8s.io/apimachinery/pkg/watch:go_default_library", + ], +) diff --git a/vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/validation/BUILD.bazel b/vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/validation/BUILD.bazel new file mode 100644 index 0000000000..d5c9fb500c --- /dev/null +++ b/vendor/sigs.k8s.io/cluster-api/cmd/clusterctl/validation/BUILD.bazel @@ -0,0 +1,41 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") + +go_library( + name = "go_default_library", + srcs = ["validate_cluster_api_objects.go"], + importpath = "sigs.k8s.io/cluster-api/cmd/clusterctl/validation", + visibility = ["//visibility:public"], + deps = [ + "//pkg/apis/cluster/common:go_default_library", + "//pkg/apis/cluster/v1alpha1:go_default_library", + "//pkg/controller/noderefutil:go_default_library", + "//vendor/golang.org/x/net/context:go_default_library", + "//vendor/k8s.io/api/core/v1:go_default_library", + "//vendor/k8s.io/apimachinery/pkg/types:go_default_library", + "//vendor/sigs.k8s.io/controller-runtime/pkg/client:go_default_library", + ], +) + +go_test( + name = "go_default_test", + srcs = [ + "validate_cluster_api_objects_suite_test.go", + "validate_cluster_api_objects_test.go", + ], + data = glob(["testdata/**"]), + embed = [":go_default_library"], + deps = [ + "//pkg/apis:go_default_library", + "//pkg/apis/cluster/common:go_default_library", + "//pkg/apis/cluster/v1alpha1:go_default_library", + "//pkg/apis/cluster/v1alpha1/testutil:go_default_library", + "//vendor/k8s.io/api/core/v1:go_default_library", + "//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library", + "//vendor/k8s.io/apimachinery/pkg/types:go_default_library", + "//vendor/k8s.io/client-go/kubernetes/scheme:go_default_library", + "//vendor/k8s.io/client-go/rest:go_default_library", + "//vendor/sigs.k8s.io/controller-runtime/pkg/client:go_default_library", + "//vendor/sigs.k8s.io/controller-runtime/pkg/envtest:go_default_library", + "//vendor/sigs.k8s.io/controller-runtime/pkg/manager:go_default_library", + ], +) diff --git a/vendor/sigs.k8s.io/cluster-api/cmd/manager/BUILD.bazel b/vendor/sigs.k8s.io/cluster-api/cmd/manager/BUILD.bazel new file mode 100644 index 0000000000..dbc53953f8 --- /dev/null +++ b/vendor/sigs.k8s.io/cluster-api/cmd/manager/BUILD.bazel @@ -0,0 +1,22 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") + +go_library( + name = "go_default_library", + srcs = ["main.go"], + importpath = "sigs.k8s.io/cluster-api/cmd/manager", + visibility = ["//visibility:private"], + deps = [ + "//pkg/apis:go_default_library", + "//pkg/controller:go_default_library", + "//vendor/k8s.io/client-go/plugin/pkg/client/auth/gcp:go_default_library", + "//vendor/sigs.k8s.io/controller-runtime/pkg/client/config:go_default_library", + "//vendor/sigs.k8s.io/controller-runtime/pkg/manager:go_default_library", + "//vendor/sigs.k8s.io/controller-runtime/pkg/runtime/signals:go_default_library", + ], +) + +go_binary( + name = "manager", + embed = [":go_default_library"], + visibility = ["//visibility:public"], +) diff --git a/vendor/sigs.k8s.io/cluster-api/config/BUILD.bazel b/vendor/sigs.k8s.io/cluster-api/config/BUILD.bazel new file mode 100644 index 0000000000..db8db9790e --- /dev/null +++ b/vendor/sigs.k8s.io/cluster-api/config/BUILD.bazel @@ -0,0 +1,22 @@ +filegroup( + name = "kustomize-yaml", + srcs = glob([ + "crds/*.yaml", + "rbac/*.yaml", + "manager/*.yaml", + "default/*.yaml", + ]), + visibility = ["//visibility:private"], +) + +genrule( + name = "cluster-api-yaml", + cmd = "$(location @io_k8s_sigs_kustomize//:kustomize) build $$(dirname $(location :default/kustomization.yaml)) > $@", + srcs = [ + ":kustomize-yaml", + ":default/kustomization.yaml", + ], + tools = ["@io_k8s_sigs_kustomize//:kustomize"], + outs = ["cluster_api.yaml"], + visibility = ["//visibility:public"], +) diff --git a/vendor/sigs.k8s.io/cluster-api/config/crds/cluster_v1alpha1_cluster.yaml b/vendor/sigs.k8s.io/cluster-api/config/crds/cluster_v1alpha1_cluster.yaml index 5d510f025c..ac8250c707 100644 --- a/vendor/sigs.k8s.io/cluster-api/config/crds/cluster_v1alpha1_cluster.yaml +++ b/vendor/sigs.k8s.io/cluster-api/config/crds/cluster_v1alpha1_cluster.yaml @@ -51,7 +51,7 @@ spec: - pods - serviceDomain type: object - providerConfig: + providerSpec: properties: value: type: object diff --git a/vendor/sigs.k8s.io/cluster-api/config/crds/cluster_v1alpha1_machine.yaml b/vendor/sigs.k8s.io/cluster-api/config/crds/cluster_v1alpha1_machine.yaml index ee1d3bed43..e53b5a6351 100644 --- a/vendor/sigs.k8s.io/cluster-api/config/crds/cluster_v1alpha1_machine.yaml +++ b/vendor/sigs.k8s.io/cluster-api/config/crds/cluster_v1alpha1_machine.yaml @@ -28,7 +28,7 @@ spec: type: object metadata: type: object - providerConfig: + providerSpec: properties: value: type: object @@ -55,7 +55,7 @@ spec: - kubelet type: object required: - - providerConfig + - providerSpec type: object status: properties: @@ -71,11 +71,25 @@ spec: type: string errorReason: type: string + lastOperation: + properties: + description: + type: string + lastUpdated: + format: date-time + type: string + state: + type: string + type: + type: string + type: object lastUpdated: format: date-time type: string nodeRef: type: object + phase: + type: string providerStatus: type: object versions: diff --git a/vendor/sigs.k8s.io/cluster-api/config/crds/cluster_v1alpha1_machineclass.yaml b/vendor/sigs.k8s.io/cluster-api/config/crds/cluster_v1alpha1_machineclass.yaml index c89ef40185..5de01dc582 100644 --- a/vendor/sigs.k8s.io/cluster-api/config/crds/cluster_v1alpha1_machineclass.yaml +++ b/vendor/sigs.k8s.io/cluster-api/config/crds/cluster_v1alpha1_machineclass.yaml @@ -20,10 +20,10 @@ spec: type: string metadata: type: object - providerConfig: + providerSpec: type: object required: - - providerConfig + - providerSpec version: v1alpha1 status: acceptedNames: diff --git a/vendor/sigs.k8s.io/cluster-api/config/crds/cluster_v1alpha1_machinedeployment.yaml b/vendor/sigs.k8s.io/cluster-api/config/crds/cluster_v1alpha1_machinedeployment.yaml index 42a5bb33d8..cc174de47b 100644 --- a/vendor/sigs.k8s.io/cluster-api/config/crds/cluster_v1alpha1_machinedeployment.yaml +++ b/vendor/sigs.k8s.io/cluster-api/config/crds/cluster_v1alpha1_machinedeployment.yaml @@ -64,7 +64,7 @@ spec: type: object metadata: type: object - providerConfig: + providerSpec: properties: value: type: object @@ -91,7 +91,7 @@ spec: - kubelet type: object required: - - providerConfig + - providerSpec type: object type: object required: diff --git a/vendor/sigs.k8s.io/cluster-api/config/crds/cluster_v1alpha1_machineset.yaml b/vendor/sigs.k8s.io/cluster-api/config/crds/cluster_v1alpha1_machineset.yaml index cef75e8c57..101db09963 100644 --- a/vendor/sigs.k8s.io/cluster-api/config/crds/cluster_v1alpha1_machineset.yaml +++ b/vendor/sigs.k8s.io/cluster-api/config/crds/cluster_v1alpha1_machineset.yaml @@ -46,7 +46,7 @@ spec: type: object metadata: type: object - providerConfig: + providerSpec: properties: value: type: object @@ -73,7 +73,7 @@ spec: - kubelet type: object required: - - providerConfig + - providerSpec type: object type: object required: diff --git a/vendor/sigs.k8s.io/cluster-api/config/default/kustomization.yaml b/vendor/sigs.k8s.io/cluster-api/config/default/kustomization.yaml index 782ca306c0..2e1e38c32e 100644 --- a/vendor/sigs.k8s.io/cluster-api/config/default/kustomization.yaml +++ b/vendor/sigs.k8s.io/cluster-api/config/default/kustomization.yaml @@ -20,6 +20,7 @@ namePrefix: cluster-api- resources: - ../crds/cluster_v1alpha1_cluster.yaml - ../crds/cluster_v1alpha1_machine.yaml +- ../crds/cluster_v1alpha1_machineclass.yaml - ../crds/cluster_v1alpha1_machinedeployment.yaml - ../crds/cluster_v1alpha1_machineset.yaml - ../rbac/rbac_role.yaml diff --git a/vendor/sigs.k8s.io/cluster-api/config/manager/manager.yaml b/vendor/sigs.k8s.io/cluster-api/config/manager/manager.yaml index 7b3ce562fb..7bc5fc6bb6 100644 --- a/vendor/sigs.k8s.io/cluster-api/config/manager/manager.yaml +++ b/vendor/sigs.k8s.io/cluster-api/config/manager/manager.yaml @@ -53,7 +53,7 @@ spec: operator: Exists containers: - command: - - /root/manager + - /manager image: controller:latest name: manager resources: diff --git a/vendor/sigs.k8s.io/cluster-api/docs/book/appendices/keps/0003-cluster-api.md b/vendor/sigs.k8s.io/cluster-api/docs/book/appendices/keps/0003-cluster-api.md index f211a53431..d13587930f 100644 --- a/vendor/sigs.k8s.io/cluster-api/docs/book/appendices/keps/0003-cluster-api.md +++ b/vendor/sigs.k8s.io/cluster-api/docs/book/appendices/keps/0003-cluster-api.md @@ -1 +1 @@ -{% include "git+https://github.com/kubernetes/community.git/keps/sig-cluster-lifecycle/0003-cluster-api.md" %} +{% include "git+https://github.com/kubernetes/enhancements.git/keps/sig-cluster-lifecycle/0003-cluster-api.md" %} diff --git a/vendor/sigs.k8s.io/cluster-api/docs/book/provider_implementations/create_actuators.md b/vendor/sigs.k8s.io/cluster-api/docs/book/provider_implementations/create_actuators.md index 33c6ae5458..54b1b75357 100644 --- a/vendor/sigs.k8s.io/cluster-api/docs/book/provider_implementations/create_actuators.md +++ b/vendor/sigs.k8s.io/cluster-api/docs/book/provider_implementations/create_actuators.md @@ -90,6 +90,7 @@ limitations under the License. package machine import ( + "context" "fmt" "log" @@ -119,25 +120,25 @@ func NewActuator(params ActuatorParams) (*Actuator, error) { } // Create creates a machine and is invoked by the Machine Controller -func (a *Actuator) Create(cluster *clusterv1.Cluster, machine *clusterv1.Machine) error { +func (a *Actuator) Create(ctx context.Context, cluster *clusterv1.Cluster, machine *clusterv1.Machine) error { log.Printf("Creating machine %v for cluster %v.", machine.Name, cluster.Name) return fmt.Errorf("TODO: Not yet implemented") } // Delete deletes a machine and is invoked by the Machine Controller -func (a *Actuator) Delete(cluster *clusterv1.Cluster, machine *clusterv1.Machine) error { +func (a *Actuator) Delete(ctx context.Context, cluster *clusterv1.Cluster, machine *clusterv1.Machine) error { log.Printf("Deleting machine %v for cluster %v.", machine.Name, cluster.Name) return fmt.Errorf("TODO: Not yet implemented") } // Update updates a machine and is invoked by the Machine Controller -func (a *Actuator) Update(cluster *clusterv1.Cluster, machine *clusterv1.Machine) error { +func (a *Actuator) Update(ctx context.Context, cluster *clusterv1.Cluster, machine *clusterv1.Machine) error { log.Printf("Updating machine %v for cluster %v.", machine.Name, cluster.Name) return fmt.Errorf("TODO: Not yet implemented") } // Exists test for the existance of a machine and is invoked by the Machine Controller -func (a *Actuator) Exists(cluster *clusterv1.Cluster, machine *clusterv1.Machine) (bool, error) { +func (a *Actuator) Exists(ctx context.Context, cluster *clusterv1.Cluster, machine *clusterv1.Machine) (bool, error) { log.Printf("Checking if machine %v for cluster %v exists.", machine.Name, cluster.Name) return false, fmt.Errorf("TODO: Not yet implemented") } diff --git a/vendor/sigs.k8s.io/cluster-api/docs/book/provider_implementations/overview.md b/vendor/sigs.k8s.io/cluster-api/docs/book/provider_implementations/overview.md index 164678f9bd..9e2c7a4966 100644 --- a/vendor/sigs.k8s.io/cluster-api/docs/book/provider_implementations/overview.md +++ b/vendor/sigs.k8s.io/cluster-api/docs/book/provider_implementations/overview.md @@ -20,7 +20,7 @@ Much of the information here was adapted directly from it. brew install kubernetes-cli # Install minikube -curl -Lo minikube https://storage.googleapis.com/minikube/releases/v0.30.0/minikube-darwin-amd64 && \ +curl -fLo minikube https://storage.googleapis.com/minikube/releases/v0.30.0/minikube-darwin-amd64 && \ chmod +x minikube && \ sudo cp minikube /usr/local/bin/ && \ rm minikube @@ -30,22 +30,22 @@ brew install kustomize ``` ```bash::Linux # Install kubectl -KUBECTL_VERSION=$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt) -curl -LO https://storage.googleapis.com/kubernetes-release/release/${KUBECTL_VERSION}/bin/linux/amd64/kubectl +KUBECTL_VERSION=$(curl -sf https://storage.googleapis.com/kubernetes-release/release/stable.txt) +curl -fLO https://storage.googleapis.com/kubernetes-release/release/${KUBECTL_VERSION}/bin/linux/amd64/kubectl # Install minikube -curl -Lo minikube https://storage.googleapis.com/minikube/releases/v0.30.0/minikube-linux-amd64 && \ +curl -fLo minikube https://storage.googleapis.com/minikube/releases/v0.30.0/minikube-linux-amd64 && \ chmod +x minikube && \ sudo cp minikube /usr/local/bin/ && \ rm minikube # Install kustomize OS_TYPE=linux -curl -s https://api.github.com/repos/kubernetes-sigs/kustomize/releases/latest |\ +curl -sf https://api.github.com/repos/kubernetes-sigs/kustomize/releases/latest |\ grep browser_download |\ grep ${OS_TYPE} |\ cut -d '"' -f 4 |\ - xargs curl -O -L + xargs curl -f -O -L mv kustomize_*_${OS_TYPE}_amd64 /usr/local/bin/kustomize chmod u+x /usr/local/bin/kustomize ``` diff --git a/vendor/sigs.k8s.io/cluster-api/docs/proposals/machine-api-proposal.md b/vendor/sigs.k8s.io/cluster-api/docs/proposals/machine-api-proposal.md index a7141e9e3c..971973a871 100644 --- a/vendor/sigs.k8s.io/cluster-api/docs/proposals/machine-api-proposal.md +++ b/vendor/sigs.k8s.io/cluster-api/docs/proposals/machine-api-proposal.md @@ -41,15 +41,15 @@ provider-specific controller, and should be deleted as well. Fields like the kubelet version are modeled as fields on the Machine's spec. Any other information that is provider-specific, though, is part of an opaque -ProviderConfig string that is not portable between different providers. +ProviderSpec string that is not portable between different providers. -The ProviderConfig is recommended to be a serialized API object in a format +The ProviderSpec is recommended to be a serialized API object in a format owned by that provider, akin to the [Component Config](https://goo.gl/opSc2o) pattern. This will allow the configuration to be strongly typed, versioned, and have as much nested depth as appropriate. These provider-specific API definitions are meant to live outside of the Machines API, which will allow them to evolve independently of it. Attributes like instance type, which network to -use, and the OS image all belong in the ProviderConfig. +use, and the OS image all belong in the ProviderSpec. ## In-place vs. Replace diff --git a/vendor/github.com/kubernetes-incubator/apiserver-builder/Makefile b/vendor/sigs.k8s.io/cluster-api/hack/update-bazel.sh old mode 100644 new mode 100755 similarity index 70% rename from vendor/github.com/kubernetes-incubator/apiserver-builder/Makefile rename to vendor/sigs.k8s.io/cluster-api/hack/update-bazel.sh index 1a9df8f8e2..b32b850967 --- a/vendor/github.com/kubernetes-incubator/apiserver-builder/Makefile +++ b/vendor/sigs.k8s.io/cluster-api/hack/update-bazel.sh @@ -1,4 +1,5 @@ -# Copyright 2017 The Kubernetes Authors. +#!/usr/bin/env bash +# Copyright 2018 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. @@ -12,11 +13,12 @@ # See the License for the specific language governing permissions and # limitations under the License. -.PHONY: test -test: - go test ./pkg/... ./cmd/... +set -o errexit +set -o nounset +set -o pipefail -.PHONY: install -install: - go install -v ./pkg/... ./cmd/... +export KUBE_ROOT=$(dirname "${BASH_SOURCE}")/.. +cd $KUBE_ROOT +find $KUBE_ROOT/vendor -name 'BUILD' -delete +bazel run //:gazelle diff --git a/vendor/sigs.k8s.io/cluster-api/hack/verify-bazel.sh b/vendor/sigs.k8s.io/cluster-api/hack/verify-bazel.sh new file mode 100755 index 0000000000..05a3d67bca --- /dev/null +++ b/vendor/sigs.k8s.io/cluster-api/hack/verify-bazel.sh @@ -0,0 +1,30 @@ +#!/usr/bin/env bash +# Copyright 2018 The Kubernetes Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -o errexit +set -o nounset +set -o pipefail +set -o verbose + +if ! which bazel &>/dev/null; then echo "Bazel not available, skipping validation"; exit; fi + +diff=$(bazel run //:gazelle -- update -mode diff -external vendored) + +if [[ -n "${diff}" ]]; then + echo "${diff}" >&2 + echo >&2 + echo "Run ./hack/update-bazel.sh" >&2 + exit 1 +fi diff --git a/vendor/sigs.k8s.io/cluster-api/hack/verify_clientset.sh b/vendor/sigs.k8s.io/cluster-api/hack/verify_clientset.sh index 6f2db67318..c8d36fb696 100755 --- a/vendor/sigs.k8s.io/cluster-api/hack/verify_clientset.sh +++ b/vendor/sigs.k8s.io/cluster-api/hack/verify_clientset.sh @@ -38,7 +38,7 @@ make clientset echo "diffing ${DIFFROOT} against freshly generated codegen" ret=0 -diff -Naupr "${DIFFROOT}" "${TMP_DIFFROOT}" || ret=$? +diff -Naupr "${DIFFROOT}" "${TMP_DIFFROOT}" -x '*.bazel' -x 'BUILD' || ret=$? cp -a "${TMP_DIFFROOT}"/* "${DIFFROOT}" if [[ $ret -eq 0 ]] then diff --git a/vendor/sigs.k8s.io/cluster-api/pkg/apis/BUILD.bazel b/vendor/sigs.k8s.io/cluster-api/pkg/apis/BUILD.bazel new file mode 100644 index 0000000000..5fb1263e99 --- /dev/null +++ b/vendor/sigs.k8s.io/cluster-api/pkg/apis/BUILD.bazel @@ -0,0 +1,15 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +go_library( + name = "go_default_library", + srcs = [ + "addtoscheme_cluster_v1alpha1.go", + "apis.go", + ], + importpath = "sigs.k8s.io/cluster-api/pkg/apis", + visibility = ["//visibility:public"], + deps = [ + "//pkg/apis/cluster/v1alpha1:go_default_library", + "//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library", + ], +) diff --git a/vendor/sigs.k8s.io/cluster-api/pkg/apis/cluster/BUILD.bazel b/vendor/sigs.k8s.io/cluster-api/pkg/apis/cluster/BUILD.bazel new file mode 100644 index 0000000000..f8a8882a79 --- /dev/null +++ b/vendor/sigs.k8s.io/cluster-api/pkg/apis/cluster/BUILD.bazel @@ -0,0 +1,8 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +go_library( + name = "go_default_library", + srcs = ["group.go"], + importpath = "sigs.k8s.io/cluster-api/pkg/apis/cluster", + visibility = ["//visibility:public"], +) diff --git a/vendor/sigs.k8s.io/cluster-api/pkg/apis/cluster/common/BUILD.bazel b/vendor/sigs.k8s.io/cluster-api/pkg/apis/cluster/common/BUILD.bazel new file mode 100644 index 0000000000..899f3e11d8 --- /dev/null +++ b/vendor/sigs.k8s.io/cluster-api/pkg/apis/cluster/common/BUILD.bazel @@ -0,0 +1,12 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +go_library( + name = "go_default_library", + srcs = [ + "consts.go", + "plugins.go", + ], + importpath = "sigs.k8s.io/cluster-api/pkg/apis/cluster/common", + visibility = ["//visibility:public"], + deps = ["//vendor/k8s.io/klog:go_default_library"], +) diff --git a/vendor/sigs.k8s.io/cluster-api/pkg/apis/cluster/common/consts.go b/vendor/sigs.k8s.io/cluster-api/pkg/apis/cluster/common/consts.go index 6990f76ebb..81fed067fe 100644 --- a/vendor/sigs.k8s.io/cluster-api/pkg/apis/cluster/common/consts.go +++ b/vendor/sigs.k8s.io/cluster-api/pkg/apis/cluster/common/consts.go @@ -25,7 +25,7 @@ const ( // is not supported by this cluster. This is not a transient error, but // indicates a state that must be fixed before progress can be made. // - // Example: the ProviderConfig specifies an instance type that doesn't exist, + // Example: the ProviderSpec specifies an instance type that doesn't exist, InvalidConfigurationMachineError MachineStatusError = "InvalidConfiguration" // This indicates that the MachineSpec has been updated in a way that @@ -92,7 +92,7 @@ const ( // is not supported by this cluster. This is not a transient error, but // indicates a state that must be fixed before progress can be made. // - // Example: the ProviderConfig specifies an instance type that doesn't exist. + // Example: the ProviderSpec specifies an instance type that doesn't exist. InvalidConfigurationMachineSetError MachineSetStatusError = "InvalidConfiguration" ) @@ -100,6 +100,6 @@ type MachineDeploymentStrategyType string const ( // Replace the old MachineSet by new one using rolling update - // i.e gradually scale down the old MachineSet and scale up the new one. + // i.e. gradually scale down the old MachineSet and scale up the new one. RollingUpdateMachineDeploymentStrategyType MachineDeploymentStrategyType = "RollingUpdate" ) diff --git a/vendor/sigs.k8s.io/cluster-api/pkg/apis/cluster/common/plugins.go b/vendor/sigs.k8s.io/cluster-api/pkg/apis/cluster/common/plugins.go index 1ef4543d89..276cbe9be5 100644 --- a/vendor/sigs.k8s.io/cluster-api/pkg/apis/cluster/common/plugins.go +++ b/vendor/sigs.k8s.io/cluster-api/pkg/apis/cluster/common/plugins.go @@ -20,7 +20,7 @@ import ( "fmt" "sync" - "github.com/golang/glog" + "k8s.io/klog" ) var ( @@ -34,9 +34,9 @@ func RegisterClusterProvisioner(name string, provisioner interface{}) { providersMutex.Lock() defer providersMutex.Unlock() if _, found := providers[name]; found { - glog.Fatalf("Cluster provisioner %q was registered twice", name) + klog.Fatalf("Cluster provisioner %q was registered twice", name) } - glog.V(1).Infof("Registered cluster provisioner %q", name) + klog.V(1).Infof("Registered cluster provisioner %q", name) providers[name] = provisioner } diff --git a/vendor/sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1/BUILD.bazel b/vendor/sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1/BUILD.bazel new file mode 100644 index 0000000000..074fbc10c0 --- /dev/null +++ b/vendor/sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1/BUILD.bazel @@ -0,0 +1,52 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") + +go_library( + name = "go_default_library", + srcs = [ + "cluster_types.go", + "common_types.go", + "defaults.go", + "doc.go", + "machine_types.go", + "machineclass_types.go", + "machinedeployment_types.go", + "machineset_types.go", + "register.go", + "zz_generated.deepcopy.go", + ], + importpath = "sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1", + visibility = ["//visibility:public"], + deps = [ + "//pkg/apis/cluster/common:go_default_library", + "//vendor/k8s.io/api/core/v1:go_default_library", + "//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library", + "//vendor/k8s.io/apimachinery/pkg/apis/meta/v1/validation:go_default_library", + "//vendor/k8s.io/apimachinery/pkg/labels: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/intstr:go_default_library", + "//vendor/k8s.io/apimachinery/pkg/util/validation/field:go_default_library", + "//vendor/sigs.k8s.io/controller-runtime/pkg/runtime/scheme:go_default_library", + ], +) + +go_test( + name = "go_default_test", + srcs = [ + "cluster_types_test.go", + "machine_types_test.go", + "machinedeployment_types_test.go", + "machineset_types_test.go", + "v1alpha1_suite_test.go", + ], + embed = [":go_default_library"], + deps = [ + "//vendor/golang.org/x/net/context:go_default_library", + "//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library", + "//vendor/k8s.io/apimachinery/pkg/types:go_default_library", + "//vendor/k8s.io/client-go/kubernetes/scheme:go_default_library", + "//vendor/k8s.io/client-go/rest:go_default_library", + "//vendor/sigs.k8s.io/controller-runtime/pkg/client:go_default_library", + "//vendor/sigs.k8s.io/controller-runtime/pkg/envtest:go_default_library", + ], +) diff --git a/vendor/sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1/cluster_types.go b/vendor/sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1/cluster_types.go index d07a217892..c0cd29a46b 100644 --- a/vendor/sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1/cluster_types.go +++ b/vendor/sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1/cluster_types.go @@ -54,7 +54,7 @@ type ClusterSpec struct { // their own versioned API types that should be // serialized/deserialized from this field. // +optional - ProviderConfig ProviderConfig `json:"providerConfig,omitempty"` + ProviderSpec ProviderSpec `json:"providerSpec,omitempty"` } /// [ClusterSpec] @@ -66,7 +66,7 @@ type ClusterNetworkingConfig struct { // The network ranges from which service VIPs are allocated. Services NetworkRanges `json:"services"` - // The network ranges from which POD networks are allocated. + // The network ranges from which Pod networks are allocated. Pods NetworkRanges `json:"pods"` // Domain name for services. diff --git a/vendor/sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1/common_types.go b/vendor/sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1/common_types.go index 32bb55f8c1..7a9c647fe2 100644 --- a/vendor/sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1/common_types.go +++ b/vendor/sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1/common_types.go @@ -21,8 +21,8 @@ import ( runtime "k8s.io/apimachinery/pkg/runtime" ) -// ProviderConfig defines the configuration to use during node creation. -type ProviderConfig struct { +// ProviderSpec defines the configuration to use during node creation. +type ProviderSpec struct { // No more than one of the following may be specified. @@ -36,12 +36,12 @@ type ProviderConfig struct { // Source for the provider configuration. Cannot be used if value is // not empty. // +optional - ValueFrom *ProviderConfigSource `json:"valueFrom,omitempty"` + ValueFrom *ProviderSpecSource `json:"valueFrom,omitempty"` } -// ProviderConfigSource represents a source for the provider-specific +// ProviderSpecSource represents a source for the provider-specific // resource configuration. -type ProviderConfigSource struct { +type ProviderSpecSource struct { // The machine class from which the provider config should be sourced. // +optional MachineClass *MachineClassRef `json:"machineClass,omitempty"` diff --git a/vendor/sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1/defaults.go b/vendor/sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1/defaults.go new file mode 100644 index 0000000000..f9aeb4b438 --- /dev/null +++ b/vendor/sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1/defaults.go @@ -0,0 +1,74 @@ +/* +Copyright 2018 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1alpha1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/util/intstr" + "sigs.k8s.io/cluster-api/pkg/apis/cluster/common" +) + +// PopulateDefaultsMachineDeployment fills in default field values +// Currently it is called after reading objects, but it could be called in an admission webhook also +func PopulateDefaultsMachineDeployment(d *MachineDeployment) { + if d.Spec.Replicas == nil { + d.Spec.Replicas = new(int32) + *d.Spec.Replicas = 1 + } + + if d.Spec.MinReadySeconds == nil { + d.Spec.MinReadySeconds = new(int32) + *d.Spec.MinReadySeconds = 0 + } + + if d.Spec.RevisionHistoryLimit == nil { + d.Spec.RevisionHistoryLimit = new(int32) + *d.Spec.RevisionHistoryLimit = 1 + } + + if d.Spec.ProgressDeadlineSeconds == nil { + d.Spec.ProgressDeadlineSeconds = new(int32) + *d.Spec.ProgressDeadlineSeconds = 600 + } + + if d.Spec.Strategy == nil { + d.Spec.Strategy = &MachineDeploymentStrategy{} + } + + if d.Spec.Strategy.Type == "" { + d.Spec.Strategy.Type = common.RollingUpdateMachineDeploymentStrategyType + } + + // Default RollingUpdate strategy only if strategy type is RollingUpdate. + if d.Spec.Strategy.Type == common.RollingUpdateMachineDeploymentStrategyType { + if d.Spec.Strategy.RollingUpdate == nil { + d.Spec.Strategy.RollingUpdate = &MachineRollingUpdateDeployment{} + } + if d.Spec.Strategy.RollingUpdate.MaxSurge == nil { + ios1 := intstr.FromInt(1) + d.Spec.Strategy.RollingUpdate.MaxSurge = &ios1 + } + if d.Spec.Strategy.RollingUpdate.MaxUnavailable == nil { + ios0 := intstr.FromInt(0) + d.Spec.Strategy.RollingUpdate.MaxUnavailable = &ios0 + } + } + + if len(d.Namespace) == 0 { + d.Namespace = metav1.NamespaceDefault + } +} diff --git a/vendor/sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1/machine_types.go b/vendor/sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1/machine_types.go index 55dda209b1..5a10bba39f 100644 --- a/vendor/sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1/machine_types.go +++ b/vendor/sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1/machine_types.go @@ -24,7 +24,7 @@ import ( "sigs.k8s.io/cluster-api/pkg/apis/cluster/common" ) -// Finalizer is set on PreareForCreate callback +// Finalizer is set on PrepareForCreate callback const MachineFinalizer = "machine.cluster.k8s.io" // +genclient @@ -61,7 +61,7 @@ type MachineSpec struct { // Provider-specific configuration to use during node creation. // +optional - ProviderConfig ProviderConfig `json:"providerConfig"` + ProviderSpec ProviderSpec `json:"providerSpec"` // Versions of key software to use. This field is optional at cluster // creation time, and omitting the field indicates that the cluster @@ -74,7 +74,7 @@ type MachineSpec struct { // To populate in the associated Node for dynamic kubelet config. This // field already exists in Node, so any updates to it in the Machine - // spec will be automatially copied to the linked NodeRef from the + // spec will be automatically copied to the linked NodeRef from the // status. The rest of dynamic kubelet config support should then work // as-is. // +optional @@ -151,6 +151,35 @@ type MachineStatus struct { // Refer: https://kubernetes.io/docs/concepts/architecture/nodes/#condition // +optional Conditions []corev1.NodeCondition `json:"conditions,omitempty"` + + // LastOperation describes the last-operation performed by the machine-controller. + // This API should be useful as a history in terms of the latest operation performed on the + // specific machine. It should also convey the state of the latest-operation for example if + // it is still on-going, failed or completed successfully. + // +optional + LastOperation *LastOperation `json:"lastOperation,omitempty"` + + // Phase represents the current phase of machine actuation. + // E.g. Pending, Running, Terminating, Failed etc. + // +optional + Phase *string `json:"phase,omitempty"` +} + +// LastOperation represents the detail of the last performed operation on the MachineObject. +type LastOperation struct { + // Description is the human-readable description of the last operation. + Description *string `json:"description,omitempty"` + + // LastUpdateTime is the timestamp at which LastOperation API was last-updated. + LastUpdated *metav1.Time `json:"lastUpdated,omitempty"` + + // State is the current status of the last performed operation. + // E.g. Processing, Failed, Successful etc + State *string `json:"state,omitempty"` + + // Type is the type of operation which was last performed. + // E.g. Create, Delete, Update etc + Type *string `json:"type,omitempty"` } /// [MachineStatus] diff --git a/vendor/sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1/machineclass_types.go b/vendor/sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1/machineclass_types.go index 9358577935..7844f6cfa4 100644 --- a/vendor/sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1/machineclass_types.go +++ b/vendor/sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1/machineclass_types.go @@ -56,7 +56,7 @@ type MachineClass struct { // Allocatable corev1.ResourceList `json:"allocatable"` // Provider-specific configuration to use during node creation. - ProviderConfig runtime.RawExtension `json:"providerConfig"` + ProviderSpec runtime.RawExtension `json:"providerSpec"` // TODO: should this use an api.ObjectReference to a 'MachineTemplate' instead? // A link to the MachineTemplate that will be used to create provider diff --git a/vendor/sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1/machineset_types.go b/vendor/sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1/machineset_types.go index a528d06b23..40c04286a3 100644 --- a/vendor/sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1/machineset_types.go +++ b/vendor/sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1/machineset_types.go @@ -120,7 +120,7 @@ type MachineSetStatus struct { // These fields should not be set for transitive errors that a // controller faces that are expected to be fixed automatically over // time (like service outages), but instead indicate that something is - // fundamentally wrong with the MachineTemplates's spec or the configuration of + // fundamentally wrong with the MachineTemplate's spec or the configuration of // the machine controller, and that manual intervention is required. Examples // of terminal errors would be invalid combinations of settings in the // spec, values that are unsupported by the machine controller, or the diff --git a/vendor/sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1/testutil/BUILD.bazel b/vendor/sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1/testutil/BUILD.bazel new file mode 100644 index 0000000000..bcee50bdc5 --- /dev/null +++ b/vendor/sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1/testutil/BUILD.bazel @@ -0,0 +1,9 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +go_library( + name = "go_default_library", + srcs = ["testutil.go"], + importpath = "sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1/testutil", + visibility = ["//visibility:public"], + deps = ["//pkg/apis/cluster/v1alpha1:go_default_library"], +) diff --git a/vendor/sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1/zz_generated.deepcopy.go b/vendor/sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1/zz_generated.deepcopy.go index 9de6a26780..9b0a035208 100644 --- a/vendor/sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1/zz_generated.deepcopy.go +++ b/vendor/sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1/zz_generated.deepcopy.go @@ -126,7 +126,7 @@ func (in *ClusterNetworkingConfig) DeepCopy() *ClusterNetworkingConfig { func (in *ClusterSpec) DeepCopyInto(out *ClusterSpec) { *out = *in in.ClusterNetwork.DeepCopyInto(&out.ClusterNetwork) - in.ProviderConfig.DeepCopyInto(&out.ProviderConfig) + in.ProviderSpec.DeepCopyInto(&out.ProviderSpec) return } @@ -166,6 +166,41 @@ func (in *ClusterStatus) DeepCopy() *ClusterStatus { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *LastOperation) DeepCopyInto(out *LastOperation) { + *out = *in + if in.Description != nil { + in, out := &in.Description, &out.Description + *out = new(string) + **out = **in + } + if in.LastUpdated != nil { + in, out := &in.LastUpdated, &out.LastUpdated + *out = (*in).DeepCopy() + } + if in.State != nil { + in, out := &in.State, &out.State + *out = new(string) + **out = **in + } + if in.Type != nil { + in, out := &in.Type, &out.Type + *out = new(string) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LastOperation. +func (in *LastOperation) DeepCopy() *LastOperation { + if in == nil { + return nil + } + out := new(LastOperation) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Machine) DeepCopyInto(out *Machine) { *out = *in @@ -199,7 +234,7 @@ func (in *MachineClass) DeepCopyInto(out *MachineClass) { *out = *in out.TypeMeta = in.TypeMeta in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - in.ProviderConfig.DeepCopyInto(&out.ProviderConfig) + in.ProviderSpec.DeepCopyInto(&out.ProviderSpec) return } @@ -596,7 +631,7 @@ func (in *MachineSpec) DeepCopyInto(out *MachineSpec) { (*in)[i].DeepCopyInto(&(*out)[i]) } } - in.ProviderConfig.DeepCopyInto(&out.ProviderConfig) + in.ProviderSpec.DeepCopyInto(&out.ProviderSpec) out.Versions = in.Versions if in.ConfigSource != nil { in, out := &in.ConfigSource, &out.ConfigSource @@ -660,6 +695,16 @@ func (in *MachineStatus) DeepCopyInto(out *MachineStatus) { (*in)[i].DeepCopyInto(&(*out)[i]) } } + if in.LastOperation != nil { + in, out := &in.LastOperation, &out.LastOperation + *out = new(LastOperation) + (*in).DeepCopyInto(*out) + } + if in.Phase != nil { + in, out := &in.Phase, &out.Phase + *out = new(string) + **out = **in + } return } @@ -729,7 +774,7 @@ func (in *NetworkRanges) DeepCopy() *NetworkRanges { } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ProviderConfig) DeepCopyInto(out *ProviderConfig) { +func (in *ProviderSpec) DeepCopyInto(out *ProviderSpec) { *out = *in if in.Value != nil { in, out := &in.Value, &out.Value @@ -738,24 +783,24 @@ func (in *ProviderConfig) DeepCopyInto(out *ProviderConfig) { } if in.ValueFrom != nil { in, out := &in.ValueFrom, &out.ValueFrom - *out = new(ProviderConfigSource) + *out = new(ProviderSpecSource) (*in).DeepCopyInto(*out) } return } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ProviderConfig. -func (in *ProviderConfig) DeepCopy() *ProviderConfig { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ProviderSpec. +func (in *ProviderSpec) DeepCopy() *ProviderSpec { if in == nil { return nil } - out := new(ProviderConfig) + out := new(ProviderSpec) in.DeepCopyInto(out) return out } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ProviderConfigSource) DeepCopyInto(out *ProviderConfigSource) { +func (in *ProviderSpecSource) DeepCopyInto(out *ProviderSpecSource) { *out = *in if in.MachineClass != nil { in, out := &in.MachineClass, &out.MachineClass @@ -765,12 +810,12 @@ func (in *ProviderConfigSource) DeepCopyInto(out *ProviderConfigSource) { return } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ProviderConfigSource. -func (in *ProviderConfigSource) DeepCopy() *ProviderConfigSource { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ProviderSpecSource. +func (in *ProviderSpecSource) DeepCopy() *ProviderSpecSource { if in == nil { return nil } - out := new(ProviderConfigSource) + out := new(ProviderSpecSource) in.DeepCopyInto(out) return out } diff --git a/vendor/sigs.k8s.io/cluster-api/pkg/cert/BUILD.bazel b/vendor/sigs.k8s.io/cluster-api/pkg/cert/BUILD.bazel new file mode 100644 index 0000000000..160388a913 --- /dev/null +++ b/vendor/sigs.k8s.io/cluster-api/pkg/cert/BUILD.bazel @@ -0,0 +1,15 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") + +go_library( + name = "go_default_library", + srcs = ["cert_authority.go"], + importpath = "sigs.k8s.io/cluster-api/pkg/cert", + visibility = ["//visibility:public"], + deps = ["//vendor/k8s.io/klog:go_default_library"], +) + +go_test( + name = "go_default_test", + srcs = ["cert_authority_test.go"], + embed = [":go_default_library"], +) diff --git a/vendor/sigs.k8s.io/cluster-api/pkg/cert/cert_authority.go b/vendor/sigs.k8s.io/cluster-api/pkg/cert/cert_authority.go index 31b1a1d6a3..591602d9d6 100644 --- a/vendor/sigs.k8s.io/cluster-api/pkg/cert/cert_authority.go +++ b/vendor/sigs.k8s.io/cluster-api/pkg/cert/cert_authority.go @@ -18,10 +18,11 @@ package cert import ( "fmt" - "github.com/golang/glog" "io/ioutil" "os" "path/filepath" + + "k8s.io/klog" ) type CertificateAuthority struct { @@ -37,7 +38,7 @@ type CertificateAuthority struct { // read the given file and attempt to load the other associated file. For example, if the path given is /path/to/my-ca.crt, // then load will attempt to load the private key file at /path/to/my-ca.key. func Load(caPath string) (*CertificateAuthority, error) { - glog.Infof("Loading certificate authority from %v", caPath) + klog.Infof("Loading certificate authority from %v", caPath) certPath, keyPath, err := certPathToCertAndKeyPaths(caPath) if err != nil { return nil, err diff --git a/vendor/sigs.k8s.io/cluster-api/pkg/client/clientset_generated/clientset/BUILD.bazel b/vendor/sigs.k8s.io/cluster-api/pkg/client/clientset_generated/clientset/BUILD.bazel new file mode 100644 index 0000000000..9665ba8d3d --- /dev/null +++ b/vendor/sigs.k8s.io/cluster-api/pkg/client/clientset_generated/clientset/BUILD.bazel @@ -0,0 +1,17 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +go_library( + name = "go_default_library", + srcs = [ + "clientset.go", + "doc.go", + ], + importpath = "sigs.k8s.io/cluster-api/pkg/client/clientset_generated/clientset", + visibility = ["//visibility:public"], + deps = [ + "//pkg/client/clientset_generated/clientset/typed/cluster/v1alpha1:go_default_library", + "//vendor/k8s.io/client-go/discovery:go_default_library", + "//vendor/k8s.io/client-go/rest:go_default_library", + "//vendor/k8s.io/client-go/util/flowcontrol:go_default_library", + ], +) diff --git a/vendor/sigs.k8s.io/cluster-api/pkg/client/clientset_generated/clientset/fake/BUILD.bazel b/vendor/sigs.k8s.io/cluster-api/pkg/client/clientset_generated/clientset/fake/BUILD.bazel new file mode 100644 index 0000000000..e3d124b8b1 --- /dev/null +++ b/vendor/sigs.k8s.io/cluster-api/pkg/client/clientset_generated/clientset/fake/BUILD.bazel @@ -0,0 +1,27 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +go_library( + name = "go_default_library", + srcs = [ + "clientset_generated.go", + "doc.go", + "register.go", + ], + importpath = "sigs.k8s.io/cluster-api/pkg/client/clientset_generated/clientset/fake", + visibility = ["//visibility:public"], + deps = [ + "//pkg/apis/cluster/v1alpha1:go_default_library", + "//pkg/client/clientset_generated/clientset:go_default_library", + "//pkg/client/clientset_generated/clientset/typed/cluster/v1alpha1:go_default_library", + "//pkg/client/clientset_generated/clientset/typed/cluster/v1alpha1/fake: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/runtime:go_default_library", + "//vendor/k8s.io/apimachinery/pkg/watch:go_default_library", + "//vendor/k8s.io/client-go/discovery:go_default_library", + "//vendor/k8s.io/client-go/discovery/fake:go_default_library", + "//vendor/k8s.io/client-go/testing:go_default_library", + ], +) diff --git a/vendor/sigs.k8s.io/cluster-api/pkg/client/clientset_generated/clientset/scheme/BUILD.bazel b/vendor/sigs.k8s.io/cluster-api/pkg/client/clientset_generated/clientset/scheme/BUILD.bazel new file mode 100644 index 0000000000..967e9635f2 --- /dev/null +++ b/vendor/sigs.k8s.io/cluster-api/pkg/client/clientset_generated/clientset/scheme/BUILD.bazel @@ -0,0 +1,19 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +go_library( + name = "go_default_library", + srcs = [ + "doc.go", + "register.go", + ], + importpath = "sigs.k8s.io/cluster-api/pkg/client/clientset_generated/clientset/scheme", + visibility = ["//visibility:public"], + deps = [ + "//pkg/apis/cluster/v1alpha1: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/runtime:go_default_library", + ], +) diff --git a/vendor/sigs.k8s.io/cluster-api/pkg/client/clientset_generated/clientset/typed/cluster/v1alpha1/BUILD.bazel b/vendor/sigs.k8s.io/cluster-api/pkg/client/clientset_generated/clientset/typed/cluster/v1alpha1/BUILD.bazel new file mode 100644 index 0000000000..d7034eae03 --- /dev/null +++ b/vendor/sigs.k8s.io/cluster-api/pkg/client/clientset_generated/clientset/typed/cluster/v1alpha1/BUILD.bazel @@ -0,0 +1,26 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +go_library( + name = "go_default_library", + srcs = [ + "cluster.go", + "cluster_client.go", + "doc.go", + "generated_expansion.go", + "machine.go", + "machineclass.go", + "machinedeployment.go", + "machineset.go", + ], + importpath = "sigs.k8s.io/cluster-api/pkg/client/clientset_generated/clientset/typed/cluster/v1alpha1", + visibility = ["//visibility:public"], + deps = [ + "//pkg/apis/cluster/v1alpha1:go_default_library", + "//pkg/client/clientset_generated/clientset/scheme:go_default_library", + "//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library", + "//vendor/k8s.io/apimachinery/pkg/runtime/serializer:go_default_library", + "//vendor/k8s.io/apimachinery/pkg/types:go_default_library", + "//vendor/k8s.io/apimachinery/pkg/watch:go_default_library", + "//vendor/k8s.io/client-go/rest:go_default_library", + ], +) diff --git a/vendor/sigs.k8s.io/cluster-api/pkg/client/clientset_generated/clientset/typed/cluster/v1alpha1/fake/BUILD.bazel b/vendor/sigs.k8s.io/cluster-api/pkg/client/clientset_generated/clientset/typed/cluster/v1alpha1/fake/BUILD.bazel new file mode 100644 index 0000000000..76a6933b28 --- /dev/null +++ b/vendor/sigs.k8s.io/cluster-api/pkg/client/clientset_generated/clientset/typed/cluster/v1alpha1/fake/BUILD.bazel @@ -0,0 +1,27 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +go_library( + name = "go_default_library", + srcs = [ + "doc.go", + "fake_cluster.go", + "fake_cluster_client.go", + "fake_machine.go", + "fake_machineclass.go", + "fake_machinedeployment.go", + "fake_machineset.go", + ], + importpath = "sigs.k8s.io/cluster-api/pkg/client/clientset_generated/clientset/typed/cluster/v1alpha1/fake", + visibility = ["//visibility:public"], + deps = [ + "//pkg/apis/cluster/v1alpha1:go_default_library", + "//pkg/client/clientset_generated/clientset/typed/cluster/v1alpha1:go_default_library", + "//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library", + "//vendor/k8s.io/apimachinery/pkg/labels:go_default_library", + "//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library", + "//vendor/k8s.io/apimachinery/pkg/types:go_default_library", + "//vendor/k8s.io/apimachinery/pkg/watch:go_default_library", + "//vendor/k8s.io/client-go/rest:go_default_library", + "//vendor/k8s.io/client-go/testing:go_default_library", + ], +) diff --git a/vendor/sigs.k8s.io/cluster-api/pkg/client/informers_generated/externalversions/BUILD.bazel b/vendor/sigs.k8s.io/cluster-api/pkg/client/informers_generated/externalversions/BUILD.bazel new file mode 100644 index 0000000000..039490a151 --- /dev/null +++ b/vendor/sigs.k8s.io/cluster-api/pkg/client/informers_generated/externalversions/BUILD.bazel @@ -0,0 +1,21 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +go_library( + name = "go_default_library", + srcs = [ + "factory.go", + "generic.go", + ], + importpath = "sigs.k8s.io/cluster-api/pkg/client/informers_generated/externalversions", + visibility = ["//visibility:public"], + deps = [ + "//pkg/apis/cluster/v1alpha1:go_default_library", + "//pkg/client/clientset_generated/clientset:go_default_library", + "//pkg/client/informers_generated/externalversions/cluster:go_default_library", + "//pkg/client/informers_generated/externalversions/internalinterfaces: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/client-go/tools/cache:go_default_library", + ], +) diff --git a/vendor/sigs.k8s.io/cluster-api/pkg/client/informers_generated/externalversions/cluster/BUILD.bazel b/vendor/sigs.k8s.io/cluster-api/pkg/client/informers_generated/externalversions/cluster/BUILD.bazel new file mode 100644 index 0000000000..b8cbc69a99 --- /dev/null +++ b/vendor/sigs.k8s.io/cluster-api/pkg/client/informers_generated/externalversions/cluster/BUILD.bazel @@ -0,0 +1,12 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +go_library( + name = "go_default_library", + srcs = ["interface.go"], + importpath = "sigs.k8s.io/cluster-api/pkg/client/informers_generated/externalversions/cluster", + visibility = ["//visibility:public"], + deps = [ + "//pkg/client/informers_generated/externalversions/cluster/v1alpha1:go_default_library", + "//pkg/client/informers_generated/externalversions/internalinterfaces:go_default_library", + ], +) diff --git a/vendor/sigs.k8s.io/cluster-api/pkg/client/informers_generated/externalversions/cluster/v1alpha1/BUILD.bazel b/vendor/sigs.k8s.io/cluster-api/pkg/client/informers_generated/externalversions/cluster/v1alpha1/BUILD.bazel new file mode 100644 index 0000000000..ffabb236fe --- /dev/null +++ b/vendor/sigs.k8s.io/cluster-api/pkg/client/informers_generated/externalversions/cluster/v1alpha1/BUILD.bazel @@ -0,0 +1,25 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +go_library( + name = "go_default_library", + srcs = [ + "cluster.go", + "interface.go", + "machine.go", + "machineclass.go", + "machinedeployment.go", + "machineset.go", + ], + importpath = "sigs.k8s.io/cluster-api/pkg/client/informers_generated/externalversions/cluster/v1alpha1", + visibility = ["//visibility:public"], + deps = [ + "//pkg/apis/cluster/v1alpha1:go_default_library", + "//pkg/client/clientset_generated/clientset:go_default_library", + "//pkg/client/informers_generated/externalversions/internalinterfaces:go_default_library", + "//pkg/client/listers_generated/cluster/v1alpha1: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/watch:go_default_library", + "//vendor/k8s.io/client-go/tools/cache:go_default_library", + ], +) diff --git a/vendor/sigs.k8s.io/cluster-api/pkg/client/informers_generated/externalversions/internalinterfaces/BUILD.bazel b/vendor/sigs.k8s.io/cluster-api/pkg/client/informers_generated/externalversions/internalinterfaces/BUILD.bazel new file mode 100644 index 0000000000..d6a8332c99 --- /dev/null +++ b/vendor/sigs.k8s.io/cluster-api/pkg/client/informers_generated/externalversions/internalinterfaces/BUILD.bazel @@ -0,0 +1,14 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +go_library( + name = "go_default_library", + srcs = ["factory_interfaces.go"], + importpath = "sigs.k8s.io/cluster-api/pkg/client/informers_generated/externalversions/internalinterfaces", + visibility = ["//visibility:public"], + deps = [ + "//pkg/client/clientset_generated/clientset: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/client-go/tools/cache:go_default_library", + ], +) diff --git a/vendor/sigs.k8s.io/cluster-api/pkg/client/listers_generated/cluster/v1alpha1/BUILD.bazel b/vendor/sigs.k8s.io/cluster-api/pkg/client/listers_generated/cluster/v1alpha1/BUILD.bazel new file mode 100644 index 0000000000..40ed528680 --- /dev/null +++ b/vendor/sigs.k8s.io/cluster-api/pkg/client/listers_generated/cluster/v1alpha1/BUILD.bazel @@ -0,0 +1,21 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +go_library( + name = "go_default_library", + srcs = [ + "cluster.go", + "expansion_generated.go", + "machine.go", + "machineclass.go", + "machinedeployment.go", + "machineset.go", + ], + importpath = "sigs.k8s.io/cluster-api/pkg/client/listers_generated/cluster/v1alpha1", + visibility = ["//visibility:public"], + deps = [ + "//pkg/apis/cluster/v1alpha1:go_default_library", + "//vendor/k8s.io/apimachinery/pkg/api/errors:go_default_library", + "//vendor/k8s.io/apimachinery/pkg/labels:go_default_library", + "//vendor/k8s.io/client-go/tools/cache:go_default_library", + ], +) diff --git a/vendor/sigs.k8s.io/cluster-api/pkg/cmd-runner/BUILD.bazel b/vendor/sigs.k8s.io/cluster-api/pkg/cmd-runner/BUILD.bazel new file mode 100644 index 0000000000..40cf8d60b3 --- /dev/null +++ b/vendor/sigs.k8s.io/cluster-api/pkg/cmd-runner/BUILD.bazel @@ -0,0 +1,14 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") + +go_library( + name = "go_default_library", + srcs = ["cmd_runner.go"], + importpath = "sigs.k8s.io/cluster-api/pkg/cmd-runner", + visibility = ["//visibility:public"], +) + +go_test( + name = "go_default_test", + srcs = ["cmd_runner_test.go"], + embed = [":go_default_library"], +) diff --git a/vendor/sigs.k8s.io/cluster-api/pkg/controller/BUILD.bazel b/vendor/sigs.k8s.io/cluster-api/pkg/controller/BUILD.bazel new file mode 100644 index 0000000000..8f075625a7 --- /dev/null +++ b/vendor/sigs.k8s.io/cluster-api/pkg/controller/BUILD.bazel @@ -0,0 +1,19 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +go_library( + name = "go_default_library", + srcs = [ + "add_machinedeployment.go", + "add_machineset.go", + "add_node.go", + "controller.go", + ], + importpath = "sigs.k8s.io/cluster-api/pkg/controller", + visibility = ["//visibility:public"], + deps = [ + "//pkg/controller/machinedeployment:go_default_library", + "//pkg/controller/machineset:go_default_library", + "//pkg/controller/node:go_default_library", + "//vendor/sigs.k8s.io/controller-runtime/pkg/manager:go_default_library", + ], +) diff --git a/vendor/sigs.k8s.io/cluster-api/pkg/controller/cluster/BUILD.bazel b/vendor/sigs.k8s.io/cluster-api/pkg/controller/cluster/BUILD.bazel new file mode 100644 index 0000000000..61c5fa9a23 --- /dev/null +++ b/vendor/sigs.k8s.io/cluster-api/pkg/controller/cluster/BUILD.bazel @@ -0,0 +1,48 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") + +go_library( + name = "go_default_library", + srcs = [ + "actuator.go", + "controller.go", + "testactuator.go", + ], + importpath = "sigs.k8s.io/cluster-api/pkg/controller/cluster", + visibility = ["//visibility:public"], + deps = [ + "//pkg/apis/cluster/v1alpha1:go_default_library", + "//pkg/controller/error:go_default_library", + "//pkg/util:go_default_library", + "//vendor/k8s.io/apimachinery/pkg/api/errors:go_default_library", + "//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library", + "//vendor/k8s.io/klog:go_default_library", + "//vendor/sigs.k8s.io/controller-runtime/pkg/client:go_default_library", + "//vendor/sigs.k8s.io/controller-runtime/pkg/controller:go_default_library", + "//vendor/sigs.k8s.io/controller-runtime/pkg/handler:go_default_library", + "//vendor/sigs.k8s.io/controller-runtime/pkg/manager:go_default_library", + "//vendor/sigs.k8s.io/controller-runtime/pkg/reconcile:go_default_library", + "//vendor/sigs.k8s.io/controller-runtime/pkg/source:go_default_library", + ], +) + +go_test( + name = "go_default_test", + srcs = [ + "cluster_controller_suite_test.go", + "cluster_controller_test.go", + ], + embed = [":go_default_library"], + deps = [ + "//pkg/apis:go_default_library", + "//pkg/apis/cluster/v1alpha1:go_default_library", + "//vendor/golang.org/x/net/context:go_default_library", + "//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library", + "//vendor/k8s.io/apimachinery/pkg/types:go_default_library", + "//vendor/k8s.io/client-go/kubernetes/scheme:go_default_library", + "//vendor/k8s.io/client-go/rest:go_default_library", + "//vendor/sigs.k8s.io/controller-runtime/pkg/client:go_default_library", + "//vendor/sigs.k8s.io/controller-runtime/pkg/envtest:go_default_library", + "//vendor/sigs.k8s.io/controller-runtime/pkg/manager:go_default_library", + "//vendor/sigs.k8s.io/controller-runtime/pkg/reconcile:go_default_library", + ], +) diff --git a/vendor/sigs.k8s.io/cluster-api/pkg/controller/cluster/controller.go b/vendor/sigs.k8s.io/cluster-api/pkg/controller/cluster/controller.go index b7d0efee3d..c9b6118f90 100644 --- a/vendor/sigs.k8s.io/cluster-api/pkg/controller/cluster/controller.go +++ b/vendor/sigs.k8s.io/cluster-api/pkg/controller/cluster/controller.go @@ -19,9 +19,9 @@ package cluster import ( "context" - "github.com/golang/glog" "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/runtime" + "k8s.io/klog" clusterv1 "sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1" clusterv1alpha1 "sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1" controllerError "sigs.k8s.io/cluster-api/pkg/controller/error" @@ -86,7 +86,7 @@ func (r *ReconcileCluster) Reconcile(request reconcile.Request) (reconcile.Resul } name := cluster.Name - glog.Infof("Running reconcile Cluster for %s\n", name) + klog.Infof("Running reconcile Cluster for %s\n", name) // If object hasn't been deleted and doesn't have a finalizer, add one // Add a finalizer to newly created objects. @@ -94,41 +94,44 @@ func (r *ReconcileCluster) Reconcile(request reconcile.Request) (reconcile.Resul !util.Contains(cluster.ObjectMeta.Finalizers, clusterv1.ClusterFinalizer) { cluster.Finalizers = append(cluster.Finalizers, clusterv1.ClusterFinalizer) if err = r.Update(context.Background(), cluster); err != nil { - glog.Infof("failed to add finalizer to cluster object %v due to error %v.", name, err) + klog.Infof("failed to add finalizer to cluster object %v due to error %v.", name, err) return reconcile.Result{}, err } + + // Since adding the finalizer updates the object return to avoid later update issues + return reconcile.Result{}, nil } if !cluster.ObjectMeta.DeletionTimestamp.IsZero() { // no-op if finalizer has been removed. if !util.Contains(cluster.ObjectMeta.Finalizers, clusterv1.ClusterFinalizer) { - glog.Infof("reconciling cluster object %v causes a no-op as there is no finalizer.", name) + klog.Infof("reconciling cluster object %v causes a no-op as there is no finalizer.", name) return reconcile.Result{}, nil } - glog.Infof("reconciling cluster object %v triggers delete.", name) + klog.Infof("reconciling cluster object %v triggers delete.", name) if err := r.actuator.Delete(cluster); err != nil { - glog.Errorf("Error deleting cluster object %v; %v", name, err) + klog.Errorf("Error deleting cluster object %v; %v", name, err) return reconcile.Result{}, err } // Remove finalizer on successful deletion. - glog.Infof("cluster object %v deletion successful, removing finalizer.", name) + klog.Infof("cluster object %v deletion successful, removing finalizer.", name) cluster.ObjectMeta.Finalizers = util.Filter(cluster.ObjectMeta.Finalizers, clusterv1.ClusterFinalizer) if err := r.Client.Update(context.Background(), cluster); err != nil { - glog.Errorf("Error removing finalizer from cluster object %v; %v", name, err) + klog.Errorf("Error removing finalizer from cluster object %v; %v", name, err) return reconcile.Result{}, err } return reconcile.Result{}, nil } - glog.Infof("reconciling cluster object %v triggers idempotent reconcile.", name) + klog.Infof("reconciling cluster object %v triggers idempotent reconcile.", name) err = r.actuator.Reconcile(cluster) if err != nil { if requeueErr, ok := err.(*controllerError.RequeueAfterError); ok { - glog.Infof("Actuator returned requeue after error: %v", requeueErr) + klog.Infof("Actuator returned requeue after error: %v", requeueErr) return reconcile.Result{Requeue: true, RequeueAfter: requeueErr.RequeueAfter}, nil } - glog.Errorf("Error reconciling cluster object %v; %v", name, err) + klog.Errorf("Error reconciling cluster object %v; %v", name, err) return reconcile.Result{}, err } return reconcile.Result{}, nil diff --git a/vendor/sigs.k8s.io/cluster-api/pkg/controller/config/BUILD.bazel b/vendor/sigs.k8s.io/cluster-api/pkg/controller/config/BUILD.bazel new file mode 100644 index 0000000000..67471d9dcc --- /dev/null +++ b/vendor/sigs.k8s.io/cluster-api/pkg/controller/config/BUILD.bazel @@ -0,0 +1,13 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +go_library( + name = "go_default_library", + srcs = ["configuration.go"], + importpath = "sigs.k8s.io/cluster-api/pkg/controller/config", + visibility = ["//visibility:public"], + deps = [ + "//vendor/github.com/spf13/pflag:go_default_library", + "//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library", + "//vendor/k8s.io/client-go/tools/leaderelection/resourcelock:go_default_library", + ], +) diff --git a/vendor/sigs.k8s.io/cluster-api/pkg/controller/machine/BUILD.bazel b/vendor/sigs.k8s.io/cluster-api/pkg/controller/machine/BUILD.bazel new file mode 100644 index 0000000000..b63ecbdd57 --- /dev/null +++ b/vendor/sigs.k8s.io/cluster-api/pkg/controller/machine/BUILD.bazel @@ -0,0 +1,49 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") + +go_library( + name = "go_default_library", + srcs = [ + "actuator.go", + "controller.go", + "testactuator.go", + ], + importpath = "sigs.k8s.io/cluster-api/pkg/controller/machine", + visibility = ["//visibility:public"], + deps = [ + "//pkg/apis/cluster/v1alpha1:go_default_library", + "//pkg/controller/error:go_default_library", + "//pkg/util:go_default_library", + "//vendor/k8s.io/api/core/v1:go_default_library", + "//vendor/k8s.io/apimachinery/pkg/api/errors:go_default_library", + "//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library", + "//vendor/k8s.io/klog:go_default_library", + "//vendor/sigs.k8s.io/controller-runtime/pkg/client:go_default_library", + "//vendor/sigs.k8s.io/controller-runtime/pkg/controller:go_default_library", + "//vendor/sigs.k8s.io/controller-runtime/pkg/handler:go_default_library", + "//vendor/sigs.k8s.io/controller-runtime/pkg/manager:go_default_library", + "//vendor/sigs.k8s.io/controller-runtime/pkg/reconcile:go_default_library", + "//vendor/sigs.k8s.io/controller-runtime/pkg/source:go_default_library", + ], +) + +go_test( + name = "go_default_test", + srcs = [ + "machine_controller_suite_test.go", + "machine_controller_test.go", + ], + embed = [":go_default_library"], + deps = [ + "//pkg/apis:go_default_library", + "//pkg/apis/cluster/v1alpha1:go_default_library", + "//vendor/golang.org/x/net/context:go_default_library", + "//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library", + "//vendor/k8s.io/apimachinery/pkg/types:go_default_library", + "//vendor/k8s.io/client-go/kubernetes/scheme:go_default_library", + "//vendor/k8s.io/client-go/rest:go_default_library", + "//vendor/sigs.k8s.io/controller-runtime/pkg/client:go_default_library", + "//vendor/sigs.k8s.io/controller-runtime/pkg/envtest:go_default_library", + "//vendor/sigs.k8s.io/controller-runtime/pkg/manager:go_default_library", + "//vendor/sigs.k8s.io/controller-runtime/pkg/reconcile:go_default_library", + ], +) diff --git a/vendor/sigs.k8s.io/cluster-api/pkg/controller/machine/controller.go b/vendor/sigs.k8s.io/cluster-api/pkg/controller/machine/controller.go index 063e9eaf7a..19f258632c 100644 --- a/vendor/sigs.k8s.io/cluster-api/pkg/controller/machine/controller.go +++ b/vendor/sigs.k8s.io/cluster-api/pkg/controller/machine/controller.go @@ -21,11 +21,10 @@ import ( "errors" "os" - "github.com/golang/glog" - corev1 "k8s.io/api/core/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/runtime" + "k8s.io/klog" clusterv1 "sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1" controllerError "sigs.k8s.io/cluster-api/pkg/controller/error" "sigs.k8s.io/cluster-api/pkg/util" @@ -55,7 +54,7 @@ func newReconciler(mgr manager.Manager, actuator Actuator) reconcile.Reconciler } if r.nodeName == "" { - glog.Warningf("environment variable %v is not set, this controller will not protect against deleting its own machine", NodeNameEnvVar) + klog.Warningf("environment variable %v is not set, this controller will not protect against deleting its own machine", NodeNameEnvVar) } return r @@ -99,8 +98,7 @@ func (r *ReconcileMachine) Reconcile(request reconcile.Request) (reconcile.Resul ctx := context.TODO() // Fetch the Machine instance m := &clusterv1.Machine{} - err := r.Get(ctx, request.NamespacedName, m) - if err != nil { + if err := r.Client.Get(ctx, request.NamespacedName, m); err != nil { if apierrors.IsNotFound(err) { // Object not found, return. Created objects are automatically garbage collected. // For additional cleanup logic use finalizers. @@ -112,40 +110,47 @@ func (r *ReconcileMachine) Reconcile(request reconcile.Request) (reconcile.Resul // Implement controller logic here name := m.Name - glog.Infof("Running reconcile Machine for %s\n", name) + klog.Infof("Running reconcile Machine for %s\n", name) // If object hasn't been deleted and doesn't have a finalizer, add one // Add a finalizer to newly created objects. if m.ObjectMeta.DeletionTimestamp.IsZero() && !util.Contains(m.ObjectMeta.Finalizers, clusterv1.MachineFinalizer) { m.Finalizers = append(m.Finalizers, clusterv1.MachineFinalizer) - if err = r.Update(ctx, m); err != nil { - glog.Infof("failed to add finalizer to machine object %v due to error %v.", name, err) + if err := r.Client.Update(ctx, m); err != nil { + klog.Infof("failed to add finalizer to machine object %v due to error %v.", name, err) return reconcile.Result{}, err } + + // Since adding the finalizer updates the object return to avoid later update issues + return reconcile.Result{}, nil } if !m.ObjectMeta.DeletionTimestamp.IsZero() { // no-op if finalizer has been removed. if !util.Contains(m.ObjectMeta.Finalizers, clusterv1.MachineFinalizer) { - glog.Infof("reconciling machine object %v causes a no-op as there is no finalizer.", name) + klog.Infof("reconciling machine object %v causes a no-op as there is no finalizer.", name) return reconcile.Result{}, nil } if !r.isDeleteAllowed(m) { - glog.Infof("Skipping reconciling of machine object %v", name) + klog.Infof("Skipping reconciling of machine object %v", name) return reconcile.Result{}, nil } - glog.Infof("reconciling machine object %v triggers delete.", name) + klog.Infof("reconciling machine object %v triggers delete.", name) if err := r.delete(ctx, m); err != nil { - glog.Errorf("Error deleting machine object %v; %v", name, err) + klog.Errorf("Error deleting machine object %v; %v", name, err) + if requeueErr, ok := err.(*controllerError.RequeueAfterError); ok { + klog.Infof("Actuator returned requeue-after error: %v", requeueErr) + return reconcile.Result{Requeue: true, RequeueAfter: requeueErr.RequeueAfter}, nil + } return reconcile.Result{}, err } // Remove finalizer on successful deletion. - glog.Infof("machine object %v deletion successful, removing finalizer.", name) + klog.Infof("machine object %v deletion successful, removing finalizer.", name) m.ObjectMeta.Finalizers = util.Filter(m.ObjectMeta.Finalizers, clusterv1.MachineFinalizer) if err := r.Client.Update(context.Background(), m); err != nil { - glog.Errorf("Error removing finalizer from machine object %v; %v", name, err) + klog.Errorf("Error removing finalizer from machine object %v; %v", name, err) return reconcile.Result{}, err } return reconcile.Result{}, nil @@ -158,15 +163,14 @@ func (r *ReconcileMachine) Reconcile(request reconcile.Request) (reconcile.Resul exist, err := r.actuator.Exists(ctx, cluster, m) if err != nil { - glog.Errorf("Error checking existence of machine instance for machine object %v; %v", name, err) + klog.Errorf("Error checking existence of machine instance for machine object %v; %v", name, err) return reconcile.Result{}, err } if exist { - glog.Infof("Reconciling machine object %v triggers idempotent update.", name) - err := r.update(ctx, m) - if err != nil { + klog.Infof("Reconciling machine object %v triggers idempotent update.", name) + if err := r.update(ctx, m); err != nil { if requeueErr, ok := err.(*controllerError.RequeueAfterError); ok { - glog.Infof("Actuator returned requeue-after error: %v", requeueErr) + klog.Infof("Actuator returned requeue-after error: %v", requeueErr) return reconcile.Result{Requeue: true, RequeueAfter: requeueErr.RequeueAfter}, nil } return reconcile.Result{}, err @@ -174,11 +178,11 @@ func (r *ReconcileMachine) Reconcile(request reconcile.Request) (reconcile.Resul return reconcile.Result{}, nil } // Machine resource created. Machine does not yet exist. - glog.Infof("Reconciling machine object %v triggers idempotent create.", m.ObjectMeta.Name) + klog.Infof("Reconciling machine object %v triggers idempotent create.", m.ObjectMeta.Name) if err := r.create(ctx, m); err != nil { - glog.Warningf("unable to create machine %v: %v", name, err) + klog.Warningf("unable to create machine %v: %v", name, err) if requeueErr, ok := err.(*controllerError.RequeueAfterError); ok { - glog.Infof("Actuator returned requeue-after error: %v", requeueErr) + klog.Infof("Actuator returned requeue-after error: %v", requeueErr) return reconcile.Result{Requeue: true, RequeueAfter: requeueErr.RequeueAfter}, nil } return reconcile.Result{}, err @@ -186,39 +190,38 @@ func (r *ReconcileMachine) Reconcile(request reconcile.Request) (reconcile.Resul return reconcile.Result{}, nil } -func (c *ReconcileMachine) create(ctx context.Context, machine *clusterv1.Machine) error { - cluster, err := c.getCluster(ctx, machine) +func (r *ReconcileMachine) create(ctx context.Context, machine *clusterv1.Machine) error { + cluster, err := r.getCluster(ctx, machine) if err != nil { return err } - return c.actuator.Create(ctx, cluster, machine) + return r.actuator.Create(ctx, cluster, machine) } -func (c *ReconcileMachine) update(ctx context.Context, new_machine *clusterv1.Machine) error { - cluster, err := c.getCluster(ctx, new_machine) +func (r *ReconcileMachine) update(ctx context.Context, new_machine *clusterv1.Machine) error { + cluster, err := r.getCluster(ctx, new_machine) if err != nil { return err } // TODO: Assume single master for now. // TODO: Assume we never change the role for the machines. (Master->Node, Node->Master, etc) - return c.actuator.Update(ctx, cluster, new_machine) + return r.actuator.Update(ctx, cluster, new_machine) } -func (c *ReconcileMachine) delete(ctx context.Context, machine *clusterv1.Machine) error { - cluster, err := c.getCluster(ctx, machine) +func (r *ReconcileMachine) delete(ctx context.Context, machine *clusterv1.Machine) error { + cluster, err := r.getCluster(ctx, machine) if err != nil { return err } - return c.actuator.Delete(ctx, cluster, machine) + return r.actuator.Delete(ctx, cluster, machine) } -func (c *ReconcileMachine) getCluster(ctx context.Context, machine *clusterv1.Machine) (*clusterv1.Cluster, error) { +func (r *ReconcileMachine) getCluster(ctx context.Context, machine *clusterv1.Machine) (*clusterv1.Cluster, error) { clusterList := clusterv1.ClusterList{} - err := c.Client.List(ctx, client.InNamespace(machine.Namespace), &clusterList) - if err != nil { + if err := r.Client.List(ctx, client.InNamespace(machine.Namespace), &clusterList); err != nil { return nil, err } @@ -232,17 +235,17 @@ func (c *ReconcileMachine) getCluster(ctx context.Context, machine *clusterv1.Ma } } -func (c *ReconcileMachine) isDeleteAllowed(machine *clusterv1.Machine) bool { - if c.nodeName == "" || machine.Status.NodeRef == nil { +func (r *ReconcileMachine) isDeleteAllowed(machine *clusterv1.Machine) bool { + if r.nodeName == "" || machine.Status.NodeRef == nil { return true } - if machine.Status.NodeRef.Name != c.nodeName { + if machine.Status.NodeRef.Name != r.nodeName { return true } node := &corev1.Node{} - err := c.Client.Get(context.Background(), client.ObjectKey{Name: c.nodeName}, node) + err := r.Client.Get(context.Background(), client.ObjectKey{Name: r.nodeName}, node) if err != nil { - glog.Infof("unable to determine if controller's node is associated with machine '%v', error getting node named '%v': %v", machine.Name, c.nodeName, err) + klog.Infof("unable to determine if controller's node is associated with machine '%v', error getting node named '%v': %v", machine.Name, r.nodeName, err) return true } // When the UID of the machine's node reference and this controller's actual node match then then the request is to diff --git a/vendor/sigs.k8s.io/cluster-api/pkg/controller/machinedeployment/BUILD.bazel b/vendor/sigs.k8s.io/cluster-api/pkg/controller/machinedeployment/BUILD.bazel new file mode 100644 index 0000000000..65ae4d7f89 --- /dev/null +++ b/vendor/sigs.k8s.io/cluster-api/pkg/controller/machinedeployment/BUILD.bazel @@ -0,0 +1,57 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") + +go_library( + name = "go_default_library", + srcs = [ + "controller.go", + "rolling.go", + "sync.go", + ], + importpath = "sigs.k8s.io/cluster-api/pkg/controller/machinedeployment", + visibility = ["//visibility:public"], + deps = [ + "//pkg/apis/cluster/common:go_default_library", + "//pkg/apis/cluster/v1alpha1:go_default_library", + "//pkg/controller/machinedeployment/util:go_default_library", + "//vendor/k8s.io/apimachinery/pkg/api/equality: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/labels:go_default_library", + "//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library", + "//vendor/k8s.io/apimachinery/pkg/types:go_default_library", + "//vendor/k8s.io/apimachinery/pkg/util/rand:go_default_library", + "//vendor/k8s.io/client-go/util/integer:go_default_library", + "//vendor/k8s.io/client-go/util/retry:go_default_library", + "//vendor/k8s.io/klog:go_default_library", + "//vendor/sigs.k8s.io/controller-runtime/pkg/client:go_default_library", + "//vendor/sigs.k8s.io/controller-runtime/pkg/controller:go_default_library", + "//vendor/sigs.k8s.io/controller-runtime/pkg/handler:go_default_library", + "//vendor/sigs.k8s.io/controller-runtime/pkg/manager:go_default_library", + "//vendor/sigs.k8s.io/controller-runtime/pkg/reconcile:go_default_library", + "//vendor/sigs.k8s.io/controller-runtime/pkg/source:go_default_library", + ], +) + +go_test( + name = "go_default_test", + srcs = [ + "machinedeployment_controller_suite_test.go", + "machinedeployment_controller_test.go", + ], + embed = [":go_default_library"], + deps = [ + "//pkg/apis:go_default_library", + "//pkg/apis/cluster/common:go_default_library", + "//pkg/apis/cluster/v1alpha1:go_default_library", + "//vendor/golang.org/x/net/context:go_default_library", + "//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library", + "//vendor/k8s.io/apimachinery/pkg/types:go_default_library", + "//vendor/k8s.io/apimachinery/pkg/util/intstr:go_default_library", + "//vendor/k8s.io/client-go/kubernetes/scheme:go_default_library", + "//vendor/k8s.io/client-go/rest:go_default_library", + "//vendor/sigs.k8s.io/controller-runtime/pkg/client:go_default_library", + "//vendor/sigs.k8s.io/controller-runtime/pkg/envtest:go_default_library", + "//vendor/sigs.k8s.io/controller-runtime/pkg/manager:go_default_library", + "//vendor/sigs.k8s.io/controller-runtime/pkg/reconcile:go_default_library", + ], +) diff --git a/vendor/sigs.k8s.io/cluster-api/pkg/controller/machinedeployment/controller.go b/vendor/sigs.k8s.io/cluster-api/pkg/controller/machinedeployment/controller.go index 2ae5ba4646..6abb0a48ab 100644 --- a/vendor/sigs.k8s.io/cluster-api/pkg/controller/machinedeployment/controller.go +++ b/vendor/sigs.k8s.io/cluster-api/pkg/controller/machinedeployment/controller.go @@ -21,12 +21,12 @@ import ( "fmt" "reflect" - "github.com/golang/glog" "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/types" + "k8s.io/klog" "sigs.k8s.io/cluster-api/pkg/apis/cluster/common" "sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1" "sigs.k8s.io/controller-runtime/pkg/client" @@ -95,8 +95,18 @@ func (r *ReconcileMachineDeployment) getMachineSetsForDeployment(d *v1alpha1.Mac // List all MachineSets to find those we own but that no longer match our // selector. machineSets := &v1alpha1.MachineSetList{} - err := r.List(context.Background(), client.InNamespace(d.Namespace), machineSets) - if err != nil { + listOptions := &client.ListOptions{ + Namespace: d.Namespace, + // This is set so the fake client can be used for unit test. See: + // https://github.com/kubernetes-sigs/controller-runtime/issues/168 + Raw: &metav1.ListOptions{ + TypeMeta: metav1.TypeMeta{ + APIVersion: v1alpha1.SchemeGroupVersion.String(), + Kind: "MachineSet", + }, + }, + } + if err := r.Client.List(context.Background(), listOptions, machineSets); err != nil { return nil, err } @@ -106,21 +116,21 @@ func (r *ReconcileMachineDeployment) getMachineSetsForDeployment(d *v1alpha1.Mac for idx, _ := range machineSets.Items { ms := &machineSets.Items[idx] if metav1.GetControllerOf(ms) == nil || (metav1.GetControllerOf(ms) != nil && !metav1.IsControlledBy(ms, d)) { - glog.V(4).Infof("%s not controlled by %v", ms.Name, d.Name) + klog.V(4).Infof("%s not controlled by %v", ms.Name, d.Name) continue } selector, err := metav1.LabelSelectorAsSelector(&d.Spec.Selector) if err != nil { - glog.Errorf("Skipping machineset %v, failed to get label selector from spec selector.", ms.Name) + klog.Errorf("Skipping machineset %v, failed to get label selector from spec selector.", ms.Name) continue } // If a deployment with a nil or empty selector creeps in, it should match nothing, not everything. if selector.Empty() { - glog.Warningf("Skipping machineset %v as the selector is empty.", ms.Name) + klog.Warningf("Skipping machineset %v as the selector is empty.", ms.Name) continue } if !selector.Matches(labels.Set(ms.Labels)) { - glog.V(4).Infof("Skipping machineset %v, label mismatch.", ms.Name) + klog.V(4).Infof("Skipping machineset %v, label mismatch.", ms.Name) continue } filteredMS = append(filteredMS, ms) @@ -145,12 +155,14 @@ func (r *ReconcileMachineDeployment) Reconcile(request reconcile.Request) (recon return reconcile.Result{}, err } + v1alpha1.PopulateDefaultsMachineDeployment(d) + everything := metav1.LabelSelector{} if reflect.DeepEqual(d.Spec.Selector, &everything) { if d.Status.ObservedGeneration < d.Generation { d.Status.ObservedGeneration = d.Generation if err := r.Status().Update(context.Background(), d); err != nil { - glog.Warningf("Failed to update status for deployment %v. %v", d.Name, err) + klog.Warningf("Failed to update status for deployment %v. %v", d.Name, err) return reconcile.Result{}, err } } @@ -187,14 +199,24 @@ func (r *ReconcileMachineDeployment) Reconcile(request reconcile.Request) (recon // match a MachineSet. func (r *ReconcileMachineDeployment) getMachineDeploymentsForMachineSet(ms *v1alpha1.MachineSet) []*v1alpha1.MachineDeployment { if len(ms.Labels) == 0 { - glog.Warningf("no machine deployments found for MachineSet %v because it has no labels", ms.Name) + klog.Warningf("no machine deployments found for MachineSet %v because it has no labels", ms.Name) return nil } dList := &v1alpha1.MachineDeploymentList{} - err := r.Client.List(context.Background(), client.InNamespace(ms.Namespace), dList) - if err != nil { - glog.Warningf("failed to list machine deployments, %v", err) + listOptions := &client.ListOptions{ + Namespace: ms.Namespace, + // This is set so the fake client can be used for unit test. See: + // https://github.com/kubernetes-sigs/controller-runtime/issues/168 + Raw: &metav1.ListOptions{ + TypeMeta: metav1.TypeMeta{ + APIVersion: v1alpha1.SchemeGroupVersion.String(), + Kind: "MachineDeployment", + }, + }, + } + if err := r.Client.List(context.Background(), listOptions, dList); err != nil { + klog.Warningf("failed to list machine deployments, %v", err) return nil } @@ -228,8 +250,18 @@ func (r *ReconcileMachineDeployment) getMachineMapForDeployment(d *v1alpha1.Mach return nil, err } machines := &v1alpha1.MachineList{} - err = r.List(context.Background(), client.InNamespace(d.Namespace).MatchingLabels(selector), machines) - if err != nil { + listOptions := &client.ListOptions{ + Namespace: d.Namespace, + // This is set so the fake client can be used for unit test. See: + // https://github.com/kubernetes-sigs/controller-runtime/issues/168 + Raw: &metav1.ListOptions{ + TypeMeta: metav1.TypeMeta{ + APIVersion: v1alpha1.SchemeGroupVersion.String(), + Kind: "Machine", + }, + }, + } + if err = r.Client.List(context.Background(), listOptions.MatchingLabels(selector), machines); err != nil { return nil, err } // Group Machines by their controller (if it's in msList). @@ -259,7 +291,7 @@ func (r *ReconcileMachineDeployment) MachineSetToDeployments(o handler.MapObject key := client.ObjectKey{Namespace: o.Meta.GetNamespace(), Name: o.Meta.GetName()} err := r.Client.Get(context.Background(), key, ms) if err != nil { - glog.Errorf("Unable to retrieve Machineset %v from store: %v", key, err) + klog.Errorf("Unable to retrieve Machineset %v from store: %v", key, err) return nil } @@ -271,7 +303,7 @@ func (r *ReconcileMachineDeployment) MachineSetToDeployments(o handler.MapObject mds := r.getMachineDeploymentsForMachineSet(ms) if len(mds) == 0 { - glog.V(4).Infof("Found no machine set for machine: %v", ms.Name) + klog.V(4).Infof("Found no machine set for machine: %v", ms.Name) return nil } diff --git a/vendor/sigs.k8s.io/cluster-api/pkg/controller/machinedeployment/rolling.go b/vendor/sigs.k8s.io/cluster-api/pkg/controller/machinedeployment/rolling.go index 417f298643..b6786fb101 100644 --- a/vendor/sigs.k8s.io/cluster-api/pkg/controller/machinedeployment/rolling.go +++ b/vendor/sigs.k8s.io/cluster-api/pkg/controller/machinedeployment/rolling.go @@ -20,10 +20,9 @@ import ( "fmt" "sort" - "github.com/golang/glog" - "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/util/integer" + "k8s.io/klog" "sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1" dutil "sigs.k8s.io/cluster-api/pkg/controller/machinedeployment/util" @@ -35,6 +34,12 @@ func (r *ReconcileMachineDeployment) rolloutRolling(d *v1alpha1.MachineDeploymen if err != nil { return err } + // newMS can be nil in case there is already a MachineSet associated with this deployment, + // but there are only either changes in annotations or MinReadySeconds. Or in other words, + // this can be nil if there are changes, but no replacement of existing machines is needed. + if newMS == nil { + return nil + } allMSs := append(oldMSs, newMS) // Scale up, if we can. @@ -102,7 +107,7 @@ func (r *ReconcileMachineDeployment) reconcileOldMachineSets(allMSs []*v1alpha1. } allMachinesCount := dutil.GetReplicaCountForMachineSets(allMSs) - glog.V(4).Infof("New machine set %s/%s has %d available machines.", newMS.Namespace, newMS.Name, newMS.Status.AvailableReplicas) + klog.V(4).Infof("New machine set %s/%s has %d available machines.", newMS.Namespace, newMS.Name, newMS.Status.AvailableReplicas) maxUnavailable := dutil.MaxUnavailable(*deployment) // Check if we can scale down. We can scale down in the following 2 cases: @@ -148,7 +153,7 @@ func (r *ReconcileMachineDeployment) reconcileOldMachineSets(allMSs []*v1alpha1. if err != nil { return nil } - glog.V(4).Infof("Cleaned up unhealthy replicas from old MSes by %d", cleanupCount) + klog.V(4).Infof("Cleaned up unhealthy replicas from old MSes by %d", cleanupCount) // Scale down old machine sets, need check maxUnavailable to ensure we can scale down allMSs = append(oldMSs, newMS) @@ -156,7 +161,7 @@ func (r *ReconcileMachineDeployment) reconcileOldMachineSets(allMSs []*v1alpha1. if err != nil { return err } - glog.V(4).Infof("Scaled down old MSes of deployment %s by %d", deployment.Name, scaledDownCount) + klog.V(4).Infof("Scaled down old MSes of deployment %s by %d", deployment.Name, scaledDownCount) return nil } @@ -182,7 +187,7 @@ func (r *ReconcileMachineDeployment) cleanupUnhealthyReplicas(oldMSs []*v1alpha1 continue } oldMSAvailableReplicas := targetMS.Status.AvailableReplicas - glog.V(4).Infof("Found %d available machines in old MS %s/%s", oldMSAvailableReplicas, targetMS.Namespace, targetMS.Name) + klog.V(4).Infof("Found %d available machines in old MS %s/%s", oldMSAvailableReplicas, targetMS.Namespace, targetMS.Name) if oldMSReplicas == oldMSAvailableReplicas { // no unhealthy replicas found, no scaling required. continue @@ -222,7 +227,7 @@ func (r *ReconcileMachineDeployment) scaleDownOldMachineSetsForRollingUpdate(all // Cannot scale down. return 0, nil } - glog.V(4).Infof("Found %d available machines in deployment %s, scaling down old MSes", availableMachineCount, deployment.Name) + klog.V(4).Infof("Found %d available machines in deployment %s, scaling down old MSes", availableMachineCount, deployment.Name) sort.Sort(dutil.MachineSetsByCreationTimestamp(oldMSs)) diff --git a/vendor/sigs.k8s.io/cluster-api/pkg/controller/machinedeployment/sync.go b/vendor/sigs.k8s.io/cluster-api/pkg/controller/machinedeployment/sync.go index 515e8f9863..557e49fdd1 100644 --- a/vendor/sigs.k8s.io/cluster-api/pkg/controller/machinedeployment/sync.go +++ b/vendor/sigs.k8s.io/cluster-api/pkg/controller/machinedeployment/sync.go @@ -23,14 +23,13 @@ import ( "sort" "strconv" - "github.com/golang/glog" - "k8s.io/apimachinery/pkg/api/equality" "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" apirand "k8s.io/apimachinery/pkg/util/rand" "k8s.io/client-go/util/retry" + "k8s.io/klog" clusterv1alpha1 "sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1" "sigs.k8s.io/controller-runtime/pkg/client" @@ -128,6 +127,11 @@ func (r *ReconcileMachineDeployment) getNewMachineSet(d *clusterv1alpha1.Machine // Add machineTemplateHash label to selector. newMSSelector := dutil.CloneSelectorAndAddLabel(&d.Spec.Selector, dutil.DefaultMachineDeploymentUniqueLabelKey, machineTemplateSpecHash) + minReadySeconds := int32(0) + if d.Spec.MinReadySeconds != nil { + minReadySeconds = *d.Spec.MinReadySeconds + } + // Create new MachineSet newMS := clusterv1alpha1.MachineSet{ ObjectMeta: metav1.ObjectMeta{ @@ -139,7 +143,7 @@ func (r *ReconcileMachineDeployment) getNewMachineSet(d *clusterv1alpha1.Machine }, Spec: clusterv1alpha1.MachineSetSpec{ Replicas: new(int32), - MinReadySeconds: *d.Spec.MinReadySeconds, + MinReadySeconds: minReadySeconds, Selector: *newMSSelector, Template: newMSTemplate, }, @@ -183,12 +187,12 @@ func (r *ReconcileMachineDeployment) getNewMachineSet(d *clusterv1alpha1.Machine return nil, err case err != nil: - glog.V(4).Infof("Failed to create new machine set %q: %v", newMS.Name, err) + klog.V(4).Infof("Failed to create new machine set %q: %v", newMS.Name, err) return nil, err } if !alreadyExists { - glog.V(4).Infof("Created new machine set %q", createdMS.Name) + klog.V(4).Infof("Created new machine set %q", createdMS.Name) } err = r.updateMachineDeployment(d, func(innerDeployment *clusterv1alpha1.MachineDeployment) { dutil.SetDeploymentRevision(d, newRevision) @@ -270,7 +274,7 @@ func (r *ReconcileMachineDeployment) scale(deployment *clusterv1alpha1.MachineDe for i := range allMSs { ms := allMSs[i] if ms.Spec.Replicas == nil { - glog.Errorf("spec replicas for machine set %v is nil, this is unexpected.", ms.Name) + klog.Errorf("spec replicas for machine set %v is nil, this is unexpected.", ms.Name) continue } @@ -385,7 +389,7 @@ func (r *ReconcileMachineDeployment) scaleMachineSetOperation(ms *clusterv1alpha return scaled, err } -// cleanupDeployment is responsible for cleaning up a deployment ie. retains all but the latest N old machine sets +// cleanupDeployment is responsible for cleaning up a deployment i.e. retains all but the latest N old machine sets // where N=d.Spec.RevisionHistoryLimit. Old machine sets are older versions of the machinetemplate of a deployment kept // around by default 1) for historical reasons and 2) for the ability to rollback a deployment. func (r *ReconcileMachineDeployment) cleanupDeployment(oldMSs []*clusterv1alpha1.MachineSet, deployment *clusterv1alpha1.MachineDeployment) error { @@ -405,7 +409,7 @@ func (r *ReconcileMachineDeployment) cleanupDeployment(oldMSs []*clusterv1alpha1 } sort.Sort(dutil.MachineSetsByCreationTimestamp(cleanableMSes)) - glog.V(4).Infof("Looking to cleanup old machine sets for deployment %q", deployment.Name) + klog.V(4).Infof("Looking to cleanup old machine sets for deployment %q", deployment.Name) for i := int32(0); i < diff; i++ { ms := cleanableMSes[i] @@ -416,7 +420,7 @@ func (r *ReconcileMachineDeployment) cleanupDeployment(oldMSs []*clusterv1alpha1 if ms.Status.Replicas != 0 || *(ms.Spec.Replicas) != 0 || ms.Generation > ms.Status.ObservedGeneration || ms.DeletionTimestamp != nil { continue } - glog.V(4).Infof("Trying to cleanup machine set %q for deployment %q", ms.Name, deployment.Name) + klog.V(4).Infof("Trying to cleanup machine set %q for deployment %q", ms.Name, deployment.Name) if err := r.Delete(context.Background(), ms); err != nil && !errors.IsNotFound(err) { // Return error instead of aggregating and continuing DELETEs on the theory // that we may be overloading the api server. @@ -469,6 +473,8 @@ func updateMachineDeployment(c client.Client, d *clusterv1alpha1.MachineDeployme if err := c.Get(context.Background(), types.NamespacedName{Namespace: d.Namespace, Name: d.Name}, d); err != nil { return err } + + clusterv1alpha1.PopulateDefaultsMachineDeployment(d) // Apply modifications modify(d) // Update the machineDeployment diff --git a/vendor/sigs.k8s.io/cluster-api/pkg/controller/machinedeployment/util/BUILD.bazel b/vendor/sigs.k8s.io/cluster-api/pkg/controller/machinedeployment/util/BUILD.bazel new file mode 100644 index 0000000000..97d651bc83 --- /dev/null +++ b/vendor/sigs.k8s.io/cluster-api/pkg/controller/machinedeployment/util/BUILD.bazel @@ -0,0 +1,38 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") + +go_library( + name = "go_default_library", + srcs = ["util.go"], + importpath = "sigs.k8s.io/cluster-api/pkg/controller/machinedeployment/util", + visibility = ["//visibility:public"], + deps = [ + "//pkg/apis/cluster/common:go_default_library", + "//pkg/apis/cluster/v1alpha1:go_default_library", + "//vendor/github.com/davecgh/go-spew/spew:go_default_library", + "//vendor/k8s.io/api/core/v1:go_default_library", + "//vendor/k8s.io/apimachinery/pkg/api/equality: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/util/intstr:go_default_library", + "//vendor/k8s.io/client-go/util/integer:go_default_library", + "//vendor/k8s.io/klog:go_default_library", + ], +) + +go_test( + name = "go_default_test", + srcs = ["util_test.go"], + embed = [":go_default_library"], + deps = [ + "//pkg/apis/cluster/common:go_default_library", + "//pkg/apis/cluster/v1alpha1:go_default_library", + "//pkg/client/clientset_generated/clientset/fake: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/types:go_default_library", + "//vendor/k8s.io/apimachinery/pkg/util/intstr:go_default_library", + "//vendor/k8s.io/apiserver/pkg/storage/names:go_default_library", + "//vendor/k8s.io/client-go/testing:go_default_library", + ], +) diff --git a/vendor/sigs.k8s.io/cluster-api/pkg/controller/machinedeployment/util/util.go b/vendor/sigs.k8s.io/cluster-api/pkg/controller/machinedeployment/util/util.go index ed080d294e..f95739e0d9 100644 --- a/vendor/sigs.k8s.io/cluster-api/pkg/controller/machinedeployment/util/util.go +++ b/vendor/sigs.k8s.io/cluster-api/pkg/controller/machinedeployment/util/util.go @@ -25,8 +25,6 @@ import ( "strings" "github.com/davecgh/go-spew/spew" - "github.com/golang/glog" - "k8s.io/api/core/v1" apiequality "k8s.io/apimachinery/pkg/api/equality" "k8s.io/apimachinery/pkg/api/meta" @@ -34,6 +32,7 @@ import ( "k8s.io/apimachinery/pkg/runtime" intstrutil "k8s.io/apimachinery/pkg/util/intstr" "k8s.io/client-go/util/integer" + "k8s.io/klog" "sigs.k8s.io/cluster-api/pkg/apis/cluster/common" "sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1" @@ -132,7 +131,7 @@ func MaxRevision(allMSs []*v1alpha1.MachineSet) int64 { for _, ms := range allMSs { if v, err := Revision(ms); err != nil { // Skip the machine sets when it failed to parse their revision information - glog.V(4).Infof("Error: %v. Couldn't parse revision for machine set %#v, deployment controller will skip it when reconciling revisions.", err, ms) + klog.V(4).Infof("Error: %v. Couldn't parse revision for machine set %#v, deployment controller will skip it when reconciling revisions.", err, ms) } else if v > max { max = v } @@ -205,7 +204,7 @@ func getIntFromAnnotation(ms *v1alpha1.MachineSet, annotationKey string) (int32, } intValue, err := strconv.Atoi(annotationValue) if err != nil { - glog.V(2).Infof("Cannot convert the value %q with annotation key %q for the machine set %q", annotationValue, annotationKey, ms.Name) + klog.V(2).Infof("Cannot convert the value %q with annotation key %q for the machine set %q", annotationValue, annotationKey, ms.Name) return int32(0), false } return int32(intValue), true @@ -228,7 +227,7 @@ func SetNewMachineSetAnnotations(deployment *v1alpha1.MachineDeployment, newMS * oldRevisionInt, err := strconv.ParseInt(oldRevision, 10, 64) if err != nil { if oldRevision != "" { - glog.Warningf("Updating machine set revision OldRevision not int %s", err) + klog.Warningf("Updating machine set revision OldRevision not int %s", err) return false } //If the MS annotation is empty then initialise it to 0 @@ -236,13 +235,13 @@ func SetNewMachineSetAnnotations(deployment *v1alpha1.MachineDeployment, newMS * } newRevisionInt, err := strconv.ParseInt(newRevision, 10, 64) if err != nil { - glog.Warningf("Updating machine set revision NewRevision not int %s", err) + klog.Warningf("Updating machine set revision NewRevision not int %s", err) return false } if oldRevisionInt < newRevisionInt { newMS.Annotations[RevisionAnnotation] = newRevision annotationChanged = true - glog.V(4).Infof("Updating machine set %q revision to %s", newMS.Name, newRevision) + klog.V(4).Infof("Updating machine set %q revision to %s", newMS.Name, newRevision) } // If a revision annotation already existed and this machine set was updated with a new revision // then that means we are rolling back to this machine set. We need to preserve the old revisions @@ -504,7 +503,7 @@ func DeploymentComplete(deployment *v1alpha1.MachineDeployment, newStatus *v1alp } // NewMSNewReplicas calculates the number of replicas a deployment's new MS should have. -// When one of the followings is true, we're rolling out the deployment; otherwise, we're scaling it. +// When one of the following is true, we're rolling out the deployment; otherwise, we're scaling it. // 1) The new MS is saturated: newMS's replicas == deployment's replicas // 2) Max number of machines allowed is reached: deployment's replicas + maxSurge == all MSs' replicas func NewMSNewReplicas(deployment *v1alpha1.MachineDeployment, allMSs []*v1alpha1.MachineSet, newMS *v1alpha1.MachineSet) (int32, error) { diff --git a/vendor/sigs.k8s.io/cluster-api/pkg/controller/machineset/BUILD.bazel b/vendor/sigs.k8s.io/cluster-api/pkg/controller/machineset/BUILD.bazel new file mode 100644 index 0000000000..8aec373aac --- /dev/null +++ b/vendor/sigs.k8s.io/cluster-api/pkg/controller/machineset/BUILD.bazel @@ -0,0 +1,53 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") + +go_library( + name = "go_default_library", + srcs = [ + "controller.go", + "delete_policy.go", + "machine.go", + "status.go", + ], + importpath = "sigs.k8s.io/cluster-api/pkg/controller/machineset", + visibility = ["//visibility:public"], + deps = [ + "//pkg/apis/cluster/v1alpha1:go_default_library", + "//pkg/controller/noderefutil:go_default_library", + "//pkg/util:go_default_library", + "//vendor/k8s.io/api/core/v1: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/labels:go_default_library", + "//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library", + "//vendor/k8s.io/klog:go_default_library", + "//vendor/sigs.k8s.io/controller-runtime/pkg/client:go_default_library", + "//vendor/sigs.k8s.io/controller-runtime/pkg/controller:go_default_library", + "//vendor/sigs.k8s.io/controller-runtime/pkg/handler:go_default_library", + "//vendor/sigs.k8s.io/controller-runtime/pkg/manager:go_default_library", + "//vendor/sigs.k8s.io/controller-runtime/pkg/reconcile:go_default_library", + "//vendor/sigs.k8s.io/controller-runtime/pkg/source:go_default_library", + ], +) + +go_test( + name = "go_default_test", + srcs = [ + "delete_policy_test.go", + "machineset_controller_suite_test.go", + "machineset_controller_test.go", + ], + embed = [":go_default_library"], + deps = [ + "//pkg/apis:go_default_library", + "//pkg/apis/cluster/v1alpha1:go_default_library", + "//vendor/golang.org/x/net/context:go_default_library", + "//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library", + "//vendor/k8s.io/apimachinery/pkg/types:go_default_library", + "//vendor/k8s.io/client-go/kubernetes/scheme:go_default_library", + "//vendor/k8s.io/client-go/rest:go_default_library", + "//vendor/sigs.k8s.io/controller-runtime/pkg/client:go_default_library", + "//vendor/sigs.k8s.io/controller-runtime/pkg/envtest:go_default_library", + "//vendor/sigs.k8s.io/controller-runtime/pkg/manager:go_default_library", + "//vendor/sigs.k8s.io/controller-runtime/pkg/reconcile:go_default_library", + ], +) diff --git a/vendor/sigs.k8s.io/cluster-api/pkg/controller/machineset/controller.go b/vendor/sigs.k8s.io/cluster-api/pkg/controller/machineset/controller.go index 7aaf745340..a1d3923bec 100644 --- a/vendor/sigs.k8s.io/cluster-api/pkg/controller/machineset/controller.go +++ b/vendor/sigs.k8s.io/cluster-api/pkg/controller/machineset/controller.go @@ -23,10 +23,10 @@ import ( "sync" "time" - "github.com/golang/glog" "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" + "k8s.io/klog" clusterv1alpha1 "sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1" "sigs.k8s.io/cluster-api/pkg/util" "sigs.k8s.io/controller-runtime/pkg/client" @@ -50,7 +50,7 @@ var stateConfirmationInterval = 100 * time.Millisecond // and Start it when the Manager is Started. func Add(mgr manager.Manager) error { r := newReconciler(mgr) - return add(mgr, r, r.MachineSetToMachines) + return add(mgr, r, r.MachineToMachineSets) } // newReconciler returns a new reconcile.Reconciler @@ -100,13 +100,13 @@ type ReconcileMachineSet struct { scheme *runtime.Scheme } -func (r *ReconcileMachineSet) MachineSetToMachines(o handler.MapObject) []reconcile.Request { +func (r *ReconcileMachineSet) MachineToMachineSets(o handler.MapObject) []reconcile.Request { result := []reconcile.Request{} m := &clusterv1alpha1.Machine{} key := client.ObjectKey{Namespace: o.Meta.GetNamespace(), Name: o.Meta.GetName()} err := r.Client.Get(context.Background(), key, m) if err != nil { - glog.Errorf("Unable to retrieve Machine %v from store: %v", key, err) + klog.Errorf("Unable to retrieve Machine %v from store: %v", key, err) return nil } @@ -118,7 +118,7 @@ func (r *ReconcileMachineSet) MachineSetToMachines(o handler.MapObject) []reconc mss := r.getMachineSetsForMachine(m) if len(mss) == 0 { - glog.V(4).Infof("Found no machine set for machine: %v", m.Name) + klog.V(4).Infof("Found no machine set for machine: %v", m.Name) return nil } @@ -149,7 +149,7 @@ func (r *ReconcileMachineSet) Reconcile(request reconcile.Request) (reconcile.Re return reconcile.Result{}, err } - glog.V(4).Infof("Reconcile machineset %v", machineSet.Name) + klog.V(4).Infof("Reconcile machineset %v", machineSet.Name) allMachines := &clusterv1alpha1.MachineList{} err = r.Client.List(context.Background(), client.InNamespace(machineSet.Namespace), allMachines) @@ -167,7 +167,7 @@ func (r *ReconcileMachineSet) Reconcile(request reconcile.Request) (reconcile.Re // Attempt to adopt machine if it meets previous conditions and it has no controller ref. if metav1.GetControllerOf(machine) == nil { if err := r.adoptOrphan(machineSet, machine); err != nil { - glog.Warningf("failed to adopt machine %v into machineset %v. %v", machine.Name, machineSet.Name, err) + klog.Warningf("failed to adopt machine %v into machineset %v. %v", machine.Name, machineSet.Name, err) continue } } @@ -219,16 +219,16 @@ func (c *ReconcileMachineSet) syncReplicas(ms *clusterv1alpha1.MachineSet, machi if diff < 0 { diff *= -1 - glog.Infof("Too few replicas for %v %s/%s, need %d, creating %d", controllerKind, ms.Namespace, ms.Name, *(ms.Spec.Replicas), diff) + klog.Infof("Too few replicas for %v %s/%s, need %d, creating %d", controllerKind, ms.Namespace, ms.Name, *(ms.Spec.Replicas), diff) var machineList []*clusterv1alpha1.Machine var errstrings []string for i := 0; i < diff; i++ { - glog.Infof("creating machine %d of %d, ( spec.replicas(%d) > currentMachineCount(%d) )", i+1, diff, *(ms.Spec.Replicas), len(machines)) + klog.Infof("creating machine %d of %d, ( spec.replicas(%d) > currentMachineCount(%d) )", i+1, diff, *(ms.Spec.Replicas), len(machines)) machine := c.createMachine(ms) err := c.Client.Create(context.Background(), machine) if err != nil { - glog.Errorf("unable to create a machine = %s, due to %v", machine.Name, err) + klog.Errorf("unable to create a machine = %s, due to %v", machine.Name, err) errstrings = append(errstrings, err.Error()) continue } @@ -240,7 +240,7 @@ func (c *ReconcileMachineSet) syncReplicas(ms *clusterv1alpha1.MachineSet, machi } return c.waitForMachineCreation(machineList) } else if diff > 0 { - glog.Infof("Too many replicas for %v %s/%s, need %d, deleting %d", controllerKind, ms.Namespace, ms.Name, *(ms.Spec.Replicas), diff) + klog.Infof("Too many replicas for %v %s/%s, need %d, deleting %d", controllerKind, ms.Namespace, ms.Name, *(ms.Spec.Replicas), diff) // Choose which Machines to delete. machinesToDelete := getMachinesToDeletePrioritized(machines, diff, simpleDeletePriority) @@ -254,7 +254,7 @@ func (c *ReconcileMachineSet) syncReplicas(ms *clusterv1alpha1.MachineSet, machi defer wg.Done() err := c.Client.Delete(context.Background(), targetMachine) if err != nil { - glog.Errorf("unable to delete a machine = %s, due to %v", targetMachine.Name, err) + klog.Errorf("unable to delete a machine = %s, due to %v", targetMachine.Name, err) errCh <- err } }(machine) @@ -294,11 +294,11 @@ func (c *ReconcileMachineSet) createMachine(machineSet *clusterv1alpha1.MachineS return machine } -// shoudExcludeMachine returns true if the machine should be filtered out, false otherwise. +// shouldExcludeMachine returns true if the machine should be filtered out, false otherwise. func shouldExcludeMachine(machineSet *clusterv1alpha1.MachineSet, machine *clusterv1alpha1.Machine) bool { // Ignore inactive machines. if metav1.GetControllerOf(machine) != nil && !metav1.IsControlledBy(machine, machineSet) { - glog.V(4).Infof("%s not controlled by %v", machine.Name, machineSet.Name) + klog.V(4).Infof("%s not controlled by %v", machine.Name, machineSet.Name) return true } if machine.ObjectMeta.DeletionTimestamp != nil { @@ -321,7 +321,7 @@ func (c *ReconcileMachineSet) adoptOrphan(machineSet *clusterv1alpha1.MachineSet ownerRefs = append(ownerRefs, newRef) machine.ObjectMeta.SetOwnerReferences(ownerRefs) if err := c.Client.Update(context.Background(), machine); err != nil { - glog.Warningf("Failed to update machine owner reference. %v", err) + klog.Warningf("Failed to update machine owner reference. %v", err) return err } return nil @@ -333,17 +333,17 @@ func (c *ReconcileMachineSet) waitForMachineCreation(machineList []*clusterv1alp err := c.Client.Get(context.Background(), client.ObjectKey{Namespace: machine.Namespace, Name: machine.Name}, &clusterv1alpha1.Machine{}) - glog.Error(err) if err == nil { return true, nil } + klog.Error(err) if errors.IsNotFound(err) { return false, nil } return false, err }) if pollErr != nil { - glog.Error(pollErr) + klog.Error(pollErr) return fmt.Errorf("failed waiting for machine object to be created. %v", pollErr) } } @@ -363,7 +363,7 @@ func (c *ReconcileMachineSet) waitForMachineDeletion(machineList []*clusterv1alp return false, err }) if pollErr != nil { - glog.Error(pollErr) + klog.Error(pollErr) return fmt.Errorf("failed waiting for machine object to be deleted. %v", pollErr) } } diff --git a/vendor/sigs.k8s.io/cluster-api/pkg/controller/machineset/machine.go b/vendor/sigs.k8s.io/cluster-api/pkg/controller/machineset/machine.go index 9ca4bdca2f..f6b6c0e6dd 100644 --- a/vendor/sigs.k8s.io/cluster-api/pkg/controller/machineset/machine.go +++ b/vendor/sigs.k8s.io/cluster-api/pkg/controller/machineset/machine.go @@ -18,24 +18,35 @@ package machineset import ( "context" - - "github.com/golang/glog" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/labels" + "k8s.io/klog" "sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1" "sigs.k8s.io/controller-runtime/pkg/client" ) func (c *ReconcileMachineSet) getMachineSetsForMachine(m *v1alpha1.Machine) []*v1alpha1.MachineSet { if len(m.Labels) == 0 { - glog.Warningf("No machine sets found for Machine %v because it has no labels", m.Name) + klog.Warningf("No machine sets found for Machine %v because it has no labels", m.Name) return nil } msList := &v1alpha1.MachineSetList{} - err := c.Client.List(context.Background(), &client.ListOptions{Namespace: m.Namespace}, msList) + listOptions := &client.ListOptions{ + Namespace: m.Namespace, + // This is set so the fake client can be used for unit test. See: + // https://github.com/kubernetes-sigs/controller-runtime/issues/168 + Raw: &metav1.ListOptions{ + TypeMeta: metav1.TypeMeta{ + APIVersion: v1alpha1.SchemeGroupVersion.String(), + Kind: "MachineSet", + }, + }, + } + + err := c.Client.List(context.Background(), listOptions, msList) if err != nil { - glog.Errorf("Failed to list machine sets, %v", err) + klog.Errorf("Failed to list machine sets, %v", err) return nil } @@ -53,16 +64,16 @@ func (c *ReconcileMachineSet) getMachineSetsForMachine(m *v1alpha1.Machine) []*v func hasMatchingLabels(machineSet *v1alpha1.MachineSet, machine *v1alpha1.Machine) bool { selector, err := metav1.LabelSelectorAsSelector(&machineSet.Spec.Selector) if err != nil { - glog.Warningf("unable to convert selector: %v", err) + klog.Warningf("unable to convert selector: %v", err) return false } // If a deployment with a nil or empty selector creeps in, it should match nothing, not everything. if selector.Empty() { - glog.V(2).Infof("%v machineset has empty selector", machineSet.Name) + klog.V(2).Infof("%v machineset has empty selector", machineSet.Name) return false } if !selector.Matches(labels.Set(machine.Labels)) { - glog.V(4).Infof("%v machine has mismatch labels", machine.Name) + klog.V(4).Infof("%v machine has mismatch labels", machine.Name) return false } return true diff --git a/vendor/sigs.k8s.io/cluster-api/pkg/controller/machineset/status.go b/vendor/sigs.k8s.io/cluster-api/pkg/controller/machineset/status.go index c71e9940e9..fed150a29a 100644 --- a/vendor/sigs.k8s.io/cluster-api/pkg/controller/machineset/status.go +++ b/vendor/sigs.k8s.io/cluster-api/pkg/controller/machineset/status.go @@ -19,11 +19,10 @@ package machineset import ( "fmt" - "github.com/golang/glog" - corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/labels" + "k8s.io/klog" "context" @@ -54,7 +53,7 @@ func (c *ReconcileMachineSet) calculateStatus(ms *v1alpha1.MachineSet, filteredM } node, err := c.getMachineNode(machine) if err != nil { - glog.V(4).Infof("Unable to get node for machine %v, %v", machine.Name, err) + klog.V(4).Infof("Unable to get node for machine %v, %v", machine.Name, err) continue } if noderefutil.IsNodeReady(node) { @@ -97,7 +96,7 @@ func updateMachineSetStatus(c client.Client, ms *v1alpha1.MachineSet, newStatus if ms.Spec.Replicas != nil { replicas = *ms.Spec.Replicas } - glog.V(4).Infof(fmt.Sprintf("Updating status for %v: %s/%s, ", ms.Kind, ms.Namespace, ms.Name) + + klog.V(4).Infof(fmt.Sprintf("Updating status for %v: %s/%s, ", ms.Kind, ms.Namespace, ms.Name) + fmt.Sprintf("replicas %d->%d (need %d), ", ms.Status.Replicas, newStatus.Replicas, replicas) + fmt.Sprintf("fullyLabeledReplicas %d->%d, ", ms.Status.FullyLabeledReplicas, newStatus.FullyLabeledReplicas) + fmt.Sprintf("readyReplicas %d->%d, ", ms.Status.ReadyReplicas, newStatus.ReadyReplicas) + diff --git a/vendor/sigs.k8s.io/cluster-api/pkg/controller/node/BUILD.bazel b/vendor/sigs.k8s.io/cluster-api/pkg/controller/node/BUILD.bazel new file mode 100644 index 0000000000..0af213d294 --- /dev/null +++ b/vendor/sigs.k8s.io/cluster-api/pkg/controller/node/BUILD.bazel @@ -0,0 +1,51 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") + +go_library( + name = "go_default_library", + srcs = [ + "node.go", + "node_controller.go", + ], + importpath = "sigs.k8s.io/cluster-api/pkg/controller/node", + visibility = ["//visibility:public"], + deps = [ + "//pkg/apis/cluster/v1alpha1:go_default_library", + "//pkg/controller/noderefutil:go_default_library", + "//pkg/util:go_default_library", + "//vendor/k8s.io/api/core/v1: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/client-go/tools/cache:go_default_library", + "//vendor/k8s.io/klog:go_default_library", + "//vendor/sigs.k8s.io/controller-runtime/pkg/client:go_default_library", + "//vendor/sigs.k8s.io/controller-runtime/pkg/controller:go_default_library", + "//vendor/sigs.k8s.io/controller-runtime/pkg/handler:go_default_library", + "//vendor/sigs.k8s.io/controller-runtime/pkg/manager:go_default_library", + "//vendor/sigs.k8s.io/controller-runtime/pkg/reconcile:go_default_library", + "//vendor/sigs.k8s.io/controller-runtime/pkg/source:go_default_library", + ], +) + +go_test( + name = "go_default_test", + srcs = [ + "node_controller_suite_test.go", + "node_controller_test.go", + ], + embed = [":go_default_library"], + deps = [ + "//pkg/apis:go_default_library", + "//vendor/golang.org/x/net/context:go_default_library", + "//vendor/k8s.io/api/core/v1: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/types:go_default_library", + "//vendor/k8s.io/client-go/kubernetes/scheme:go_default_library", + "//vendor/k8s.io/client-go/rest:go_default_library", + "//vendor/sigs.k8s.io/controller-runtime/pkg/client:go_default_library", + "//vendor/sigs.k8s.io/controller-runtime/pkg/envtest:go_default_library", + "//vendor/sigs.k8s.io/controller-runtime/pkg/manager:go_default_library", + "//vendor/sigs.k8s.io/controller-runtime/pkg/reconcile:go_default_library", + ], +) diff --git a/vendor/sigs.k8s.io/cluster-api/pkg/controller/node/node.go b/vendor/sigs.k8s.io/cluster-api/pkg/controller/node/node.go index cb16730be4..a954342d39 100644 --- a/vendor/sigs.k8s.io/cluster-api/pkg/controller/node/node.go +++ b/vendor/sigs.k8s.io/cluster-api/pkg/controller/node/node.go @@ -17,11 +17,10 @@ limitations under the License. package node import ( - "github.com/golang/glog" - corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/tools/cache" + "k8s.io/klog" "context" @@ -32,7 +31,7 @@ import ( ) const ( - machineAnnotationKey = "machine" + machineAnnotationKey = "cluster.k8s.io/machine" ) // We are using "machine" annotation to link node and machine resource. The "machine" @@ -60,7 +59,7 @@ func (c *ReconcileNode) link(node *corev1.Node) error { namespace, mach, err := cache.SplitMetaNamespaceKey(val) if err != nil { - glog.Errorf("Machine annotation format is incorrect %v: %v\n", val, err) + klog.Errorf("Machine annotation format is incorrect %v: %v\n", val, err) return err } namespace = util.GetNamespaceOrDefault(namespace) @@ -68,7 +67,7 @@ func (c *ReconcileNode) link(node *corev1.Node) error { machine := &v1alpha1.Machine{} if err = c.Client.Get(context.Background(), key, machine); err != nil { - glog.Errorf("Error getting machine %v: %v\n", mach, err) + klog.Errorf("Error getting machine %v: %v\n", mach, err) return err } @@ -76,9 +75,9 @@ func (c *ReconcileNode) link(node *corev1.Node) error { machine.Status.LastUpdated = &t machine.Status.NodeRef = objectRef(node) if err = c.Client.Status().Update(context.Background(), machine); err != nil { - glog.Errorf("Error updating machine to link to node: %v\n", err) + klog.Errorf("Error updating machine to link to node: %v\n", err) } else { - glog.Infof("Successfully linked machine %s to node %s\n", + klog.Infof("Successfully linked machine %s to node %s\n", machine.ObjectMeta.Name, node.ObjectMeta.Name) c.linkedNodes[node.ObjectMeta.Name] = true c.cachedReadiness[node.ObjectMeta.Name] = nodeReady @@ -94,7 +93,7 @@ func (c *ReconcileNode) unlink(node *corev1.Node) error { namespace, mach, err := cache.SplitMetaNamespaceKey(val) if err != nil { - glog.Errorf("Machine annotation format is incorrect %v: %v\n", val, err) + klog.Errorf("Machine annotation format is incorrect %v: %v\n", val, err) return err } namespace = util.GetNamespaceOrDefault(namespace) @@ -102,7 +101,7 @@ func (c *ReconcileNode) unlink(node *corev1.Node) error { machine := &v1alpha1.Machine{} if err = c.Client.Get(context.Background(), key, machine); err != nil { - glog.Errorf("Error getting machine %v: %v\n", mach, err) + klog.Errorf("Error getting machine %v: %v\n", mach, err) return err } @@ -113,7 +112,7 @@ func (c *ReconcileNode) unlink(node *corev1.Node) error { // This machine was linked to a different node, don't unlink them if machine.Status.NodeRef.Name != node.ObjectMeta.Name { - glog.Warningf("Node (%v) is tring to unlink machine (%v) which is linked with node (%v).", + klog.Warningf("Node (%v) is tring to unlink machine (%v) which is linked with node (%v).", node.ObjectMeta.Name, machine.ObjectMeta.Name, machine.Status.NodeRef.Name) return nil } @@ -122,10 +121,10 @@ func (c *ReconcileNode) unlink(node *corev1.Node) error { machine.Status.LastUpdated = &t machine.Status.NodeRef = nil if err = c.Client.Status().Update(context.Background(), machine); err != nil { - glog.Errorf("Error updating machine %s to unlink node %s: %v\n", + klog.Errorf("Error updating machine %s to unlink node %s: %v\n", machine.ObjectMeta.Name, node.ObjectMeta.Name, err) } else { - glog.Infof("Successfully unlinked node %s from machine %s\n", + klog.Infof("Successfully unlinked node %s from machine %s\n", node.ObjectMeta.Name, machine.ObjectMeta.Name) delete(c.cachedReadiness, node.ObjectMeta.Name) delete(c.linkedNodes, node.ObjectMeta.Name) diff --git a/vendor/sigs.k8s.io/cluster-api/pkg/controller/node/node_controller.go b/vendor/sigs.k8s.io/cluster-api/pkg/controller/node/node_controller.go index 5d0305d31c..d66fee4e1c 100644 --- a/vendor/sigs.k8s.io/cluster-api/pkg/controller/node/node_controller.go +++ b/vendor/sigs.k8s.io/cluster-api/pkg/controller/node/node_controller.go @@ -19,10 +19,10 @@ package node import ( "context" - "github.com/golang/glog" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/runtime" + "k8s.io/klog" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/controller" "sigs.k8s.io/controller-runtime/pkg/handler" @@ -87,7 +87,7 @@ func (r *ReconcileNode) Reconcile(request reconcile.Request) (reconcile.Result, if errors.IsNotFound(err) { // Object not found, return. Created objects are automatically garbage collected. // For additional cleanup logic use finalizers. - glog.Errorf("Unable to retrieve Node %v from store: %v", request, err) + klog.Errorf("Unable to retrieve Node %v from store: %v", request, err) return reconcile.Result{}, nil } // Error reading the object - requeue the request. diff --git a/vendor/sigs.k8s.io/cluster-api/pkg/controller/noderefutil/BUILD.bazel b/vendor/sigs.k8s.io/cluster-api/pkg/controller/noderefutil/BUILD.bazel new file mode 100644 index 0000000000..7868e41e82 --- /dev/null +++ b/vendor/sigs.k8s.io/cluster-api/pkg/controller/noderefutil/BUILD.bazel @@ -0,0 +1,22 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") + +go_library( + name = "go_default_library", + srcs = ["util.go"], + importpath = "sigs.k8s.io/cluster-api/pkg/controller/noderefutil", + visibility = ["//visibility:public"], + deps = [ + "//vendor/k8s.io/api/core/v1:go_default_library", + "//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library", + ], +) + +go_test( + name = "go_default_test", + srcs = ["util_test.go"], + embed = [":go_default_library"], + deps = [ + "//vendor/k8s.io/api/core/v1:go_default_library", + "//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library", + ], +) diff --git a/vendor/sigs.k8s.io/cluster-api/pkg/errors/BUILD.bazel b/vendor/sigs.k8s.io/cluster-api/pkg/errors/BUILD.bazel new file mode 100644 index 0000000000..3d2cd66d09 --- /dev/null +++ b/vendor/sigs.k8s.io/cluster-api/pkg/errors/BUILD.bazel @@ -0,0 +1,13 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +go_library( + name = "go_default_library", + srcs = [ + "clusters.go", + "deployer.go", + "machines.go", + ], + importpath = "sigs.k8s.io/cluster-api/pkg/errors", + visibility = ["//visibility:public"], + deps = ["//pkg/apis/cluster/common:go_default_library"], +) diff --git a/vendor/sigs.k8s.io/cluster-api/pkg/kubeadm/BUILD.bazel b/vendor/sigs.k8s.io/cluster-api/pkg/kubeadm/BUILD.bazel new file mode 100644 index 0000000000..d260f7ac7c --- /dev/null +++ b/vendor/sigs.k8s.io/cluster-api/pkg/kubeadm/BUILD.bazel @@ -0,0 +1,16 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") + +go_library( + name = "go_default_library", + srcs = ["kubeadm.go"], + importpath = "sigs.k8s.io/cluster-api/pkg/kubeadm", + visibility = ["//visibility:public"], + deps = ["//pkg/cmd-runner:go_default_library"], +) + +go_test( + name = "go_default_test", + srcs = ["kubeadm_test.go"], + embed = [":go_default_library"], + deps = ["//pkg/test-cmd-runner:go_default_library"], +) diff --git a/vendor/sigs.k8s.io/cluster-api/pkg/test-cmd-runner/BUILD.bazel b/vendor/sigs.k8s.io/cluster-api/pkg/test-cmd-runner/BUILD.bazel new file mode 100644 index 0000000000..e0fb797d38 --- /dev/null +++ b/vendor/sigs.k8s.io/cluster-api/pkg/test-cmd-runner/BUILD.bazel @@ -0,0 +1,14 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") + +go_library( + name = "go_default_library", + srcs = ["test_cmd_runner.go"], + importpath = "sigs.k8s.io/cluster-api/pkg/test-cmd-runner", + visibility = ["//visibility:public"], +) + +go_test( + name = "go_default_test", + srcs = ["test_cmd_runner_test.go"], + embed = [":go_default_library"], +) diff --git a/vendor/sigs.k8s.io/cluster-api/pkg/util/BUILD.bazel b/vendor/sigs.k8s.io/cluster-api/pkg/util/BUILD.bazel new file mode 100644 index 0000000000..d0bc45d475 --- /dev/null +++ b/vendor/sigs.k8s.io/cluster-api/pkg/util/BUILD.bazel @@ -0,0 +1,26 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") + +go_library( + name = "go_default_library", + srcs = [ + "retry.go", + "util.go", + ], + importpath = "sigs.k8s.io/cluster-api/pkg/util", + visibility = ["//visibility:public"], + deps = [ + "//pkg/apis/cluster/v1alpha1:go_default_library", + "//vendor/k8s.io/api/core/v1:go_default_library", + "//vendor/k8s.io/apimachinery/pkg/api/errors:go_default_library", + "//vendor/k8s.io/apimachinery/pkg/util/wait:go_default_library", + "//vendor/k8s.io/klog:go_default_library", + "//vendor/sigs.k8s.io/controller-runtime/pkg/client:go_default_library", + "//vendor/sigs.k8s.io/yaml:go_default_library", + ], +) + +go_test( + name = "go_default_test", + srcs = ["util_test.go"], + embed = [":go_default_library"], +) diff --git a/vendor/sigs.k8s.io/cluster-api/pkg/util/util.go b/vendor/sigs.k8s.io/cluster-api/pkg/util/util.go index bd6f066939..b67bb00237 100644 --- a/vendor/sigs.k8s.io/cluster-api/pkg/util/util.go +++ b/vendor/sigs.k8s.io/cluster-api/pkg/util/util.go @@ -27,9 +27,9 @@ import ( "strings" "time" - "github.com/golang/glog" "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/klog" clusterv1 "sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/yaml" @@ -81,7 +81,7 @@ func Home() string { usr, err := user.Current() if err != nil { - glog.Warningf("unable to find user: %v", err) + klog.Warningf("unable to find user: %v", err) return "" } return usr.HomeDir @@ -91,7 +91,7 @@ func GetDefaultKubeConfigPath() string { localDir := fmt.Sprintf("%s/.kube", Home()) if _, err := os.Stat(localDir); os.IsNotExist(err) { if err := os.Mkdir(localDir, 0777); err != nil { - glog.Fatal(err) + klog.Fatal(err) } } return fmt.Sprintf("%s/config", localDir) @@ -144,7 +144,11 @@ func Copy(m *clusterv1.Machine) *clusterv1.Machine { } func ExecCommand(name string, args ...string) string { - cmdOut, _ := exec.Command(name, args...).Output() + cmdOut, err := exec.Command(name, args...).Output() + if err != nil { + s := strings.Join(append([]string{name}, args...), " ") + klog.Errorf("error executing command %q: %v", s, err) + } return string(cmdOut) } diff --git a/vendor/sigs.k8s.io/cluster-api/sample/machineclass.yaml b/vendor/sigs.k8s.io/cluster-api/sample/machineclass.yaml index 6cf45d4e2e..8ca63eff03 100644 --- a/vendor/sigs.k8s.io/cluster-api/sample/machineclass.yaml +++ b/vendor/sigs.k8s.io/cluster-api/sample/machineclass.yaml @@ -4,7 +4,7 @@ kind: MachineClass metadata: name: small namespace: foo -providerConfig: +providerSpec: apiVersion: "gceproviderconfig/v1alpha1" kind: "GCEProviderConfig" project: "$GCLOUD_PROJECT" @@ -18,14 +18,14 @@ providerConfig: apiVersion: cluster.k8s.io/v1alpha1 kind: Machine metadata: - name: test-machine + name: test-machine namespace: foo labels: - test-label: test-label + test-label: test-label spec: - providerConfig: + providerSpec: valueFrom: - machineClass: + machineClass: provider: gcp name: small namespace: foo diff --git a/vendor/sigs.k8s.io/cluster-api/sample/machinedeployment.yaml b/vendor/sigs.k8s.io/cluster-api/sample/machinedeployment.yaml index f69dc90ace..a00bd6ee32 100644 --- a/vendor/sigs.k8s.io/cluster-api/sample/machinedeployment.yaml +++ b/vendor/sigs.k8s.io/cluster-api/sample/machinedeployment.yaml @@ -12,7 +12,7 @@ spec: labels: foo: bar spec: - providerConfig: + providerSpec: value: apiVersion: "gceproviderconfig/v1alpha1" kind: "GCEProviderConfig" diff --git a/vendor/sigs.k8s.io/cluster-api/sample/machineset.yaml b/vendor/sigs.k8s.io/cluster-api/sample/machineset.yaml index 88b39dbf59..a08b92cf64 100644 --- a/vendor/sigs.k8s.io/cluster-api/sample/machineset.yaml +++ b/vendor/sigs.k8s.io/cluster-api/sample/machineset.yaml @@ -12,7 +12,7 @@ spec: labels: foo: bar spec: - providerConfig: + providerSpec: value: apiVersion: "gceproviderconfig/v1alpha1" kind: "GCEMachineProviderConfig" diff --git a/vendor/sigs.k8s.io/cluster-api/scripts/fetch_ext_bins.sh b/vendor/sigs.k8s.io/cluster-api/scripts/fetch_ext_bins.sh index c1100da03a..4dc2c38953 100755 --- a/vendor/sigs.k8s.io/cluster-api/scripts/fetch_ext_bins.sh +++ b/vendor/sigs.k8s.io/cluster-api/scripts/fetch_ext_bins.sh @@ -98,7 +98,7 @@ function fetch_tools { kb_tools_archive_path="$tmp_root/$kb_tools_archive_name" if [ ! -f $kb_tools_archive_path ]; then - curl -sL ${kb_tools_download_url} -o "$kb_tools_archive_path" + curl -fsL ${kb_tools_download_url} -o "$kb_tools_archive_path" fi tar -zvxf "$kb_tools_archive_path" -C "$tmp_root/" }