diff --git a/.gitignore b/.gitignore index 459ff0ba..d61628d2 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,10 @@ go.work.sum # Project Specific *.csv + +# Binaries for programs and plugins +*.exe +*.exe~ +*.dll +*.so +/bin \ No newline at end of file diff --git a/Makefile b/Makefile index 7cff763e..b8c2bec4 100644 --- a/Makefile +++ b/Makefile @@ -22,6 +22,17 @@ KARPENTER_CORE_DIR = $(shell go list -m -f '{{ .Dir }}' sigs.k8s.io/karpenter) # TEST_SUITE enables you to select a specific test suite directory to run "make e2etests" against TEST_SUITE ?= "..." +## Location to install dependencies to +LOCALBIN ?= $(shell pwd)/bin +$(LOCALBIN): + mkdir -p $(LOCALBIN) + +## Tool Binaries +CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen + +## Tool Versions +CONTROLLER_TOOLS_VERSION ?= v0.16.4 + help: ## Display help @awk 'BEGIN {FS = ":.*##"; printf "Usage:\n make \033[36m\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) @@ -39,7 +50,14 @@ run: ## Run Karpenter controller binary against your local cluster FEATURE_GATES="SpotToSpotConsolidation=true" \ go run ./cmd/controller/main.go -update: tidy download ## Update go files header, CRD and generated code +controller-gen: $(CONTROLLER_GEN) ## Download controller-gen locally if necessary. +$(CONTROLLER_GEN): $(LOCALBIN) + test -s $(LOCALBIN)/controller-gen || GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-tools/cmd/controller-gen@$(CONTROLLER_TOOLS_VERSION) + +generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations. + $(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..." + +update: tidy download generate ## Update go files header, CRD and generated code hack/boilerplate.sh hack/update-generated.sh @@ -80,7 +98,7 @@ download: ## Run "go mod download" codegen: ## Auto generate files based on AlibabaCloud APIs ./hack/codegen.sh -.PHONY: help presubmit run ut-test coverage update verify image apply delete toolchain tidy download +.PHONY: help presubmit run ut-test coverage update verify image apply delete toolchain tidy download controller-gen generate define newline diff --git a/hack/update-generated.sh b/hack/update-generated.sh index bbe40a10..866f09f3 100755 --- a/hack/update-generated.sh +++ b/hack/update-generated.sh @@ -2,8 +2,11 @@ set -eu -o pipefail +LOCALBIN=$(pwd)/bin +CONTROLLER_GEN=${LOCALBIN}/controller-gen + # Update CRD -controller-gen crd paths=./pkg/apis/v1alpha1/... output:crd:dir=./charts/karpenter/crds +${CONTROLLER_GEN} crd paths=./pkg/apis/v1alpha1/... output:crd:dir=./charts/karpenter/crds # Update generated code export REPO_ROOT=$(pwd) @@ -22,8 +25,3 @@ mkdir -p "${GO_PKG_DIR}" if [[ ! -e "${GO_PKG_DIR}" || "$(readlink "${GO_PKG_DIR}")" != "${REPO_ROOT}" ]]; then ln -snf "${REPO_ROOT}" "${GO_PKG_DIR}" fi - -deepcopy-gen \ - --go-header-file hack/boilerplate.go.txt \ - --output-file-base zz_generated.deepcopy \ - --input-dirs github.com/cloudpilot-ai/karpenter-provider-alibabacloud/pkg/apis/v1alpha1 diff --git a/pkg/apis/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/v1alpha1/zz_generated.deepcopy.go index fd94c1e7..56a1f959 100644 --- a/pkg/apis/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/v1alpha1/zz_generated.deepcopy.go @@ -1,5 +1,4 @@ //go:build !ignore_autogenerated -// +build !ignore_autogenerated /* Copyright 2024 The CloudPilot AI Authors. @@ -17,14 +16,14 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by deepcopy-gen. DO NOT EDIT. +// Code generated by controller-gen. DO NOT EDIT. package v1alpha1 import ( - status "github.com/awslabs/operatorpkg/status" - v1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "github.com/awslabs/operatorpkg/status" + corev1 "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" ) @@ -35,7 +34,6 @@ func (in *ECSNodeClass) DeepCopyInto(out *ECSNodeClass) { in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) in.Spec.DeepCopyInto(&out.Spec) in.Status.DeepCopyInto(&out.Status) - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ECSNodeClass. @@ -68,7 +66,6 @@ func (in *ECSNodeClassList) DeepCopyInto(out *ECSNodeClassList) { (*in)[i].DeepCopyInto(&(*out)[i]) } } - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ECSNodeClassList. @@ -128,7 +125,6 @@ func (in *ECSNodeClassSpec) DeepCopyInto(out *ECSNodeClassSpec) { (*out)[key] = val } } - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ECSNodeClassSpec. @@ -168,7 +164,6 @@ func (in *ECSNodeClassStatus) DeepCopyInto(out *ECSNodeClassStatus) { (*in)[i].DeepCopyInto(&(*out)[i]) } } - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ECSNodeClassStatus. @@ -186,12 +181,11 @@ func (in *Image) DeepCopyInto(out *Image) { *out = *in if in.Requirements != nil { in, out := &in.Requirements, &out.Requirements - *out = make([]v1.NodeSelectorRequirement, len(*in)) + *out = make([]corev1.NodeSelectorRequirement, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) } } - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Image. @@ -207,7 +201,6 @@ func (in *Image) DeepCopy() *Image { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ImageSelectorTerm) DeepCopyInto(out *ImageSelectorTerm) { *out = *in - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ImageSelectorTerm. @@ -268,7 +261,7 @@ func (in *KubeletConfiguration) DeepCopyInto(out *KubeletConfiguration) { } if in.EvictionSoftGracePeriod != nil { in, out := &in.EvictionSoftGracePeriod, &out.EvictionSoftGracePeriod - *out = make(map[string]metav1.Duration, len(*in)) + *out = make(map[string]v1.Duration, len(*in)) for key, val := range *in { (*out)[key] = val } @@ -293,7 +286,6 @@ func (in *KubeletConfiguration) DeepCopyInto(out *KubeletConfiguration) { *out = new(bool) **out = **in } - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KubeletConfiguration. @@ -309,7 +301,6 @@ func (in *KubeletConfiguration) DeepCopy() *KubeletConfiguration { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *SecurityGroup) DeepCopyInto(out *SecurityGroup) { *out = *in - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SecurityGroup. @@ -332,7 +323,6 @@ func (in *SecurityGroupSelectorTerm) DeepCopyInto(out *SecurityGroupSelectorTerm (*out)[key] = val } } - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SecurityGroupSelectorTerm. @@ -363,7 +353,6 @@ func (in *SystemDisk) DeepCopyInto(out *SystemDisk) { *out = new(string) **out = **in } - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SystemDisk. @@ -379,7 +368,6 @@ func (in *SystemDisk) DeepCopy() *SystemDisk { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *VSwitch) DeepCopyInto(out *VSwitch) { *out = *in - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VSwitch. @@ -402,7 +390,6 @@ func (in *VSwitchSelectorTerm) DeepCopyInto(out *VSwitchSelectorTerm) { (*out)[key] = val } } - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VSwitchSelectorTerm.