Skip to content

Commit 2db8b6b

Browse files
committed
initial commit
0 parents  commit 2db8b6b

35 files changed

+2614
-0
lines changed

.editorconfig

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
2+
# EditorConfig https://EditorConfig.org
3+
4+
root = true
5+
6+
[*]
7+
end_of_line = lf
8+
charset = utf-8
9+
trim_trailing_whitespace = true
10+
insert_final_newline = true
11+
12+
[Makefile]
13+
indent_style = tab
14+
15+
[*.yml]
16+
indent_style = space
17+
indent_size = 2
18+
19+
[*.tf]
20+
indent_stype = space
21+
indent_size = 2

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @chanzuckerberg/czi-shared-infra

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
coverage.txt
2+
bin/
3+
dist/
4+
.vscode
5+
.env
6+
.envrc

.goreleaser.prerelease.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
before:
2+
hooks:
3+
- make clean
4+
5+
builds:
6+
- binary: aws-oidc
7+
env:
8+
- CGO_ENABLED=0
9+
goos:
10+
- darwin
11+
- linux
12+
goarch:
13+
- amd64
14+
ldflags:
15+
- "-w -s -X github.com/chanzuckerberg/aws-oidc/pkg/util.GitSha={{.Commit}} -X github.com/chanzuckerberg/aws-oidc/pkg/util.Version={{.Version}} -X github.com/chanzuckerberg/aws-oidc/pkg/util.Dirty=false -X github.com/chanzuckerberg/aws-oidc/pkg/util.Release=true"
16+
17+
dockers:
18+
- dockerfile: Dockerfile
19+
image_templates:
20+
- docker.pkg.github.com/chanzuckerberg/aws-oidc/aws-oidc:{{.ShortCommit}}
21+
extra_files:
22+
- cmd
23+
- pkg
24+
- go.mod
25+
- go.sum
26+
- main.go
27+
28+
archives:
29+
- files:
30+
- none*
31+
32+
release:
33+
prerelease: true
34+
35+
env_files:
36+
github_token: ~/.config/goreleaser/github_token

.goreleaser.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
before:
2+
hooks:
3+
- make clean
4+
5+
builds:
6+
- binary: aws-oidc
7+
env:
8+
- CGO_ENABLED=0
9+
goos:
10+
- darwin
11+
- linux
12+
goarch:
13+
- amd64
14+
ldflags:
15+
- "-w -s -X github.com/chanzuckerberg/aws-oidc/pkg/util.GitSha={{.Commit}} -X github.com/chanzuckerberg/aws-oidc/pkg/util.Version={{.Version}} -X github.com/chanzuckerberg/aws-oidc/pkg/util.Dirty=false -X github.com/chanzuckerberg/aws-oidc/pkg/util.Release=true"
16+
17+
dockers:
18+
- dockerfile: Dockerfile
19+
image_templates:
20+
- docker.pkg.github.com/chanzuckerberg/aws-oidc/aws-oidc:v{{.Version}}
21+
extra_files:
22+
- cmd
23+
- pkg
24+
- go.mod
25+
- go.sum
26+
- main.go
27+
28+
archives:
29+
- files:
30+
- none*
31+
32+
release:
33+
prerelease: false
34+
35+
brews:
36+
- description: "A command line utility tool to help generate AWS STS credentials from an OIDC application."
37+
github:
38+
owner: chanzuckerberg
39+
name: homebrew-tap
40+
homepage: "https://github.com/chanzuckerberg/aws-oidc"
41+
test: system "#{bin}/aws-oidc version"
42+
43+
env_files:
44+
github_token: ~/.config/goreleaser/github_token

.reviewdog.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
runner:
2+
golangci:
3+
cmd: ./bin/golangci-lint run --out-format=line-number
4+
errorformat:
5+
- '%E%f:%l:%c: %m'
6+
- '%E%f:%l: %m'
7+
- '%C%.%#'
8+
level: warning

.travis.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
dist: bionic
2+
language: go
3+
go:
4+
- '1.14.1'
5+
os:
6+
- linux
7+
env:
8+
- GO111MODULE=on
9+
install:
10+
- make setup
11+
jobs:
12+
include:
13+
- name: check-mod
14+
stage: test
15+
script: make check-mod
16+
- name: lint
17+
stage: test
18+
script:
19+
- make lint-ci
20+
- name: test
21+
stage: test
22+
script:
23+
- make test
24+
after_success:
25+
- bash <(curl -s https://codecov.io/bash)

Dockerfile

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# First stage: build the executable
2+
FROM golang:1.14 AS builder
3+
4+
# Enable Go modules
5+
ENV GO111MODULE=on CGO_ENABLED=0 GOOS=linux
6+
7+
# Set the Current Working Directory inside the container
8+
WORKDIR /app
9+
10+
# Copy the source from the current directory to the Working Directory inside the container
11+
COPY cmd cmd
12+
COPY go.mod go.sum main.go ./
13+
COPY pkg pkg
14+
15+
# Build the Go app
16+
RUN go build -o aws-oidc .
17+
18+
# Final stage: the running container
19+
FROM alpine:latest AS final
20+
21+
# Install SSL root certificates
22+
RUN apk update && apk --no-cache add ca-certificates curl
23+
24+
COPY --from=builder /app/aws-oidc /bin/aws-oidc
25+
26+
ADD https://github.com/segmentio/chamber/releases/download/v2.7.5/chamber-v2.7.5-linux-amd64 /bin/chamber
27+
RUN chmod +x /bin/chamber
28+
29+
30+
CMD ["aws-oidc"]

LICENSE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2019-2020 Chan Zuckerberg Initiative, LLC
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Makefile

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
SHA=$(shell git rev-parse --short HEAD)
2+
VERSION=$(shell cat VERSION)
3+
DIRTY=false
4+
GO_PACKAGE=$(shell go list)
5+
LDFLAGS=-ldflags "-w -s -X $(GO_PACKAGE)/pkg/util.GitSha=${SHA} -X $(GO_PACKAGE)/pkg/util.Version=${VERSION} -X $(GO_PACKAGE)/pkg/util.Dirty=${DIRTY}"
6+
export GO111MODULE=on
7+
8+
clean: ## clean the repo
9+
rm aws-oidc 2>/dev/null || true
10+
go clean
11+
go clean -testcache
12+
rm -rf dist 2>/dev/null || true
13+
rm coverage.out 2>/dev/null || true
14+
if [ -e /tmp/aws-oidc.lock ]; then \
15+
rm /tmp/aws-oidc.lock; \
16+
fi \
17+
18+
setup: # setup development dependencies
19+
export GO111MODULE=on
20+
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh
21+
curl -sfL https://raw.githubusercontent.com/reviewdog/reviewdog/master/install.sh| sh -s -- v0.9.14
22+
curl -sfL https://raw.githubusercontent.com/chanzuckerberg/bff/master/download.sh | sh
23+
.PHONY: setup
24+
25+
install:
26+
go install
27+
.PHONY: install
28+
29+
test:
30+
go test -coverprofile=coverage.txt -covermode=atomic ./...
31+
.PHONY: test
32+
33+
test-all:
34+
go test -v -coverprofile=coverage.txt -covermode=atomic ./... -tags=integration
35+
.PHONY: test-all
36+
37+
test-coverage: ## run the test with proper coverage reporting
38+
go test -coverprofile=coverage.out -covermode=atomic ./...
39+
go tool cover -html=coverage.out
40+
.PHONY: test-coverage
41+
42+
test-coverage-integration: ## run the test with proper coverage reporting
43+
go test -coverprofile=coverage.out -covermode=atomic ./... -tags=integration
44+
go tool cover -html=coverage.out
45+
.PHONY: test-coverage-all
46+
47+
deps:
48+
go get -u ./...
49+
go mod tidy
50+
.PHONY: deps
51+
52+
lint:
53+
golangci-lint run -E whitespace --exclude-use-default
54+
.PHONY: lint
55+
56+
lint-ci: ## run the fast go linters
57+
./bin/reviewdog -conf .reviewdog.yml -reporter=github-pr-review
58+
.PHONY: lint-ci
59+
60+
release: ## run a release
61+
bff bump
62+
git push
63+
goreleaser release --rm-dist
64+
.PHONY: release
65+
66+
release-prerelease: ## release to github as a 'pre-release'
67+
go build ${LDFLAGS} .
68+
commit=`git rev-parse --short HEAD`; \
69+
version=`cat VERSION`; \
70+
git tag v"$$version"+"$$commit"; \
71+
git push
72+
git push --tags
73+
goreleaser release -f .goreleaser.prerelease.yml --debug --rm-dist
74+
.PHONY: release-prelease
75+
76+
fmt:
77+
goimports -w -d $$(find . -type f -name '*.go' -not -path "./vendor/*")
78+
.PHONY: fmt
79+
80+
check-mod:
81+
go mod tidy
82+
git diff --exit-code -- go.mod go.sum
83+
.PHONY: check-mod

0 commit comments

Comments
 (0)