Skip to content

Commit

Permalink
Merge pull request openstack-k8s-operators#797 from stuggi/golang_upd…
Browse files Browse the repository at this point in the history
…ate_1_3_x

[1.3.x] update golang to 1.19 and operator-sdk to 1.26
  • Loading branch information
openshift-merge-robot authored Apr 17, 2023
2 parents 90a2520 + 8e861e4 commit 3d4161c
Show file tree
Hide file tree
Showing 60 changed files with 216 additions and 309 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build-osp-director-operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v3
with:
go-version: 1.18.x
go-version: 1.19.x

- name: Checkout osp-director-operator repository
uses: actions/checkout@v3
Expand All @@ -173,7 +173,7 @@ jobs:
uses: redhat-actions/openshift-tools-installer@v1
with:
source: github
operator-sdk: '1.23.0'
operator-sdk: '1.26.0'

- name: Log in to Quay Registry
uses: redhat-actions/podman-login@v1
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/golangci-lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v3
with:
go-version: 1.18.x
go-version: 1.19.x
- name: Checkout project code
uses: actions/checkout@v3
- name: Checkout openstack-k8s-operators-ci project
Expand All @@ -32,7 +32,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v3
with:
go-version: 1.18.x
go-version: 1.19.x
- name: Checkout project code
uses: actions/checkout@v3
- name: Run golangci lint
Expand Down
17 changes: 17 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
linters:
# Enable specific linter
# https://golangci-lint.run/usage/linters/#enabled-by-default
enable:
- errorlint
- revive
- gofmt
- govet
linters-settings:
revive:
rules:
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unused-parameter
- name: unused-parameter
severity: warning
disabled: true
run:
timeout: 5m
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG GOLANG_BUILDER=golang:1.18
ARG GOLANG_BUILDER=golang:1.19
ARG OPERATOR_BASE_IMAGE=gcr.io/distroless/static:nonroot

# Build the manager binary
Expand Down
31 changes: 27 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ endif
# Image URL to use all building/pushing image targets
IMG ?= controller:latest
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
ENVTEST_K8S_VERSION = 1.24
ENVTEST_K8S_VERSION = 1.25.0
# Metrics bind address
METRICS_BIND_ADDRESS ?= :8080
CRD_OPTIONS ?= "crd:crdVersions=v1,generateEmbeddedObjectMeta=true"
Expand Down Expand Up @@ -148,7 +148,7 @@ vet: ## Run go vet against code.

.PHONY: test
test: manifests generate fmt vet envtest ## Run tests.
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" go test ./... -coverprofile cover.out
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" go test ./... -coverprofile cover.out

##@ Build

Expand All @@ -157,8 +157,14 @@ build: generate fmt vet ## Build manager binary.
go build -o bin/manager main.go

.PHONY: run
run: export METRICS_PORT?=8080
run: export HEALTH_PORT?=8081
run: export OPERATOR_TEMPLATES=./templates
run: export WATCH_NAMESPACE=openstack,openshift-machine-api,openshift-sriov-network-operator
run: export ENABLE_WEBHOOKS=false
run: manifests generate fmt vet ## Run a controller from your host.
go run ./main.go -metrics-bind-address ${METRICS_BIND_ADDRESS}
go run ./main.go -metrics-bind-address ":$(METRICS_PORT)" -health-probe-bind-address ":$(HEALTH_PORT)"


.PHONY: docker-build
docker-build: test ## Build docker image with the manager.
Expand All @@ -168,6 +174,23 @@ docker-build: test ## Build docker image with the manager.
docker-push: ## Push docker image with the manager.
podman push ${IMG}

# PLATFORMS defines the target platforms for the manager image be build to provide support to multiple
# architectures. (i.e. make docker-buildx IMG=myregistry/mypoperator:0.0.1). To use this option you need to:
# - able to use docker buildx . More info: https://docs.docker.com/build/buildx/
# - have enable BuildKit, More info: https://docs.docker.com/develop/develop-images/build_enhancements/
# - be able to push the image for your registry (i.e. if you do not inform a valid value via IMG=<myregistry/image:<tag>> than the export will fail)
# To properly provided solutions that supports more than one platform you should use this option.
PLATFORMS ?= linux/arm64,linux/amd64,linux/s390x,linux/ppc64le
.PHONY: docker-buildx
docker-buildx: test ## Build and push docker image for the manager for cross-platform support
# copy existing Dockerfile and insert --platform=${BUILDPLATFORM} into Dockerfile.cross, and preserve the original Dockerfile
sed -e '1 s/\(^FROM\)/FROM --platform=\$$\{BUILDPLATFORM\}/; t' -e ' 1,// s//FROM --platform=\$$\{BUILDPLATFORM\}/' Dockerfile > Dockerfile.cross
- docker buildx create --name project-v3-builder
docker buildx use project-v3-builder
- docker buildx build --push --platform=$(PLATFORMS) --tag ${IMG} -f Dockerfile.cross
- docker buildx rm project-v3-builder
rm Dockerfile.cross

##@ Deployment

ifndef ignore-not-found
Expand Down Expand Up @@ -205,7 +228,7 @@ ENVTEST ?= $(LOCALBIN)/setup-envtest

## Tool Versions
KUSTOMIZE_VERSION ?= v3.8.7
CONTROLLER_TOOLS_VERSION ?= v0.9.2
CONTROLLER_TOOLS_VERSION ?= v0.10.0

KUSTOMIZE_INSTALL_SCRIPT ?= "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh"
.PHONY: kustomize
Expand Down
26 changes: 0 additions & 26 deletions api/shared/conditions.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,7 @@ const (
CommonCondReasonServiceNotFound ConditionReason = "ServiceNotFound"
)

//
// Client
//
const (
//
// condition reasones
Expand Down Expand Up @@ -128,9 +126,7 @@ const (
OsClientCondReasonPodMissing ConditionReason = "OpenStackClientPodMissing"
)

//
// ConfigGenerator
//
const (
//
// condition types
Expand Down Expand Up @@ -195,9 +191,7 @@ const (
ConfigGeneratorCondReasonClusterServiceIPError ConditionReason = "ClusterServiceIPError"
)

//
// BaremetalSet
//
const (
// BaremetalSetCondTypeEmpty - special state for 0 requested BaremetalHosts and 0 already provisioned
BaremetalSetCondTypeEmpty ConditionType = "Empty"
Expand Down Expand Up @@ -261,9 +255,7 @@ const (
BaremetalSetCondReasonVirtualMachineCountZero ConditionReason = "BaremetalHostCountZero"
)

//
// ControlPlane
//
const (
// ControlPlaneEmpty - special state for 0 requested VMs and 0 already provisioned
ControlPlaneEmpty ConditionType = "Empty"
Expand Down Expand Up @@ -300,9 +292,7 @@ const (
ControlPlaneReasonDeploymentSSHKeysSecretCreateOrUpdateError ConditionReason = "DeploymentSSHKeysSecretCreateOrUpdateError"
)

//
// Deploy
//
const (
//
// condition types
Expand Down Expand Up @@ -337,9 +327,7 @@ const (
DeployCondReasonConfigCreate ConditionReason = "ConfigCreate"
)

//
// EphemeralHeat
//
const (
//
// condition reasons
Expand All @@ -365,9 +353,7 @@ const (
EphemeralHeatReady ConditionReason = "EphemeralHeatReady"
)

//
// IPSet
//
const (
//
// condition reasones
Expand All @@ -383,9 +369,7 @@ const (
IPSetCondReasonCreated ConditionReason = "OpenStackIPSetCreated"
)

//
// MACAddress
//
const (
//
// condition types
Expand Down Expand Up @@ -418,9 +402,7 @@ const (
MACCondReasonMACNotFound ConditionReason = "OpenStackMACNotFound"
)

//
// Net
//
const (
//
// condition types
Expand Down Expand Up @@ -449,9 +431,7 @@ const (
NetCondReasonNetNotFound ConditionReason = "OpenStackNetNotFound"
)

//
// NetAttach
//
const (
//
// condition types
Expand All @@ -478,9 +458,7 @@ const (
NetAttachCondReasonCreateError ConditionReason = "OpenStackNetAttachCreateError"
)

//
// NetConfig
//
const (
// NetConfigWaiting - the network configuration is blocked by prerequisite objects
NetConfigWaiting ConditionType = "Waiting"
Expand All @@ -505,9 +483,7 @@ const (
NetConfigCondReasonIPReservation ConditionReason = "IPReservationCreated"
)

//
// ProvisionServer
//
const (
// ProvisionServerCondTypeWaiting - something else is causing the OpenStackProvisionServer to wait
ProvisionServerCondTypeWaiting ConditionType = "Waiting"
Expand Down Expand Up @@ -548,9 +524,7 @@ const (
OpenStackProvisionServerCondReasonCreated ConditionReason = "OpenStackProvisionServerCreated"
)

//
// VMSet
//
const (
//
// condition types
Expand Down
4 changes: 2 additions & 2 deletions api/shared/osp.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ const (
)

// GetOSPVersion - returns unified ospdirectorv1beta1.OSPVersion for upstream/downstream version
// - TemplateVersion16_2 for eitner 16.2 or upstream train
// - TemplateVersion17_0 for eitner 17.0 or upstream wallaby
// - TemplateVersion16_2 for eitner 16.2 or upstream train
// - TemplateVersion17_0 for eitner 17.0 or upstream wallaby
func GetOSPVersion(parsedVersion string) (OSPVersion, error) {
switch parsedVersion {
case string(TemplateVersionTrain):
Expand Down
2 changes: 0 additions & 2 deletions api/v1beta1/common_openstackcontrolplane.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@ import (
ctrl "sigs.k8s.io/controller-runtime"
)

//
// GetControlPlane - Get OSP ControlPlane CR where e.g. the status information has the
// OSP version: controlPlane.Status.OSPVersion
// FIXME: We assume there is only one ControlPlane CR for now (enforced by webhook), but this might need to change
//
func GetControlPlane(
c client.Client,
obj metav1.Object,
Expand Down
6 changes: 0 additions & 6 deletions api/v1beta1/common_openstacknet.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"
)

//
// AddOSNetNameLowerLabels - add osnetcfg CR label reference which is used in
// the in the osnetcfg controller to watch this resource and reconcile
//
func AddOSNetNameLowerLabels(
log logr.Logger,
labels map[string]string,
Expand Down Expand Up @@ -85,10 +83,8 @@ func AddOSNetNameLowerLabels(
return labels
}

//
// AddOSNetConfigRefLabel - add osnetcfg CR label reference which is used in
// the in the osnetcfg controller to watch this resource and reconcile
//
func AddOSNetConfigRefLabel(
c client.Client,
namespace string,
Expand Down Expand Up @@ -201,9 +197,7 @@ func GetOpenStackNetsMapWithLabel(
return osNetMap, nil
}

//
// GetOsNetCfg -
//
func GetOsNetCfg(
c client.Client,
namespace string,
Expand Down
2 changes: 0 additions & 2 deletions api/v1beta1/common_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,7 @@ type HostStatus struct {
NetworkDataSecretName string `json:"networkDataSecretName"`
}

//
// SyncIPsetStatus - sync relevant information from IPSet to CR status
//
func SyncIPsetStatus(
cond *shared.Condition,
instanceStatus map[string]HostStatus,
Expand Down
2 changes: 0 additions & 2 deletions api/v1beta1/openstackdeploy_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,8 @@ func (r *OpenStackDeploy) ValidateDelete() error {
return nil
}

//
// Validates all NNCPs created by the used osnetcfg to be in condition.Reason == nmstateshared.NodeNetworkConfigurationPolicyConditionSuccessfullyConfigured.
// If not, stop deployment. User can overwrite this via parameter spec.SkipNNCPValidation: true
//
func (r *OpenStackDeploy) validateNNCP() error {

// 1) get the osctlplane of the namespace (right now there can only be one)
Expand Down
Loading

0 comments on commit 3d4161c

Please sign in to comment.