Skip to content

Commit

Permalink
Merge pull request #31 from Kong/goreleaser
Browse files Browse the repository at this point in the history
Feat: Adds goreleaser
  • Loading branch information
rspurgeon authored Mar 4, 2025
2 parents 9cc8617 + ebb4467 commit 6a4fb20
Show file tree
Hide file tree
Showing 4 changed files with 163 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,5 @@ koctl
.vscode/

.DS_Store
# Added by goreleaser init:
dist/
104 changes: 104 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
run:
timeout: 10m
build-tags:
- integration
linters:
enable:
- asciicheck
- dogsled
- durationcheck
- exhaustive
- copyloopvar
- gci
- goconst
- gofmt
- gofumpt
- goimports
- gomodguard
- gosec
- govet
- importas
- lll
- misspell
- nakedret
- nilerr
- nolintlint
- predeclared
- revive
- stylecheck
- unconvert
- unparam
- wastedassign
- errorlint
issues:
max-same-issues: 0
exclude-rules:
- linters:
- gosec
text: "weak cryptographic primitive"
path: "state/indexers/md5Indexer.*"
- linters:
- gosec
text: "TLS MinVersion too low"
path: "tests/integration/"
- linters:
- gosec
text: "weak random number generator"
path: _test\.go
- linters:
- errcheck
text: "Error return value" # ignore err not checked in test files
path: _test\.go
- linters:
- gosec
text: "Expect WriteFile permissions to be 0600 or less"
path: file/codegen/main.go
# ignore unused warnings in test utils files
- linters:
- unused
- unparam
path: test_.*
# ignore SA1019 deprecation warning
- linters:
- staticcheck
text: "SA1019: rand..*"
# ignore formatting warnings in cmd/root.go due to nolint statements
- linters:
- gofumpt
text: "File is not `gofumpt`-ed"
path: cmd/root.go
- linters:
- gofmt
text: "File is not `gofmt`-ed with `-s`"
path: cmd/root.go
- linters:
- goimports
text: "File is not `goimports`-ed"
path: cmd/root.go

linters-settings:
gci:
sections:
- standard
- default
goconst:
min-occurrences: 10
gomodguard:
blocked:
modules:
- github.com/ghodss/yaml:
recommendations:
- sigs.k8s.io/yaml
- gopkg.in/yaml.v2:
recommendations:
- sigs.k8s.io/yaml
- gopkg.in/yaml.v3:
recommendations:
- sigs.k8s.io/yaml
- github.com/pkg/errors:
recommendations:
- fmt
- errors
- golang.org/x/net/context:
recommendations:
- context
45 changes: 45 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
version: 2

before:
hooks:
# You may remove this if you don't use go modules.
- go mod tidy
# you may remove this if you don't need go generate
- go generate ./...
builds:
- env:
- CGO_ENABLED=0
goos:
- linux
- windows
- darwin
archives:
- name_template: "{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}"
format: zip
checksum:
name_template: "checksums.txt"
snapshot:
name_template: "{{ incpatch .Version }}-next"
changelog:
sort: asc
filters:
exclude:
- "^docs:"
- "^test:"
brews:
- repository:
owner: kong
name: homebrew-konnect-orchestrator
token: "{{ .Env.TAP_GITHUB_TOKEN }}"
branch: main
pull_request:
enabled: false
commit_author:
name: Rick Spurgeon
email: [email protected]
homepage: "https://github.com/kong/konnect-orchestrator"
description: Konnect Organization orchestration via declarative configuration
skip_upload: auto
test: |
system "#{bin}/koctl", "version"
12 changes: 12 additions & 0 deletions cmd/koctl/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ var loopInterval int
var platformFileArg string
var teamsFileArg string
var organizationsFileArg string
var version = "0.1.0" // Replace with build info
var commit = "unknown" // Replace with build info
var date = "unknown" // Replace with build info

var rootCmd = &cobra.Command{
Use: "koctl",
Expand All @@ -57,6 +60,14 @@ The files should be in YAML format and contain the necessary resource definition
RunE: runApply,
}

var versionCmd = &cobra.Command{
Use: "version",
Short: "Print the version of koctl",
Run: func(cmd *cobra.Command, args []string) {
fmt.Printf("koctl version: %s\nCommit: %s\nBuild date: %s\n", version, commit, date)
},
}

func init() {
applyCmd.Flags().StringVar(&platformFileArg, "platform", "", "Path to the platform configuration file")
applyCmd.Flags().StringVar(&teamsFileArg, "teams", "", "Path to the teams configuration file")
Expand All @@ -70,6 +81,7 @@ func init() {
cobra.OnInitialize(initConfig)

rootCmd.AddCommand(applyCmd)
rootCmd.AddCommand(versionCmd)
}

func readConfigSection(filePath string, out interface{}) error {
Expand Down

0 comments on commit 6a4fb20

Please sign in to comment.