Skip to content

Commit

Permalink
Merge pull request #49 from gibizer/lint-improvements
Browse files Browse the repository at this point in the history
Lint improvements
  • Loading branch information
openshift-merge-robot committed Dec 9, 2022
2 parents 84274c0 + 842f3c0 commit 7333ce4
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 9 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/golangci-lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,16 @@ jobs:
with:
version: latest
args: --timeout 5m

operator-lint:
name: operator-lint
runs-on: ubuntu-latest
steps:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.18.x
- name: Checkout project code
uses: actions/checkout@v2
- name: Run operator-lint
run: make operator-lint
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,6 @@ config/manager/kustomization.yaml
# Common CI tools repository
CI_TOOLS_REPO
*~
# generated workspace file
go.work
go.work.sum
31 changes: 24 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,13 @@ fmt: ## Run go fmt against code.
go fmt ./...

.PHONY: vet
vet: ## Run go vet against code.
vet: gowork ## Run go vet against code.
go vet ./...
go vet ./api/...

.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) -p path)" go test ./... ./api/... -coverprofile cover.out

##@ Build

Expand Down Expand Up @@ -253,20 +254,36 @@ get-ci-tools:

# Run go fmt against code
gofmt: get-ci-tools
$(CI_TOOLS_REPO_DIR)/test-runner/gofmt.sh
GOWORK=off $(CI_TOOLS_REPO_DIR)/test-runner/gofmt.sh
GOWORK=off $(CI_TOOLS_REPO_DIR)/test-runner/gofmt.sh ./api

# Run go vet against code
govet: get-ci-tools
$(CI_TOOLS_REPO_DIR)/test-runner/govet.sh
GOWORK=off $(CI_TOOLS_REPO_DIR)/test-runner/govet.sh
GOWORK=off $(CI_TOOLS_REPO_DIR)/test-runner/govet.sh ./api

# Run go test against code
gotest: get-ci-tools
$(CI_TOOLS_REPO_DIR)/test-runner/gotest.sh
GOWORK=off $(CI_TOOLS_REPO_DIR)/test-runner/gotest.sh
GOWORK=off $(CI_TOOLS_REPO_DIR)/test-runner/gotest.sh ./api

# Run golangci-lint test against code
golangci: get-ci-tools
$(CI_TOOLS_REPO_DIR)/test-runner/golangci.sh
GOWORK=off $(CI_TOOLS_REPO_DIR)/test-runner/golangci.sh
GOWORK=off $(CI_TOOLS_REPO_DIR)/test-runner/golangci.sh ./api

# Run go lint against code
golint: get-ci-tools
PATH=$(GOBIN):$(PATH); $(CI_TOOLS_REPO_DIR)/test-runner/golint.sh
GOWORK=off PATH=$(GOBIN):$(PATH); $(CI_TOOLS_REPO_DIR)/test-runner/golint.sh
GOWORK=off PATH=$(GOBIN):$(PATH); $(CI_TOOLS_REPO_DIR)/test-runner/golint.sh ./api

.PHONY: gowork
gowork: ## Generate go.work file to support our multi module repository
test -f go.work || go work init
go work use .
go work use ./api

.PHONY: operator-lint
operator-lint: gowork ## Runs operator-lint
GOBIN=$(LOCALBIN) go install github.com/gibizer/operator-lint@v0.1.0
go vet -vettool=$(LOCALBIN)/operator-lint ./... ./api/...
2 changes: 2 additions & 0 deletions api/bases/neutron.openstack.org_neutronapis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,9 @@ spec:
to register in neutron
type: string
required:
- databaseInstance
- rabbitMqClusterName
- secret
type: object
status:
description: NeutronAPIStatus defines the observed state of NeutronAPI
Expand Down
4 changes: 2 additions & 2 deletions api/v1beta1/neutronapi_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ type NeutronAPISpec struct {
// MariaDB instance name
// Right now required by the maridb-operator to get the credentials from the instance to create the DB
// Might not be required in future
DatabaseInstance string `json:"databaseInstance,omitempty"`
DatabaseInstance string `json:"databaseInstance"`

// +kubebuilder:validation:Optional
// +kubebuilder:default=neutron
Expand All @@ -80,7 +80,7 @@ type NeutronAPISpec struct {

// +kubebuilder:validation:Required
// Secret containing OpenStack password information for neutron NeutronPassword NovaPassword
Secret string `json:"secret,omitempty"`
Secret string `json:"secret"`

// +kubebuilder:validation:Optional
// +kubebuilder:default={database: NeutronDatabasePassword, service: NeutronPassword, novaservice: NovaPassword}
Expand Down
2 changes: 2 additions & 0 deletions config/crd/bases/neutron.openstack.org_neutronapis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,9 @@ spec:
to register in neutron
type: string
required:
- databaseInstance
- rabbitMqClusterName
- secret
type: object
status:
description: NeutronAPIStatus defines the observed state of NeutronAPI
Expand Down

0 comments on commit 7333ce4

Please sign in to comment.