Skip to content

Commit

Permalink
Merge branch 'main' into feat/otel-provider
Browse files Browse the repository at this point in the history
  • Loading branch information
niklastreml committed Jul 29, 2024
2 parents 1535e27 + a5384d0 commit f9f4af0
Show file tree
Hide file tree
Showing 30 changed files with 442 additions and 141 deletions.
30 changes: 30 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
version: 2
updates:
- package-ecosystem: "gomod"
directory: "/"
schedule:
interval: "daily"
labels:
- "housekeeping"
- "dependencies"
commit-message:
prefix: "chore"
include: "scope"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
labels:
- "housekeeping"
commit-message:
prefix: "chore"
include: "scope"
- package-ecosystem: "docker"
directory: "/"
schedule:
interval: "daily"
labels:
- "housekeeping"
commit-message:
prefix: "chore"
include: "scope"
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version-file: go.mod

Expand All @@ -42,7 +42,7 @@ jobs:
output: "trivy-results.sarif"

- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v2
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: "trivy-results.sarif"

Expand Down
33 changes: 33 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: pre-commit.ci

on: [push, pull_request]

jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"

- uses: actions/setup-go@v5
with:
go-version-file: "go.mod"

- name: Install go toolchain for pre-commit
run: |
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.58.0
go install mvdan.cc/gofumpt@latest
go install github.com/matryer/moq@latest
go install github.com/norwoodj/helm-docs/cmd/helm-docs@latest
- name: Run pre-commit
uses: pre-commit/[email protected]

- name: Run pre-commit.ci
uses: pre-commit-ci/[email protected]
if: always()
with:
msg: |
chore(deps): [pre-commit.ci] auto fixes\n\nFor more information, see https://pre-commit.ci
4 changes: 2 additions & 2 deletions .github/workflows/prune.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:

steps:
- name: Prune Images
uses: vlaurin/action-ghcr-prune@v0.5.0
uses: vlaurin/action-ghcr-prune@v0.6.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
organization: ${{ github.repository_owner }}
Expand All @@ -27,7 +27,7 @@ jobs:
^commit-
- name: Prune Charts
uses: vlaurin/action-ghcr-prune@v0.5.0
uses: vlaurin/action-ghcr-prune@v0.6.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
organization: ${{ github.repository_owner }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version-file: go.mod

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test_unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version-file: go.mod

Expand Down
20 changes: 9 additions & 11 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# yaml-language-server: $schema=https://golangci-lint.run/jsonschema/golangci.jsonschema.json
linters-settings:
depguard:
# new configuration
Expand Down Expand Up @@ -36,7 +37,7 @@ linters-settings:
replacement: "any"
goimports:
local-prefixes: github.com/golangci/golangci-lint
gomnd:
mnd:
# don't include the "operation" and "assign"
checks:
- argument
Expand All @@ -52,14 +53,17 @@ linters-settings:
- strings.SplitN

govet:
check-shadowing: true
enable-all: true
disable:
- fieldalignment # disabled because it's too strict, it checks if struct fields are sorted by size
settings:
printf:
funcs:
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Infof
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Warnf
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Errorf
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Fatalf

lll:
line-length: 140
misspell:
Expand Down Expand Up @@ -91,7 +95,7 @@ linters:
- gocyclo
- gofmt
- goimports
- gomnd
- mnd
- goprintffuncname
- gosec
- gosimple
Expand Down Expand Up @@ -127,12 +131,11 @@ linters:
# - wsl

issues:
# Excluding configuration per-path, per-linter, per-text and per-source
exclude-rules:
- path: _test\.go
linters:
- gomnd
- revive
- mnd # test files can have magic numbers
- revive # test files can have unused parameters

- path: pkg/golinters/errcheck.go
text: "SA1019: errCfg.Exclude is deprecated: use ExcludeFunctions instead"
Expand All @@ -154,8 +157,3 @@ issues:

run:
timeout: 5m
skip-dirs:
- test/testdata_etc # test files
- internal/cache # extracted from Go code
- internal/renameio # extracted from Go code
- internal/robustio # extracted from Go code
2 changes: 2 additions & 0 deletions .goreleaser-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ snapshot:
name_template: "commit-{{ .ShortCommit }}"
builds:
- env: [CGO_ENABLED=0]
flags:
- -tags=viper_bind_struct # https://github.com/caas-team/sparrow/issues/78, https://github.com/spf13/viper/pull/1429#issuecomment-1870976604
ldflags:
- -s -w -X main.version={{ .Version }}
- -extldflags "-static"
Expand Down
2 changes: 2 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
project_name: sparrow
builds:
- env: [CGO_ENABLED=0]
flags:
- -tags=viper_bind_struct # https://github.com/caas-team/sparrow/issues/78, https://github.com/spf13/viper/pull/1429#issuecomment-1870976604
ldflags:
- -s -w -X main.version={{ .Tag }}
- -extldflags "-static"
Expand Down
6 changes: 6 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ repos:
types: [go]
pass_filenames: false
always_run: true

- repo: https://github.com/tekwizely/pre-commit-golang
rev: v1.0.0-rc.1
hooks:
Expand All @@ -20,6 +21,11 @@ repos:
args: [-l, -w]
- id: golangci-lint-repo-mod
args: [--config, .golangci.yaml, --, --fix]

# You need to install helm-docs manually via the go toolchain:
# go install github.com/norwoodj/helm-docs/cmd/helm-docs@latest
# If you have installed it in a different way, you should use the binary of the
# go toolchain instead, because behavior may differ.
- repo: https://github.com/norwoodj/helm-docs
rev: v1.13.1
hooks:
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM alpine:3.18 as prep
FROM alpine:3.20 as prep

RUN apk add --no-cache ca-certificates
RUN adduser \
Expand Down
45 changes: 33 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,22 @@ loader:
api:
# Which address to expose Sparrow's REST API on
address: :8080
# Configures tls for the http server
# including prometheus metrics etc
tls:
# whether to enable tls, default is false
enabled: true
# path to your x509 certificate
certPath: mycert.pem
# path to your certificate key
keyPath: mykey.key
# Configures the target manager
# Omitting this section will disable the target manager
targetManager:
# whether to enable the target manager. defaults to false
enabled: true
# Defines which target manager to use.
type: gitlab
# The interval for the target reconciliation process
Expand All @@ -244,6 +256,8 @@ targetManager:
# before it is removed from the global target list
# A duration of 0 means no removal
unhealthyThreshold: 360m
# Scheme defines with which scheme sparrow should register itself
scheme: http
# Configuration options for the GitLab target manager
gitlab:
# The URL of your GitLab host
Expand Down Expand Up @@ -304,16 +318,18 @@ the `TargetManager` interface. This feature is optional; if the startup configur
the `targetManager`, it will not be used. When configured, it offers various settings, detailed below, which can be set
in the startup YAML configuration file as shown in the [example configuration](#example-startup-configuration).

| Type | Description |
| ------------------------------------ | -------------------------------------------------------------------------------------------- |
| `targetManager.type` | Type of the target manager. Options: `gitlab` |
| `targetManager.checkInterval` | Interval for checking new targets. |
| `targetManager.unhealthyThreshold` | Threshold for marking a target as unhealthy. 0 means no cleanup. |
| `targetManager.registrationInterval` | Interval for registering the current sparrow at the target backend. 0 means no registration. |
| `targetManager.updateInterval` | Interval for updating the registration of the current sparrow. 0 means no update. |
| `targetManager.gitlab.baseUrl` | Base URL of the GitLab instance. |
| `targetManager.gitlab.token` | Token for authenticating with the GitLab instance. |
| `targetManager.gitlab.projectId` | Project ID for the GitLab project used as a remote state backend. |
| Type | Description |
| ------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------- |
| `targetManager.enabled` | Whether to enable the target manager. Defaults to false |
| `targetManager.type` | Type of the target manager. Options: `gitlab` |
| `targetManager.checkInterval` | Interval for checking new targets. |
| `targetManager.unhealthyThreshold` | Threshold for marking a target as unhealthy. 0 means no cleanup. |
| `targetManager.registrationInterval` | Interval for registering the current sparrow at the target backend. 0 means no registration. |
| `targetManager.updateInterval` | Interval for updating the registration of the current sparrow. 0 means no update. |
| `targetManager.gitlab.baseUrl` | Base URL of the GitLab instance. |
| `targetManager.gitlab.token` | Token for authenticating with the GitLab instance. |
| `targetManager.gitlab.projectId` | Project ID for the GitLab project used as a remote state backend. |
| `targetManager.scheme` | Should the target register itself as http or https. Can be `http` or `https`. This needs to be set to `https`, when `api.tls.enabled` == `true` |

Currently, only one target manager exists: the Gitlab target manager. It uses a gitlab project as the remote state
backend. The various `sparrow` instances can register themselves as targets in the project.
Expand All @@ -323,7 +339,7 @@ which is named after the DNS name of the `sparrow`. The state file contains the

```json
{
"url": "https://<SPARROW_DNS_NAME>",
"url": "<SCHEME>://<SPARROW_DNS_NAME>",
"lastSeen": "2021-09-30T12:00:00Z"
}
```
Expand Down Expand Up @@ -393,9 +409,14 @@ latency:

- `sparrow_latency_duration_seconds`
- Type: Gauge
- Description: Latency with status information of targets
- Description: Latency with status information of targets. This metric is DEPRECATED. Use `sparrow_latency_seconds`.
- Labelled with `target` and `status`

- `sparrow_latency_seconds`
- Type: Gauge
- Description: Latency information of targets
- Labelled with `target`

- `sparrow_latency_count`
- Type: Counter
- Description: Count of latency checks done
Expand Down
2 changes: 0 additions & 2 deletions chart/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,3 @@ A Helm chart to install Sparrow
| startupProbe | object | `{"enabled":false,"failureThreshold":10,"initialDelaySeconds":10,"path":"/","periodSeconds":5,"successThreshold":1,"timeoutSeconds":1}` | Specifies the configuration for a startup probe to check if the sparrow application is started. Ref: https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/ |
| tolerations | list | `[]` | |

----------------------------------------------
Autogenerated from chart metadata using [helm-docs v1.13.1](https://github.com/norwoodj/helm-docs/releases/v1.13.1)
Loading

0 comments on commit f9f4af0

Please sign in to comment.