Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OCPCLOUD-2642: manifests-gen: Allow overriding kustomize component path #228

Merged
merged 1 commit into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions manifests-gen/README.md
Original file line number Diff line number Diff line change
@@ -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.
1 change: 1 addition & 0 deletions manifests-gen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
14 changes: 8 additions & 6 deletions manifests-gen/providers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
}
Expand Down