Skip to content

Commit 1356dbd

Browse files
feat: add initial deploykf cli (#2)
Signed-off-by: Mathew Wicks <[email protected]>
1 parent 70b662b commit 1356dbd

File tree

17 files changed

+2849
-2
lines changed

17 files changed

+2849
-2
lines changed

.github/workflows/check-commit.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Check Commit
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
lint:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Check out code
13+
uses: actions/checkout@v3
14+
15+
- name: Set up Go
16+
uses: actions/setup-go@v4
17+
with:
18+
go-version: 1.19
19+
20+
- name: Install golangci-lint
21+
run: |
22+
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.52.2
23+
24+
- name: Lint Code
25+
run: make lint
26+
27+
test:
28+
runs-on: ubuntu-latest
29+
steps:
30+
- name: Check out code
31+
uses: actions/checkout@v3
32+
33+
- name: Set up Go
34+
uses: actions/setup-go@v4
35+
with:
36+
go-version: 1.19
37+
38+
- name: Run Tests
39+
run: make test
40+
41+
build:
42+
runs-on: ubuntu-latest
43+
steps:
44+
- name: Check out code
45+
uses: actions/checkout@v3
46+
47+
- name: Set up Go
48+
uses: actions/setup-go@v4
49+
with:
50+
go-version: 1.19
51+
52+
- name: Build single target
53+
run: make build

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,7 @@ Sessionx.vim
3737
.DS_Store
3838
.AppleDouble
3939
.LSOverride
40-
._*
40+
._*
41+
42+
## Build
43+
bin/

.golangci.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
run:
2+
timeout: 10m
3+
4+
linters:
5+
disable-all: true
6+
enable:
7+
- dupl
8+
- gofmt
9+
- goimports
10+
- gosimple
11+
- govet
12+
- ineffassign
13+
- misspell
14+
- nakedret
15+
- revive
16+
- unused
17+
- staticcheck
18+
19+
linters-settings:
20+
gofmt:
21+
simplify: true
22+
goimports:
23+
local-prefixes: github.com/deployKF/cli
24+
dupl:
25+
threshold: 400

Makefile

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
APP_NAME := deploykf
2+
3+
BINDIR := $(CURDIR)/bin
4+
INSTALL_PATH ?= /usr/local/bin
5+
6+
GIT_COMMIT := $(shell git rev-parse HEAD)
7+
GIT_TAG := $(shell git describe --tags --abbrev=0 --exact-match 2>/dev/null)
8+
GIT_TREE_STATE := $(shell test -n "`git status --porcelain`" && echo "dirty" || echo "clean")
9+
10+
ifdef VERSION
11+
BINARY_VERSION = $(VERSION)
12+
endif
13+
ifeq ($(GIT_TAG),)
14+
GIT_TAG := v0.0.0
15+
endif
16+
BINARY_VERSION ?= ${GIT_TAG}
17+
18+
LDFLAGS := -w -s
19+
LDFLAGS += -X github.com/deployKF/cli/internal/version.version=${BINARY_VERSION}
20+
LDFLAGS += -X github.com/deployKF/cli/internal/version.gitCommit=${GIT_COMMIT}
21+
LDFLAGS += -X github.com/deployKF/cli/internal/version.gitTreeState=${GIT_TREE_STATE}
22+
23+
TARGETS := \
24+
linux-amd64 \
25+
linux-arm64 \
26+
darwin-amd64 \
27+
darwin-arm64 \
28+
windows-amd64
29+
30+
# ------------------------------------------------------------------------------
31+
# checks
32+
33+
.PHONY: check-golangci-lint
34+
check-golangci-lint:
35+
ifeq (, $(shell which golangci-lint))
36+
$(error "golangci-lint is not installed. Please install it using the following command: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.52.2")
37+
endif
38+
39+
# ------------------------------------------------------------------------------
40+
# build
41+
42+
.PHONY: build
43+
build:
44+
@echo "********** building $(APP_NAME) for $(shell go env GOOS)/$(shell go env GOARCH) **********"
45+
CGO_ENABLED=0 go build -ldflags '$(LDFLAGS)' -o '$(BINDIR)/$(APP_NAME)'
46+
47+
# ------------------------------------------------------------------------------
48+
# build-all
49+
50+
.PHONY: build-all
51+
build-all: $(addprefix build-, $(TARGETS))
52+
build-%:
53+
$(eval os_arch := $(subst -, ,$*))
54+
$(eval GOOS := $(word 1, $(os_arch)))
55+
$(eval GOARCH := $(word 2, $(os_arch)))
56+
$(eval EXT := $(if $(filter windows,$(GOOS)),.exe,))
57+
58+
@echo "********** building $(APP_NAME) for $(GOOS)/$(GOARCH) **********"
59+
GOOS=$(GOOS) GOARCH=$(GOARCH) CGO_ENABLED=0 go build -ldflags '$(LDFLAGS)' -o '$(BINDIR)/$(APP_NAME)-$(GOOS)-$(GOARCH)$(EXT)'
60+
61+
# ------------------------------------------------------------------------------
62+
# install
63+
64+
.PHONY: install
65+
install: build
66+
@echo "********** installing into $(INSTALL_PATH)/$(APP_NAME) **********"
67+
@install '$(BINDIR)/$(APP_NAME)' '$(INSTALL_PATH)/$(APP_NAME)'
68+
69+
# ------------------------------------------------------------------------------
70+
# test
71+
72+
.PHONY: test
73+
test:
74+
@echo "********** running tests **********"
75+
@go test -race -v ./...
76+
77+
# ------------------------------------------------------------------------------
78+
# lint
79+
80+
.PHONY: lint
81+
lint: check-golangci-lint
82+
@echo "********** running golangci-lint **********"
83+
@golangci-lint run ./...
84+
85+
# ------------------------------------------------------------------------------
86+
# lint-fix
87+
88+
.PHONY: lint-fix
89+
lint-fix: check-golangci-lint
90+
@echo "********** running gofmt and goimports **********"
91+
@find . -name '*.go' -type f -not -path './vendor/*' -exec gofmt -s -w {} \;
92+
@goimports -local github.com/deployKF/cli -w $(shell find . -type f -name '*.go' -not -path "./vendor/*")
93+
94+
@echo "********** running golangci-lint --fix **********"
95+
@golangci-lint run --fix ./...
96+
97+
# ------------------------------------------------------------------------------
98+
# clean
99+
100+
.PHONY: clean
101+
clean:
102+
@echo "********** cleaning up build artifacts **********"
103+
@rm -rf '$(BINDIR)'

README.md

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,28 @@
11
# deployKF - cli
22

3-
The CLI for [deployKF](https://github.com/deployKF/deployKF).
3+
The CLI for [deployKF](https://github.com/deployKF/deployKF).
4+
5+
## Usage
6+
7+
The simplest usage of the `deploykf` CLI is to run the following command:
8+
9+
```bash
10+
deploykf \
11+
--source-version=v0.1.0 \
12+
--values "./custom-values.yaml" \
13+
--output-dir "./GENERATOR_OUTPUT"
14+
```
15+
16+
Which will generate deployKF manifests in the `./GENERATOR_OUTPUT` directory based on the `v0.1.0` source version and your `./values.yaml` file.
17+
18+
The `--source-version` flag must be a tag associated with a [deployKF release](https://github.com/deployKF/deployKF/releases).
19+
20+
## Development
21+
22+
Running `make build` will build the binary for your local platform and output it to `./bin/deploykf`.
23+
24+
Running `make install` will install the binary to `/usr/local/bin`.
25+
26+
Running `make lint` will run `golangci-lint` against the codebase.
27+
28+
Running `make lint-fix` will attempt to automatically fix linting errors.

0 commit comments

Comments
 (0)