diff --git a/Makefile b/Makefile index 6db1e4c4b..e177655b8 100644 --- a/Makefile +++ b/Makefile @@ -5,6 +5,12 @@ GIT_MODULE ?= opendev.org/airship/airshipctl/pkg/version GO_FLAGS := -ldflags '-extldflags "-static"' -tags=netgo -trimpath GO_FLAGS += -ldflags "-X ${GIT_MODULE}.gitVersion=${GIT_VERSION}" +# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set) +ifeq (,$(shell go env GOBIN)) +GOBIN = $(shell go env GOPATH)/bin +else +GOBIN = $(shell go env GOBIN) +endif BINDIR := bin EXECUTABLE_CLI := airshipctl @@ -241,3 +247,24 @@ check-copyright: .PHONY: validate-docs validate-docs: @./tools/validate_docs + +# Generate code +generate: controller-gen + $(CONTROLLER_GEN) object:headerFile="tools/license_go.txt" paths="./..." + +# find or download controller-gen +# download controller-gen if necessary +controller-gen: +ifeq (, $(shell which controller-gen)) + @{ \ + set -e ;\ + CONTROLLER_GEN_TMP_DIR=$$(mktemp -d) ;\ + cd $$CONTROLLER_GEN_TMP_DIR ;\ + go mod init tmp ;\ + go get sigs.k8s.io/controller-tools/cmd/controller-gen@v0.2.5 ;\ + rm -rf $$CONTROLLER_GEN_TMP_DIR ;\ + } +CONTROLLER_GEN=$(GOBIN)/controller-gen +else +CONTROLLER_GEN=$(shell which controller-gen) +endif diff --git a/pkg/api/v1alpha1/bootconfiguration_types.go b/pkg/api/v1alpha1/bootconfiguration_types.go index 77b0e7fd9..157f091f4 100644 --- a/pkg/api/v1alpha1/bootconfiguration_types.go +++ b/pkg/api/v1alpha1/bootconfiguration_types.go @@ -18,6 +18,18 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) +// +kubebuilder:object:root=true + +// BootConfiguration structure is inherited from apimachinery TypeMeta and ObjectMeta and is a top level +// configuration structure for the bootstrap container +type BootConfiguration struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + BootstrapContainer BootstrapContainer `json:"bootstrapContainer"` + EphemeralCluster EphemeralCluster `json:"ephemeralCluster"` +} + // EphemeralCluster structure contains the data for the ephemeral cluster type EphemeralCluster struct { BootstrapCommand string `json:"bootstrapCommand,omitempty"` @@ -32,16 +44,6 @@ type BootstrapContainer struct { Kubeconfig string `json:"kubeconfig,omitempty"` } -// BootConfiguration structure is inherited from apimachinery TypeMeta and ObjectMeta and is a top level -// configuration structure for the bootstrap container -type BootConfiguration struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata,omitempty"` - - BootstrapContainer BootstrapContainer `json:"bootstrapContainer"` - EphemeralCluster EphemeralCluster `json:"ephemeralCluster"` -} - // DefaultBootConfiguration can be used to safely unmarshal BootConfiguration object without nil pointers func DefaultBootConfiguration() *BootConfiguration { return &BootConfiguration{} diff --git a/pkg/api/v1alpha1/zz_generated.deepcopy.go b/pkg/api/v1alpha1/zz_generated.deepcopy.go index 62a48c1d7..faf4ea2c9 100644 --- a/pkg/api/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/api/v1alpha1/zz_generated.deepcopy.go @@ -1,5 +1,19 @@ // +build !ignore_autogenerated +/* + 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 + + https://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. +*/ + // Code generated by controller-gen. DO NOT EDIT. package v1alpha1 @@ -217,6 +231,13 @@ func (in *Clusterctl) DeepCopyInto(out *Clusterctl) { (*out)[key] = val } } + if in.ImageMetas != nil { + in, out := &in.ImageMetas, &out.ImageMetas + *out = make(map[string]ImageMeta, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Clusterctl. @@ -302,6 +323,21 @@ func (in *ImageConfiguration) DeepCopyObject() runtime.Object { return nil } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ImageMeta) DeepCopyInto(out *ImageMeta) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ImageMeta. +func (in *ImageMeta) DeepCopy() *ImageMeta { + if in == nil { + return nil + } + out := new(ImageMeta) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *InitOptions) DeepCopyInto(out *InitOptions) { *out = *in diff --git a/tools/check_copyright b/tools/check_copyright index 04d7b1e3a..ee1039271 100755 --- a/tools/check_copyright +++ b/tools/check_copyright @@ -18,7 +18,7 @@ declare FILES_MISSING_COPYRIGHT=() check_license() { ext=$1 # skipping license for testdata and manifests folders - FILES=$(find -L . -name "*.${ext}" | grep -vE "(testdata|manifests|zz_generated)") + FILES=$(find -L . -name "*.${ext}" | grep -vE "(testdata|manifests)") for each in $FILES do