Skip to content

Commit

Permalink
New HashiCorp Vault Plugin releaser using GitHub Actions. (#248)
Browse files Browse the repository at this point in the history
Release will be triggered when a new tag `vault-plugin-secrets-ksm/v*` is created in the repository
  • Loading branch information
maksimu authored Apr 1, 2022
1 parent e015f32 commit 345b181
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 20 deletions.
61 changes: 61 additions & 0 deletions .github/workflows/publish.hashicorpvault.plugin.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Release HV Plugin

on:
workflow_dispatch:
push:
tags:
- 'vault-plugin-secrets-ksm/v*'

jobs:
release-hv-plugin:
environment: prod
runs-on: ubuntu-latest

defaults:
run:
working-directory: integration/vault-plugin-secrets-ksm

steps:

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

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.17

# Cache GoLang libs
- uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Create binaries
run: | # initially `github.ref` == "ref/tags/vault-plugin-secrets-ksm/vX.Y.Z"
PLUGIN_NAME="$(cut -d'/' -f3 <<<${{ github.ref }})"
PLUGIN_VERSION=${"$(cut -d'/' -f4 <<<${{ github.ref }})":1}
echo "Plugin name: [${PLUGIN_NAME}]"
echo "Plugin version: [${PLUGIN_VERSION}]"
make release-all PLUGIN_NAME="${PLUGIN_NAME}" PLUGIN_VERSION="${PLUGIN_VERSION}"
- name: "Info: List created files"
run: |
pwd
ls -la
# Publish binaries
- name: Release Binaries
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: integration/vault-plugin-secrets-ksm/vault-plugin-secrets-ksm*
tag: ${{ github.ref }}
overwrite: true
file_glob: true
body: "KSM Hashicorp Vault Secrets Plugin ${{ github.ref }}"
1 change: 0 additions & 1 deletion integration/vault-plugin-secrets-ksm/.VERSION

This file was deleted.

29 changes: 14 additions & 15 deletions integration/vault-plugin-secrets-ksm/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
PLUGIN_NAME = vault-plugin-secrets-ksm
versionFile = $(CURDIR)/.VERSION
VERSION := $(shell cat $(versionFile) | sed 's/^v//')
PLUGIN_NAME = $(PLUGIN_NAME)
PLUGIN_VERSION = $(PLUGIN_VERSION)

all: fmt build

Expand All @@ -20,15 +19,15 @@ release:
go build; zip -m ${PLUGIN_NAME}.zip ${PLUGIN_NAME} ${PLUGIN_NAME}.exe

release-all:
$(eval GOOS=darwin) $(eval GOARCH=amd64) GOOS=${GOOS} GOARCH=${GOARCH} go build ; zip -m ${PLUGIN_NAME}_${VERSION}_${GOOS}_${GOARCH}.zip ${PLUGIN_NAME}
$(eval GOOS=darwin) $(eval GOARCH=arm64) GOOS=${GOOS} GOARCH=${GOARCH} go build ; zip -m ${PLUGIN_NAME}_${VERSION}_${GOOS}_${GOARCH}.zip ${PLUGIN_NAME}
$(eval GOOS=freebsd) $(eval GOARCH=386) GOOS=${GOOS} GOARCH=${GOARCH} go build ; zip -m ${PLUGIN_NAME}_${VERSION}_${GOOS}_${GOARCH}.zip ${PLUGIN_NAME}
$(eval GOOS=freebsd) $(eval GOARCH=amd64) GOOS=${GOOS} GOARCH=${GOARCH} go build ; zip -m ${PLUGIN_NAME}_${VERSION}_${GOOS}_${GOARCH}.zip ${PLUGIN_NAME}
$(eval GOOS=freebsd) $(eval GOARCH=arm) GOOS=${GOOS} GOARCH=${GOARCH} go build ; zip -m ${PLUGIN_NAME}_${VERSION}_${GOOS}_${GOARCH}.zip ${PLUGIN_NAME}
$(eval GOOS=linux) $(eval GOARCH=386) GOOS=${GOOS} GOARCH=${GOARCH} go build ; zip -m ${PLUGIN_NAME}_${VERSION}_${GOOS}_${GOARCH}.zip ${PLUGIN_NAME}
$(eval GOOS=linux) $(eval GOARCH=amd64) GOOS=${GOOS} GOARCH=${GOARCH} go build ; zip -m ${PLUGIN_NAME}_${VERSION}_${GOOS}_${GOARCH}.zip ${PLUGIN_NAME}
$(eval GOOS=linux) $(eval GOARCH=arm) GOOS=${GOOS} GOARCH=${GOARCH} go build ; zip -m ${PLUGIN_NAME}_${VERSION}_${GOOS}_${GOARCH}.zip ${PLUGIN_NAME}
$(eval GOOS=linux) $(eval GOARCH=arm64) GOOS=${GOOS} GOARCH=${GOARCH} go build ; zip -m ${PLUGIN_NAME}_${VERSION}_${GOOS}_${GOARCH}.zip ${PLUGIN_NAME}
$(eval GOOS=windows) $(eval GOARCH=386) GOOS=${GOOS} GOARCH=${GOARCH} go build ; zip -m ${PLUGIN_NAME}_${VERSION}_${GOOS}_${GOARCH}.zip ${PLUGIN_NAME}.exe
$(eval GOOS=windows) $(eval GOARCH=amd64) GOOS=${GOOS} GOARCH=${GOARCH} go build ; zip -m ${PLUGIN_NAME}_${VERSION}_${GOOS}_${GOARCH}.zip ${PLUGIN_NAME}.exe
sha256sum ${PLUGIN_NAME}_${VERSION}_*.zip > ${PLUGIN_NAME}_${VERSION}_SHA256SUMS
$(eval GOOS=darwin) $(eval GOARCH=amd64) GOOS=${GOOS} GOARCH=${GOARCH} go build ; zip -m ${PLUGIN_NAME}_${PLUGIN_VERSION}_${GOOS}_${GOARCH}.zip ${PLUGIN_NAME}
$(eval GOOS=darwin) $(eval GOARCH=arm64) GOOS=${GOOS} GOARCH=${GOARCH} go build ; zip -m ${PLUGIN_NAME}_${PLUGIN_VERSION}_${GOOS}_${GOARCH}.zip ${PLUGIN_NAME}
$(eval GOOS=freebsd) $(eval GOARCH=386) GOOS=${GOOS} GOARCH=${GOARCH} go build ; zip -m ${PLUGIN_NAME}_${PLUGIN_VERSION}_${GOOS}_${GOARCH}.zip ${PLUGIN_NAME}
$(eval GOOS=freebsd) $(eval GOARCH=amd64) GOOS=${GOOS} GOARCH=${GOARCH} go build ; zip -m ${PLUGIN_NAME}_${PLUGIN_VERSION}_${GOOS}_${GOARCH}.zip ${PLUGIN_NAME}
$(eval GOOS=freebsd) $(eval GOARCH=arm) GOOS=${GOOS} GOARCH=${GOARCH} go build ; zip -m ${PLUGIN_NAME}_${PLUGIN_VERSION}_${GOOS}_${GOARCH}.zip ${PLUGIN_NAME}
$(eval GOOS=linux) $(eval GOARCH=386) GOOS=${GOOS} GOARCH=${GOARCH} go build ; zip -m ${PLUGIN_NAME}_${PLUGIN_VERSION}_${GOOS}_${GOARCH}.zip ${PLUGIN_NAME}
$(eval GOOS=linux) $(eval GOARCH=amd64) GOOS=${GOOS} GOARCH=${GOARCH} go build ; zip -m ${PLUGIN_NAME}_${PLUGIN_VERSION}_${GOOS}_${GOARCH}.zip ${PLUGIN_NAME}
$(eval GOOS=linux) $(eval GOARCH=arm) GOOS=${GOOS} GOARCH=${GOARCH} go build ; zip -m ${PLUGIN_NAME}_${PLUGIN_VERSION}_${GOOS}_${GOARCH}.zip ${PLUGIN_NAME}
$(eval GOOS=linux) $(eval GOARCH=arm64) GOOS=${GOOS} GOARCH=${GOARCH} go build ; zip -m ${PLUGIN_NAME}_${PLUGIN_VERSION}_${GOOS}_${GOARCH}.zip ${PLUGIN_NAME}
$(eval GOOS=windows) $(eval GOARCH=386) GOOS=${GOOS} GOARCH=${GOARCH} go build ; zip -m ${PLUGIN_NAME}_${PLUGIN_VERSION}_${GOOS}_${GOARCH}.zip ${PLUGIN_NAME}.exe
$(eval GOOS=windows) $(eval GOARCH=amd64) GOOS=${GOOS} GOARCH=${GOARCH} go build ; zip -m ${PLUGIN_NAME}_${PLUGIN_VERSION}_${GOOS}_${GOARCH}.zip ${PLUGIN_NAME}.exe
sha256sum ${PLUGIN_NAME}_${PLUGIN_VERSION}_*.zip > ${PLUGIN_NAME}_${PLUGIN_VERSION}_SHA256SUMS
9 changes: 5 additions & 4 deletions sdk/python/core/keeper_secrets_manager_core/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -619,11 +619,11 @@ def get_notation(self, url):
Example:
RECORD_UID/field/password => MyPasswprd
RECORD_UID/field/password => MyPassword
RECORD_UID/field/password[0] => MyPassword
RECORD_UID/field/password[] => ["MyPassword"]
RECORD_UID/custom_field/name[first] => John
RECORD_UID/custom_field/name[last] => Smitht
RECORD_UID/custom_field/name[last] => Smith
RECORD_UID/custom_field/phone[0][number] => "555-5555555"
RECORD_UID/custom_field/phone[1][number] => "777-7777777"
RECORD_UID/custom_field/phone[] => [{"number": "555-555...}, { "number": "777.....}]
Expand All @@ -640,7 +640,8 @@ def get_notation(self, url):
# Get the except below handle it
raise ValueError()
except IndexError:
raise ValueError("Keeper url missing information about the uid, field type, and field key.")
raise ValueError("Keeper url [{}] missing information about the uid, field type, and field key."
.format(url))

try:
(uid, file_data_type, key) = url.split('/')
Expand All @@ -654,7 +655,7 @@ def get_notation(self, url):
if key is None:
raise ValueError("file key is missing the in the keeper url.")

# By default we want to return a single value, which is the first item in the array
# By default, we want to return a single value, which is the first item in the array
return_single = True
index = 0
dict_key = None
Expand Down

0 comments on commit 345b181

Please sign in to comment.