diff --git a/Makefile b/Makefile index daf98e6a11..c72ab0769c 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,15 @@ all: build .PHONY: all +# IMPORTANT: Awkward though it is to read, this dependency chain needs to be +# defined *before* we include the build-machinery-go rules. That's because +# we need to install vendored CRDs and generate our own CRDs *before* we +# update bindata to include them. (Dependencies seem to run in the order they +# are defined, with subsequent definitions appended iff not already in the +# chain.) +update: update-vendored-crds update-codegen-crds update-bindata generate +.PHONY: update + # Include the library makefile include $(addprefix ./vendor/github.com/openshift/build-machinery-go/make/, \ golang.mk \ @@ -76,45 +85,18 @@ $(call build-image,ocp-cloud-credential-operator,$(IMAGE_REGISTRY)/$(IMAGE_REPO) # $2 - apis # $3 - manifests # $4 - output -$(call add-crd-gen,cloudcredential-manifests,./pkg/apis/cloudcredential/v1,./manifests,./manifests) -$(call add-crd-gen,cloudcredential-bindata,./pkg/apis/cloudcredential/v1,./bindata/bootstrap,./bindata/bootstrap) - -update: update-codegen update-bindata generate -.PHONY: update +$(call add-crd-gen,cloudcredential-manifests,./pkg/apis/cloudcredential/v1,./manifests/generated,./manifests/generated) +$(call add-crd-gen,cloudcredential-bindata,./pkg/apis/cloudcredential/v1,./bindata/bootstrap/generated,./bindata/bootstrap/generated) generate: go generate ${GO_TEST_PACKAGES} .PHONY: generate -# TODO: consider migrating to the openshift/api codegen tool -# https://github.com/openshift/api/tree/master/tools/codegen -# -# update-codegen-crds-cloudcredential-manifests and -# update-codegen-crds-cloudcredential-bindata make targets override -# "update-codegen-crds-*" targets created by the above invocations of -# "add-crd-gen". -# -# We copy the cloud credential operator config CRD from the -# openshift/api repository (via the vendor dir) and since -# openshift/api now utilizes a different codegen utility than -# build-machinery-go, running the schemapatch code generator against -# the copied manifest results in a different formatting. This results -# in a diff which causes our verify target to fail so we ensure the -# copied manifests remain unchanged by copying the CRDs once more -# after generating CRDs as a workaround. -update-codegen-crds-cloudcredential-manifests: ensure-controller-gen ensure-yq ensure-yaml-patch - $(run-crd-gen,./pkg/apis/cloudcredential/v1,./manifests) - $(MAKE) update-vendored-crds - -update-codegen-crds-cloudcredential-bindata: ensure-controller-gen ensure-yq ensure-yaml-patch - $(run-crd-gen,./pkg/apis/cloudcredential/v1,./bindata/bootstrap) - $(MAKE) update-vendored-crds - update-vendored-crds: # copy config CRD from openshift/api - cp vendor/github.com/openshift/api/operator/v1/0000_40_cloud-credential-operator_00_config.crd.yaml ./manifests/00-config-custresdef.yaml + cp vendor/github.com/openshift/api/operator/v1/0000_40_cloud-credential-operator_00_config.crd.yaml ./manifests/imported/00-config-custresdef.yaml # ...and into where we generate bindata from - cp vendor/github.com/openshift/api/operator/v1/0000_40_cloud-credential-operator_00_config.crd.yaml ./bindata/bootstrap/cloudcredential_v1_operator_config_custresdef.yaml + cp vendor/github.com/openshift/api/operator/v1/0000_40_cloud-credential-operator_00_config.crd.yaml ./bindata/bootstrap/imported/cloudcredential_v1_operator_config_custresdef.yaml .PHONY: update-vendored-crds update-codegen: update-codegen-crds @@ -128,8 +110,8 @@ verify-codegen: verify-codegen-crds .PHONY: verify-codegen verify-vendored-crds: - diff vendor/github.com/openshift/api/operator/v1/0000_40_cloud-credential-operator_00_config.crd.yaml ./manifests/00-config-custresdef.yaml - diff vendor/github.com/openshift/api/operator/v1/0000_40_cloud-credential-operator_00_config.crd.yaml ./bindata/bootstrap/cloudcredential_v1_operator_config_custresdef.yaml + diff vendor/github.com/openshift/api/operator/v1/0000_40_cloud-credential-operator_00_config.crd.yaml ./manifests/imported/00-config-custresdef.yaml + diff vendor/github.com/openshift/api/operator/v1/0000_40_cloud-credential-operator_00_config.crd.yaml ./bindata/bootstrap/imported/cloudcredential_v1_operator_config_custresdef.yaml .PHONY: verify-vendored-crds clean: @@ -142,7 +124,7 @@ run: build # Install CRDs into a cluster install: update-codegen - kubectl apply -f manifests/00-crd.yaml + kubectl apply -f manifests/generated/00-crd.yaml # TODO targets for backward compatibility while we make the shift in CI test-no-gen: test diff --git a/bindata/bootstrap/cloudcredential_v1_credentialsrequest_crd.yaml b/bindata/bootstrap/generated/cloudcredential_v1_credentialsrequest_crd.yaml similarity index 100% rename from bindata/bootstrap/cloudcredential_v1_credentialsrequest_crd.yaml rename to bindata/bootstrap/generated/cloudcredential_v1_credentialsrequest_crd.yaml diff --git a/bindata/bootstrap/cloudcredential_v1_operator_config_custresdef.yaml b/bindata/bootstrap/imported/cloudcredential_v1_operator_config_custresdef.yaml similarity index 100% rename from bindata/bootstrap/cloudcredential_v1_operator_config_custresdef.yaml rename to bindata/bootstrap/imported/cloudcredential_v1_operator_config_custresdef.yaml diff --git a/manifests/00-crd.yaml b/manifests/generated/00-crd.yaml similarity index 100% rename from manifests/00-crd.yaml rename to manifests/generated/00-crd.yaml diff --git a/manifests/00-config-custresdef.yaml b/manifests/imported/00-config-custresdef.yaml similarity index 100% rename from manifests/00-config-custresdef.yaml rename to manifests/imported/00-config-custresdef.yaml diff --git a/pkg/assets/bootstrap/bindata.go b/pkg/assets/bootstrap/bindata.go index babbcbecd1..4843db0198 100644 --- a/pkg/assets/bootstrap/bindata.go +++ b/pkg/assets/bootstrap/bindata.go @@ -1,7 +1,7 @@ // Code generated for package bootstrap by go-bindata DO NOT EDIT. (@generated) // sources: -// bindata/bootstrap/cloudcredential_v1_credentialsrequest_crd.yaml -// bindata/bootstrap/cloudcredential_v1_operator_config_custresdef.yaml +// bindata/bootstrap/generated/cloudcredential_v1_credentialsrequest_crd.yaml +// bindata/bootstrap/imported/cloudcredential_v1_operator_config_custresdef.yaml // bindata/bootstrap/namespace.yaml package bootstrap @@ -56,7 +56,7 @@ func (fi bindataFileInfo) Sys() interface{} { return nil } -var _bootstrapCloudcredential_v1_credentialsrequest_crdYaml = []byte(`apiVersion: apiextensions.k8s.io/v1 +var _bootstrapGeneratedCloudcredential_v1_credentialsrequest_crdYaml = []byte(`apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: @@ -228,22 +228,22 @@ status: storedVersions: [] `) -func bootstrapCloudcredential_v1_credentialsrequest_crdYamlBytes() ([]byte, error) { - return _bootstrapCloudcredential_v1_credentialsrequest_crdYaml, nil +func bootstrapGeneratedCloudcredential_v1_credentialsrequest_crdYamlBytes() ([]byte, error) { + return _bootstrapGeneratedCloudcredential_v1_credentialsrequest_crdYaml, nil } -func bootstrapCloudcredential_v1_credentialsrequest_crdYaml() (*asset, error) { - bytes, err := bootstrapCloudcredential_v1_credentialsrequest_crdYamlBytes() +func bootstrapGeneratedCloudcredential_v1_credentialsrequest_crdYaml() (*asset, error) { + bytes, err := bootstrapGeneratedCloudcredential_v1_credentialsrequest_crdYamlBytes() if err != nil { return nil, err } - info := bindataFileInfo{name: "bootstrap/cloudcredential_v1_credentialsrequest_crd.yaml", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)} + info := bindataFileInfo{name: "bootstrap/generated/cloudcredential_v1_credentialsrequest_crd.yaml", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)} a := &asset{bytes: bytes, info: info} return a, nil } -var _bootstrapCloudcredential_v1_operator_config_custresdefYaml = []byte(`apiVersion: apiextensions.k8s.io/v1 +var _bootstrapImportedCloudcredential_v1_operator_config_custresdefYaml = []byte(`apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: @@ -387,17 +387,17 @@ spec: status: {} `) -func bootstrapCloudcredential_v1_operator_config_custresdefYamlBytes() ([]byte, error) { - return _bootstrapCloudcredential_v1_operator_config_custresdefYaml, nil +func bootstrapImportedCloudcredential_v1_operator_config_custresdefYamlBytes() ([]byte, error) { + return _bootstrapImportedCloudcredential_v1_operator_config_custresdefYaml, nil } -func bootstrapCloudcredential_v1_operator_config_custresdefYaml() (*asset, error) { - bytes, err := bootstrapCloudcredential_v1_operator_config_custresdefYamlBytes() +func bootstrapImportedCloudcredential_v1_operator_config_custresdefYaml() (*asset, error) { + bytes, err := bootstrapImportedCloudcredential_v1_operator_config_custresdefYamlBytes() if err != nil { return nil, err } - info := bindataFileInfo{name: "bootstrap/cloudcredential_v1_operator_config_custresdef.yaml", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)} + info := bindataFileInfo{name: "bootstrap/imported/cloudcredential_v1_operator_config_custresdef.yaml", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -480,9 +480,9 @@ func AssetNames() []string { // _bindata is a table, holding each asset generator, mapped to its name. var _bindata = map[string]func() (*asset, error){ - "bootstrap/cloudcredential_v1_credentialsrequest_crd.yaml": bootstrapCloudcredential_v1_credentialsrequest_crdYaml, - "bootstrap/cloudcredential_v1_operator_config_custresdef.yaml": bootstrapCloudcredential_v1_operator_config_custresdefYaml, - "bootstrap/namespace.yaml": bootstrapNamespaceYaml, + "bootstrap/generated/cloudcredential_v1_credentialsrequest_crd.yaml": bootstrapGeneratedCloudcredential_v1_credentialsrequest_crdYaml, + "bootstrap/imported/cloudcredential_v1_operator_config_custresdef.yaml": bootstrapImportedCloudcredential_v1_operator_config_custresdefYaml, + "bootstrap/namespace.yaml": bootstrapNamespaceYaml, } // AssetDir returns the file names below a certain @@ -529,8 +529,12 @@ type bintree struct { var _bintree = &bintree{nil, map[string]*bintree{ "bootstrap": {nil, map[string]*bintree{ - "cloudcredential_v1_credentialsrequest_crd.yaml": {bootstrapCloudcredential_v1_credentialsrequest_crdYaml, map[string]*bintree{}}, - "cloudcredential_v1_operator_config_custresdef.yaml": {bootstrapCloudcredential_v1_operator_config_custresdefYaml, map[string]*bintree{}}, + "generated": {nil, map[string]*bintree{ + "cloudcredential_v1_credentialsrequest_crd.yaml": {bootstrapGeneratedCloudcredential_v1_credentialsrequest_crdYaml, map[string]*bintree{}}, + }}, + "imported": {nil, map[string]*bintree{ + "cloudcredential_v1_operator_config_custresdef.yaml": {bootstrapImportedCloudcredential_v1_operator_config_custresdefYaml, map[string]*bintree{}}, + }}, "namespace.yaml": {bootstrapNamespaceYaml, map[string]*bintree{}}, }}, }} diff --git a/pkg/cmd/render/render.go b/pkg/cmd/render/render.go index be3b83e372..eb8f63a7e8 100644 --- a/pkg/cmd/render/render.go +++ b/pkg/cmd/render/render.go @@ -90,8 +90,8 @@ spec: credentialsMode: "{{ .CredentialsMode }}"`)) renderAssets = []string{ - "bootstrap/cloudcredential_v1_operator_config_custresdef.yaml", - "bootstrap/cloudcredential_v1_credentialsrequest_crd.yaml", + "bootstrap/imported/cloudcredential_v1_operator_config_custresdef.yaml", + "bootstrap/generated/cloudcredential_v1_credentialsrequest_crd.yaml", "bootstrap/namespace.yaml", }