Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adopt Kubernetes's API tooling to automatically generate #36

Merged
merged 3 commits into from
Oct 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
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"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should be using matching versions of code-generator and apimachinery... perhaps best to switch code-generator to master for now too, if we require master of apimachinery? /cc @BenTheElder


[[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