Skip to content
This repository was archived by the owner on Dec 6, 2024. It is now read-only.

Commit 15f2aa9

Browse files
committed
use megalinter
Add megalinter config and tooling to run megalinter. Signed-off-by: Blaine Gardner <[email protected]>
1 parent e9d5dfb commit 15f2aa9

15 files changed

+160
-34
lines changed

Diff for: .cspell.json

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
// cSpell Settings
2+
{
3+
// Version of the setting file. Always 0.2
4+
"version": "0.2",
5+
// language - current active spelling language
6+
"language": "en",
7+
// words - list of words to be always considered correct
8+
"words": [
9+
"apiextensions",
10+
"bucketaccess",
11+
"bucketaccessclass",
12+
"bucketaccessclasses",
13+
"bucketaccesses",
14+
"bucketclaim",
15+
"bucketclaims",
16+
"bucketclass",
17+
"bucketclasses",
18+
"buildroot",
19+
"buildx",
20+
"CDPATH",
21+
"cloudbuild",
22+
"codegen",
23+
"cosi",
24+
"crds",
25+
"devel",
26+
"distroless",
27+
"ghash",
28+
"GOARCH",
29+
"golangci",
30+
"hadolint",
31+
"healthz",
32+
"HIGHCPU",
33+
"klog",
34+
"kubebuilder",
35+
"kustomization",
36+
"nonroot",
37+
"objectstorage",
38+
"readyz",
39+
"rolebinding",
40+
"serviceaccount",
41+
"serviceaccounts",
42+
"shellcheck",
43+
],
44+
// flagWords - list of words to be always considered incorrect
45+
// This is useful for offensive words and common spelling errors.
46+
// For example "hte" should be "the"
47+
"flagWords": [
48+
"hte"
49+
]
50+
}

Diff for: .github/workflows/mega-linter-action.yaml

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: MegaLinter
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
- master
8+
- monorepo
9+
- release-*
10+
11+
concurrency:
12+
group: ${{ github.ref }}-${{ github.workflow }}
13+
cancel-in-progress: true
14+
15+
permissions:
16+
contents: read
17+
18+
jobs:
19+
megalinter:
20+
name: MegaLinter
21+
runs-on: ubuntu-latest
22+
steps:
23+
24+
- name: Checkout Code
25+
uses: actions/checkout@v4
26+
with:
27+
fetch-depth: 0
28+
29+
- name: Run MegaLinter
30+
uses: oxsecurity/megalinter@v8 # More info at https://megalinter.io/flavors/
31+
env:
32+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
33+
SECURED_ENV_VARIABLES: GITHUB_TOKEN # env vars hidden from sub-linters
34+
VALIDATE_ALL_CODEBASE: true
35+
FAIL_IF_MISSING_LINTER_IN_FLAVOR: true # if action can't run a desired linter, return err
36+
SHOW_ELAPSED_TIME: true # for debugging any megalinter issues
37+
PRINT_ALL_FILES: true # for debugging any megalinter issues
38+
39+
- name: Upload MegaLinter artifacts
40+
uses: actions/upload-artifact@v4
41+
if: success() || failure()
42+
with:
43+
name: MegaLinter reports
44+
path: |
45+
megalinter-reports
46+
mega-linter.log

Diff for: .gitignore

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
*.tmp
22
.DS_Store
33
.build
4+
.cache
45
*.swp
56
release-tools
67
.idea
78
travis.yml
8-
9+
megalinter-reports/
10+
mega-linter.log
11+
*megalinter*.txt

Diff for: .mega-linter.yml

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Configuration file for MegaLinter
2+
# See all available variables at https://megalinter.io/configuration/ and in linters documentation
3+
4+
ENABLE_LINTERS: # all other linters will be disabled by default
5+
- BASH_SHELLCHECK
6+
- YAML_YAMLLINT
7+
- DOCKERFILE_HADOLINT
8+
- SPELL_CSPELL
9+
10+
DISABLE_LINTERS:
11+
# golangci-lint can't lint the whole project and needs called one-by-one for each submodule
12+
- GO_GOLANGCI_LINT
13+
14+
FILTER_REGEX_EXCLUDE: '(\.github/workflows|.*/vendor|pkg/imported-.*)'
15+
16+
# MARKDOWN_FILTER_REGEX_EXCLUDE: '(license\.md|docs/licenses)'

Diff for: .prow.sh

-6
This file was deleted.

Diff for: .yamllint.yml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
extends: default
2+
rules:
3+
document-start: disable # don't care if doc doesn't start with ---
4+
line-length:
5+
level: warning
6+
indentation: # kubebuilder generator uses non-recommended indentation, but it's consistent
7+
indent-sequences: consistent

Diff for: client/apis/objectstorage/v1alpha1/types.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ type BucketClaimSpec struct {
162162
}
163163

164164
type BucketClaimStatus struct {
165-
// BucketReady indicates that the bucket is ready for consumpotion
165+
// BucketReady indicates that the bucket is ready for consumption
166166
// by workloads
167167
BucketReady bool `json:"bucketReady"`
168168

@@ -287,7 +287,7 @@ type BucketAccessSpec struct {
287287
// CredentialsSecretName is the name of the secret that COSI should populate
288288
// with the credentials. If a secret by this name already exists, then it is
289289
// assumed that credentials have already been generated. It is not overridden.
290-
// This secret is deleted when the BucketAccess is delted.
290+
// This secret is deleted when the BucketAccess is deleted.
291291
CredentialsSecretName string `json:"credentialsSecretName"`
292292

293293
// ServiceAccountName is the name of the serviceAccount that COSI will map

Diff for: client/config/crd/objectstorage.k8s.io_bucketaccesses.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ spec:
4848
CredentialsSecretName is the name of the secret that COSI should populate
4949
with the credentials. If a secret by this name already exists, then it is
5050
assumed that credentials have already been generated. It is not overridden.
51-
This secret is deleted when the BucketAccess is delted.
51+
This secret is deleted when the BucketAccess is deleted.
5252
type: string
5353
protocol:
5454
description: |-

Diff for: client/config/crd/objectstorage.k8s.io_bucketclaims.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ spec:
6969
type: string
7070
bucketReady:
7171
description: |-
72-
BucketReady indicates that the bucket is ready for consumpotion
72+
BucketReady indicates that the bucket is ready for consumption
7373
by workloads
7474
type: boolean
7575
required:

Diff for: client/hack/update-codegen.sh

+2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@ set -o errexit
1818
set -o nounset
1919
set -o pipefail
2020

21+
# shellcheck disable=SC1091 # Not following: (with below) this is working to load the right path
2122
CLIENT_ROOT=$(unset CDPATH && cd "$(dirname "${BASH_SOURCE[0]}")"/.. && pwd)
2223

24+
# shellcheck disable=SC1091 # Not following: (with above) this is working to load the right path
2325
source "${CLIENT_ROOT}/vendor/k8s.io/code-generator/kube_codegen.sh"
2426

2527
kube::codegen::gen_helpers \

Diff for: controller/Dockerfile

+4-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ COPY internal/ internal/
1616
COPY controller/go.mod controller/go.mod
1717
COPY controller/go.sum controller/go.sum
1818

19-
RUN cd controller && go mod download
19+
WORKDIR /buildroot/controller
20+
RUN go mod download
21+
22+
WORKDIR /buildroot
2023

2124
COPY controller/cmd/ controller/cmd/
2225
COPY controller/pkg/ controller/pkg/

Diff for: controller/resources/deployment.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,4 @@ spec:
3434
image: gcr.io/k8s-staging-sig-storage/objectstorage-controller:v20221027-v0.1.1-8-g300019f
3535
imagePullPolicy: Always
3636
args:
37-
- "--v=5"
37+
- "--v=5"

Diff for: controller/resources/rbac.yaml

+18-19
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,21 @@ metadata:
1010
app.kubernetes.io/version: main
1111
app.kubernetes.io/name: container-object-storage-interface-controller
1212
rules:
13-
- apiGroups: ["objectstorage.k8s.io"]
14-
resources: ["bucketclaims", "bucketaccesses", "bucketclaims/status", "bucketaccesses/status"]
15-
verbs: ["get", "list", "watch", "update"]
16-
- apiGroups: ["objectstorage.k8s.io"]
17-
resources: ["buckets"]
18-
verbs: ["get", "list", "watch", "update", "create", "delete"]
19-
- apiGroups: ["objectstorage.k8s.io"]
20-
resources: ["bucketclasses","bucketaccessclasses"]
21-
verbs: ["get", "list"]
22-
- apiGroups: [""]
23-
resources: ["events"]
24-
verbs: ["list", "watch", "create", "update", "patch"]
25-
- apiGroups: [""]
26-
resources: ["configmaps", "serviceaccounts"]
27-
verbs: ["list", "get"]
28-
13+
- apiGroups: ["objectstorage.k8s.io"]
14+
resources: ["bucketclaims", "bucketaccesses", "bucketclaims/status", "bucketaccesses/status"]
15+
verbs: ["get", "list", "watch", "update"]
16+
- apiGroups: ["objectstorage.k8s.io"]
17+
resources: ["buckets"]
18+
verbs: ["get", "list", "watch", "update", "create", "delete"]
19+
- apiGroups: ["objectstorage.k8s.io"]
20+
resources: ["bucketclasses", "bucketaccessclasses"]
21+
verbs: ["get", "list"]
22+
- apiGroups: [""]
23+
resources: ["events"]
24+
verbs: ["list", "watch", "create", "update", "patch"]
25+
- apiGroups: [""]
26+
resources: ["configmaps", "serviceaccounts"]
27+
verbs: ["list", "get"]
2928
---
3029
kind: ClusterRoleBinding
3130
apiVersion: rbac.authorization.k8s.io/v1
@@ -57,9 +56,9 @@ metadata:
5756
app.kubernetes.io/version: main
5857
app.kubernetes.io/name: container-object-storage-interface-controller
5958
rules:
60-
- apiGroups: ["coordination.k8s.io"]
61-
resources: ["leases"]
62-
verbs: ["get", "watch", "list", "delete", "update", "create"]
59+
- apiGroups: ["coordination.k8s.io"]
60+
resources: ["leases"]
61+
verbs: ["get", "watch", "list", "delete", "update", "create"]
6362
---
6463
kind: RoleBinding
6564
apiVersion: rbac.authorization.k8s.io/v1

Diff for: hack/Dockerfile.in

+4-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ COPY internal/ internal/
1414
COPY {{COMPONENT}}/go.mod {{COMPONENT}}/go.mod
1515
COPY {{COMPONENT}}/go.sum {{COMPONENT}}/go.sum
1616

17-
RUN cd {{COMPONENT}} && go mod download
17+
WORKDIR /buildroot/{{COMPONENT}}
18+
RUN go mod download
19+
20+
WORKDIR /buildroot
1821

1922
COPY {{COMPONENT}}/cmd/ {{COMPONENT}}/cmd/
2023
COPY {{COMPONENT}}/pkg/ {{COMPONENT}}/pkg/

Diff for: sidecar/Dockerfile

+4-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ COPY internal/ internal/
1616
COPY sidecar/go.mod sidecar/go.mod
1717
COPY sidecar/go.sum sidecar/go.sum
1818

19-
RUN cd sidecar && go mod download
19+
WORKDIR /buildroot/sidecar
20+
RUN go mod download
21+
22+
WORKDIR /buildroot
2023

2124
COPY sidecar/cmd/ sidecar/cmd/
2225
COPY sidecar/pkg/ sidecar/pkg/

0 commit comments

Comments
 (0)