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
  •  
  •  
  •  
6 changes: 0 additions & 6 deletions .custom-gcl.yml

This file was deleted.

147 changes: 88 additions & 59 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,64 +1,93 @@
version: "2"
run:
timeout: 10m
allow-parallel-runners: true
output:
sort-results: true
severity:
default-severity: error
issues:
exclude-rules:
- linters:
- staticcheck
text: "SA1019: src.Spec.NodeCount is deprecated: Use Replicas instead. NodeCount will be dropped in the next api release"
- linters:
- staticcheck
text: "SA1019: in.Spec.NodeCount is deprecated: Use Replicas instead. NodeCount will be dropped in the next api release."
- linters:
- staticcheck
text: "SA1019: hcp.Status.Version is deprecated: Use versionStatus.desired.version instead."
- linters:
- staticcheck
text: "SA1019: hcp.Status.ReleaseImage is deprecated: Use versionStatus.desired.image instead."
- linters:
- staticcheck
text: "SA1019: hcp.Status.LastReleaseImageTransitionTime is deprecated"
- linters:
- staticcheck
text: "SA1019: in.Status.DNSName is deprecated"
- linters:
- staticcheck
text: "SA1019: infra.Status.Platform is deprecated: Use platformStatus.type instead"
- linters:
- unused
text: "const `tuningConfigKey` is unused"
linters:
enable:
- errcheck
- gci
- gosimple
- govet
- ineffassign
- misspell
- staticcheck
- unused
linters-settings:
gci:
sections:
- standard
- dot
- prefix(github.com/openshift/hypershift)
- prefix(github.com/openshift)
- prefix(github.com/aws)
- prefix(github.com/Azure)
- prefix(k8s.io)
- prefix(sigs.k8s.io)
- default
custom-order: true
misspell:
# The use of US spelling over other English spellings, like UK, is inline with the OpenShift conventions:
# https://github.com/openshift/enhancements/blob/master/CONVENTIONS.md#terminology-grammar-and-spelling
locale: US
# Typos to ignore.
# Should be in lower case.
ignore-words:
- nto
settings:
misspell:
# The use of US spelling over other English spellings, like UK, is inline with the OpenShift conventions:
# https://github.com/openshift/enhancements/blob/master/CONVENTIONS.md#terminology-grammar-and-spelling
locale: US
# Typos to ignore.
# Should be in lower case.
ignore-rules:
- nto
exclusions:
warn-unused: true
generated: lax
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
rules:
- linters:
- staticcheck
text: 'SA1019: hcp.Status.Version is deprecated: Use versionStatus.desired.version instead.'
- linters:
- staticcheck
text: 'SA1019: hcp.Status.ReleaseImage is deprecated: Use versionStatus.desired.image instead.'
- linters:
- staticcheck
text: 'SA1019: hcp.Status.LastReleaseImageTransitionTime is deprecated'
- linters:
- staticcheck
text: 'SA1019: infra.Status.Platform is deprecated: Use platformStatus.type instead'
- linters:
- unused
text: const tuningConfigKey is unused
- linters:
- staticcheck
text: 'ST1001: should not use dot imports'
source: 'github.com/onsi/gomega'
- linters:
- staticcheck
text: 'ST1005: error strings should not be capitalized'
source: 'Konnectivity'
- linters:
- staticcheck
text: 'ST1019'
path: 'test/e2e/util/(util|kubevirt)\.go$'
- linters:
- staticcheck
text: 'ST1019'
path: 'support/util/util_test\.go$'
- linters:
- staticcheck
text: 'QF1008'
- linters:
- staticcheck
text: 'QF1007'
- linters:
- staticcheck
text: 'QF1001'
paths:
- third_party$
- builtin$
- examples$
severity:
default: error
formatters:
enable:
- gci
settings:
gci:
sections:
- standard
- dot
- prefix(github.com/openshift/hypershift)
- prefix(github.com/openshift)
- prefix(github.com/aws)
- prefix(github.com/Azure)
- prefix(k8s.io)
- prefix(sigs.k8s.io)
- default
custom-order: true
exclusions:
warn-unused: true
generated: lax
paths:
- third_party$
- builtin$
- examples$
43 changes: 21 additions & 22 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ BIN_DIR=bin
TOOLS_BIN_DIR := $(TOOLS_DIR)/$(BIN_DIR)
CONTROLLER_GEN := $(abspath $(TOOLS_BIN_DIR)/controller-gen)
CODE_GEN := $(abspath $(TOOLS_BIN_DIR)/codegen)
GOLANGCI_LINT := $(abspath $(TOOLS_BIN_DIR)/golangci-lint)
GOLANGCI_KUBEAPILINTER := $(abspath $(TOOLS_BIN_DIR)/golangci-kube-api-linter)
STATICCHECK := $(abspath $(TOOLS_BIN_DIR)/staticcheck)
GENAPIDOCS := $(abspath $(TOOLS_BIN_DIR)/gen-crd-api-reference-docs)
MOCKGEN := $(abspath $(TOOLS_BIN_DIR)/mockgen)
Expand Down Expand Up @@ -68,19 +66,21 @@ build: hypershift-operator control-plane-operator control-plane-pki-operator kar
.PHONY: update
update: api-deps workspace-sync deps api api-docs clients

$(GOLANGCI_LINT):$(TOOLS_DIR)/go.mod # Build golangci-lint from tools folder.
# Hack to install kuibe api linter plugin until https://github.com/kubernetes-sigs/kube-api-linter/pull/78 is merged
@echo 'package main; import (_ "sigs.k8s.io/kube-api-linter")' > hack/tools/vendor/github.com/golangci/golangci-lint/cmd/golangci-lint/plugins.go
cd $(TOOLS_DIR); GO111MODULE=on GOFLAGS=-mod=vendor GOWORK=off go build -tags=tools -o $(GOLANGCI_LINT) github.com/golangci/golangci-lint/cmd/golangci-lint
git checkout hack/tools/vendor/github.com/golangci/golangci-lint/cmd/golangci-lint/plugins.go
GOLANGCI_LINT := $(abspath $(TOOLS_BIN_DIR)/golangci-lint)
$(GOLANGCI_LINT): $(TOOLS_DIR)/go.mod # Build golangci-lint from tools folder.
cd $(TOOLS_DIR); $(GO) build -tags=tools -o $(GOLANGCI_LINT) github.com/golangci/golangci-lint/v2/cmd/golangci-lint

KUBEAPILINTER_PLUGIN := $(abspath $(TOOLS_BIN_DIR)/kube-api-linter.so)
$(KUBEAPILINTER_PLUGIN): $(TOOLS_DIR)/go.mod # Build kube-api-linter as Go plugin
cd $(TOOLS_DIR); CGO_ENABLED=1 $(GO) build -buildmode=plugin -o $(KUBEAPILINTER_PLUGIN) sigs.k8s.io/kube-api-linter/pkg/plugin

.PHONY: lint
lint: $(GOLANGCI_LINT)
$(GOLANGCI_LINT) run --config ./.golangci.yml -v
cd api && $(GOLANGCI_LINT) run --config ./.golangci.yml -v
lint: generate $(GOLANGCI_LINT) $(KUBEAPILINTER_PLUGIN)
$(GOLANGCI_LINT) run --config ./.golangci.yml --modules-download-mode=readonly -v
cd api && $(GOLANGCI_LINT) run --config ./.golangci.yml --modules-download-mode=readonly -v

.PHONY: lint-fix
lint-fix: $(GOLANGCI_LINT)
lint-fix: generate $(GOLANGCI_LINT) $(KUBEAPILINTER_PLUGIN)
$(GOLANGCI_LINT) run --config ./.golangci.yml --fix -v
cd api && $(GOLANGCI_LINT) run --config ./.golangci.yml --fix -v

Expand All @@ -93,25 +93,24 @@ verify: generate update staticcheck fmt vet verify-codespell lint cpo-container-
$(if $(strip $(STATUS)),$(error untracked files detected: ${STATUS}))

$(CONTROLLER_GEN): $(TOOLS_DIR)/go.mod # Build controller-gen from tools folder.
cd $(TOOLS_DIR); GO111MODULE=on GOFLAGS=-mod=vendor GOWORK=off go build -tags=tools -o $(BIN_DIR)/controller-gen sigs.k8s.io/controller-tools/cmd/controller-gen
cd $(TOOLS_DIR); $(GO) build -tags=tools -o $(BIN_DIR)/controller-gen sigs.k8s.io/controller-tools/cmd/controller-gen

$(CODE_GEN): $(TOOLS_DIR)/go.mod # Build code-gen from tools folder.
cd $(TOOLS_DIR); GO111MODULE=on GOFLAGS=-mod=vendor GOWORK=off go build -tags=tools -o $(BIN_DIR)/codegen github.com/openshift/api/tools/codegen/cmd

cd $(TOOLS_DIR); $(GO) build -tags=tools -o $(BIN_DIR)/codegen github.com/openshift/api/tools/codegen/cmd

$(STATICCHECK): $(TOOLS_DIR)/go.mod # Build staticcheck from tools folder.
cd $(TOOLS_DIR); GO111MODULE=on GOFLAGS=-mod=vendor GOWORK=off go build -tags=tools -o $(BIN_DIR)/staticcheck honnef.co/go/tools/cmd/staticcheck
cd $(TOOLS_DIR); $(GO) build -tags=tools -o $(BIN_DIR)/staticcheck honnef.co/go/tools/cmd/staticcheck

$(GENAPIDOCS): $(TOOLS_DIR)/go.mod
cd $(TOOLS_DIR); GO111MODULE=on GOFLAGS=-mod=vendor GOWORK=off go build -tags=tools -o $(GENAPIDOCS) github.com/ahmetb/gen-crd-api-reference-docs
cd $(TOOLS_DIR); $(GO) build -tags=tools -o $(GENAPIDOCS) github.com/ahmetb/gen-crd-api-reference-docs

$(MOCKGEN): ${TOOLS_DIR}/go.mod
cd $(TOOLS_DIR); GO111MODULE=on GOFLAGS=-mod=vendor GOWORK=off go build -tags=tools -o $(BIN_DIR)/mockgen go.uber.org/mock/mockgen
cd $(TOOLS_DIR); $(GO) build -tags=tools -o $(BIN_DIR)/mockgen go.uber.org/mock/mockgen


#.PHONY: generate
generate: $(MOCKGEN)
GO111MODULE=on GOFLAGS=-mod=vendor GOWORK=off go generate ./...
$(GO) generate ./...

# Compile all tests
.PHONY: tests
Expand Down Expand Up @@ -181,9 +180,9 @@ hypershift-api: $(CONTROLLER_GEN) $(CODE_GEN)
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./api/..."

# These consolidate with the 3 steps used to generate CRDs by openshift/api.
$(CODE_GEN) empty-partial-schemas --base-dir ./api/hypershift/v1beta1
$(CODE_GEN) schemapatch --base-dir ./api/hypershift/v1beta1
$(CODE_GEN) crd-manifest-merge --manifest-merge:payload-manifest-path ./api/hypershift/v1beta1/featuregates --base-dir ./api/hypershift/v1beta1
(cd ./api && $(CODE_GEN) empty-partial-schemas)
(cd ./api && $(CODE_GEN) schemapatch)
(cd ./api && $(CODE_GEN) crd-manifest-merge --manifest-merge:payload-manifest-path ./hypershift/v1beta1/featuregates)

# Move final CRDs to the install folder.
mv ./api/hypershift/v1beta1/zz_generated.crd-manifests cmd/install/assets/hypershift-operator/
Expand Down Expand Up @@ -422,4 +421,4 @@ $(GITLINT): $(TOOLS_DIR)/go.mod
mkdir -p $(TOOLS_BIN_DIR)/$(GITLINT_DIST_DIR); \
pip install --target=$(TOOLS_BIN_DIR)/$(GITLINT_DIST_DIR) gitlint==$(GITLINT_VER) --upgrade; \
cp $(TOOLS_BIN_DIR)/$(GITLINT_DIST_DIR)/bin/$(GITLINT_BIN) $(TOOLS_BIN_DIR)/$(GITLINT_DIST_DIR)/$(GITLINT_BIN)-bin; \
chmod +x $(TOOLS_BIN_DIR)/$(GITLINT_DIST_DIR)/$(GITLINT_BIN)-bin;
chmod +x $(TOOLS_BIN_DIR)/$(GITLINT_DIST_DIR)/$(GITLINT_BIN)-bin;
Loading