Skip to content

Commit

Permalink
Build Script To Build Linux Binary
Browse files Browse the repository at this point in the history
  • Loading branch information
WillJCJ committed Jun 29, 2018
1 parent fccafb4 commit 7c8a292
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 10 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
# Packages from go get
github.com

# Complied binaries
cmd/param/param-*

### macOS ###
# General
.DS_Store
Expand Down
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
38 changes: 38 additions & 0 deletions cmd/param/build-all.sh
Original file line number Diff line number Diff line change
@@ -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
8 changes: 2 additions & 6 deletions cmd/param/param.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down
5 changes: 3 additions & 2 deletions pkg/paramlist/paramlist.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 7c8a292

Please sign in to comment.