Skip to content

Commit

Permalink
Init
Browse files Browse the repository at this point in the history
  • Loading branch information
SorsOps committed Mar 27, 2023
0 parents commit e7c9e23
Show file tree
Hide file tree
Showing 27 changed files with 1,475 additions and 0 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Release

on:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

push:
# run only against tags
tags:
- 'v*'
create:
# run only against tags
tags:
- 'v*'

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages as well
permissions:
contents: write
pages: write
id-token: write


jobs:
binaries:
runs-on: ubuntu-20.04

steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Fetch Go version
run: |
GO_VERSION=$(perl -ne 'print "$1\n" if /FROM golang:([0-9.]+)/' Dockerfile | head -n1)
[ -n "$GO_VERSION" ] || exit 1
echo "go_version=$GO_VERSION" >> $GITHUB_ENV
- name: Setup Go environment
uses: actions/setup-go@v3
with:
go-version: "${{ env.go_version }}"

- name: Binaries Release
uses: goreleaser/goreleaser-action@v2.9.1
with:
version: ~> 1.5.0
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
43 changes: 43 additions & 0 deletions .github/workflows/tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Tag

on:
push:
branches: ["master"]

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages as well
permissions:
contents: write
pages: write
id-token: write


jobs:
tag-version:
runs-on: ubuntu-20.04

steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Setup dotnet
uses: actions/setup-dotnet@v3
with:
dotnet-version: 3.1.x
- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v0.9.15
with:
versionSpec: "5.x"
- name: Determine Version
id: gitversion
uses: gittools/actions/gitversion/execute@v0.9.15
with:
useConfigFile: true
- name: Bump version and push tag
id: tag_version
uses: mathieudutour/github-tag-action@v6.1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
custom_tag: ${{ steps.gitversion.outputs.SemVer }}
create_annotated_tag : true
31 changes: 31 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Test

on: [pull_request]


jobs:
build:
runs-on: ubuntu-20.04

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Fetch Go version
run: |
GO_VERSION=$(perl -ne 'print "$1\n" if /FROM golang:([0-9.]+)/' Dockerfile | head -n1)
[ -n "$GO_VERSION" ] || exit 1
echo "go_version=$GO_VERSION" >> $GITHUB_ENV
- name: Setup Go environment
uses: actions/setup-go@v3
with:
go-version: "${{ env.go_version }}"

- name: Program Test
run: go test ./...

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2.0.0

- name: Docker Build Test
run: docker buildx build --load --tag test:test --file ./Dockerfile ./
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
builds/*
tests/**/backend.tf
tests/**/.secrets.env
dist
*.env
32 changes: 32 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
before:
builds:
- env:
- CGO_ENABLED=0
ldflags:
- -s -w
- "-X main.semverVersion=1.0.0"
goos:
- linux
- windows
- darwin
- freebsd
goarch:
- 386
- amd64
- arm
- arm64
- mips
- mipsle
- mips64
- mips64le
- s390x
goarm:
- 5
- 6
- 7
gomips:
- softfloat
archives:
- format: binary
checksum:
name_template: "checksums.txt"
60 changes: 60 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Test KV Secrets [DEBUG]",
"type": "go",
"request": "launch",
"mode": "debug",
"program": "${workspaceFolder}/main.go",
"env": {},
"envFile": "${workspaceFolder}/.env",
"args": [
"--collection",
"test-kv",
"--verbose"
],
"cwd": "./tests",
"showLog": true
},
{
"name": "Test KV Secrets BAT [DEBUG]",
"type": "go",
"request": "launch",
"mode": "debug",
"program": "${workspaceFolder}/main.go",
"env": {},
"envFile": "${workspaceFolder}/.env",
"args": [
"--collection",
"test-kv",
"--output",
"./env.bat",
"--format",
"WINDOWS",
"--verbose"
],
"cwd": "./tests",
"showLog": true
},
{
"name": "Test AWS Secrets [DEBUG]",
"type": "go",
"request": "launch",
"mode": "debug",
"program": "${workspaceFolder}/main.go",
"env": {},
"envFile": "${workspaceFolder}/.env",
"args": [
"--collection",
"test-aws",
"--verbose"
],
"cwd": "./tests",
"showLog": true
}
]
}
41 changes: 41 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "run",
"type": "shell",
"command": "ginkgo -r --tags=unit_test",
"problemMatcher": [],
"group": {
"kind": "test",
"isDefault": true
}
},
{
"label": "runHelp",
"type": "shell",
"command": "go run main.go --help",
"problemMatcher": [],
"group": "test"
},
{
"label": "runVersion",
"type": "shell",
"command": "go run main.go version",
"problemMatcher": [],
"group": "test"
},
{
"label": "build",
"type": "shell",
"command": "go build -o ./builds/vault-env.exe",
"problemMatcher": [],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
16 changes: 16 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM golang:1.18.3-alpine AS builder

WORKDIR /src
COPY . .

RUN apk add --no-cache git && \
go mod download && \
CGO_ENABLED=0 go build -ldflags="-s -w" -o "vault-env"

FROM alpine:3.16.0

WORKDIR /

COPY --from=builder "/src/vault-env" "/"

ENTRYPOINT ["/vault-env"]
10 changes: 10 additions & 0 deletions GitVersion.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
tag-prefix: '[vV]?'
increment: Inherit
mode: Mainline
major-version-bump-message: '(breaking|major):\s?'
minor-version-bump-message: '(feature|minor|feat):\s?'
patch-version-bump-message: '(fix|patch):\s?'
no-bump-message: '(none|skip)\s?:'
branches:
master:
is-mainline: true
16 changes: 16 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
version: '3'
services:
build:
image: goreleaser/goreleaser
volumes:
- .:/app
command: build --clean --skip-validate
working_dir: /app
environment:
- SEMVER_VERSION
lint:
image: golangci/golangci-lint:v1.52.2
volumes:
- .:/app
command: golangci-lint run -v
working_dir: /app
55 changes: 55 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
module sorsops/vault-env/v2

go 1.18

require (
github.com/onsi/ginkgo/v2 v2.9.2
github.com/sirupsen/logrus v1.9.0
github.com/urfave/cli/v2 v2.25.1
gopkg.in/yaml.v2 v2.4.0
)

require (
github.com/go-logr/logr v1.2.3 // indirect
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38 // indirect
github.com/kr/pretty v0.1.0 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/stretchr/testify v1.7.2 // indirect
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
golang.org/x/tools v0.7.0 // indirect
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

require (
github.com/cenkalti/backoff/v3 v3.2.2 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
github.com/fatih/color v1.15.0 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-hclog v1.5.0 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/go-retryablehttp v0.7.2 // indirect
github.com/hashicorp/go-rootcerts v1.0.2 // indirect
github.com/hashicorp/go-secure-stdlib/parseutil v0.1.7 // indirect
github.com/hashicorp/go-secure-stdlib/strutil v0.1.2 // indirect
github.com/hashicorp/go-sockaddr v1.0.2 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/hashicorp/vault/api v1.9.0
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.18 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/onsi/gomega v1.27.5
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/ryanuber/go-glob v1.0.0 // indirect
golang.org/x/crypto v0.7.0 // indirect
golang.org/x/net v0.8.0 // indirect
golang.org/x/sys v0.6.0 // indirect
golang.org/x/text v0.8.0 // indirect
golang.org/x/time v0.3.0 // indirect
google.golang.org/protobuf v1.30.0 // indirect
gopkg.in/square/go-jose.v2 v2.6.0 // indirect
)
Loading

0 comments on commit e7c9e23

Please sign in to comment.