Skip to content

Commit

Permalink
Use go modules, update controller-{runtime, tools} to v2
Browse files Browse the repository at this point in the history
Signed-off-by: Vince Prignano <vincepri@vmware.com>
  • Loading branch information
vincepri committed Jun 21, 2019
1 parent 1cb3deb commit 0583f26
Show file tree
Hide file tree
Showing 1,381 changed files with 113,302 additions and 139,891 deletions.
1,316 changes: 0 additions & 1,316 deletions Gopkg.lock

This file was deleted.

41 changes: 0 additions & 41 deletions Gopkg.toml

This file was deleted.

34 changes: 18 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,16 @@ help: ## Display this help
gazelle: ## Run Bazel Gazelle
(which bazel && ./hack/update-bazel.sh) || true

.PHONY: dep-ensure
dep-ensure: ## Runs dep-ensure and rebuilds Bazel gazelle files.
find vendor -name 'BUILD.bazel' -delete
(which dep && dep ensure -v) || true
$(MAKE) gazelle
.PHONY: vendor-ensure
vendor-ensure: ## Runs go mod to ensure proper vendoring.
./hack/update-vendor.sh

.PHONY: test
test: verify generate fmt vet ## Run tests
$(MAKE) test-go

.PHONY: test
test: gazelle verify generate fmt vet manifests ## Run tests
test-go: ## Run tests
go test -v -tags=integration ./pkg/... ./cmd/...

.PHONY: manager
Expand All @@ -71,8 +73,8 @@ deploy: manifests ## Deploy controller in the configured Kubernetes cluster in ~

.PHONY: manifests
manifests: ## Generate manifests e.g. CRD, RBAC etc.
go run vendor/sigs.k8s.io/controller-tools/cmd/controller-gen/main.go all
cp -f ./config/rbac/manager*.yaml ./config/ci/rbac/
go run vendor/sigs.k8s.io/controller-tools/cmd/controller-gen/main.go paths=./pkg/... crd rbac:roleName=manager-role output:crd:dir=./config/crds
cp -f ./config/rbac/role*.yaml ./config/ci/rbac/
cp -f ./config/manager/manager*.yaml ./config/ci/manager/

.PHONY: fmt
Expand All @@ -84,28 +86,27 @@ vet: ## Run go vet against code
go vet ./pkg/... ./cmd/...

.PHONY: lint
lint: dep-ensure ## Lint codebase
lint: vendor-ensure ## Lint codebase
bazel run //:lint $(BAZEL_ARGS)

lint-full: dep-ensure ## Run slower linters to detect possible issues
lint-full: vendor-ensure ## Run slower linters to detect possible issues
bazel run //:lint-full $(BAZEL_ARGS)

.PHONY: generate
generate: clientset dep-ensure ## Generate code
generate: clientset vendor-ensure ## Generate code
go generate ./pkg/... ./cmd/...
$(MAKE) gazelle

.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 \
go run ./vendor/k8s.io/code-generator/cmd/client-gen/main.go --clientset-name clientset --input-base sigs.k8s.io/cluster-api/pkg/apis \
--input cluster/v1alpha1 --output-package sigs.k8s.io/cluster-api/pkg/client/clientset_generated \
--go-header-file=./hack/boilerplate/boilerplate.generatego.txt
$$GOPATH/bin/lister-gen --input-dirs sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1 \
go run ./vendor/k8s.io/code-generator/cmd/lister-gen/main.go --input-dirs sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1 \
--output-package sigs.k8s.io/cluster-api/pkg/client/listers_generated \
--go-header-file=./hack/boilerplate/boilerplate.generatego.txt
$$GOPATH/bin/informer-gen --input-dirs sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1 \
go run ./vendor/k8s.io/code-generator/cmd/informer-gen/main.go --input-dirs sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1 \
--versioned-clientset-package sigs.k8s.io/cluster-api/pkg/client/clientset_generated/clientset \
--listers-package sigs.k8s.io/cluster-api/pkg/client/listers_generated \
--output-package sigs.k8s.io/cluster-api/pkg/client/informers_generated \
Expand Down Expand Up @@ -162,6 +163,7 @@ docker-push-ci: docker-build-ci ## Build the docker image for ci

.PHONY: verify
verify:
./hack/verify-go.sh
./hack/verify-boilerplate.sh
./hack/verify_clientset.sh
./hack/verify-clientset.sh
./hack/verify-bazel.sh
9 changes: 0 additions & 9 deletions build/run_in_workspace_with_goroot.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,6 @@ _workspace_binary_script = rule(
)

# Wraps a binary to be run in the workspace root via bazel run.
#
# For example, one might do something like
#
# workspace_binary(
# name = "dep",
# cmd = "//vendor/github.com/golang/dep/cmd/dep",
# )
#
# which would allow running dep with bazel run.
def workspace_binary(
name,
cmd,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Global Flags:
--log-file-max-size uint Defines the maximum size a log file can grow to. Unit is megabytes. If the value is 0, the maximum file size is unlimited. (default 1800)
--log-flush-frequency duration Maximum number of seconds between log flushes (default 5s)
--logtostderr log to standard error instead of files (default true)
--master string The address of the Kubernetes API server. Overrides any value in kubeconfig. Only required if out-of-cluster.
--master --kubeconfig (Deprecated: switch to --kubeconfig) The address of the Kubernetes API server. Overrides any value in kubeconfig. Only required if out-of-cluster.
--skip-headers If true, avoid header prefixes in the log messages
--skip-log-headers If true, avoid headers when opening log files
--stderrthreshold severity logs at or above this threshold go to stderr (default 2)
Expand Down
2 changes: 1 addition & 1 deletion cmd/clusterctl/testdata/create-cluster-no-args.golden
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Global Flags:
--log-file-max-size uint Defines the maximum size a log file can grow to. Unit is megabytes. If the value is 0, the maximum file size is unlimited. (default 1800)
--log-flush-frequency duration Maximum number of seconds between log flushes (default 5s)
--logtostderr log to standard error instead of files (default true)
--master string The address of the Kubernetes API server. Overrides any value in kubeconfig. Only required if out-of-cluster.
--master --kubeconfig (Deprecated: switch to --kubeconfig) The address of the Kubernetes API server. Overrides any value in kubeconfig. Only required if out-of-cluster.
--skip-headers If true, avoid header prefixes in the log messages
--skip-log-headers If true, avoid headers when opening log files
--stderrthreshold severity logs at or above this threshold go to stderr (default 2)
Expand Down
2 changes: 1 addition & 1 deletion cmd/clusterctl/testdata/create-no-args-invalid-flag.golden
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Global Flags:
--log-file-max-size uint Defines the maximum size a log file can grow to. Unit is megabytes. If the value is 0, the maximum file size is unlimited. (default 1800)
--log-flush-frequency duration Maximum number of seconds between log flushes (default 5s)
--logtostderr log to standard error instead of files (default true)
--master string The address of the Kubernetes API server. Overrides any value in kubeconfig. Only required if out-of-cluster.
--master --kubeconfig (Deprecated: switch to --kubeconfig) The address of the Kubernetes API server. Overrides any value in kubeconfig. Only required if out-of-cluster.
--skip-headers If true, avoid header prefixes in the log messages
--skip-log-headers If true, avoid headers when opening log files
--stderrthreshold severity logs at or above this threshold go to stderr (default 2)
Expand Down
2 changes: 1 addition & 1 deletion cmd/clusterctl/testdata/create-no-args.golden
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Global Flags:
--log-file-max-size uint Defines the maximum size a log file can grow to. Unit is megabytes. If the value is 0, the maximum file size is unlimited. (default 1800)
--log-flush-frequency duration Maximum number of seconds between log flushes (default 5s)
--logtostderr log to standard error instead of files (default true)
--master string The address of the Kubernetes API server. Overrides any value in kubeconfig. Only required if out-of-cluster.
--master --kubeconfig (Deprecated: switch to --kubeconfig) The address of the Kubernetes API server. Overrides any value in kubeconfig. Only required if out-of-cluster.
--skip-headers If true, avoid header prefixes in the log messages
--skip-log-headers If true, avoid headers when opening log files
--stderrthreshold severity logs at or above this threshold go to stderr (default 2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Global Flags:
--log-file-max-size uint Defines the maximum size a log file can grow to. Unit is megabytes. If the value is 0, the maximum file size is unlimited. (default 1800)
--log-flush-frequency duration Maximum number of seconds between log flushes (default 5s)
--logtostderr log to standard error instead of files (default true)
--master string The address of the Kubernetes API server. Overrides any value in kubeconfig. Only required if out-of-cluster.
--master --kubeconfig (Deprecated: switch to --kubeconfig) The address of the Kubernetes API server. Overrides any value in kubeconfig. Only required if out-of-cluster.
--skip-headers If true, avoid header prefixes in the log messages
--skip-log-headers If true, avoid headers when opening log files
--stderrthreshold severity logs at or above this threshold go to stderr (default 2)
Expand Down
2 changes: 1 addition & 1 deletion cmd/clusterctl/testdata/delete-cluster-no-args.golden
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Global Flags:
--log-file-max-size uint Defines the maximum size a log file can grow to. Unit is megabytes. If the value is 0, the maximum file size is unlimited. (default 1800)
--log-flush-frequency duration Maximum number of seconds between log flushes (default 5s)
--logtostderr log to standard error instead of files (default true)
--master string The address of the Kubernetes API server. Overrides any value in kubeconfig. Only required if out-of-cluster.
--master --kubeconfig (Deprecated: switch to --kubeconfig) The address of the Kubernetes API server. Overrides any value in kubeconfig. Only required if out-of-cluster.
--skip-headers If true, avoid header prefixes in the log messages
--skip-log-headers If true, avoid headers when opening log files
--stderrthreshold severity logs at or above this threshold go to stderr (default 2)
Expand Down
2 changes: 1 addition & 1 deletion cmd/clusterctl/testdata/delete-no-args-invalid-flag.golden
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Global Flags:
--log-file-max-size uint Defines the maximum size a log file can grow to. Unit is megabytes. If the value is 0, the maximum file size is unlimited. (default 1800)
--log-flush-frequency duration Maximum number of seconds between log flushes (default 5s)
--logtostderr log to standard error instead of files (default true)
--master string The address of the Kubernetes API server. Overrides any value in kubeconfig. Only required if out-of-cluster.
--master --kubeconfig (Deprecated: switch to --kubeconfig) The address of the Kubernetes API server. Overrides any value in kubeconfig. Only required if out-of-cluster.
--skip-headers If true, avoid header prefixes in the log messages
--skip-log-headers If true, avoid headers when opening log files
--stderrthreshold severity logs at or above this threshold go to stderr (default 2)
Expand Down
2 changes: 1 addition & 1 deletion cmd/clusterctl/testdata/delete-no-args.golden
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Global Flags:
--log-file-max-size uint Defines the maximum size a log file can grow to. Unit is megabytes. If the value is 0, the maximum file size is unlimited. (default 1800)
--log-flush-frequency duration Maximum number of seconds between log flushes (default 5s)
--logtostderr log to standard error instead of files (default true)
--master string The address of the Kubernetes API server. Overrides any value in kubeconfig. Only required if out-of-cluster.
--master --kubeconfig (Deprecated: switch to --kubeconfig) The address of the Kubernetes API server. Overrides any value in kubeconfig. Only required if out-of-cluster.
--skip-headers If true, avoid header prefixes in the log messages
--skip-log-headers If true, avoid headers when opening log files
--stderrthreshold severity logs at or above this threshold go to stderr (default 2)
Expand Down
2 changes: 1 addition & 1 deletion cmd/clusterctl/testdata/no-args-invalid-flag.golden
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Flags:
--log-file-max-size uint Defines the maximum size a log file can grow to. Unit is megabytes. If the value is 0, the maximum file size is unlimited. (default 1800)
--log-flush-frequency duration Maximum number of seconds between log flushes (default 5s)
--logtostderr log to standard error instead of files (default true)
--master string The address of the Kubernetes API server. Overrides any value in kubeconfig. Only required if out-of-cluster.
--master --kubeconfig (Deprecated: switch to --kubeconfig) The address of the Kubernetes API server. Overrides any value in kubeconfig. Only required if out-of-cluster.
--skip-headers If true, avoid header prefixes in the log messages
--skip-log-headers If true, avoid headers when opening log files
--stderrthreshold severity logs at or above this threshold go to stderr (default 2)
Expand Down
2 changes: 1 addition & 1 deletion cmd/clusterctl/testdata/no-args.golden
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Flags:
--log-file-max-size uint Defines the maximum size a log file can grow to. Unit is megabytes. If the value is 0, the maximum file size is unlimited. (default 1800)
--log-flush-frequency duration Maximum number of seconds between log flushes (default 5s)
--logtostderr log to standard error instead of files (default true)
--master string The address of the Kubernetes API server. Overrides any value in kubeconfig. Only required if out-of-cluster.
--master --kubeconfig (Deprecated: switch to --kubeconfig) The address of the Kubernetes API server. Overrides any value in kubeconfig. Only required if out-of-cluster.
--skip-headers If true, avoid header prefixes in the log messages
--skip-log-headers If true, avoid headers when opening log files
--stderrthreshold severity logs at or above this threshold go to stderr (default 2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Global Flags:
--log-file-max-size uint Defines the maximum size a log file can grow to. Unit is megabytes. If the value is 0, the maximum file size is unlimited. (default 1800)
--log-flush-frequency duration Maximum number of seconds between log flushes (default 5s)
--logtostderr log to standard error instead of files (default true)
--master string The address of the Kubernetes API server. Overrides any value in kubeconfig. Only required if out-of-cluster.
--master --kubeconfig (Deprecated: switch to --kubeconfig) The address of the Kubernetes API server. Overrides any value in kubeconfig. Only required if out-of-cluster.
--skip-headers If true, avoid header prefixes in the log messages
--skip-log-headers If true, avoid headers when opening log files
--stderrthreshold severity logs at or above this threshold go to stderr (default 2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Global Flags:
--log-file-max-size uint Defines the maximum size a log file can grow to. Unit is megabytes. If the value is 0, the maximum file size is unlimited. (default 1800)
--log-flush-frequency duration Maximum number of seconds between log flushes (default 5s)
--logtostderr log to standard error instead of files (default true)
--master string The address of the Kubernetes API server. Overrides any value in kubeconfig. Only required if out-of-cluster.
--master --kubeconfig (Deprecated: switch to --kubeconfig) The address of the Kubernetes API server. Overrides any value in kubeconfig. Only required if out-of-cluster.
--skip-headers If true, avoid header prefixes in the log messages
--skip-log-headers If true, avoid headers when opening log files
--stderrthreshold severity logs at or above this threshold go to stderr (default 2)
Expand Down
2 changes: 1 addition & 1 deletion cmd/clusterctl/testdata/validate-no-args.golden
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Global Flags:
--log-file-max-size uint Defines the maximum size a log file can grow to. Unit is megabytes. If the value is 0, the maximum file size is unlimited. (default 1800)
--log-flush-frequency duration Maximum number of seconds between log flushes (default 5s)
--logtostderr log to standard error instead of files (default true)
--master string The address of the Kubernetes API server. Overrides any value in kubeconfig. Only required if out-of-cluster.
--master --kubeconfig (Deprecated: switch to --kubeconfig) The address of the Kubernetes API server. Overrides any value in kubeconfig. Only required if out-of-cluster.
--skip-headers If true, avoid header prefixes in the log messages
--skip-log-headers If true, avoid headers when opening log files
--stderrthreshold severity logs at or above this threshold go to stderr (default 2)
Expand Down
5 changes: 3 additions & 2 deletions cmd/clusterctl/validation/validate_cluster_api_objects.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func ValidateClusterAPIObjects(ctx context.Context, w io.Writer, c client.Client
}

machines := &clusterv1alpha1.MachineList{}
if err := c.List(ctx, client.InNamespace(namespace), machines); err != nil {
if err := c.List(ctx, machines, client.InNamespace(namespace)); err != nil {
return errors.Wrapf(err, "failed to get the machines from the apiserver in namespace %q", namespace)
}

Expand All @@ -58,7 +58,7 @@ func getClusterObject(ctx context.Context, c client.Reader, clusterName string,
}

clusters := &clusterv1alpha1.ClusterList{}
if err := c.List(ctx, &client.ListOptions{Namespace: namespace}, clusters); err != nil {
if err := c.List(ctx, clusters, client.InNamespace(namespace)); err != nil {
return nil, errors.Wrapf(err, "failed to get the clusters from the apiserver in namespace %q", namespace)
}

Expand All @@ -67,6 +67,7 @@ func getClusterObject(ctx context.Context, c client.Reader, clusterName string,
} else if numOfClusters > 1 {
return nil, errors.Errorf("fail: There is more than one cluster in namespace %q. Please specify --cluster-name", namespace)
}

return &clusters.Items[0], nil
}

Expand Down
Loading

0 comments on commit 0583f26

Please sign in to comment.