From a459ded06a8eb3886ee5bad419e92a4a5b6100d6 Mon Sep 17 00:00:00 2001 From: Chris Doherty Date: Fri, 11 Nov 2022 18:20:13 -0500 Subject: [PATCH] Remove WorkflowData API The WorkflowData API relates to multi worker workflows that aren't implemented in the Kube backend. With the move to the Kube backend we're taking the opportunity to reset and implement this sanely when its needed, not before. --- .github/workflows/ci.yaml | 3 +- Makefile | 2 +- config/crd/bases/tinkerbell.org_hardware.yaml | 9 +- .../crd/bases/tinkerbell.org_templates.yaml | 8 +- .../crd/bases/tinkerbell.org_workflows.yaml | 8 +- kube.mk | 44 ++++----- pkg/apis/core/v1alpha1/workflow_data_types.go | 47 ---------- .../core/v1alpha1/zz_generated.deepcopy.go | 89 ------------------- tools.go | 1 - 9 files changed, 31 insertions(+), 180 deletions(-) delete mode 100644 pkg/apis/core/v1alpha1/workflow_data_types.go diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 1665fa9cc..babad23d4 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -67,7 +67,8 @@ jobs: - name: Fetch Nix Packages run: nix-shell --run 'true' - - run: make bin/gofumpt + - name: Install gofumpt for ci-checks.sh + run: make bin/gofumpt - run: PATH=$PWD/bin/:$PATH ./ci-checks.sh crosscompile: diff --git a/Makefile b/Makefile index 2b409e799..9360030d7 100644 --- a/Makefile +++ b/Makefile @@ -15,7 +15,7 @@ test: e2etest-setup ## Run tests source <(setup-envtest use -p env) && go test -coverprofile=coverage.txt ./... verify: lint check-generated ## Verify code style, is lint free, freshness ... - gofumpt -s -d . + $(GOFUMPT) -s -d . generated: pbfiles protomocks generate-manifests ## Generate dynamically created files check-generated: check-pbfiles check-protomocks ## Check if generated files are up to date diff --git a/config/crd/bases/tinkerbell.org_hardware.yaml b/config/crd/bases/tinkerbell.org_hardware.yaml index 3cf890ee9..7fefd5e04 100644 --- a/config/crd/bases/tinkerbell.org_hardware.yaml +++ b/config/crd/bases/tinkerbell.org_hardware.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.8.0 + controller-gen.kubebuilder.io/version: v0.10.0 creationTimestamp: null name: hardware.tinkerbell.org spec: @@ -68,6 +68,7 @@ spec: - kind - name type: object + x-kubernetes-map-type: atomic disks: items: description: Disk represents a disk device for Tinkerbell Hardware. @@ -385,9 +386,3 @@ spec: storage: true subresources: status: {} -status: - acceptedNames: - kind: "" - plural: "" - conditions: [] - storedVersions: [] diff --git a/config/crd/bases/tinkerbell.org_templates.yaml b/config/crd/bases/tinkerbell.org_templates.yaml index 179124f74..1c7814dfc 100644 --- a/config/crd/bases/tinkerbell.org_templates.yaml +++ b/config/crd/bases/tinkerbell.org_templates.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.8.0 + controller-gen.kubebuilder.io/version: v0.10.0 creationTimestamp: null name: templates.tinkerbell.org spec: @@ -60,9 +60,3 @@ spec: storage: true subresources: status: {} -status: - acceptedNames: - kind: "" - plural: "" - conditions: [] - storedVersions: [] diff --git a/config/crd/bases/tinkerbell.org_workflows.yaml b/config/crd/bases/tinkerbell.org_workflows.yaml index 7f09f3c0b..1c662a1c7 100644 --- a/config/crd/bases/tinkerbell.org_workflows.yaml +++ b/config/crd/bases/tinkerbell.org_workflows.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.8.0 + controller-gen.kubebuilder.io/version: v0.10.0 creationTimestamp: null name: workflows.tinkerbell.org spec: @@ -138,9 +138,3 @@ spec: storage: true subresources: status: {} -status: - acceptedNames: - kind: "" - plural: "" - conditions: [] - storedVersions: [] diff --git a/kube.mk b/kube.mk index 8ff8b73c8..b14581988 100644 --- a/kube.mk +++ b/kube.mk @@ -2,48 +2,51 @@ ## Generate ## -------------------------------------- +CONTROLLER_GEN := go run sigs.k8s.io/controller-tools/cmd/controller-gen@v0.10 +GOFUMPT := go run mvdan.cc/gofumpt@v0.1 +KUSTOMIZE := go run sigs.k8s.io/kustomize/kustomize/v4@latestv4.5 + .PHONY: generate generate: generate-go generate-manifests # Generate code, manifests etc. .PHONY: generate-go -generate-go: bin/controller-gen bin/gofumpt # Generate Go code. - controller-gen object:headerFile="hack/boilerplate/boilerplate.generatego.txt" paths="./pkg/apis/..." - gofumpt -w -s ./pkg/apis +generate-go: # Generate Go code. + $(CONTROLLER_GEN) object:headerFile="hack/boilerplate/boilerplate.generatego.txt" paths="./pkg/apis/..." + $(GOFUMPT) -w ./pkg/apis .PHONY: generate-manifests generate-manifests: generate-crds generate-rbacs generate-server-rbacs # Generate manifests e.g. CRD, RBAC etc. .PHONY: generate-crds -generate-crds: bin/controller-gen - controller-gen \ +generate-crds: + $(CONTROLLER_GEN) \ paths=./pkg/apis/... \ crd:crdVersions=v1 \ rbac:roleName=manager-role \ output:crd:dir=./config/crd/bases \ output:webhook:dir=./config/webhook \ webhook - prettier --write ./config/crd/bases .PHONY: generate-rbacs -generate-rbacs: bin/controller-gen - controller-gen \ +generate-rbacs: + $(CONTROLLER_GEN) \ paths=./pkg/controllers/... \ output:rbac:dir=./config/rbac/ \ rbac:roleName=manager-role - prettier --write ./config/rbac .PHONY: generate-server-rbacs -generate-server-rbacs: bin/controller-gen - controller-gen \ +generate-server-rbacs: + $(CONTROLLER_GEN) \ paths=./server/... \ output:rbac:dir=./config/server-rbac \ rbac:roleName=server-role - prettier --write ./config/server-rbac/ -TINK_SERVER_IMAGE ?= quay.io/tinkerbell/tink-server -TINK_CONTROLLER_IMAGE ?= quay.io/tinkerbell/tink-controller -TINK_SERVER_TAG ?= latest -TINK_CONTROLLER_TAG ?= latest +TINK_SERVER_IMAGE ?= quay.io/tinkerbell/tink-server +TINK_SERVER_TAG ?= latest + +TINK_CONTROLLER_IMAGE ?= quay.io/tinkerbell/tink-controller +TINK_CONTROLLER_TAG ?= latest + NAMESPACE ?= tink-system out/release/default/kustomization.yaml: config/default/kustomization.yaml @@ -52,11 +55,12 @@ out/release/default/kustomization.yaml: config/default/kustomization.yaml cp -a config/ out/release/ out/release/tink.yaml: bin/kustomize generate-manifests out/release/default/kustomization.yaml - (cd out/release/default && \ - kustomize edit set image server=$(TINK_SERVER_IMAGE):$(TINK_CONTROLLER_TAG) controller=$(TINK_CONTROLLER_IMAGE):$(TINK_CONTROLLER_TAG) && \ - kustomize edit set namespace $(NAMESPACE) \ + ( + cd out/release/default && \ + $(KUSTOMIZE) edit set image server=$(TINK_SERVER_IMAGE):$(TINK_CONTROLLER_TAG) controller=$(TINK_CONTROLLER_IMAGE):$(TINK_CONTROLLER_TAG) && \ + $(KUSTOMIZE) edit set namespace $(NAMESPACE) \ ) - kustomize build out/release/default -o $@ + $(KUSTOMIZE) build out/release/default -o $@ prettier --write $@ release-manifests: out/release/tink.yaml ## Builds the manifests to publish with a release. diff --git a/pkg/apis/core/v1alpha1/workflow_data_types.go b/pkg/apis/core/v1alpha1/workflow_data_types.go deleted file mode 100644 index f026af0cb..000000000 --- a/pkg/apis/core/v1alpha1/workflow_data_types.go +++ /dev/null @@ -1,47 +0,0 @@ -package v1alpha1 - -import ( - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -// WorkflowSpec defines the desired state of Workflow. -type WorkflowDataSpec struct { - // Name of the Workflow associated with this workflow. - WorkflowRef string `json:"workflowRef,omitempty"` -} - -// WorkflowStatus defines the observed state of Workflow. -type WorkflowDataStatus struct { - // Data is the populated Workflow Data in Tinkerbell. - Data string `json:"data,omitempty"` - - // Metadata is the metadata stored in Tinkerbell. - Metadata string `json:"metadata,omitempty"` -} - -// +kubebuilder:subresource:status -// +kubebuilder:object:root=true -// +kubebuilder:resource:path=workflowdata,scope=Namespaced,categories=tinkerbell,shortName=wfdata -// +kubebuilder:storageversion - -// Workflow is the Schema for the Workflows API. -type WorkflowData struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata,omitempty"` - - Spec WorkflowSpec `json:"spec,omitempty"` - Status WorkflowStatus `json:"status,omitempty"` -} - -// +kubebuilder:object:root=true - -// WorkflowList contains a list of Workflows. -type WorkflowDataList struct { - metav1.TypeMeta `json:",inline"` - metav1.ListMeta `json:"metadata,omitempty"` - Items []WorkflowData `json:"items"` -} - -func init() { - SchemeBuilder.Register(&WorkflowData{}, &WorkflowDataList{}) -} diff --git a/pkg/apis/core/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/core/v1alpha1/zz_generated.deepcopy.go index c4ebda388..c9c520e1b 100644 --- a/pkg/apis/core/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/core/v1alpha1/zz_generated.deepcopy.go @@ -857,95 +857,6 @@ func (in *Workflow) DeepCopyObject() runtime.Object { return nil } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *WorkflowData) DeepCopyInto(out *WorkflowData) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - in.Spec.DeepCopyInto(&out.Spec) - in.Status.DeepCopyInto(&out.Status) -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WorkflowData. -func (in *WorkflowData) DeepCopy() *WorkflowData { - if in == nil { - return nil - } - out := new(WorkflowData) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *WorkflowData) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *WorkflowDataList) DeepCopyInto(out *WorkflowDataList) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ListMeta.DeepCopyInto(&out.ListMeta) - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]WorkflowData, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WorkflowDataList. -func (in *WorkflowDataList) DeepCopy() *WorkflowDataList { - if in == nil { - return nil - } - out := new(WorkflowDataList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *WorkflowDataList) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *WorkflowDataSpec) DeepCopyInto(out *WorkflowDataSpec) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WorkflowDataSpec. -func (in *WorkflowDataSpec) DeepCopy() *WorkflowDataSpec { - if in == nil { - return nil - } - out := new(WorkflowDataSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *WorkflowDataStatus) DeepCopyInto(out *WorkflowDataStatus) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WorkflowDataStatus. -func (in *WorkflowDataStatus) DeepCopy() *WorkflowDataStatus { - if in == nil { - return nil - } - out := new(WorkflowDataStatus) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *WorkflowList) DeepCopyInto(out *WorkflowList) { *out = *in diff --git a/tools.go b/tools.go index c7fa89eae..82597fa66 100644 --- a/tools.go +++ b/tools.go @@ -11,6 +11,5 @@ import ( _ "google.golang.org/protobuf/cmd/protoc-gen-go" _ "mvdan.cc/gofumpt" _ "sigs.k8s.io/controller-runtime/tools/setup-envtest" - _ "sigs.k8s.io/controller-tools/cmd/controller-gen" _ "sigs.k8s.io/kustomize/kustomize/v4" )