-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Split client commands into distinct packages - Adding in goreleaser w/ docker build - Adding in additional Makefile targets
- Loading branch information
Justin Nauman
committed
May 1, 2018
1 parent
4819714
commit 6e9426f
Showing
13 changed files
with
175 additions
and
113 deletions.
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
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,30 @@ | ||
project_name: k8-kms-enc-provider | ||
|
||
builds: | ||
- binary: k8-kms-enc-provider | ||
main: . | ||
ldflags: -s -w -X github.com/jrnt30/k8-kms-enc-provider/cmd.GitCommit={{.Commit}} | ||
lang: go | ||
env: | ||
- CGO_ENABLED=0 | ||
goos: | ||
- linux | ||
- darwin | ||
goarch: | ||
- amd64 | ||
|
||
dockers: | ||
- image: jrnt30/k8-kms-enc-provider | ||
dockerfile: Dockerfile.gorelease | ||
tag_templates: | ||
- "{{ .Tag }}" | ||
- latest | ||
|
||
release: | ||
github: | ||
owner: jrnt30 | ||
name: k8-kms-enc-provider | ||
name_template: '{{.Tag}}' | ||
|
||
git: | ||
short_hash: 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
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,8 @@ | ||
FROM alpine:3.7 | ||
|
||
RUN adduser -D -u 10000 k8-kms-enc-provider | ||
RUN apk add --no-cache ca-certificates | ||
|
||
COPY k8-kms-enc-provider / | ||
USER k8-kms-enc-provider | ||
ENTRYPOINT ["/k8-kms-enc-provider"] |
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 |
---|---|---|
@@ -1,11 +1,38 @@ | ||
default: ; @true | ||
# Heavily inspired by https://github.com/heptio/authenticator/ Makefile/GoReleaser | ||
default: build | ||
GORELEASER := $(shell command -v goreleaser 2> /dev/null) | ||
PROTOC := $(shell command -v protoc 2> /dev/null) | ||
|
||
# TODO | ||
# For each .proto file, ensure there is a correpsonding .db.go file present | ||
.PHONY: protos | ||
protos: | ||
protoc --go_out plugins=grpc:generated/ --proto_path proto/ proto/*.proto | ||
.PHONY: build test format check-formatting check-tools generate-protobufs | ||
|
||
docker-build: | ||
docker build -t kms-server . | ||
check: check-formatting check-tools | ||
|
||
check-tools: | ||
ifndef GORELEASER | ||
$(error "goreleaser not found (`go get -u -v github.com/goreleaser/goreleaser` to fix)") | ||
endif | ||
ifndef PROTOC | ||
$(error "PROTOC not found (`go get -u -v github.com/goreleaser/goreleaser` to fix)") | ||
endif | ||
@true | ||
|
||
check-formatting: | ||
@if [ ! `find . -path ./vendor -prune -type f -o -name '*.go' -exec gofmt -l {} + | wc -l` -eq 0 ]; then \ | ||
echo "Changes present in go files. Run 'make format' to clean"; \ | ||
exit 127; \ | ||
fi | ||
|
||
format: | ||
find . -path ./vendor -prune -type f -o -name '*.go' -exec gofmt -w {} +; | ||
|
||
release: check-tools | ||
$(GORELEASER) --rm-dist | ||
|
||
generate-protobufs: check-tools | ||
$(PROTOC) --go_out plugins=grpc:v1beta1/ --proto_path proto/ proto/*.proto | ||
|
||
build-local: check-tools | ||
$(GORELEASER) release --skip-publish | ||
|
||
build: check-tools generate-protobufs format | ||
$(GORELEASER) --skip-publish --rm-dist --snapshot |
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
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
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
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,64 @@ | ||
// Copyright © 2018 Justin Nauman <justin@spantree.net> | ||
// | ||
// 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. | ||
|
||
package cmd | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"log" | ||
"net" | ||
"time" | ||
|
||
"github.com/spf13/cobra" | ||
"google.golang.org/grpc" | ||
|
||
"github.com/jrnt30/k8-kms-enc-provider/v1beta1" | ||
) | ||
|
||
// versionCmd represents the version command | ||
var versionCmd = &cobra.Command{ | ||
Use: "version", | ||
Short: "Executes the server's Version endpoint", | ||
Run: func(cmd *cobra.Command, args []string) { | ||
var err error | ||
|
||
gc, err := grpc.Dial(socketPath, | ||
grpc.WithInsecure(), | ||
grpc.WithDialer(func(addr string, timeout time.Duration) (net.Conn, error) { | ||
return net.DialTimeout("unix", addr, timeout) | ||
})) | ||
|
||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
client := v1beta1.NewKeyManagementServiceClient(gc) | ||
|
||
resp, err := client.Version(context.Background(), &v1beta1.VersionRequest{}) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
fmt.Println("Got response: ", resp) | ||
}, | ||
} | ||
|
||
func init() { | ||
clientCmd.AddCommand(versionCmd) | ||
} |
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
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
Oops, something went wrong.