Skip to content

Commit

Permalink
User/zawachte/alphav4 (#155)
Browse files Browse the repository at this point in the history
* con

* alphav4
  • Loading branch information
zawachte authored Sep 28, 2021
1 parent 205d8ce commit 89d6125
Show file tree
Hide file tree
Showing 91 changed files with 6,136 additions and 1,422 deletions.
103 changes: 79 additions & 24 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,24 +37,61 @@ export GOPRIVATE = github.com/microsoft
# Directories.
ROOT_DIR:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
TOOLS_DIR := hack/tools
TOOLS_BIN_DIR := $(TOOLS_DIR)/bin
TOOLS_BIN_DIR := $(abspath $(TOOLS_DIR)/bin)
BIN_DIR := bin

# set --output-base used for conversion-gen which needs to be different for in GOPATH and outside GOPATH dev
OUTPUT_BASE := --output-base=$(ROOT_DIR)


# Binaries.
CLUSTERCTL := $(BIN_DIR)/clusterctl
CONTROLLER_GEN := $(TOOLS_BIN_DIR)/controller-gen
ENVSUBST := $(TOOLS_BIN_DIR)/envsubst
GOLANGCI_LINT := $(TOOLS_BIN_DIR)/golangci-lint
MOCKGEN := $(TOOLS_BIN_DIR)/mockgen
CONVERSION_GEN := $(TOOLS_BIN_DIR)/conversion-gen
KUBECTL=$(TOOLS_BIN_DIR)/kubectl
KUBE_APISERVER=$(TOOLS_BIN_DIR)/kube-apiserver
ETCD=$(TOOLS_BIN_DIR)/etcd
GO_INSTALL = ./scripts/go_install.sh

# Binaries.
CONTROLLER_GEN_VER := v0.6.1
CONTROLLER_GEN_BIN := controller-gen
CONTROLLER_GEN := $(TOOLS_BIN_DIR)/$(CONTROLLER_GEN_BIN)-$(CONTROLLER_GEN_VER)

CONVERSION_GEN_VER := v0.20.2
CONVERSION_GEN_BIN := conversion-gen
CONVERSION_GEN := $(TOOLS_BIN_DIR)/$(CONVERSION_GEN_BIN)-$(CONVERSION_GEN_VER)


GOLANGCI_LINT_VER := v1.41.1
GOLANGCI_LINT_BIN := golangci-lint
GOLANGCI_LINT := $(TOOLS_BIN_DIR)/$(GOLANGCI_LINT_BIN)-$(GOLANGCI_LINT_VER)

KUSTOMIZE_VER := v4.1.3
KUSTOMIZE_BIN := kustomize
KUSTOMIZE := $(TOOLS_BIN_DIR)/$(KUSTOMIZE_BIN)-$(KUSTOMIZE_VER)

MOCKGEN_VER := v1.6.0
MOCKGEN_BIN := mockgen
MOCKGEN := $(TOOLS_BIN_DIR)/$(MOCKGEN_BIN)-$(MOCKGEN_VER)

RELEASE_NOTES_VER := v0.9.0
RELEASE_NOTES_BIN := release-notes
RELEASE_NOTES := $(TOOLS_BIN_DIR)/$(RELEASE_NOTES_BIN)-$(RELEASE_NOTES_VER)

GO_APIDIFF_VER := v0.1.0
GO_APIDIFF_BIN := go-apidiff
GO_APIDIFF := $(TOOLS_BIN_DIR)/$(GO_APIDIFF_BIN)

GINKGO_VER := v1.16.4
GINKGO_BIN := ginkgo
GINKGO := $(TOOLS_BIN_DIR)/$(GINKGO_BIN)-$(GINKGO_VER)

KUBECTL_VER := v1.21.4
KUBECTL_BIN := kubectl
KUBECTL := $(TOOLS_BIN_DIR)/$(KUBECTL_BIN)-$(KUBECTL_VER)

# Version
MAJOR_VER ?= 0
MINOR_VER ?= 3
PATCH_VER ?= 10-alpha
MINOR_VER ?= 4
PATCH_VER ?= 0-alpha

# Define Docker related variables. Releases should modify and double check these vars.
REGISTRY ?= mocimages.azurecr.io
Expand Down Expand Up @@ -129,20 +166,37 @@ manager: ## Build manager binary.
$(CLUSTERCTL): go.mod ## Build clusterctl binary.
go build -o $(BIN_DIR)/clusterctl sigs.k8s.io/cluster-api/cmd/clusterctl

$(CONTROLLER_GEN): $(TOOLS_DIR)/go.mod # Build controller-gen from tools folder.
cd $(TOOLS_DIR); go build -tags=tools -o $(BIN_DIR)/controller-gen sigs.k8s.io/controller-tools/cmd/controller-gen
$(CONTROLLER_GEN): ## Build controller-gen from tools folder.
GOBIN=$(TOOLS_BIN_DIR) $(GO_INSTALL) sigs.k8s.io/controller-tools/cmd/controller-gen $(CONTROLLER_GEN_BIN) $(CONTROLLER_GEN_VER)

$(CONVERSION_GEN): ## Build conversion-gen.
GOBIN=$(TOOLS_BIN_DIR) $(GO_INSTALL) k8s.io/code-generator/cmd/conversion-gen $(CONVERSION_GEN_BIN) $(CONVERSION_GEN_VER)

$(ENVSUBST): ## Build envsubst from tools folder.
rm -f $(TOOLS_BIN_DIR)/$(ENVSUBST_BIN)*
mkdir -p $(TOOLS_DIR) && cd $(TOOLS_DIR) && go build -tags=tools -o $(ENVSUBST) github.com/drone/envsubst/v2/cmd/envsubst
ln -sf $(ENVSUBST) $(TOOLS_BIN_DIR)/$(ENVSUBST_BIN)

$(ENVSUBST): $(TOOLS_DIR)/go.mod # Build envsubst from tools folder.
cd $(TOOLS_DIR); go build -tags=tools -o $(BIN_DIR)/envsubst github.com/a8m/envsubst/cmd/envsubst
.PHONY: $(ENVSUBST_BIN)
$(ENVSUBST_BIN): $(ENVSUBST) ## Build envsubst from tools folder.

$(GOLANGCI_LINT): $(TOOLS_DIR)/go.mod # Build golangci-lint from tools folder.
cd $(TOOLS_DIR); go build -tags=tools -o $(BIN_DIR)/golangci-lint github.com/golangci/golangci-lint/cmd/golangci-lint
$(GOLANGCI_LINT): ## Build golangci-lint from tools folder.
GOBIN=$(TOOLS_BIN_DIR) $(GO_INSTALL) github.com/golangci/golangci-lint/cmd/golangci-lint $(GOLANGCI_LINT_BIN) $(GOLANGCI_LINT_VER)

$(MOCKGEN): $(TOOLS_DIR)/go.mod # Build mockgen from tools folder.
cd $(TOOLS_DIR); go build -tags=tools -o $(BIN_DIR)/mockgen github.com/golang/mock/mockgen
$(KUSTOMIZE): ## Build kustomize from tools folder.
GOBIN=$(TOOLS_BIN_DIR) $(GO_INSTALL) sigs.k8s.io/kustomize/kustomize/v4 $(KUSTOMIZE_BIN) $(KUSTOMIZE_VER)

$(CONVERSION_GEN): $(TOOLS_DIR)/go.mod
cd $(TOOLS_DIR); go build -tags=tools -o $(BIN_DIR)/conversion-gen k8s.io/code-generator/cmd/conversion-gen
$(MOCKGEN): ## Build mockgen from tools folder.
GOBIN=$(TOOLS_BIN_DIR) $(GO_INSTALL) github.com/golang/mock/mockgen $(MOCKGEN_BIN) $(MOCKGEN_VER)

$(RELEASE_NOTES): ## Build release notes.
GOBIN=$(TOOLS_BIN_DIR) $(GO_INSTALL) k8s.io/release/cmd/release-notes $(RELEASE_NOTES_BIN) $(RELEASE_NOTES_VER)

$(GO_APIDIFF): ## Build go-apidiff.
GOBIN=$(TOOLS_BIN_DIR) $(GO_INSTALL) github.com/joelanford/go-apidiff $(GO_APIDIFF_BIN) $(GO_APIDIFF_VER)

$(GINKGO): ## Build ginkgo.
GOBIN=$(TOOLS_BIN_DIR) $(GO_INSTALL) github.com/onsi/ginkgo/ginkgo $(GINKGO_BIN) $(GINKGO_VER)

$(RELEASE_NOTES) : $(TOOLS_DIR)/go.mod
cd $(TOOLS_DIR) && go build -tags tools -o $(BIN_DIR)/release-notes sigs.k8s.io/cluster-api/hack/tools/release
Expand Down Expand Up @@ -182,14 +236,15 @@ generate-go: $(CONTROLLER_GEN) $(MOCKGEN) $(CONVERSION_GEN) ## Runs Go related g

$(CONVERSION_GEN) \
--input-dirs=./api/v1alpha3 \
--output-file-base=zz_generated.conversion \
--output-file-base=zz_generated.conversion $(OUTPUT_BASE) \
--go-header-file=./hack/boilerplate/boilerplate.generatego.txt

.PHONY: generate-manifests
generate-manifests: $(CONTROLLER_GEN) ## Generate manifests e.g. CRD, RBAC etc.
$(CONTROLLER_GEN) \
paths=./api/... \
crd:crdVersions=v1 \
rbac:roleName=manager-role \
output:crd:dir=$(CRD_ROOT) \
output:webhook:dir=$(WEBHOOK_ROOT) \
webhook
Expand Down Expand Up @@ -256,12 +311,12 @@ docker-push-manifest: ## Push the fat manifest docker image.
.PHONY: set-manifest-image
set-manifest-image:
$(info Updating kustomize image patch file for manager resource)
sed -i'' -e 's@image: .*@image: '"${MANIFEST_IMG}:$(MANIFEST_TAG)"'@' ./config/manager/manager_image_patch.yaml
sed -i'' -e 's@image: .*@image: '"${MANIFEST_IMG}:$(MANIFEST_TAG)"'@' ./config/default/manager_image_patch.yaml

.PHONY: set-manifest-pull-policy
set-manifest-pull-policy:
$(info Updating kustomize pull policy file for manager resource)
sed -i'' -e 's@imagePullPolicy: .*@imagePullPolicy: '"$(PULL_POLICY)"'@' ./config/manager/manager_pull_policy.yaml
sed -i'' -e 's@imagePullPolicy: .*@imagePullPolicy: '"$(PULL_POLICY)"'@' ./config/default/manager_pull_policy.yaml

## --------------------------------------
## Release
Expand All @@ -286,7 +341,7 @@ release: clean-release ## Builds and push container images using the latest git

.PHONY: release-manifests
release-manifests: $(RELEASE_DIR) ## Builds the manifests to publish with a release
kustomize build config > $(RELEASE_DIR)/infrastructure-components.yaml
kustomize build config/default > $(RELEASE_DIR)/infrastructure-components.yaml

.PHONY: release-binary
release-binary: $(RELEASE_DIR)
Expand Down
27 changes: 21 additions & 6 deletions PROJECT
Original file line number Diff line number Diff line change
@@ -1,19 +1,34 @@
version: "2"
domain: cluster.x-k8s.io
repo: github.com/microsoft/cluster-api-provider-azurestackhci
resources:
- group: infrastructure
version: v1alpha3
kind: AzureStackHCICluster
- group: infrastructure
version: v1alpha3
kind: AzureStackHCIMachine
- group: infrastructure
kind: AzureStackHCIMachine
version: v1alpha3
kind: AzureStackHCIMachineTemplate
- group: infrastructure
kind: AzureStackHCIMachineTemplate
version: v1alpha3
- group: infrastructure
kind: AzureStackHCIVirtualMachine
version: v1alpha3
- group: infrastructure
kind: AzureStackHCILoadBalancer
version: v1alpha3
kind: AzureStackHCILoadBalancer
- group: infrastructure
kind: AzureStackHCICluster
version: v1alpha4
- group: infrastructure
kind: AzureStackHCIMachine
version: v1alpha4
- group: infrastructure
kind: AzureStackHCIMachineTemplate
version: v1alpha4
- group: infrastructure
kind: AzureStackHCIVirtualMachine
version: v1alpha4
- group: infrastructure
kind: AzureStackHCILoadBalancer
version: v1alpha4
version: "2"
27 changes: 23 additions & 4 deletions api/v1alpha3/azurestackhcicluster_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,27 @@ limitations under the License.

package v1alpha3

// Hub marks AzureStackHCICluster as a conversion hub.
func (*AzureStackHCICluster) Hub() {}
import (
infrav1alpha4 "github.com/microsoft/cluster-api-provider-azurestackhci/api/v1alpha4"
"sigs.k8s.io/controller-runtime/pkg/conversion"
)

// Hub marks AzureStackHCIClusterList as a conversion hub.
func (*AzureStackHCIClusterList) Hub() {}
func (src *AzureStackHCICluster) ConvertTo(dstRaw conversion.Hub) error {
dst := dstRaw.(*infrav1alpha4.AzureStackHCICluster)
return Convert_v1alpha3_AzureStackHCICluster_To_v1alpha4_AzureStackHCICluster(src, dst, nil)
}

func (dst *AzureStackHCICluster) ConvertFrom(srcRaw conversion.Hub) error {
src := srcRaw.(*infrav1alpha4.AzureStackHCICluster)
return Convert_v1alpha4_AzureStackHCICluster_To_v1alpha3_AzureStackHCICluster(src, dst, nil)
}

func (src *AzureStackHCIClusterList) ConvertTo(dstRaw conversion.Hub) error {
dst := dstRaw.(*infrav1alpha4.AzureStackHCIClusterList)
return Convert_v1alpha3_AzureStackHCIClusterList_To_v1alpha4_AzureStackHCIClusterList(src, dst, nil)
}

func (dst *AzureStackHCIClusterList) ConvertFrom(srcRaw conversion.Hub) error {
src := srcRaw.(*infrav1alpha4.AzureStackHCIClusterList)
return Convert_v1alpha4_AzureStackHCIClusterList_To_v1alpha3_AzureStackHCIClusterList(src, dst, nil)
}
27 changes: 23 additions & 4 deletions api/v1alpha3/azurestackhciloadbalancer_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,27 @@ limitations under the License.

package v1alpha3

// Hub marks AzureStackHCILoadBalancer as a conversion hub.
func (*AzureStackHCILoadBalancer) Hub() {}
import (
infrav1alpha4 "github.com/microsoft/cluster-api-provider-azurestackhci/api/v1alpha4"
"sigs.k8s.io/controller-runtime/pkg/conversion"
)

// Hub marks AzureStackHCILoadBalancerList as a conversion hub.
func (*AzureStackHCILoadBalancerList) Hub() {}
func (src *AzureStackHCILoadBalancer) ConvertTo(dstRaw conversion.Hub) error {
dst := dstRaw.(*infrav1alpha4.AzureStackHCILoadBalancer)
return Convert_v1alpha3_AzureStackHCILoadBalancer_To_v1alpha4_AzureStackHCILoadBalancer(src, dst, nil)
}

func (dst *AzureStackHCILoadBalancer) ConvertFrom(srcRaw conversion.Hub) error {
src := srcRaw.(*infrav1alpha4.AzureStackHCILoadBalancer)
return Convert_v1alpha4_AzureStackHCILoadBalancer_To_v1alpha3_AzureStackHCILoadBalancer(src, dst, nil)
}

func (src *AzureStackHCILoadBalancerList) ConvertTo(dstRaw conversion.Hub) error {
dst := dstRaw.(*infrav1alpha4.AzureStackHCILoadBalancerList)
return Convert_v1alpha3_AzureStackHCILoadBalancerList_To_v1alpha4_AzureStackHCILoadBalancerList(src, dst, nil)
}

func (dst *AzureStackHCILoadBalancerList) ConvertFrom(srcRaw conversion.Hub) error {
src := srcRaw.(*infrav1alpha4.AzureStackHCILoadBalancerList)
return Convert_v1alpha4_AzureStackHCILoadBalancerList_To_v1alpha3_AzureStackHCILoadBalancerList(src, dst, nil)
}
27 changes: 23 additions & 4 deletions api/v1alpha3/azurestackhcimachine_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,27 @@ limitations under the License.

package v1alpha3

// Hub marks AzureStackHCIMachine as a conversion hub.
func (*AzureStackHCIMachine) Hub() {}
import (
infrav1alpha4 "github.com/microsoft/cluster-api-provider-azurestackhci/api/v1alpha4"
"sigs.k8s.io/controller-runtime/pkg/conversion"
)

// Hub marks AzureStackHCIMachineList as a conversion hub.
func (*AzureStackHCIMachineList) Hub() {}
func (src *AzureStackHCIMachine) ConvertTo(dstRaw conversion.Hub) error {
dst := dstRaw.(*infrav1alpha4.AzureStackHCIMachine)
return Convert_v1alpha3_AzureStackHCIMachine_To_v1alpha4_AzureStackHCIMachine(src, dst, nil)
}

func (dst *AzureStackHCIMachine) ConvertFrom(srcRaw conversion.Hub) error {
src := srcRaw.(*infrav1alpha4.AzureStackHCIMachine)
return Convert_v1alpha4_AzureStackHCIMachine_To_v1alpha3_AzureStackHCIMachine(src, dst, nil)
}

func (src *AzureStackHCIMachineList) ConvertTo(dstRaw conversion.Hub) error {
dst := dstRaw.(*infrav1alpha4.AzureStackHCIMachineList)
return Convert_v1alpha3_AzureStackHCIMachineList_To_v1alpha4_AzureStackHCIMachineList(src, dst, nil)
}

func (dst *AzureStackHCIMachineList) ConvertFrom(srcRaw conversion.Hub) error {
src := srcRaw.(*infrav1alpha4.AzureStackHCIMachineList)
return Convert_v1alpha4_AzureStackHCIMachineList_To_v1alpha3_AzureStackHCIMachineList(src, dst, nil)
}
60 changes: 0 additions & 60 deletions api/v1alpha3/azurestackhcimachine_webhook.go

This file was deleted.

27 changes: 23 additions & 4 deletions api/v1alpha3/azurestackhcimachinetemplate_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,27 @@ limitations under the License.

package v1alpha3

// Hub marks AzureStackHCIMachineTemplate as a conversion hub.
func (*AzureStackHCIMachineTemplate) Hub() {}
import (
infrav1alpha4 "github.com/microsoft/cluster-api-provider-azurestackhci/api/v1alpha4"
"sigs.k8s.io/controller-runtime/pkg/conversion"
)

// Hub marks AzureStackHCIMachineTemplateList as a conversion hub.
func (*AzureStackHCIMachineTemplateList) Hub() {}
func (src *AzureStackHCIMachineTemplate) ConvertTo(dstRaw conversion.Hub) error {
dst := dstRaw.(*infrav1alpha4.AzureStackHCIMachineTemplate)
return Convert_v1alpha3_AzureStackHCIMachineTemplate_To_v1alpha4_AzureStackHCIMachineTemplate(src, dst, nil)
}

func (dst *AzureStackHCIMachineTemplate) ConvertFrom(srcRaw conversion.Hub) error {
src := srcRaw.(*infrav1alpha4.AzureStackHCIMachineTemplate)
return Convert_v1alpha4_AzureStackHCIMachineTemplate_To_v1alpha3_AzureStackHCIMachineTemplate(src, dst, nil)
}

func (src *AzureStackHCIMachineTemplateList) ConvertTo(dstRaw conversion.Hub) error {
dst := dstRaw.(*infrav1alpha4.AzureStackHCIMachineTemplateList)
return Convert_v1alpha3_AzureStackHCIMachineTemplateList_To_v1alpha4_AzureStackHCIMachineTemplateList(src, dst, nil)
}

func (dst *AzureStackHCIMachineTemplateList) ConvertFrom(srcRaw conversion.Hub) error {
src := srcRaw.(*infrav1alpha4.AzureStackHCIMachineTemplateList)
return Convert_v1alpha4_AzureStackHCIMachineTemplateList_To_v1alpha3_AzureStackHCIMachineTemplateList(src, dst, nil)
}
Loading

0 comments on commit 89d6125

Please sign in to comment.