Skip to content
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
2 changes: 1 addition & 1 deletion .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
${{ runner.os }}-go-

- name: Lint
run: go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.55.0 && golangci-lint run ./... --deadline=15m
run: go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.8.0 && golangci-lint run --timeout=15m ./...

- name: Unit
run: CGO_ENABLED=1 go test -coverprofile=cov.out -race -test.v ./... | tee out.txt
Expand Down
329 changes: 171 additions & 158 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -1,165 +1,178 @@
version: "2"
run:
build-tags:
- integration
linters:
disable-all: true
default: none
# One can't use disable and disable-all. disable-all is preferred to avoid lint failing when golangci gets updated and linters are added.
# at the same time but it is nice to explicitly state which linters we do not want.
#disable:
#- containedctx # Context.Context within a struct a struct (as opposed to a func parameter) is nasty for many reasons, but actually sometimes useful.
#- contextcheck # Not that useful/false positives.
#- cyclop # Cyclo complexity already calculated by other linters.
#- depguard # We do not restrict imports.
#- dogsled # Could be nice in the future.
#- dupl # Could be nice in the future.
#- exhaustive # Not that useful/false positives.
#- exhaustruct # Not that useful/false positives.
#- forcetypeassert # We want a panic in situations when a type is asserted.
#- funlen # We really like long functions.
#- gci # Conflicts with other linters.
#- gochecknoglobals # We need globals.
#- gochecknoinits # We have a lot of those.
#- gocognit # Not that useful/false positives.
#- godox # Not that useful/false positives.
#- gomnd # The annoy is strong.
#- gomoddirectives # Not that useful/false positives.
#- interfacebloat # WE do bloaty interfaces.
#- inamedparam # Not that useful.
#- ireturn # Not that useful/false positives.
#- lll # Could be nice in the future.
#- musttag # Dislikes our deps.
#- nakedret # Naked return good return.
#- nlreturn # Could be nice in the future.
#- nonamedreturns # Named return good return.
#- rowserrcheck # No SQL here.
#- sqlclosecheck # No SQL here.
#- tagliatelle # Reports issues that are not right for us.
#- testpackage # Could be nice in the future.
#- unparam # Not that useful/false positives.
#- varnamelen # Not that useful/false positives.
#- wrapcheck # Not that useful/false positives.
#- wsl # Not that useful/false positives.
#- zerologlint # No zerolog here.
#- goerr113
# - containedctx # Context.Context within a struct (as opposed to a func parameter) is nasty for many reasons, but actually sometimes useful.
# - contextcheck # Not that useful/false positives.
# - cyclop # Cyclo complexity already calculated by other linters.
# - dogsled # Could be nice in the future.
# - dupl # Could be nice in the future.
# - err113 # Could be nice in the future.
# - exhaustive # Not that useful/false positives.
# - exhaustruct # Not that useful/false positives.
# - forcetypeassert # We want a panic in situations when a type is asserted.
# - funcorder # Not that useful.
# - funlen # We really like long functions.
# - gochecknoglobals # We need globals.
# - gochecknoinits # We have a lot of those.
# - gocognit # Not that useful/false positives.
# - godox # Not that useful/false positives.
# - gomoddirectives # Not that useful/false positives.
# - inamedparam # Not that useful.
# - interfacebloat # We do bloaty interfaces.
# - ireturn # Not that useful/false positives.
# - mnd # The annoy is strong.
# - nakedret # Naked return good return.
# - nlreturn # Could be nice in the future.
# - nonamedreturns # Named return good return.
# - recvcheck # Could be nice in the future.
# - tagliatelle # Reports issues that are not right for us.
# - testpackage # Whitebox testing is fine too.
# - usetesting # Would be nice to have.
# - varnamelen # Not that useful/false positives.
# - wrapcheck # Not that useful/false positives.
# - wsl # Not that useful/false positives.
enable:
- asasalint
- asciicheck
- bidichk
- bodyclose
- decorder
- dupword
- durationcheck
- errcheck
- errchkjson
- errname
- errorlint
- execinquery
- exportloopref
- forbidigo
- ginkgolinter
- gocheckcompilerdirectives
- gochecksumtype
- goconst
- gocritic
- gocyclo
- godot
- gofmt
- gofumpt
- goheader
- goimports
- gosmopolitan
- govet
- grouper
- importas
- ineffassign
- loggercheck
- maintidx
- makezero
- mirror
- misspell
- musttag
- nestif
- nilerr
- nilnil
- noctx
- nolintlint
- nosprintfhostport
- paralleltest
- perfsprint
- prealloc
- predeclared
- promlinter
- protogetter
- reassign
- revive
- rowserrcheck
- sloglint
- staticcheck
- stylecheck
- tagalign
- tenv
- testableexamples
- testifylint
- thelper
- tparallel
- typecheck
- unconvert
- unused
- usestdlibvars
- wastedassign
- whitespace
- asasalint
- asciicheck
- bidichk
- bodyclose
- canonicalheader
- copyloopvar
- decorder
- depguard
- dupword
- durationcheck
- errcheck
- errchkjson
- errname
- errorlint
- exptostd
- fatcontext
- forbidigo
- ginkgolinter
- gocheckcompilerdirectives
- gochecksumtype
- goconst
- gocritic
- gocyclo
- godot
- goheader
- gomodguard
- goprintffuncname
- gosec
- gosmopolitan
- govet
- grouper
- iface
- importas
- ineffassign
- intrange
- lll
- loggercheck
- maintidx
- makezero
- mirror
- misspell
- musttag
- nestif
- nilerr
- nilnesserr
- nilnil
- noctx
- nolintlint
- nosprintfhostport
- paralleltest
- perfsprint
- prealloc
- predeclared
- promlinter
- protogetter
- reassign
- revive
- rowserrcheck
- sloglint
- spancheck
- sqlclosecheck
- staticcheck
- tagalign
- testableexamples
- testifylint
- thelper
- tparallel
- unconvert
- unparam
- unused
- usestdlibvars
- wastedassign
- whitespace
- zerologlint
settings:
depguard:
rules:
xcontext:
deny:
- pkg: golang.org/x/net/context
desc: use context package
gosec:
excludes:
- G115
- G204
- G301
- G302
- G304
- G306
- G601
- G602
exclusions:
generated: lax
rules:
- linters:
- lll
source: ^//( ?)[+]kubebuilder
- linters:
- lll
source: "^\t*//( ?)http(s?)://"
- linters:
- paralleltest
path: integration\/.+\.go
- path: internal/
text: ((comment on exported (method|function|type|const)|should have( a package)? comment|comment should be of the form)|exported (.+) should have comment( \(or a comment on this block\))? or be unexported|package comment should be of the form "(.+)...|comment on exported (.+) should be of the form "(.+)..."|should have a package comment)
- path: cmd/
text: ((comment on exported (method|function|type|const)|should have( a package)? comment|comment should be of the form)|exported (.+) should have comment( \(or a comment on this block\))? or be unexported|package comment should be of the form "(.+)...|comment on exported (.+) should be of the form "(.+)..."|should have a package comment)
- path: integration/
text: ((comment on exported (method|function|type|const)|should have( a package)? comment|comment should be of the form)|exported (.+) should have comment( \(or a comment on this block\))? or be unexported|package comment should be of the form "(.+)...|comment on exported (.+) should be of the form "(.+)..."|should have a package comment)
paths:
- internal/packages/internal/packagekickstart/rukpak
- third_party$
- builtin$
- examples$
issues:
max-same-issues: 0
max-issues-per-linter: 0
exclude-rules:
# Integration tests MUST NOT run in parallel.
- path: 'integration\/.+\.go'
linters:
- paralleltest
run:
skip-files: [ "zz_generated.deepcopy.go$" ]
linters-settings:
goimports:
local-prefixes: package-operator.run
gosec:
excludes:
- G301 # Poor file permissions used when creating a directory.
- G302 # Poor file permissions used with chmod.
- G306 # Poor file permissions used when writing to a new file.
- G601 # Taking address of loop variable - not relevant anymore.
- G602 # Should reports out of bound access but is broken.
importas:
no-unaliased: false
no-extra-aliases: true
alias:
- pkg: k8s\.io\/api\/([^\/]+)\/([^\/]+)
alias: $1$2
- pkg: k8s\.io\/apimachinery\/pkg\/([^\/]+)
alias: $1
- pkg: k8s\.io\/apimachinery\/pkg\/apis\/([^\/]+)\/([^\/]+)
alias: $1$2
- pkg: package-operator\.run\/apis
alias: apis
- pkg: package-operator\.run\/apis\/([^\/]+)\/([^\/]+)
alias: $1$2
- pkg: k8s\.io\/apiextensions-apiserver\/pkg\/apis\/([^\/]+)\/([^\/]+)
alias: $1$2
- pkg: github\.com\/openshift\/api\/([^\/]+)\/([^\/]+)
alias: $1$2
- pkg: package-operator.run/internal/controllers/hostedclusters/([^\/]+)\/([^\/]+)
alias: $1$2
- pkg: k8s\.io\/apimachinery\/pkg\/api\/([^\/]+)
alias: apimachinery$1
- pkg: sigs\.k8s\.io\/controller-runtime
alias: ctrl
- pkg: package-operator\.run\/internal\/cmd
alias: internalcmd
- pkg: package-operator\.run\/internal\/probing
alias: internalprobing
- pkg: package-operator\.run\/internal\/controllers\/packages
alias: controllerspackages
- pkg: github\.com\/google\/go-containerregistry\/pkg\/v1
alias: containerregistrypkgv1
- pkg: k8s\.io\/utils\/clock\/testing
alias: clocktesting
- pkg: k8s\.io\/apiserver\/pkg\/cel
alias: apiservercel
- pkg: k8s\.io\/apiserver\/pkg\/apis\/cel
alias: apiserverapiscel
max-same-issues: 0
formatters:
enable:
- gofmt
- gofumpt
- goimports
settings:
goimports:
local-prefixes:
- package-operator.run
gofmt:
simplify: true
rewrite-rules:
- pattern: interface{}
replacement: any
exclusions:
generated: lax
paths:
- internal/packages/internal/packagekickstart/rukpak
- third_party$
- builtin$
- examples$
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ repos:
hooks:
- id: lint
name: lint
entry: golangci-lint run ./... --deadline=15m
entry: golangci-lint run --timeout=3m --fix ./...
language: system
exclude: ".*"
always_run: true
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Semver

The `semver` package implements logic to work with [Sementic Versioning 2.0.0](http://semver.org/) in Go.
The `semver` package implements logic to work with [Sementic Versioning 2.0.0](http://semver.org/) in Go.
It provides:
- Parser for semantic versions
- Validation of semantic versions
Expand All @@ -10,15 +10,15 @@ It provides:
- whether version contained in range
- whether a range is contained in another range

This library is loosely based on the awesome:
This library is loosely based on the awesome:
https://github.com/Masterminds/semver

## Parsing Semantic Versions

This library implements strict parsing of semantic versions as outlined in the [Sementic Versioning](http://semver.org/) spec. Shorthand forms or a `v` prefix e.g. 2.0, 1, v2.1.2 are not considered valid semantic versions following the 2.0.0 spec.

> **Parsing Huge Versions**
> Semver does not limit the amount of Major, Minor or Patch version numbers.
> **Parsing Huge Versions**
> Semver does not limit the amount of Major, Minor or Patch version numbers.
Making `99999999999999999999999.999999999999999999.99999999999999999` a valid semver.
> For simplicity this library uses `uint64` as underlying datatype for Major, Minor and Patch, limiting the maximum number to `9999999999999999999`.

Expand All @@ -39,7 +39,7 @@ e.g. `1 - 2` => `1.0.0 - 2.0.0`

Pre release versions that fall within a range will match. If pre release versions should be excluded, they have to be filtered before checking against constraints.

Specifying pre-release ranges is NOT supported.
Specifying pre-release ranges is NOT supported.
e.g. `1.0.0-rc.0 - 1.0.0.rc.10`

In the following examples `<max>` is used to denote the max number possible to put into the Major, Minor or Patch section of a semantic version.
Expand Down Expand Up @@ -93,4 +93,4 @@ The caret (^) comparison operator is for major level changes once a stable (`1.0
**unstable versions**
- `^0.2.3` is expanded to `0.2.3 - 0.2.<max>`
- `^0.2` is expanded to `0.2.0 - 0.2.<max>`
- `^0` is expanded to `0.0.0 - 0.0.<max>`
- `^0` is expanded to `0.0.0 - 0.0.<max>`
Loading