- Go 1.25+
- Podman (or Docker, set
CONTAINER_TOOL=docker) ocorkubectlCLI- Access to an OpenShift cluster on vSphere (for integration testing)
# Build the operator binary
make build
# Build the container image
make operator-image IMG=<registry>/vcf-migration-operator:devAfter modifying types in api/v1alpha1/:
# Regenerate DeepCopy methods and CRD manifests
make generate manifestsThis runs controller-gen to produce:
zz_generated.deepcopy.go— DeepCopy implementationsconfig/crd/bases/— CRD YAMLconfig/rbac/role.yaml— ClusterRole from//+kubebuilder:rbacmarkers
# Install CRDs, then run the controller against your current kubeconfig
make install
make runThe controller listens on :8081 (health) and :8443 (metrics).
# Build, push, and deploy
make operator-image operator-push IMG=<registry>/vcf-migration-operator:dev
make deploy IMG=<registry>/vcf-migration-operator:devEverything deploys to the openshift-vcf-migration namespace.
make testUses Ginkgo/Gomega with envtest (local etcd + apiserver, Kubernetes v1.35.0 binaries). vSphere operations are tested against the govmomi simulator.
Test files live alongside the code they test:
internal/controller/*_test.gointernal/vsphere/*_test.gointernal/openshift/*_test.gointernal/metadata/*_test.go
# Creates a Kind cluster, builds/loads the image, and runs tests
RUN_E2E=true make test-e2e
# Tear down the Kind cluster afterward
make cleanup-test-e2emake lint # Check
make lint-fix # Auto-fixUses golangci-lint v2.1.0. Config in .golangci.yml.
# Regenerate bundle manifests from current CRDs/RBAC
make bundle
# Build and push bundle + catalog images
make bundle-build bundle-push BUNDLE_IMG=<registry>/vcf-migration-operator-bundle:v0.0.1
make catalog-build catalog-push CATALOG_IMG=<registry>/vcf-migration-operator-catalog:v0.0.1make bundle-verify checks that the bundle is up-to-date with the current code.
-
Add a condition constant in
api/v1alpha1/vmwarecloudfoundationmigration_types.go:const ConditionMyPhase = "MyPhase"
-
Add it to
conditionOrderininternal/controller/vmwarecloudfoundationmigration_controller.go. -
Write the handler function:
func (r *VmwareCloudFoundationMigrationReconciler) ensureMyPhase( ctx context.Context, migration *v1alpha1.VmwareCloudFoundationMigration, ) (string, ctrl.Result, error) { // Do work... return "phase complete", ctrl.Result{}, nil }
-
Register the handler in the
handlersmap insideReconcile(). -
Regenerate manifests:
make generate manifests -
Add tests in
internal/controller/.
vSphere operations live in internal/vsphere/. Tests use govmomi's simulator:
simulator.Test(func(ctx context.Context, c *vim25.Client) {
// c is a real govmomi client pointed at the in-process simulator
})OpenShift operations live in internal/openshift/. Each manager type (InfrastructureManager, MachineManager, etc.) takes injected Kubernetes/OpenShift clients for testability.
| Variable | Default | Description |
|---|---|---|
IMG |
registry.ci.openshift.org/origin/vcf-migration-operator:latest |
Operator image |
CONTAINER_TOOL |
podman |
Container build tool |
VERSION |
0.0.1 |
Project version |
CHANNELS |
dev-preview |
OLM bundle channel |
KIND_CLUSTER |
vcf-migration-operator-test-e2e |
Kind cluster name for e2e |
ENVTEST_K8S_VERSION |
1.35.0 |
Kubernetes version for envtest |
- OpenShift CI:
.ci-operator.yaml— builds onrhel-9-release-golang-1.25-openshift-4.22 - Tekton/Konflux:
.tekton/— pipelines for PR validation and push builds make verify-diffensures no uncommitted generated files in CI