Skip to content

Commit

Permalink
Merge pull request #36 from Lion-Wei/generator
Browse files Browse the repository at this point in the history
adopt Kubernetes's API tooling to automatically generate
  • Loading branch information
k8s-ci-robot authored Oct 8, 2018
2 parents 2ae73f8 + 3a9831f commit 7ec9f52
Show file tree
Hide file tree
Showing 330 changed files with 61,279 additions and 192 deletions.
71 changes: 68 additions & 3 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 11 additions & 2 deletions Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ required = [
"github.com/jteeuwen/go-bindata/go-bindata",
"github.com/golang/dep/cmd/dep",
"github.com/golang/lint/golint",
"k8s.io/code-generator/cmd/defaulter-gen",
"k8s.io/code-generator/cmd/deepcopy-gen",
]

# prune out unused content from vendor
Expand All @@ -12,7 +14,10 @@ required = [
non-go = true
unused-packages = true

# overrides for dev-time dependencies
# Don't prune helper scripts from code-generator
[[prune.project]]
name = "k8s.io/code-generator"
unused-packages = false

[[override]]
name = "github.com/jteeuwen/go-bindata"
Expand Down Expand Up @@ -42,7 +47,11 @@ required = [
name = "github.com/spf13/cobra"
version = "0.0.3"


[[constraint]]
branch = "master"
name = "k8s.io/apimachinery"

[[constraint]]
name = "k8s.io/code-generator"
branch = "release-1.11"

15 changes: 15 additions & 0 deletions boilerplate.go.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
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.
*/
4 changes: 2 additions & 2 deletions cmd/kind/create/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import (
"github.com/spf13/cobra"

"sigs.k8s.io/kind/pkg/cluster"
"sigs.k8s.io/kind/pkg/cluster/config"
"sigs.k8s.io/kind/pkg/cluster/config/encoding"
"sigs.k8s.io/kind/pkg/util"
)

type flags struct {
Expand Down Expand Up @@ -61,7 +61,7 @@ func run(flags *flags, cmd *cobra.Command, args []string) {
err = cfg.Validate()
if err != nil {
log.Error("Invalid configuration!")
configErrors := err.(*config.Errors)
configErrors := err.(*util.Errors)
for _, problem := range configErrors.Errors() {
log.Error(problem)
}
Expand Down
8 changes: 7 additions & 1 deletion hack/update-generated.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,15 @@ REPO_ROOT=$(git rev-parse --show-toplevel)
OUTPUT_GOBIN="${REPO_ROOT}/_output/bin"
cd "${REPO_ROOT}"
GOBIN="${OUTPUT_GOBIN}" go install ./vendor/github.com/jteeuwen/go-bindata/go-bindata
GOBIN="${OUTPUT_GOBIN}" go install ./vendor/k8s.io/code-generator/cmd/defaulter-gen
GOBIN="${OUTPUT_GOBIN}" go install ./vendor/k8s.io/code-generator/cmd/deepcopy-gen

# go generate (using go-bindata)
# NOTE: go will only take package paths, not absolute directories
PATH="${OUTPUT_GOBIN}:${PATH}" go generate ./...
export PATH="${OUTPUT_GOBIN}:${PATH}"
go generate ./...
deepcopy-gen -i ./pkg/cluster/config/ -O zz_generated.deepcopy --go-header-file boilerplate.go.txt
defaulter-gen -i ./pkg/cluster/config -O zz_generated.default --go-header-file boilerplate.go.txt

# gofmt the tree
find . -path "./vendor" -prune -o -name "*.go" -type f -print0 | xargs -0 gofmt -s -w
85 changes: 0 additions & 85 deletions pkg/cluster/config/deepcopy.go

This file was deleted.

77 changes: 0 additions & 77 deletions pkg/cluster/config/deepcopy_test.go

This file was deleted.

Loading

0 comments on commit 7ec9f52

Please sign in to comment.