From 8042f2c93d55b413f44d8ba8d6ec39baa7d966a6 Mon Sep 17 00:00:00 2001 From: Nolan Brubaker Date: Wed, 30 Oct 2024 14:20:30 -0400 Subject: [PATCH] Allow overriding kustomize component path Signed-off-by: Nolan Brubaker --- manifests-gen/README.md | 19 +++++++++++++++++++ manifests-gen/main.go | 1 + manifests-gen/providers.go | 14 ++++++++------ 3 files changed, 28 insertions(+), 6 deletions(-) create mode 100644 manifests-gen/README.md diff --git a/manifests-gen/README.md b/manifests-gen/README.md new file mode 100644 index 000000000..47f000b33 --- /dev/null +++ b/manifests-gen/README.md @@ -0,0 +1,19 @@ +manifests-gen +============= + +This tool is used to generate manifests for Cluster API Providers suitable for use within OpenShift Container Platform. + +The tool makes the following assumptions, and uses relative paths based on those: + + * The forked provider repository has directories `openshift` and `openshift/tools` + * `manifests-gen`'s working directory is `openshift/tools` (invoked via `openshift/Makefile`) + +Most often, the base Cluster API Provider YAML manifests will be stored in `config/default`. + +If there are any OpenShift-specific changes that do not warrant inclusion into this tool, +the directory can be overriden with `--kustomize-dir`. Often, this should be `--kustomize-dir=openshift` +and a `openshift/kustomization.yaml` file should be present that references `config/default` as the base. + +Changes that warrant making edits via this tool are things that apply to all or many resources. +Changes that target a single resource, such as changing a single, specific `Deployment`'s +container arguments should be applies as Kustomize patches local to the provider repo. diff --git a/manifests-gen/main.go b/manifests-gen/main.go index e246382e0..df2f2f497 100644 --- a/manifests-gen/main.go +++ b/manifests-gen/main.go @@ -19,6 +19,7 @@ import ( var ( basePath = flag.String("base-path", "", "path to the root of the provider's repository") manifestsPath = flag.String("manifests-path", "", "path to the desired directory where to output the generated manifests") + kustomizeDir = flag.String("kustomize-dir", defaultKustomizeComponentsPath, "directory to search for kustomization.yaml file, relative to the base-path") providerName = flag.String("provider-name", "", "name of the provider") providerType = flag.String("provider-type", "", "type of the provider") providerVersion = flag.String("provider-version", "", "version of the provider") diff --git a/manifests-gen/providers.go b/manifests-gen/providers.go index f1f7dfeb6..c290d4be4 100644 --- a/manifests-gen/providers.go +++ b/manifests-gen/providers.go @@ -21,11 +21,11 @@ import ( ) const ( - powerVSProvider = "powervs" - ibmCloudProvider = "ibmcloud" - coreCAPIProvider = "cluster-api" - metadataFilePath = "./metadata.yaml" - kustomizeComponentsPath = "./config/default" + powerVSProvider = "powervs" + ibmCloudProvider = "ibmcloud" + coreCAPIProvider = "cluster-api" + metadataFilePath = "./metadata.yaml" + defaultKustomizeComponentsPath = "./config/default" // customizedComponentsFilename is a name for file containing customized infrastructure components. // This file helps with code review as it is always uncompressed unlike the components configMap. customizedComponentsFilename = "infrastructure-components-openshift.yaml" @@ -60,7 +60,9 @@ func (p *provider) loadComponents() error { } // Compile assets using kustomize. - rawComponents, err := fetchAndCompileComponents(path.Join(projDir, kustomizeComponentsPath)) + kustomizeComponentsPath := path.Join(projDir, *kustomizeDir) + fmt.Printf("> Generating OpenShift manifests based on kustomize.yaml from %q\n", kustomizeComponentsPath) + rawComponents, err := fetchAndCompileComponents(kustomizeComponentsPath) if err != nil { return fmt.Errorf("error fetching and compiling assets using kustomize: %w", err) }