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

use megalinter #98

Closed
wants to merge 1 commit into from
Closed
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
50 changes: 50 additions & 0 deletions .cspell.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// cSpell Settings
{
// Version of the setting file. Always 0.2
"version": "0.2",
// language - current active spelling language
"language": "en",
// words - list of words to be always considered correct
"words": [
"apiextensions",
"bucketaccess",
"bucketaccessclass",
"bucketaccessclasses",
"bucketaccesses",
"bucketclaim",
"bucketclaims",
"bucketclass",
"bucketclasses",
"buildroot",
"buildx",
"CDPATH",
"cloudbuild",
"codegen",
"cosi",
"crds",
"devel",
"distroless",
"ghash",
"GOARCH",
"golangci",
"hadolint",
"healthz",
"HIGHCPU",
"klog",
"kubebuilder",
"kustomization",
"nonroot",
"objectstorage",
"readyz",
"rolebinding",
"serviceaccount",
"serviceaccounts",
"shellcheck",
],
// flagWords - list of words to be always considered incorrect
// This is useful for offensive words and common spelling errors.
// For example "hte" should be "the"
"flagWords": [
"hte"
]
}
46 changes: 46 additions & 0 deletions .github/workflows/mega-linter-action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: MegaLinter

on:
pull_request:
branches:
- main
- master
- monorepo
- release-*

concurrency:
group: ${{ github.ref }}-${{ github.workflow }}
cancel-in-progress: true

permissions:
contents: read

jobs:
megalinter:
name: MegaLinter
runs-on: ubuntu-latest
steps:

- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Run MegaLinter
uses: oxsecurity/megalinter@v8 # More info at https://megalinter.io/flavors/
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SECURED_ENV_VARIABLES: GITHUB_TOKEN # env vars hidden from sub-linters
VALIDATE_ALL_CODEBASE: true
FAIL_IF_MISSING_LINTER_IN_FLAVOR: true # if action can't run a desired linter, return err
SHOW_ELAPSED_TIME: true # for debugging any megalinter issues
PRINT_ALL_FILES: true # for debugging any megalinter issues

- name: Upload MegaLinter artifacts
uses: actions/upload-artifact@v4
if: success() || failure()
with:
name: MegaLinter reports
path: |
megalinter-reports
mega-linter.log
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
*.tmp
.DS_Store
.build
.cache
*.swp
release-tools
.idea
travis.yml

megalinter-reports/
mega-linter.log
*megalinter*.txt
18 changes: 18 additions & 0 deletions .mega-linter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Configuration file for MegaLinter
# See all available variables at https://megalinter.io/configuration/ and in linters documentation

ENABLE_LINTERS: # all other linters will be disabled by default
- BASH_SHELLCHECK
- YAML_YAMLLINT
- DOCKERFILE_HADOLINT
- SPELL_CSPELL

DISABLE_LINTERS:
# golangci-lint can't lint the whole project and needs called one-by-one for each submodule
- GO_GOLANGCI_LINT

FILTER_REGEX_INCLUDE: '(\.*\.go)'

FILTER_REGEX_EXCLUDE: '(\.github/workflows|.*/vendor|pkg/imported-.*)'

# MARKDOWN_FILTER_REGEX_EXCLUDE: '(license\.md|docs/licenses)'
6 changes: 0 additions & 6 deletions .prow.sh

This file was deleted.

7 changes: 7 additions & 0 deletions .yamllint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
extends: default
rules:
document-start: disable # don't care if doc doesn't start with ---
line-length:
level: warning
indentation: # kubebuilder generator uses non-recommended indentation, but it's consistent
indent-sequences: consistent
4 changes: 2 additions & 2 deletions client/apis/objectstorage/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ type BucketClaimSpec struct {
}

type BucketClaimStatus struct {
// BucketReady indicates that the bucket is ready for consumpotion
// BucketReady indicates that the bucket is ready for consumption
// by workloads
BucketReady bool `json:"bucketReady"`

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

// ServiceAccountName is the name of the serviceAccount that COSI will map
Expand Down
2 changes: 1 addition & 1 deletion client/config/crd/objectstorage.k8s.io_bucketaccesses.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ spec:
CredentialsSecretName is the name of the secret that COSI should populate
with the credentials. If a secret by this name already exists, then it is
assumed that credentials have already been generated. It is not overridden.
This secret is deleted when the BucketAccess is delted.
This secret is deleted when the BucketAccess is deleted.
type: string
protocol:
description: |-
Expand Down
2 changes: 1 addition & 1 deletion client/config/crd/objectstorage.k8s.io_bucketclaims.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ spec:
type: string
bucketReady:
description: |-
BucketReady indicates that the bucket is ready for consumpotion
BucketReady indicates that the bucket is ready for consumption
by workloads
type: boolean
required:
Expand Down
2 changes: 2 additions & 0 deletions client/hack/update-codegen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ set -o errexit
set -o nounset
set -o pipefail

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

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

kube::codegen::gen_helpers \
Expand Down
5 changes: 4 additions & 1 deletion controller/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ COPY internal/ internal/
COPY controller/go.mod controller/go.mod
COPY controller/go.sum controller/go.sum

RUN cd controller && go mod download
WORKDIR /buildroot/controller
RUN go mod download

WORKDIR /buildroot

COPY controller/cmd/ controller/cmd/
COPY controller/pkg/ controller/pkg/
Expand Down
2 changes: 1 addition & 1 deletion controller/resources/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ spec:
image: gcr.io/k8s-staging-sig-storage/objectstorage-controller:v20221027-v0.1.1-8-g300019f
imagePullPolicy: Always
args:
- "--v=5"
- "--v=5"
37 changes: 18 additions & 19 deletions controller/resources/rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,21 @@ metadata:
app.kubernetes.io/version: main
app.kubernetes.io/name: container-object-storage-interface-controller
rules:
- apiGroups: ["objectstorage.k8s.io"]
resources: ["bucketclaims", "bucketaccesses", "bucketclaims/status", "bucketaccesses/status"]
verbs: ["get", "list", "watch", "update"]
- apiGroups: ["objectstorage.k8s.io"]
resources: ["buckets"]
verbs: ["get", "list", "watch", "update", "create", "delete"]
- apiGroups: ["objectstorage.k8s.io"]
resources: ["bucketclasses","bucketaccessclasses"]
verbs: ["get", "list"]
- apiGroups: [""]
resources: ["events"]
verbs: ["list", "watch", "create", "update", "patch"]
- apiGroups: [""]
resources: ["configmaps", "serviceaccounts"]
verbs: ["list", "get"]

- apiGroups: ["objectstorage.k8s.io"]
resources: ["bucketclaims", "bucketaccesses", "bucketclaims/status", "bucketaccesses/status"]
verbs: ["get", "list", "watch", "update"]
- apiGroups: ["objectstorage.k8s.io"]
resources: ["buckets"]
verbs: ["get", "list", "watch", "update", "create", "delete"]
- apiGroups: ["objectstorage.k8s.io"]
resources: ["bucketclasses", "bucketaccessclasses"]
verbs: ["get", "list"]
- apiGroups: [""]
resources: ["events"]
verbs: ["list", "watch", "create", "update", "patch"]
- apiGroups: [""]
resources: ["configmaps", "serviceaccounts"]
verbs: ["list", "get"]
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
Expand Down Expand Up @@ -57,9 +56,9 @@ metadata:
app.kubernetes.io/version: main
app.kubernetes.io/name: container-object-storage-interface-controller
rules:
- apiGroups: ["coordination.k8s.io"]
resources: ["leases"]
verbs: ["get", "watch", "list", "delete", "update", "create"]
- apiGroups: ["coordination.k8s.io"]
resources: ["leases"]
verbs: ["get", "watch", "list", "delete", "update", "create"]
---
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
Expand Down
5 changes: 4 additions & 1 deletion hack/Dockerfile.in
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ COPY internal/ internal/
COPY {{COMPONENT}}/go.mod {{COMPONENT}}/go.mod
COPY {{COMPONENT}}/go.sum {{COMPONENT}}/go.sum

RUN cd {{COMPONENT}} && go mod download
WORKDIR /buildroot/{{COMPONENT}}
RUN go mod download

WORKDIR /buildroot

COPY {{COMPONENT}}/cmd/ {{COMPONENT}}/cmd/
COPY {{COMPONENT}}/pkg/ {{COMPONENT}}/pkg/
Expand Down
5 changes: 4 additions & 1 deletion sidecar/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ COPY internal/ internal/
COPY sidecar/go.mod sidecar/go.mod
COPY sidecar/go.sum sidecar/go.sum

RUN cd sidecar && go mod download
WORKDIR /buildroot/sidecar
RUN go mod download

WORKDIR /buildroot

COPY sidecar/cmd/ sidecar/cmd/
COPY sidecar/pkg/ sidecar/pkg/
Expand Down