-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from sapcc/dev
Minimum viable product
- Loading branch information
Showing
2,606 changed files
with
1,053,956 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.git/ | ||
.github/ | ||
build/ | ||
dist/ | ||
test/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// This files contains a list of functions to exclude from checking by the | ||
// errcheck linter. The file should contain one function signature per line. | ||
// See https://github.com/kisielk/errcheck#excluding-functions for details. | ||
|
||
(github.com/go-kit/kit/log.Logger).Log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
version: 2 | ||
updates: | ||
|
||
# Maintain dependencies for GitHub Actions | ||
- package-ecosystem: "github-actions" | ||
directory: "/" | ||
schedule: | ||
interval: "monthly" | ||
reviewers: | ||
- "majewsky" | ||
- "talal" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
name: Build and Test | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
branches: | ||
- '*' | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
if: "!contains(github.event.head_commit.message, '[ci skip]')" | ||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@v2 | ||
with: | ||
# Only a single commit is fetched by default, for the ref/SHA that | ||
# triggered the workflow. We need `fetch-depth: 0` to fetch all | ||
# history for all branches and tags. | ||
fetch-depth: 0 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.14 | ||
|
||
- name: Cache kubebuilder control plane binaries | ||
uses: actions/cache@v2 | ||
with: | ||
path: test/bin | ||
key: ${{ runner.os }}-kubebuilder-${{ hashFiles('test/.kubebuilder-version') }} | ||
|
||
- name: Basic build | ||
run: make GO_BUILDFLAGS='-mod vendor' | ||
|
||
- name: Run tests with coverage | ||
run: make test-coverage | ||
|
||
- name: Upload coverage report to Coveralls | ||
run: | | ||
GO111MODULE=off go get -u github.com/mattn/goveralls | ||
goveralls -coverprofile=build/cover.out -service=github | ||
env: | ||
COVERALLS_TOKEN: ${{ github.token }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
name: golangci-lint | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
branches: | ||
- '*' | ||
|
||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
if: "!contains(github.event.head_commit.message, '[ci skip]')" | ||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Run golangci-lint | ||
uses: golangci/golangci-lint-action@v2 | ||
with: | ||
# Required: the version of golangci-lint is required and must be | ||
# specified without patch version: we always use the latest patch | ||
# version. | ||
version: v1.30 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: License | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
branches: | ||
- '*' | ||
|
||
jobs: | ||
check: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.14 | ||
|
||
- name: Run license checker | ||
run: | | ||
GO111MODULE=off go get -u github.com/google/addlicense | ||
addlicense --check -- *.go internal/ test/*.go test/fixtures/*.go |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
name: goreleaser | ||
|
||
# Run GoReleaser only on new tag. | ||
on: | ||
push: | ||
tags: | ||
- 'v*.*.*' | ||
|
||
jobs: | ||
release: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@v2 | ||
with: | ||
# Only a single commit is fetched by default, for the ref/SHA that | ||
# triggered the workflow. We need `fetch-depth: 0` to fetch all | ||
# history for all branches and tags. | ||
fetch-depth: 0 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.14 | ||
|
||
- name: Generate release info | ||
run: make build/release-info | ||
|
||
- name: Run GoReleaser | ||
uses: goreleaser/goreleaser-action@v2 | ||
with: | ||
version: latest | ||
args: release --rm-dist --release-notes=./build/release-info | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# build artifacts | ||
build/ | ||
dist/ | ||
|
||
# test artifacts | ||
test/bin/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
run: | ||
modules-download-mode: vendor | ||
deadline: 2m # 1m by default | ||
|
||
linters: | ||
# Do not use 'enable-all', it is deprecated. | ||
# We use 'disable-all' and enable linters explicitly so that a newer version | ||
# will not introduce new linters unexpectedly. | ||
disable-all: true | ||
enable: | ||
- bodyclose | ||
- deadcode | ||
- depguard | ||
- dogsled | ||
- dupl | ||
- errcheck | ||
- gochecknoinits | ||
- gocognit | ||
- goconst | ||
- gocritic | ||
- gocyclo | ||
- gofmt | ||
- goimports | ||
- golint | ||
- goprintffuncname | ||
- gosec | ||
- gosimple | ||
- govet | ||
- ineffassign | ||
- interfacer | ||
- lll | ||
- maligned | ||
- misspell | ||
- nakedret | ||
- prealloc | ||
- rowserrcheck | ||
- scopelint | ||
- staticcheck | ||
- structcheck | ||
- stylecheck | ||
- typecheck | ||
- unconvert | ||
- unparam | ||
- unused | ||
- varcheck | ||
- whitespace | ||
|
||
linters-settings: | ||
dupl: | ||
# Tokens count to trigger issue, 150 by default. | ||
threshold: 100 | ||
|
||
errcheck: | ||
# Report about assignment of errors to blank identifier: | ||
# `num, _ := strconv.Atoi(numStr)`; | ||
check-blank: true | ||
|
||
# Report about not checking of errors in type assertions: | ||
# `a := b.(MyStruct)`; | ||
check-type-assertions: false | ||
|
||
# Path to a file containing a list of functions to exclude from checking. | ||
# See https://github.com/kisielk/errcheck#excluding-functions for details. | ||
exclude: ./.errcheck-excludes | ||
|
||
gocognit: | ||
# Minimal code complexity to report, 30 by default. | ||
min-complexity: 20 | ||
|
||
gocyclo: | ||
# Minimal code complexity to report, 30 by default. | ||
min-complexity: 20 | ||
|
||
goimports: | ||
# Put imports beginning with prefix after 3rd-party packages. It's a | ||
# comma-separated list of prefixes. | ||
local-prefixes: github.com/sapcc/absent-metrics-operator | ||
|
||
lll: | ||
line-length: 140 | ||
|
||
maligned: | ||
# Print struct with more effective memory layout. | ||
suggest-new: true | ||
|
||
unused: | ||
# Treat code as a program (not a library) and report unused exported | ||
# identifiers. | ||
# If you enable this setting, unused will report a lot of false-positives | ||
# in text editors. All text editor integrations with golangci-lint call it | ||
# on a directory with the changed file. | ||
check-exported: true | ||
|
||
whitespace: | ||
# Enforce newlines (or comments) after multi-line function signature. | ||
multi-func: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
builds: | ||
- env: | ||
- CGO_ENABLED=0 | ||
goos: | ||
- linux | ||
goarch: | ||
- amd64 | ||
ldflags: | ||
- -s -w -X main.version={{.Version}} -X main.gitCommitHash={{.Commit}} | ||
mod_timestamp: '{{ .CommitTimestamp }}' # Ensure builds are reproducible | ||
|
||
archives: | ||
- name_template: '{{ .ProjectName }}-{{ replace .Version "v" "" }}-{{ .Os }}-{{ .Arch }}' | ||
|
||
checksum: | ||
name_template: 'checksums.txt' | ||
|
||
snapshot: | ||
name_template: "{{ .Tag }}-next" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Changelog | ||
|
||
All notable changes to this project will be documented in this file. | ||
|
||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), | ||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | ||
|
||
## [Unreleased] | ||
### Added | ||
- Initial release. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
FROM golang:1.14-alpine as builder | ||
RUN apk add --no-cache make gcc musl-dev | ||
|
||
COPY . /src | ||
RUN make -C /src install PREFIX=/pkg GO_BUILDFLAGS='-mod vendor' | ||
|
||
################################################################################ | ||
|
||
FROM alpine:latest | ||
LABEL source_repository="https://github.com/sapcc/absent-metrics-operator" | ||
|
||
RUN apk add --no-cache ca-certificates | ||
COPY --from=builder /pkg/ /usr/ | ||
ENTRYPOINT [ "/usr/bin/absent-metrics-operator" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
PKG = github.com/sapcc/absent-metrics-operator | ||
PREFIX := /usr | ||
|
||
GOOS = $(shell go env GOOS) | ||
GOARCH = $(shell go env GOARCH) | ||
KUBEBUILDER_RELEASE_VERSION = $(shell cat test/.kubebuilder-version) | ||
|
||
# TODO: uncomment when at least one tag exists | ||
# VERSION := $(shell git describe --long --abbrev=7) | ||
GIT_COMMIT_HASH := $(shell git rev-parse --verify HEAD) | ||
|
||
GO := GOBIN=$(CURDIR)/build go | ||
GO_BUILDFLAGS := | ||
GO_LDFLAGS := -s -w -X main.version=$(VERSION) -X main.gitCommitHash=$(GIT_COMMIT_HASH) | ||
|
||
all: FORCE build/absent-metrics-operator | ||
|
||
build/absent-metrics-operator: FORCE | build | ||
$(GO) install $(GO_BUILDFLAGS) -ldflags '$(GO_LDFLAGS)' '$(PKG)' | ||
|
||
install: FORCE build/absent-metrics-operator | ||
install -D -m 0755 build/absent-metrics-operator "$(DESTDIR)$(PREFIX)/bin/absent-metrics-operator" | ||
|
||
# Run all checks | ||
check: FORCE build/absent-metrics-operator lint build/cover.html | ||
@printf "\e[1;32m>> All checks successful\e[0m\n" | ||
|
||
lint: FORCE | ||
@printf "\e[1;34m>> golangci-lint\e[0m\n" | ||
@command -v golangci-lint >/dev/null 2>&1 || { echo >&2 "Error: golangci-lint is not installed. See: https://golangci-lint.run/usage/install/"; exit 1; } | ||
golangci-lint run | ||
|
||
# Run unit tests | ||
test: FORCE | test/bin | ||
@printf "\e[1;34m>> go test\e[0m\n" | ||
$(GO) test $(GO_BUILDFLAGS) -ldflags '$(GO_LDFLAGS)' $(PKG)/test | ||
|
||
# Test with coverage | ||
test-coverage: FORCE build/cover.out | ||
build/cover.out: FORCE | build test/bin | ||
@printf "\e[1;34m>> go test with coverage\e[0m\n" | ||
$(GO) test $(GO_BUILDFLAGS) -ldflags '$(GO_LDFLAGS)' -failfast -race -covermode=atomic -coverpkg=$(PKG)/internal/controller -coverprofile=$@ $(PKG)/test | ||
build/cover.html: build/cover.out | ||
$(GO) tool cover -html $< -o $@ | ||
|
||
build/release-info: CHANGELOG.md | build | ||
$(GO) run $(GO_BUILDFLAGS) tools/releaseinfo.go $< $(shell git describe --tags --abbrev=0) > $@ | ||
|
||
build: | ||
mkdir $@ | ||
|
||
# Download the kubebuilder control plane binaries | ||
test/bin: | ||
mkdir $@ | ||
# Download kubebuilder and extract it to tmp | ||
curl -L https://go.kubebuilder.io/dl/$(KUBEBUILDER_RELEASE_VERSION)/$(GOOS)/$(GOARCH) | tar -xz -C /tmp/ | ||
# Move to test/bin | ||
mv /tmp/kubebuilder*/bin/* test/bin/ | ||
|
||
clean: FORCE | ||
rm -rf -- build test/bin | ||
|
||
vendor: FORCE | ||
$(GO) mod tidy -v | ||
$(GO) mod vendor | ||
$(GO) mod verify | ||
|
||
.PHONY: FORCE |
Oops, something went wrong.