Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing linting tasks #67

Merged
merged 5 commits into from
Nov 3, 2022
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions .github/workflows/code-style.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ jobs:
- tool: gofmt
options: -s
- tool: goimports
importpath: golang.org/x/tools/cmd/goimports
importpath: golang.org/x/tools/cmd/goimports@latest

steps:
- name: Set up Go 1.17.x
- name: Set up Go 1.18.x
uses: actions/setup-go@v2
with:
go-version: 1.17.x
go-version: 1.18.x
id: go

- name: Check out code
Expand All @@ -53,7 +53,7 @@ jobs:
if: ${{ matrix.importpath != '' }}
run: |
cd $(mktemp -d)
GO111MODULE=on go get ${{ matrix.importpath }}
GO111MODULE=on go install ${{ matrix.importpath }}

- name: ${{ matrix.tool }} ${{ matrix.options }}
shell: bash
Expand Down Expand Up @@ -90,10 +90,10 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Set up Go 1.17.x
- name: Set up Go 1.18.x
uses: actions/setup-go@v2
with:
go-version: 1.17.x
go-version: 1.18.x
id: go

- name: Check out code
Expand All @@ -111,7 +111,7 @@ jobs:
echo '::endgroup::'

echo '::group:: Installing misspell ... https://github.com/client9/misspell'
go get github.com/client9/misspell/cmd/misspell
go install github.com/client9/misspell/cmd/misspell@latest
echo '::endgroup::'

echo '::group:: Installing woke ... https://github.com/get-woke/woke'
Expand Down
3 changes: 3 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,6 @@ issues:
- text: "ST1000: at least one file in a package should have a package comment"
linters:
- stylecheck
- text: "var-naming: don't use leading k in Go names"
linters:
- revive
15 changes: 15 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -366,5 +366,20 @@ catalog-generate: opm ## Generate a catalog/index Dockerfile.
catalog-push: ## Push a catalog image.
$(MAKE) docker-push IMG=$(CATALOG_IMG)

##@ Code Style

GOLANGCI-LINT = $(PROJECT_PATH)/bin/golangci-lint

.PHONY: run-lint
run-lint: $(GOLANGCI-LINT) ## Run lint tests
$(GOLANGCI-LINT) run

$(GOLANGCI-LINT):
curl -sSfL https://github.com/raw/golangci/golangci-lint/master/install.sh | sh -s -- -b $(PROJECT_PATH)/bin v1.50.1

.PHONY: golangci-lint
golangci-lint: $(GOLANGCI-LINT) ## Download golangci-lint locally if necessary.


# Include last to avoid changing MAKEFILE_LIST used above
include ./make/*.mk
3 changes: 2 additions & 1 deletion controllers/helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ import (
"bytes"
"context"
"errors"
kuadrantv1beta1 "github.com/kuadrant/kuadrant-operator/api/v1beta1"
"io"
"os"
"path/filepath"
"time"

kuadrantv1beta1 "github.com/kuadrant/kuadrant-operator/api/v1beta1"

"github.com/google/uuid"
. "github.com/onsi/gomega"
v1 "k8s.io/api/core/v1"
Expand Down
9 changes: 5 additions & 4 deletions controllers/kuadrant_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"context"
"encoding/json"
"fmt"

"google.golang.org/protobuf/types/known/structpb"
istiomeshv1alpha1 "istio.io/api/mesh/v1alpha1"

Expand Down Expand Up @@ -380,26 +381,26 @@ func meshConfigFromStruct(structure *structpb.Struct) (*istiomeshv1alpha1.MeshCo
if structure == nil {
return &istiomeshv1alpha1.MeshConfig{}, nil
}
meshConfigJson, err := structure.MarshalJSON()
meshConfigJSON, err := structure.MarshalJSON()
if err != nil {
return nil, err
}
meshConfig := &istiomeshv1alpha1.MeshConfig{}
if err = json.Unmarshal(meshConfigJson, meshConfig); err != nil {
if err = json.Unmarshal(meshConfigJSON, meshConfig); err != nil {
return nil, err
}

return meshConfig, nil
}

func meshConfigToStruct(config *istiomeshv1alpha1.MeshConfig) (*structpb.Struct, error) {
configJson, err := json.Marshal(config)
configJSON, err := json.Marshal(config)
if err != nil {
return nil, err
}
configStruct := &structpb.Struct{}

if err = configStruct.UnmarshalJSON(configJson); err != nil {
if err = configStruct.UnmarshalJSON(configJSON); err != nil {
return nil, err
}
return configStruct, nil
Expand Down
6 changes: 3 additions & 3 deletions pkg/common/wasm_shim_image.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package common

const (
DEFAULT_WASMSHIM_IMAGE_VERSION = "oci://quay.io/kuadrant/wasm-shim:latest"
WASM_SHIM_IMAGE_ENV_NAME = "RELATED_IMAGE_WASMSHIM"
defaultWasmShimImageVersion = "oci://quay.io/kuadrant/wasm-shim:latest"
wasmShimImageEnvName = "RELATED_IMAGE_WASMSHIM"
)

func GetWASMShimImageVersion() string {
return FetchEnv(WASM_SHIM_IMAGE_ENV_NAME, DEFAULT_WASMSHIM_IMAGE_VERSION)
return FetchEnv(wasmShimImageEnvName, defaultWasmShimImageVersion)
}
3 changes: 2 additions & 1 deletion pkg/common/yaml_decoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package common
import (
"bytes"
"context"
"errors"
"io"
"io/ioutil"

Expand All @@ -26,7 +27,7 @@ func DecodeFile(ctx context.Context, fileData []byte, scheme *runtime.Scheme, cb
for {
n, err := docDecoder.Read(buf)
if err != nil {
if err == io.EOF {
if errors.Is(io.EOF, err) {
break
}
return err
Expand Down