Skip to content
Open
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ FROM registry.ci.openshift.org/ocp/builder:rhel-9-golang-1.25-openshift-4.22 AS
WORKDIR /go/src/github.com/openshift/cluster-cloud-controller-manager-operator
COPY . .
RUN make build &&\
gzip /go/src/github.com/openshift/cluster-cloud-controller-manager-operator/bin/cloud-controller-manager-aws-tests-ext
gzip /go/src/github.com/openshift/cluster-cloud-controller-manager-operator/bin/cloud-controller-manager-aws-tests-ext &&\
gzip /go/src/github.com/openshift/cluster-cloud-controller-manager-operator/openshift-tests/bin/cloud-controller-manager-operator-tests-ext

FROM registry.ci.openshift.org/ocp/4.22:base-rhel9
COPY --from=builder /go/src/github.com/openshift/cluster-cloud-controller-manager-operator/bin/cluster-controller-manager-operator .
COPY --from=builder /go/src/github.com/openshift/cluster-cloud-controller-manager-operator/bin/config-sync-controllers .
COPY --from=builder /go/src/github.com/openshift/cluster-cloud-controller-manager-operator/bin/azure-config-credentials-injector .
COPY --from=builder /go/src/github.com/openshift/cluster-cloud-controller-manager-operator/manifests manifests
COPY --from=builder /go/src/github.com/openshift/cluster-cloud-controller-manager-operator/bin/cloud-controller-manager-aws-tests-ext.gz /usr/bin/cloud-controller-manager-aws-tests-ext.gz
COPY --from=builder /go/src/github.com/openshift/cluster-cloud-controller-manager-operator/openshift-tests/bin/cloud-controller-manager-operator-tests-ext.gz /usr/bin/cloud-controller-manager-operator-tests-ext.gz

LABEL io.openshift.release.operator true
19 changes: 12 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))
CONTROLLER_GEN = go run ${PROJECT_DIR}/vendor/sigs.k8s.io/controller-tools/cmd/controller-gen
ENVTEST = go run ${PROJECT_DIR}/vendor/sigs.k8s.io/controller-runtime/tools/setup-envtest
GOLANGCI_LINT = go run ${PROJECT_DIR}/vendor/github.com/golangci/golangci-lint/v2/cmd/golangci-lint
REPO_PATH ?= github.com/openshift/cluster-cloud-controller-manager-operator

HOME ?= /tmp/kubebuilder-testing
ifeq ($(HOME), /)
Expand Down Expand Up @@ -37,7 +38,8 @@ unit:
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path --bin-dir $(PROJECT_DIR)/bin --index https://raw.githubusercontent.com/openshift/api/master/envtest-releases.yaml)" ./hack/ci-test.sh

# Build operator binaries
build: operator config-sync-controllers azure-config-credentials-injector cloud-controller-manager-aws-tests-ext
.PHONY: build
build: operator config-sync-controllers azure-config-credentials-injector cloud-controller-manager-aws-tests-ext cluster-cloud-controller-manager-operator-tests-ext

operator:
go build -o bin/cluster-controller-manager-operator cmd/cluster-cloud-controller-manager-operator/main.go
Expand All @@ -50,11 +52,16 @@ azure-config-credentials-injector:

cloud-controller-manager-aws-tests-ext:
cd cmd/cloud-controller-manager-aws-tests-ext && \
GO111MODULE=on CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=$(GOARCH) GOPROXY=$(GOPROXY) go build \
GOWORK=off GO111MODULE=on CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=$(GOARCH) GOPROXY=$(GOPROXY) go build \
-trimpath \
-ldflags="$(LDFLAGS)" \
-o=../../bin/cloud-controller-manager-aws-tests-ext .

cluster-cloud-controller-manager-operator-tests-ext:
cd openshift-tests/operator-tests && \
mkdir -p ../bin && \
go build $(GOGCFLAGS) -o "../bin/cloud-controller-manager-operator-tests-ext" \
-trimpath -ldflags "$(LD_FLAGS)" .

# Run against the configured Kubernetes cluster in ~/.kube/config
run: verify manifests
Expand All @@ -67,7 +74,7 @@ manifests:
# Run go fmt against code
.PHONY: fmt
fmt:
go fmt ./...
go fmt -mod=mod ./...

# Run go vet against code
.PHONY: vet
Expand All @@ -82,13 +89,11 @@ lint:
# Run go mod
.PHONY: vendor
vendor:
go mod tidy
go mod vendor
go mod verify
hack/go-mod.sh

# Generate code
generate:
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="github.com/openshift/cluster-cloud-controller-manager-operator/cmd/..." paths="github.com/openshift/cluster-cloud-controller-manager-operator/pkg/..."

# Build the docker image
.PHONY: image
Expand Down
6 changes: 6 additions & 0 deletions go.work
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
go 1.25.0

use (
.
./openshift-tests/operator-tests
)
252 changes: 252 additions & 0 deletions go.work.sum

Large diffs are not rendered by default.

66 changes: 66 additions & 0 deletions hack/go-mod.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#!/bin/bash

set -e

function vendor_workspace() {
echo "Updating dependencies for Cluster Cloud Controller Manager Operator workspace"

go work use -r .
go work edit -dropuse ./cmd/cloud-controller-manager-aws-tests-ext

# Discover all modules from the workspace
echo "Discovering modules from workspace..."
MODULES=$(go work edit -json | grep -o '"DiskPath": "[^"]*"' | cut -d'"' -f4 | sed 's|^\./||')
echo "Found modules: $MODULES"

# Pass 1: tidy all modules
echo "Running go mod tidy for all modules (pass 1)..."
for module in $MODULES; do
if [ -f "$module/go.mod" ]; then
echo "Tidying $module"
(cd "$module" && go mod tidy)
fi
done

# Sync: propagate highest require versions across all modules
echo "Syncing Go workspace..."
go work sync

# Pass 2: re-tidy after sync may have bumped versions
echo "Running go mod tidy for all modules (pass 2)..."
for module in $MODULES; do
if [ -f "$module/go.mod" ]; then
echo "Tidying $module"
(cd "$module" && go mod tidy)
fi
done

# Verify all modules
echo "Verifying all modules..."
for module in $MODULES; do
if [ -f "$module/go.mod" ]; then
echo "Verifying $module"
(cd "$module" && go mod verify)
fi
done

# Create unified vendor directory
echo "Creating unified vendor directory..."
go work vendor -v

echo "Done updating dependencies for Cluster Cloud Controller Manager Operator workspace"
}

# vendor_ote_ccmaws is used to update the dependencies for the CCM AWS tests.
# CCM-AWS OTE is outside of workspace to prevent cross-module dependency conflicts.
function vendor_ote_ccmaws() {
echo "Updating dependencies for CCM AWS tests"
cd cmd/cloud-controller-manager-aws-tests-ext
GOWORK=off go mod tidy
GOWORK=off go mod vendor
cd ../..
echo "Updated dependencies for CCM AWS tests"
}

vendor_ote_ccmaws
vendor_workspace
19 changes: 19 additions & 0 deletions openshift-tests/operator-tests/e2e/common/helper.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package common

import (
ginkgov2 "github.com/onsi/ginkgo/v2"
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/clientcmd"
"k8s.io/client-go/tools/clientcmd/api"
)

// NewClientConfigForTest returns a config configured to connect to the api server
func NewClientConfigForTest() (*rest.Config, error) {
loader := clientcmd.NewDefaultClientConfigLoadingRules()
clientConfig := clientcmd.NewNonInteractiveDeferredLoadingClientConfig(loader, &clientcmd.ConfigOverrides{ClusterInfo: api.Cluster{InsecureSkipTLSVerify: true}})
config, err := clientConfig.ClientConfig()
if err == nil {
ginkgov2.GinkgoLogr.Info("Found configuration for", "host", config.Host)
}
return config, err
}
Loading