Skip to content
This repository was archived by the owner on Dec 2, 2025. It is now read-only.
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
4 changes: 3 additions & 1 deletion .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: tests
name: tests and linting

on:
pull_request:
Expand Down Expand Up @@ -32,5 +32,7 @@ jobs:
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Run lint
run: make lint
- name: Run tests
run: make test
120 changes: 120 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
run:
go: "1.21"
timeout: 10m
tests: false
allow-parallel-runners: true
skip-dirs:
- "./*/mock"
skip-files:
- "pkg/providers/fakes/fake_provider.go"

linters-settings:
funlen:
lines: 150
statements: 60
staticcheck:
go: "1.21"
stylecheck:
go: "1.21"
cyclop:
max-complexity: 20
skip-tests: true
gosec:
exclude-generated: true
lll:
line-length: 150
misspell:
locale: US
govet:
check-shadowing: true
nolintlint:
allow-unused: false
require-explanation: true
require-specific: false
varnamelen:
ignore-names:
- err
- wg
- fs
- id
- vm
- ns
- ip

issues:
max-same-issues: 0
max-issues-per-linter: 0
exclude-rules:
- text: "should not use dot imports|don't use an underscore in package name"
linters:
- golint
- source: "https://"
linters:
- lll
- path: pkg/defaults/
linters:
- lll
- path: _test\.go
linters:
- goerr113
- gocyclo
- errcheck
- gosec
- dupl
- funlen
- scopelint
- testpackage
- goconst
- godox
- path: internal/version/
linters:
- gochecknoglobals
- path: internal/command/
linters:
- exhaustivestruct
- lll
- wrapcheck
- source: "// .* #\\d+"
linters:
- godox
- path: test/e2e/
linters:
- goerr113
- gomnd
# remove this once https://github.com/golangci/golangci-lint/issues/2649 is closed
- path: /
linters:
- typecheck

linters:
enable-all: true
disable:
- gci
- depguard
- exhaustivestruct
- golint
- interfacer
- ireturn
- maligned
- nilnil
- scopelint
- tagliatelle
- gomoddirectives
- varcheck
- nosnakecase
- structcheck
- ifshort
- deadcode
- forbidigo
- prealloc
- gochecknoinits
- exhaustruct
- goerr113
- govet
- nonamedreturns
- varnamelen
- wrapcheck
- staticcheck
- gochecknoglobals
- paralleltest
- wsl
11 changes: 11 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ fmt: ## Run go fmt against code.
vet: ## Run go vet against code.
go vet ./...

.PHONY: lint
lint: golangci-lint ## Run golangci-lint.
$(GOLANGCI_LINT) run

.PHONY: test
test: manifests generate fmt vet envtest ## Run tests.
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" go test ./... -coverprofile cover.out
Expand Down Expand Up @@ -137,6 +141,7 @@ $(LOCALBIN):
mkdir -p $(LOCALBIN)

## Tool Binaries
GOLANGCI_LINT ?= $(LOCALBIN)/golangci-lint
KUSTOMIZE ?= $(LOCALBIN)/kustomize
CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
ENVTEST ?= $(LOCALBIN)/setup-envtest
Expand All @@ -146,6 +151,7 @@ GEN_CRD_API_REFERENCE_DOCS ?= $(LOCALBIN)/gen-crd-api-reference-docs
KUSTOMIZE_VERSION ?= v3.8.7
CONTROLLER_TOOLS_VERSION ?= v0.9.2
GEN_API_REF_DOCS_VERSION ?= e327d0730470cbd61b06300f81c5fcf91c23c113
GOLANGCI_LINT_VERSION ?= v1.55.2

KUSTOMIZE_INSTALL_SCRIPT ?= "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh"
.PHONY: kustomize
Expand Down Expand Up @@ -178,3 +184,8 @@ generate-license:
gen-crd-api-reference-docs: $(GEN_CRD_API_REFERENCE_DOCS)
$(GEN_CRD_API_REFERENCE_DOCS): $(LOCALBIN)
GOBIN=$(LOCALBIN) go install github.com/ahmetb/gen-crd-api-reference-docs@$(GEN_API_REF_DOCS_VERSION)

.PHONY: golangci-lint
golangci-lint: $(GOLANGCI_LINT)
$(GOLANGCI_LINT): $(LOCALBIN)
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s $(GOLANGCI_LINT_VERSION)
6 changes: 0 additions & 6 deletions apis/delivery/v1alpha1/condition_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
package v1alpha1

const (
// PatchFailedReason is used when we couldn't patch an object.
PatchFailedReason = "PatchFailed"

// SnapshotGetFailedReason is used when the needed snapshot does not exist.
SnapshotGetFailedReason = "SnapshotGetFailed"

Expand All @@ -22,7 +19,4 @@ const (

// CreatePullRequestFailedReason is used when creating a pull request failed.
CreatePullRequestFailedReason = "CreatePullRequestFailed"

// GitRepositoryCreateFailedReason is used when creating a git repository failed.
GitRepositoryCreateFailedReason = "GitRepositoryCreateFailed"
)
4 changes: 4 additions & 0 deletions apis/delivery/v1alpha1/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@ const (
// StatusCheckName defines the name of the check a PullRequest will have.
StatusCheckName = "mpas/validation-check"
)

const (
LevelDebug = 4
)
4 changes: 2 additions & 2 deletions apis/delivery/v1alpha1/groupversion_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ import (
)

var (
// GroupVersion is group version used to register these objects
// GroupVersion is group version used to register these objects.
GroupVersion = schema.GroupVersion{Group: "delivery.ocm.software", Version: "v1alpha1"}

// SchemeBuilder is used to add go types to the GroupVersionKind scheme
// SchemeBuilder is used to add go types to the GroupVersionKind scheme.
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}

// AddToScheme adds the types in this group-version to the given scheme.
Expand Down
8 changes: 4 additions & 4 deletions apis/delivery/v1alpha1/sync_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ type PullRequestTemplate struct {
Base string `json:"base,omitempty"`
}

// SyncSpec defines the desired state of Sync
// SyncSpec defines the desired state of Sync.
type SyncSpec struct {
SnapshotRef v1.LocalObjectReference `json:"snapshotRef"`
RepositoryRef meta.NamespacedObjectReference `json:"repositoryRef"`
Expand All @@ -48,7 +48,7 @@ type SyncSpec struct {
PullRequestTemplate PullRequestTemplate `json:"pullRequestTemplate,omitempty"`
}

// SyncStatus defines the observed state of Sync
// SyncStatus defines the observed state of Sync.
type SyncStatus struct {
Digest string `json:"digest,omitempty"`

Expand Down Expand Up @@ -95,7 +95,7 @@ func (in Sync) GetRequeueAfter() time.Duration {
//+kubebuilder:object:root=true
//+kubebuilder:subresource:status

// Sync is the Schema for the syncs API
// Sync is the Schema for the syncs API.
type Sync struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Expand All @@ -106,7 +106,7 @@ type Sync struct {

//+kubebuilder:object:root=true

// SyncList contains a list of Sync
// SyncList contains a list of Sync.
type SyncList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Expand Down
4 changes: 2 additions & 2 deletions apis/mpas/v1alpha1/groupversion_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ import (
)

var (
// GroupVersion is group version used to register these objects
// GroupVersion is group version used to register these objects.
GroupVersion = schema.GroupVersion{Group: "mpas.ocm.software", Version: "v1alpha1"}

// SchemeBuilder is used to add go types to the GroupVersionKind scheme
// SchemeBuilder is used to add go types to the GroupVersionKind scheme.
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}

// AddToScheme adds the types in this group-version to the given scheme.
Expand Down
8 changes: 4 additions & 4 deletions apis/mpas/v1alpha1/repository_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ var (
ExistingRepositoryPolicyFail ExistingRepositoryPolicy = "fail"
)

// RepositorySpec defines the desired state of Repository
// RepositorySpec defines the desired state of Repository.
type RepositorySpec struct {
//+required
Provider string `json:"provider"`
Expand Down Expand Up @@ -73,7 +73,7 @@ type CommitTemplate struct {
Name string `json:"name"`
}

// RepositoryStatus defines the observed state of Repository
// RepositoryStatus defines the observed state of Repository.
type RepositoryStatus struct {
// ObservedGeneration is the last reconciled generation.
// +optional
Expand Down Expand Up @@ -143,7 +143,7 @@ func (in *Repository) SetObservedGeneration(v int64) {
//+kubebuilder:object:root=true
//+kubebuilder:subresource:status

// Repository is the Schema for the repositories API
// Repository is the Schema for the repositories API.
type Repository struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Expand All @@ -154,7 +154,7 @@ type Repository struct {

//+kubebuilder:object:root=true

// RepositoryList contains a list of Repository
// RepositoryList contains a list of Repository.
type RepositoryList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Expand Down
6 changes: 3 additions & 3 deletions config/crd/bases/delivery.ocm.software_syncs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ spec:
- name: v1alpha1
schema:
openAPIV3Schema:
description: Sync is the Schema for the syncs API
description: Sync is the Schema for the syncs API.
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
Expand All @@ -33,7 +33,7 @@ spec:
metadata:
type: object
spec:
description: SyncSpec defines the desired state of Sync
description: SyncSpec defines the desired state of Sync.
properties:
automaticPullRequestCreation:
type: boolean
Expand Down Expand Up @@ -106,7 +106,7 @@ spec:
- subPath
type: object
status:
description: SyncStatus defines the observed state of Sync
description: SyncStatus defines the observed state of Sync.
properties:
conditions:
items:
Expand Down
6 changes: 3 additions & 3 deletions config/crd/bases/mpas.ocm.software_repositories.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ spec:
- name: v1alpha1
schema:
openAPIV3Schema:
description: Repository is the Schema for the repositories API
description: Repository is the Schema for the repositories API.
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
Expand All @@ -33,7 +33,7 @@ spec:
metadata:
type: object
spec:
description: RepositorySpec defines the desired state of Repository
description: RepositorySpec defines the desired state of Repository.
properties:
commitTemplate:
description: CommitTemplate defines the commit template to use when
Expand Down Expand Up @@ -113,7 +113,7 @@ spec:
- provider
type: object
status:
description: RepositoryStatus defines the observed state of Repository
description: RepositoryStatus defines the observed state of Repository.
properties:
conditions:
items:
Expand Down
Loading