Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
eufebius authored and Milan Rafaj committed Nov 23, 2022
0 parents commit e9de62e
Show file tree
Hide file tree
Showing 11 changed files with 845 additions and 0 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/go-release-build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Generate release-artifacts

on:
push:
tags:
- "*"

permissions:
contents: write

jobs:
goreleaser:
runs-on: ubuntu-latest
env:
DOCKER_CLI_EXPERIMENTAL: "enabled"
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.18.2

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v3
with:
version: latest
args: release --rm-dist --debug
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
38 changes: 38 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# General
.DS_Store
.AppleDouble
.LSOverride

# Thumbnails
._*

# If you prefer the allow list template instead of the deny list, see community template:
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
#
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib

# Test binary, built with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# Dependency directories (remove the comment below to include it)
# vendor/

# Go workspace file
go.work

test/dist
build

.vscode/

bin/*

tests
20 changes: 20 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
run:
timeout: 5m
modules-download-mode: readonly

linters:
disable:
- golint
- typecheck
- structcheck
enable:
- errcheck
- goimports
- gocritic
- govet
- staticcheck

issues:
exclude-use-default: false
max-issues-per-linter: 0
max-same-issues: 0
38 changes: 38 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# This is an example .goreleaser.yml file with some sensible defaults.
# Make sure to check the documentation at https://goreleaser.com
dist: build
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
- darwin
goarch:
- amd64
- arm64

archives:
- replacements:
darwin: darwin
linux: linux
windows: windows
386: i386
amd64: amd64
checksum:
name_template: 'checksums.txt'
algorithm: sha256
snapshot:
name_template: "{{ incpatch .Version }}-next"
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
- '^vendor:'
88 changes: 88 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.2.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
- id: destroyed-symlinks
- id: detect-private-key
- id: check-ast
- id: check-case-conflict
- id: debug-statements
- repo: https://github.com/Yelp/detect-secrets
rev: v1.2.0
hooks:
- id: detect-secrets
- repo: https://github.com/tekwizely/pre-commit-golang
rev: v1.0.0-beta.5
hooks:
#
# Go Build
#
- id: go-build-mod
- id: go-build-pkg
#
# Go Mod Tidy
#
- id: go-mod-tidy
#
# Go Test
#
- id: go-test-mod
# - id: go-test-pkg
#
# Go Vet
#
# - id: go-vet
# - id: go-vet-mod
# - id: go-vet-pkg
#
# Revive
#
- id: go-revive
#
# GoSec
#
- id: go-sec-mod
#- id: go-sec-pkg
#
# StaticCheck
#
# - id: go-staticcheck-mod
# - id: go-staticcheck-pkg
# - id: go-staticcheck-repo-mod
# - id: go-staticcheck-repo-pkg
#
# StructSlop
#
# - id: go-structslop-mod
# - id: go-structslop-pkg
# - id: go-structslop-repo-mod
# - id: go-structslop-repo-pkg
#
# Formatters
#
# - id: go-fmt
# args: [ -s, -w ]
# - id: go-fmt-repo
# - id: go-fumpt # replaces go-fmt
# - id: go-fumpt-repo # replaces go-fmt-repo
# - id: go-imports # replaces go-fmt
# - id: go-imports-repo # replaces go-fmt-repo
# - id: go-returns # replaces go-imports & go-fmt
# - id: go-returns-repo # replaces go-imports-repo & go-fmt-repo
#
# Style Checkers
#
- id: go-lint
# - id: go-critic
#
# GolangCI-Lint
# - Fast Multi-Linter
# - Can be configured to replace MOST other hooks
# - Supports repo config file for configuration
# - https://github.com/golangci/golangci-lint
#
# - id: golangci-lint
31 changes: 31 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
.PHONY: build install clean test integration modverify modtidy

VERSION=`egrep -o '[0-9]+\.[0-9a-z.\-]+' version.go`
GIT_SHA=`git rev-parse --short HEAD || echo`

SRC = $(shell find . -type f -name '*.go' -not -path "./vendor/*")

build:
@echo "Building definition_exporter..."
@mkdir -p bin
@go build -ldflags "-X cmd.GitSHA=${GIT_SHA}" -o bin/definition_exporter .

install:
@echo "Installing definition_exporter..."
@install -c bin/definition_exporter /usr/local/bin/definition_exporter

clean:
@rm -f bin/*

test:
@echo "Running tests..."
#@go test `go list ./... | grep -v vendor/`

fmt:
@gofmt -l -w -s $(SRC)

modtidy:
@go mod tidy

modverify:
@go mod verify
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Devops.Infra.client-definition-exporter
9 changes: 9 additions & 0 deletions config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package main

// Ops represents the commandline/environment options for the program
type ConfigOpts struct {
BaseDir string `long:"basedir" short:"d" env:"BASEDIR" default:"/srv/www/" description:"Definition location"`
MetricsBindAddr string `long:"metrics-bind-address" short:"b" env:"METRICS_BIND_ADDRESS" default:"9115" description:"Address for binding metrics listener"`
MetricsPath string `long:"metrics-path" env:"METRICS_PATH" default:"/metrics" description:"Metrics path"`
Refresh int `long:"refresh" short:"r" env:"REFRESH" default:"60" description:"Definition refresh rate"`
}
23 changes: 23 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
module github.com/pxfd/definition-exporter

go 1.18

require (
github.com/jessevdk/go-flags v1.5.0
github.com/prometheus/client_golang v1.14.0
k8s.io/klog/v2 v2.80.1
)

require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/go-logr/logr v1.2.3 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
github.com/prometheus/client_model v0.3.0 // indirect
github.com/prometheus/common v0.37.0 // indirect
github.com/prometheus/procfs v0.8.0 // indirect
golang.org/x/sys v0.0.0-20220919091848-fb04ddd9f9c8 // indirect
google.golang.org/protobuf v1.28.1 // indirect
)
Loading

0 comments on commit e9de62e

Please sign in to comment.