Skip to content
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .ci-operator.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
build_root_image:
name: release
namespace: openshift
tag: rhel-8-release-golang-1.18-openshift-4.12
tag: rhel-8-release-golang-1.19-openshift-4.12
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM registry.ci.openshift.org/ocp/builder:rhel-8-golang-1.18-openshift-4.12 AS builder
FROM registry.ci.openshift.org/ocp/builder:rhel-8-golang-1.19-openshift-4.12 AS builder
WORKDIR /go/src/github.com/openshift/cluster-cloud-controller-manager-operator
COPY . .
RUN make build
Expand Down
32 changes: 9 additions & 23 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
IMG ?= controller:latest

# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
ENVTEST_K8S_VERSION = 1.22
ENVTEST_K8S_VERSION = 1.25

# Tools' pinned versions
CONTROLLER_GEN_VERSION = v0.8.0
GOLANGCI_LINT_VERSION = v1.44.1
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/cmd/golangci-lint

HOME ?= /tmp/kubebuilder-testing
ifeq ($(HOME), /)
Expand All @@ -32,7 +33,7 @@ verify: fmt vet lint
# Run tests
test: generate verify manifests unit

unit: envtest
unit:
KUBEBUILDER_ASSETS=$(shell $(ENVTEST) --bin-dir=$(shell pwd)/bin use $(ENVTEST_K8S_VERSION) -p path) go test ./... -coverprofile cover.out

# Build operator binaries
Expand All @@ -52,7 +53,7 @@ run: verify manifests
go run cmd/cluster-cloud-controller-manager-operator/main.go

# Generate manifests e.g. CRD, RBAC etc.
manifests: controller-gen
manifests:
$(CONTROLLER_GEN) crd rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=config/crd/bases

# Run go fmt against code
Expand All @@ -67,7 +68,7 @@ vet:

# Run golangci-lint against code
.PHONY: lint
lint: golangci-lint
lint:
( GOLANGCI_LINT_CACHE=$(PROJECT_DIR)/.cache $(GOLANGCI_LINT) run --timeout 10m )

# Run go mod
Expand All @@ -78,7 +79,7 @@ vendor:
go mod verify

# Generate code
generate: controller-gen
generate:
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."

# Build the docker image
Expand All @@ -92,18 +93,3 @@ push:
docker push ${IMG}

PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))

.PHONY: controller-gen
CONTROLLER_GEN = $(shell pwd)/bin/controller-gen
controller-gen: # Download controller-gen locally if necessary
GOBIN=$(PROJECT_DIR)/bin go install -mod=readonly sigs.k8s.io/controller-tools/cmd/controller-gen@$(CONTROLLER_GEN_VERSION)

.PHONY: golangci-lint
GOLANGCI_LINT = $(shell pwd)/bin/golangci-lint
golangci-lint: # Download golangci-lint locally if necessary
GOBIN=$(PROJECT_DIR)/bin go install -mod=readonly github.com/golangci/golangci-lint/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION)

.PHONY: envtest
ENVTEST = $(shell pwd)/bin/setup-envtest
envtest: # Download envtest-setup locally if necessary.
GOBIN=$(PROJECT_DIR)/bin go install -mod=readonly sigs.k8s.io/controller-runtime/tools/setup-envtest@latest
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package main

import (
"bytes"
"io/ioutil"
"os"
"testing"

Expand All @@ -28,15 +27,15 @@ func executeCommandC(root *cobra.Command, args ...string) (c *cobra.Command, out
}

func Test_mergeCloudConfig(t *testing.T) {
tmpDir, err := ioutil.TempDir("", "cccmo-azure-creds-injector")
tmpDir, err := os.MkdirTemp("", "cccmo-azure-creds-injector")
require.NoError(t, err)
defer os.Remove(tmpDir)

inputFile, err := ioutil.TempFile(tmpDir, "dummy-config")
inputFile, err := os.CreateTemp(tmpDir, "dummy-config")
require.NoError(t, err)
defer os.Remove(inputFile.Name())

outputFile, err := ioutil.TempFile(tmpDir, "dummy-config-merged")
outputFile, err := os.CreateTemp(tmpDir, "dummy-config-merged")
require.NoError(t, err)
defer os.Remove(outputFile.Name())

Expand All @@ -48,7 +47,7 @@ func Test_mergeCloudConfig(t *testing.T) {
}

cleanupInputFile := func(path string) {
err := ioutil.WriteFile(inputFile.Name(), []byte(""), 0644)
err := os.WriteFile(inputFile.Name(), []byte(""), 0644)
require.NoError(t, err, "Cannot cleanup input file")
}

Expand Down Expand Up @@ -130,7 +129,7 @@ func Test_mergeCloudConfig(t *testing.T) {
defer cleanupEnv(tc.envVars)

if tc.fileContent != "" {
err = ioutil.WriteFile(inputFile.Name(), []byte(tc.fileContent), 0644)
err = os.WriteFile(inputFile.Name(), []byte(tc.fileContent), 0644)
require.NoError(t, err)
defer cleanupInputFile(inputFile.Name())
}
Expand All @@ -143,7 +142,7 @@ func Test_mergeCloudConfig(t *testing.T) {
}

if tc.expectedContent != "" {
fileContent, err := ioutil.ReadFile(outputFile.Name())
fileContent, err := os.ReadFile(outputFile.Name())
require.NoError(t, err, "Cannot read output file")
stringFileContent := string(fileContent)
assert.Equal(t, tc.expectedContent, stringFileContent)
Expand Down
5 changes: 2 additions & 3 deletions cmd/azure-config-credentials-injector/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"encoding/json"
"flag"
"fmt"
"io/ioutil"
"log"
"os"

Expand Down Expand Up @@ -79,7 +78,7 @@ func mergeCloudConfig(_ *cobra.Command, args []string) error {
func readCloudConfig(path string) (map[string]interface{}, error) {
var data map[string]interface{}

rawData, err := ioutil.ReadFile(path)
rawData, err := os.ReadFile(path)
if err != nil {
return nil, err
}
Expand All @@ -102,7 +101,7 @@ func prepareCloudConfig(cloudConfig map[string]interface{}, clientId string, cli
}

func writeCloudConfig(path string, preparedConfig []byte) error {
if err := ioutil.WriteFile(path, preparedConfig, 0644); err != nil {
if err := os.WriteFile(path, preparedConfig, 0644); err != nil {
return err
}
return nil
Expand Down
Loading