Skip to content

Commit d45c797

Browse files
authored
Merge pull request #1 from sourcehawk/feature/import-from-gaugevecset
Moved from GaugeVecSet repository
2 parents e154f08 + ba53826 commit d45c797

File tree

16 files changed

+1681
-2
lines changed

16 files changed

+1681
-2
lines changed

.github/workflows/test.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Go
2+
on:
3+
push:
4+
branches: ["master"]
5+
pull_request:
6+
branches: ["master"]
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/checkout@v5
14+
15+
- name: Setup Go
16+
uses: actions/setup-go@v6
17+
with:
18+
go-version: '1.25.x'
19+
20+
- name: Install golangci-lint
21+
run: |
22+
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/HEAD/install.sh \
23+
| sh -s -- -b $(go env GOPATH)/bin v2.5.0
24+
25+
- name: Test
26+
run: make all

.gitignore

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,8 @@ go.work.sum
2828
.env
2929

3030
# Editor/IDE
31-
# .idea/
32-
# .vscode/
31+
.idea/
32+
.vscode/
33+
34+
# Generated dashboards
35+
generated

.golangci.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
version: "2"
2+
3+
run:
4+
timeout: 5m
5+
allow-parallel-runners: true
6+
relative-path-mode: cfg
7+
8+
linters:
9+
default: none
10+
enable:
11+
- dupl
12+
- errcheck
13+
- copyloopvar
14+
- ginkgolinter
15+
- goconst
16+
- gocyclo
17+
- govet
18+
- ineffassign
19+
- misspell
20+
- nakedret
21+
- unconvert
22+
- unparam
23+
- unused
24+
- staticcheck
25+
disable:
26+
- prealloc
27+
- revive
28+
29+
settings:
30+
revive:
31+
rules:
32+
- name: comment-spacings
33+
34+
formatters:
35+
enable:
36+
- gofmt
37+
- goimports
38+
# example settings for formatters; remove if unused
39+
settings:
40+
gofmt:
41+
simplify: true
42+
43+
issues: {}

.tool-versions

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
golang 1.25.1
2+
golangci-lint 2.5.0

Makefile

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
##@ General
2+
3+
# The help target prints out all targets with their descriptions organized
4+
# beneath their categories. The categories are represented by '##@' and the
5+
# target descriptions by '##'. The awk command is responsible for reading the
6+
# entire set of makefiles included in this invocation, looking for lines of the
7+
# file as xyz: ## something, and then pretty-format the target and help. Then,
8+
# if there's a line with ##@ something, that gets pretty-printed as a category.
9+
# More info on the usage of ANSI control characters for terminal formatting:
10+
# https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters
11+
# More info on the awk command:
12+
# http://linuxcommand.org/lc3_adv_awk.php
13+
14+
.PHONY: help
15+
help: ## Display this help.
16+
@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)
17+
18+
.PHONY: all
19+
all: fmt vet lint test
20+
21+
##@ Development
22+
.PHONY: fmt
23+
fmt: ## Run go fmt against code.
24+
go fmt ./...
25+
26+
.PHONY: vet
27+
vet: ## Run go vet against code.
28+
go vet ./...
29+
30+
.PHONY: lint
31+
lint: ## Run linter
32+
golangci-lint run
33+
34+
.PHONY: lint-fix
35+
lint-fix: ## Run linter and fix issues
36+
golangci-lint run --fix
37+
38+
.PHONY: test
39+
test: ## Run project tests
40+
go test ./...
41+
42+
.PHONY: benchmark
43+
benchmark: ## Run project benchmarks
44+
go test -bench=. -benchtime=10000x -benchmem ./...
45+
46+
METRIC_NAMESPACE ?= unset
47+
48+
##@ Generate
49+
.PHONY: dashboards
50+
dashboards: ## Generate dashboards from templates
51+
@# Fail if METRIC_NAMESPACE is unset
52+
@[ "$(METRIC_NAMESPACE)" != "unset" ] && [ -n "$(METRIC_NAMESPACE)" ] || { \
53+
echo "Error: METRIC_NAMESPACE is required."; \
54+
echo "Usage: make dashboards METRIC_NAMESPACE=my_operator"; \
55+
exit 1; \
56+
}
57+
@echo "Generating dashboards for $(METRIC_NAMESPACE)"
58+
@mkdir -p generated/dashboards
59+
@find dashboards -type f -name '*.tpl.json' | while IFS= read -r file; do \
60+
base_name=`basename "$$file" .tpl.json`; \
61+
new_file="generated/dashboards/$$base_name.json"; \
62+
sed "s/{{operator_namespace}}/$(METRIC_NAMESPACE)_/g" "$$file" > "$$new_file"; \
63+
done

0 commit comments

Comments
 (0)