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
26 changes: 26 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Go
on:
push:
branches: ["master"]
pull_request:
branches: ["master"]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v5

- name: Setup Go
uses: actions/setup-go@v6
with:
go-version: '1.25.x'

- name: Install golangci-lint
run: |
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/HEAD/install.sh \
| sh -s -- -b $(go env GOPATH)/bin v2.5.0

- name: Test
run: make all
7 changes: 5 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,8 @@ go.work.sum
.env

# Editor/IDE
# .idea/
# .vscode/
.idea/
.vscode/

# Generated dashboards
generated
43 changes: 43 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
version: "2"

run:
timeout: 5m
allow-parallel-runners: true
relative-path-mode: cfg

linters:
default: none
enable:
- dupl
- errcheck
- copyloopvar
- ginkgolinter
- goconst
- gocyclo
- govet
- ineffassign
- misspell
- nakedret
- unconvert
- unparam
- unused
- staticcheck
disable:
- prealloc
- revive

settings:
revive:
rules:
- name: comment-spacings

formatters:
enable:
- gofmt
- goimports
# example settings for formatters; remove if unused
settings:
gofmt:
simplify: true

issues: {}
2 changes: 2 additions & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
golang 1.25.1
golangci-lint 2.5.0
63 changes: 63 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
##@ General

# The help target prints out all targets with their descriptions organized
# beneath their categories. The categories are represented by '##@' and the
# target descriptions by '##'. The awk command is responsible for reading the
# entire set of makefiles included in this invocation, looking for lines of the
# file as xyz: ## something, and then pretty-format the target and help. Then,
# if there's a line with ##@ something, that gets pretty-printed as a category.
# More info on the usage of ANSI control characters for terminal formatting:
# https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters
# More info on the awk command:
# http://linuxcommand.org/lc3_adv_awk.php

.PHONY: help
help: ## Display this help.
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)

.PHONY: all
all: fmt vet lint test

##@ Development
.PHONY: fmt
fmt: ## Run go fmt against code.
go fmt ./...

.PHONY: vet
vet: ## Run go vet against code.
go vet ./...

.PHONY: lint
lint: ## Run linter
golangci-lint run

.PHONY: lint-fix
lint-fix: ## Run linter and fix issues
golangci-lint run --fix

.PHONY: test
test: ## Run project tests
go test ./...

.PHONY: benchmark
benchmark: ## Run project benchmarks
go test -bench=. -benchtime=10000x -benchmem ./...

METRIC_NAMESPACE ?= unset

##@ Generate
.PHONY: dashboards
dashboards: ## Generate dashboards from templates
@# Fail if METRIC_NAMESPACE is unset
@[ "$(METRIC_NAMESPACE)" != "unset" ] && [ -n "$(METRIC_NAMESPACE)" ] || { \
echo "Error: METRIC_NAMESPACE is required."; \
echo "Usage: make dashboards METRIC_NAMESPACE=my_operator"; \
exit 1; \
}
@echo "Generating dashboards for $(METRIC_NAMESPACE)…"
@mkdir -p generated/dashboards
@find dashboards -type f -name '*.tpl.json' | while IFS= read -r file; do \
base_name=`basename "$$file" .tpl.json`; \
new_file="generated/dashboards/$$base_name.json"; \
sed "s/{{operator_namespace}}/$(METRIC_NAMESPACE)_/g" "$$file" > "$$new_file"; \
done
Loading