Skip to content

Commit

Permalink
feat: initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
wI2L committed Jan 16, 2022
0 parents commit d057131
Show file tree
Hide file tree
Showing 27 changed files with 3,296 additions and 0 deletions.
61 changes: 61 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: ci
on:
push:
branches:
- master
paths-ignore:
- '*.md'
pull_request:
branches:
- master
paths-ignore:
- '*.md'
permissions:
contents: read
pull-requests: read
jobs:
lint:
name: Linting
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Run linter
uses: golangci/golangci-lint-action@v2
with:
version: v1.43.0
args: -c .golangci.yaml
only-new-issues: true
test:
name: Tests
needs:
- lint
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- macos-latest
- windows-latest
go:
- "1.17.x"
steps:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go }}
- name: Checkout repository
uses: actions/checkout@v2
- uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ matrix.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ matrix.os }}-go-
- name: Run tests
run: make test
- name: Upload coverage
uses: codecov/codecov-action@v1
with:
file: coverage.txt
23 changes: 23 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: release
on:
push:
tags:
- 'v*.*.*'
permissions:
contents: write
jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.17
- name: Run GoReleaser
run: make release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
56 changes: 56 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Linux
*~
.Trash-*

# Mac OSX
.DS_Store
.AppleDouble
.LSOverride
._*

# Folders
_obj
_test

# Compiled Object files
# Static and Dynamic libs (Shared Objects)
*.o
*.a
*.so
*.dll
*.dylib

# Executables
*.exe
*.exe~

# Architecture specific extensions/prefixes
*.[568vq]
[568vq].out

# Cgo
*.cgo1.go
*.cgo2.c
_cgo_defun.c
_cgo_gotypes.go
_cgo_export.*

# Go Tools
*.test
*.prof
*.out
_testmain.go

# Dependency directories
vendor/
Godeps/

# markdown-spellcheck
.spelling

# Tests
coverage.txt

# Build
dist/
kubectl-commitment
46 changes: 46 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
run:
timeout: 10m
linters:
disable-all: true
enable:
- asciicheck
- bodyclose
- deadcode
- depguard
- dogsled
- dupl
- errcheck
- exportloopref
- funlen
- gocognit
- goconst
- gocritic
- gocyclo
- gofmt
- goimports
- goprintffuncname
- gosec
- gosimple
- govet
- ineffassign
- misspell
- nakedret
- nolintlint
- revive
- rowserrcheck
- staticcheck
- structcheck
- stylecheck
- typecheck
- unconvert
- unparam
- unused
- varcheck
- whitespace
linters-settings:
gofmt:
simplify: true
dupl:
threshold: 400
funlen:
lines: 120
48 changes: 48 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
project_name: kubectl-commitment
release:
prerelease: auto
draft: true
before:
hooks:
- go mod tidy
- go mod download
builds:
- binary: kubectl-commitment
main: ./cmd/kubectl-commitment
goos:
- darwin
- linux
- windows
goarch:
- amd64
- arm64
ignore:
- goos: windows
goarch: arm64
mod_timestamp: '{{ .CommitTimestamp }}'
env:
- CGO_ENABLED=0
- GO111MODULE=on
ldflags:
- -s
- -w
- -X github.com/wI2L/kubectl-commitment/internal/version.buildDate={{ .Date }}
- -X github.com/wI2L/kubectl-commitment/internal/version.gitCommit={{ .FullCommit }}
- -X github.com/wI2L/kubectl-commitment/internal/version.gitVersion={{ .Version }}
- -X github.com/wI2L/kubectl-commitment/internal/version.gitTreeState={{ .Env.GIT_TREE_STATE }}
- -X github.com/wI2L/kubectl-commitment/internal/version.gitVersionMajor={{ .Major }}
- -X github.com/wI2L/kubectl-commitment/internal/version.gitVersionMinor={{ .Minor }}
archives:
- name_template: "{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}"
files:
- README.md
- LICENSE
format_overrides:
- goos: windows
format: zip
checksum:
name_template: "{{ .ProjectName }}_checksums.txt"
snapshot:
name_template: "{{ .Tag }}-snapshot"
changelog:
use: github
43 changes: 43 additions & 0 deletions .krew.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
apiVersion: krew.googlecontainertools.github.com/v1alpha2
kind: Plugin
metadata:
name: commitment
spec:
version: {{ .TagName }}
homepage: https://github.com/wI2L/kubectl-commitment
shortDescription: Compare VerticalPodAutoscaler recommendations to actual resources requests
description: |
This plugin prints a table that show the percentage increase/decrease
of the selected VerticalPodAutoscaler recommendations compared to the
targeted controller's pod resource requests.
platforms:
- selector:
matchLabels:
os: darwin
arch: amd64
{{addURIAndSha "https://github.com/wI2L/kubectl-commitment/releases/download/{{ .TagName }}/kubectl-commitment_darwin_amd64.tar.gz" .TagName }}
bin: kubectl-commitment
- selector:
matchLabels:
os: darwin
arch: arm64
{{addURIAndSha "https://github.com/wI2L/kubectl-commitment/releases/download/{{ .TagName }}/kubectl-commitment_darwin_arm64.tar.gz" .TagName }}
bin: kubectl-commitment
- selector:
matchLabels:
os: linux
arch: amd64
{{addURIAndSha "https://github.com/wI2L/kubectl-commitment/releases/download/{{ .TagName }}/kubectl-commitment_linux_amd64.tar.gz" .TagName }}
bin: kubectl-commitment
- selector:
matchLabels:
os: linux
arch: arm64
{{addURIAndSha "https://github.com/wI2L/kubectl-commitment/releases/download/{{ .TagName }}/kubectl-commitment_linux_arm64.tar.gz" .TagName }}
bin: kubectl-commitment
- selector:
matchLabels:
os: windows
arch: amd64
{{addURIAndSha "https://github.com/wI2L/kubectl-commitment/releases/download/{{ .TagName }}/kubectl-commitment_windows_amd64.zip" .TagName }}
bin: kubectl-commitment.exe
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 William Poussier <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
55 changes: 55 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
DISTDIR = dist

# Utility versions.
GORELEASER_VERSION = "v1.3.1"
GOLANGCI_LINT_VERSION = "v1.43.0"

# Build variables.
GIT_TREE_STATE=$(if $(shell git status --porcelain),dirty,clean)

.PHONY: bootstrap
# Download and install all go dependencies and tools.
bootstrap: $(RESULTSDIR) bootstrap-go install-tools

.PHONY: bootstrap-go
bootstrap-go:
go mod download

.PHONY: install-tools
install-tools: install-goreleaser install-golangci-lint

.PHONY: install-goreleaser
install-goreleaser:
go install github.com/goreleaser/goreleaser@$(GORELEASER_VERSION)

.PHONY: install-golangci-lint
install-golangci-lint:
go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION)

.PHONY: test
test:
go test -v -race -coverprofile=coverage.txt -covermode=atomic ./...

.PHONY: lint
lint:
golangci-lint run --tests=false --timeout 5m --config .golangci.yaml

.PHONY: build
build: install-goreleaser
GIT_TREE_STATE=$(GIT_TREE_STATE) goreleaser build --rm-dist --single-target

.PHONY: release
release: install-goreleaser
GIT_TREE_STATE=$(GIT_TREE_STATE) goreleaser release --rm-dist

.PHONY: release-snapshot
release-snapshot: install-goreleaser
GIT_TREE_STATE=$(GIT_TREE_STATE) goreleaser release --rm-dist --skip-publish --snapshot

.PHONY: clean-dist
clean-dist:
rm -rf $(DISTDIR)

.PHONY: clean
clean: clean-dist
rm -f coverage.txt
Loading

0 comments on commit d057131

Please sign in to comment.