Skip to content

Commit

Permalink
Initital commit of drift helm plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
nikhilsbhat committed Mar 23, 2023
0 parents commit c554f1b
Show file tree
Hide file tree
Showing 49 changed files with 3,353 additions and 0 deletions.
27 changes: 27 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

# dropping IDE data's
.vscode
.idea

.DS_Store

# dropping some kubernetes metadata .kube
.kube

# dropping vendor and other data directories
vendor/

# dropping local built binaries
helm-drift

# dropping the templates
templates-latest/

/dist

# dropping all test results
cover.out
cover.html

# dropping all local builds generated for testing
bin/
69 changes: 69 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
---
linters:
disable-all: false
enable-all: true
disable:
- gci
- wsl
- gochecknoglobals
- tagliatelle
- exhaustivestruct
- nolintlint
- exhaustruct
- forbidigo
- paralleltest
- cyclop
- ireturn
- wrapcheck
- interfacebloat
- forcetypeassert
- dupl
- goconst
- maligned

issues:
exclude-rules:
- path: _test\.go
linters:
- gomnd

# https://github.com/go-critic/go-critic/issues/926
- linters:
- gocritic
text: "unnecessaryDefer:"

linters-settings:
funlen:
lines: 160

lll:
line-length: 165

dupl:
threshold: 450

gocognit:
min-complexity: 50

run:
concurrency: 10
timeout: 10m
issues-exit-code: 1
tests: true
skip-dirs:
- scripts/
- vendor/
- docs/

skip-files:
- Makefile
- README.md
- Dockerfile

severity:
default-severity: error

service:
golangci-lint-version: 1.27.x
prepare:
- make local.check
65 changes: 65 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# This is an example .goreleaser.yml file with some sane defaults.
# Make sure to check the documentation at http://goreleaser.com
before:
hooks:
# You may remove this if you don't use go modules.
- go mod tidy

builds:
- env:
- CGO_ENABLED=0
flags:
- -trimpath
ldflags:
- -s -w -X github.com/nikhilsbhat/helm-drift/version.Version={{.Version}} -X github.com/nikhilsbhat/helm-drift/version.Env={{.Env.BUILD_ENVIRONMENT}} -X github.com/nikhilsbhat/helm-drift/version.BuildDate={{.Date}} -X github.com/nikhilsbhat/helm-drift/version.Revision={{.Commit}} -X github.com/nikhilsbhat/helm-drift/version.GoVersion={{.Env.GOVERSION}} -X github.com/nikhilsbhat/helm-drift/version.Platform={{ .Os }}/{{ .Arch }}
goos:
- linux
- darwin
- freebsd
- windows
goarch:
- amd64
- '386'
- arm
- arm64
binary: '{{ .ProjectName }}'

archives:
- format: tar.gz
replacements:
darwin: Darwin
linux: Linux
386: i386
amd64: x86_64
name_template: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}'
files:
- plugin.yaml
- LICENSE
- completion.yaml
- install-binary.sh

snapshot:
name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}"

checksum:
name_template: '{{ .ProjectName }}_{{ .Version }}_SHA256SUMS'
algorithm: sha256

signs:
- artifacts: checksum
args:
- "--batch"
- "--local-user"
- "{{ .Env.GPG_FINGERPRINT }}" # set this environment variable for your signing key
- "--output"
- "${signature}"
- "--detach-sign"
- "${artifact}"

changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'

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) 2023 Nikhil Bhat

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.
71 changes: 71 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
GOFMT_FILES?=$(shell find . -not -path "./vendor/*" -type f -name '*.go')
APP_NAME?=helm-drift
APP_DIR?=$(shell git rev-parse --show-toplevel)
DEV?=${DEVBOX_TRUE}
SRC_PACKAGES=$(shell go list -mod=vendor ./... | grep -v "vendor" | grep -v "mocks")
BUILD_ENVIRONMENT?=${ENVIRONMENT}
VERSION?=0.1.0
REVISION?=$(shell git rev-parse --verify HEAD)
DATE?=$(shell date)
PlATFORM?=$(shell go env GOOS)
ARCHITECTURE?=$(shell go env GOARCH)
GOVERSION?=$(shell go version | awk '{printf $$3}')
BUILD_WITH_FLAGS="-s -w -X 'github.com/nikhilsbhat/helm-drift/version.Version=${VERSION}' -X 'github.com/nikhilsbhat/helm-drift/version.Env=${BUILD_ENVIRONMENT}' -X 'github.com/nikhilsbhat/helm-drift/version.BuildDate=${DATE}' -X 'github.com/nikhilsbhat/helm-drift/version.Revision=${REVISION}' -X 'github.com/nikhilsbhat/helm-drift/version.Platform=${PlATFORM}/${ARCHITECTURE}' -X 'github.com/nikhilsbhat/helm-drift/version.GoVersion=${GOVERSION}'"

# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
ifeq (,$(shell go env GOBIN))
GOBIN=$(shell go env GOPATH)/bin
else
GOBIN=$(shell go env GOBIN)
endif

.PHONY: help
help: ## Prints help (only for targets with comments)
@grep -E '^[a-zA-Z0-9._-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

local.fmt: ## Lints all the go code in the application.
gofmt -w $(GOFMT_FILES)
$(GOBIN)/goimports -w $(GOFMT_FILES)
$(GOBIN)/gofumpt -l -w $(GOFMT_FILES)
$(GOBIN)/gci write $(GOFMT_FILES) --skip-generated

local.check: local.fmt ## Loads all the dependencies to vendor directory
go mod vendor
go mod tidy

local.build: local.check ## Generates the artifact with the help of 'go build'
GOVERSION=${GOVERSION} BUILD_ENVIRONMENT=${BUILD_ENVIRONMENT} goreleaser build --rm-dist

local.push: local.build ## Pushes built artifact to the specified location

local.run: local.build ## Generates the artifact and start the service in the current directory
./${APP_NAME}

publish: local.check ## Builds and publishes the app
GOVERSION=${GOVERSION} BUILD_ENVIRONMENT=${BUILD_ENVIRONMENT} PLUGIN_PATH=${APP_DIR} goreleaser release --rm-dist

mock.publish: local.check ## Builds and mocks app release
GOVERSION=${GOVERSION} BUILD_ENVIRONMENT=${BUILD_ENVIRONMENT} PLUGIN_PATH=${APP_DIR} goreleaser release --skip-publish --rm-dist

lint: ## Lint's application for errors, it is a linters aggregator (https://github.com/golangci/golangci-lint).
if [ -z "${DEV}" ]; then golangci-lint run --color always ; else docker run --rm -v $(APP_DIR):/app -w /app golangci/golangci-lint:v1.46.2-alpine golangci-lint run --color always ; fi

report: ## Publishes the go-report of the appliction (uses go-reportcard)
if [ -z "${DEV}" ]; then goreportcard -v ; else docker run --rm -v $(APP_DIR):/app -w /app basnik/goreportcard-cli:latest goreportcard-cli -v ; fi

dev.prerequisite.up: ## Sets up the development environment with all necessary components.
$(APP_DIR)/scripts/prerequisite.sh

dev.prerequisite.purge: ## Teardown the development environment by removing all components.

install.hooks: ## install pre-push hooks for the repository.
${APP_DIR}/scripts/hook.sh ${APP_DIR}

generate.mock: ## generates mocks for the selected source packages.
@go generate ${SRC_PACKAGES}

generate.document: ## generates cli documents using 'github.com/spf13/cobra/doc'.
@go generate github.com/nikhilsbhat/helm-drift/docs

test: ## runs test cases
go test ./... -mod=vendor -coverprofile cover.out
Loading

0 comments on commit c554f1b

Please sign in to comment.