diff --git a/.gitignore b/.gitignore index 368f9a7..cffe3a9 100644 --- a/.gitignore +++ b/.gitignore @@ -17,6 +17,9 @@ # Packages from go get github.com +# Complied binaries +cmd/param/param-* + ### macOS ### # General .DS_Store diff --git a/README.md b/README.md index 42fb099..8e63eb2 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,19 @@ # WIP + ## TODO -- bash completion for parameter names -- Distribute as a release. +- bash completion for parameter names. +- Distribute as a release (On multiple platforms). +https://www.digitalocean.com/community/tutorials/how-to-build-go-executables-for-multiple-platforms-on-ubuntu-16-04 +- Set parameters. - Common SSM service instead of duplicated in both. - Write tests! ## Usage +Make sure your terminal session has the correct AWS credentials. + Copy a parameter to your clipboard: $ param copy parameter_name diff --git a/cmd/param/build-all.sh b/cmd/param/build-all.sh new file mode 100755 index 0000000..85bf652 --- /dev/null +++ b/cmd/param/build-all.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# +# Trimmed down version of: https://gist.github.com/eduncan911/68775dba9d3c028181e4 +# +# GoLang cross-compile snippet for Go 1.6+ based loosely on Dave Chaney's cross-compile script: +# http://dave.cheney.net/2012/09/08/an-introduction-to-cross-compilation-with-go +# +# To use: +# +# $ cd ~/path-to/my-awesome-project +# $ go-build-all +# +PLATFORMS="darwin/amd64 linux/amd64" + +type setopt >/dev/null 2>&1 + +SCRIPT_NAME=`basename "$0"` +FAILURES="" +SOURCE_FILE=`echo $@ | sed 's/\.go//'` +CURRENT_DIRECTORY=${PWD##*/} +OUTPUT=${SOURCE_FILE:-$CURRENT_DIRECTORY} # if no src file given, use current dir name + +for PLATFORM in $PLATFORMS; do + GOOS=${PLATFORM%/*} + GOARCH=${PLATFORM#*/} + BIN_FILENAME="${OUTPUT}-${GOOS}-${GOARCH}" + if [[ "${GOOS}" == "windows" ]]; then BIN_FILENAME="${BIN_FILENAME}.exe"; fi + CMD="GOOS=${GOOS} GOARCH=${GOARCH} go build -o ${BIN_FILENAME} $@" + echo "${CMD}" + eval $CMD || FAILURES="${FAILURES} ${PLATFORM}" +done + +# eval errors +if [[ "${FAILURES}" != "" ]]; then + echo "" + echo "${SCRIPT_NAME} failed on: ${FAILURES}" + exit 1 +fi diff --git a/cmd/param/param.go b/cmd/param/param.go index c114b19..32cdf39 100644 --- a/cmd/param/param.go +++ b/cmd/param/param.go @@ -12,16 +12,12 @@ import ( ) func main() { - // add a variable to the program - var name string - flag.StringVar(&name, "name", "", "Give your name") // create the complete command cmp := complete.New( "param", complete.Command{ Flags: complete.Flags{ - "-name": complete.PredictAnything, "-complete": complete.PredictNothing, "-uncomplete": complete.PredictNothing, "-h": complete.PredictNothing, @@ -41,8 +37,8 @@ func main() { }, ) - cmp.CLI.InstallName = "complete" - cmp.CLI.UninstallName = "uncomplete" + cmp.InstallName = "complete" + cmp.UninstallName = "uncomplete" cmp.AddFlags(nil) // parse the flags - both the program's flags and the completion flags diff --git a/pkg/paramlist/paramlist.go b/pkg/paramlist/paramlist.go index 74c0d97..b32c5b5 100644 --- a/pkg/paramlist/paramlist.go +++ b/pkg/paramlist/paramlist.go @@ -2,12 +2,13 @@ package paramlist import ( "fmt" + "os" + "sort" + "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/ssm" "github.com/droundy/goopt" - "os" - "sort" ) var service = createSSMService()