From 4271f591e5320c559de938e6f68c1b6f7cad7a41 Mon Sep 17 00:00:00 2001 From: Mark Wolfe Date: Mon, 14 Dec 2015 09:14:16 +1100 Subject: [PATCH] Added setup routine to the CLI. --- Makefile | 4 ++-- cmd/unicreds/main.go | 7 +++++++ ds.go | 4 ++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 6b026d0..310d71a 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,10 @@ NAME=unicreds ARCH=$(shell uname -m) VERSION=1.0.0 -GO15VENDOREXPERIMENT=1 +GO15VENDOREXPERIMENT := 1 vendor: - godep save + godep save -t -v ./... build: rm -rf build && mkdir build diff --git a/cmd/unicreds/main.go b/cmd/unicreds/main.go index a8d48dc..4775c47 100644 --- a/cmd/unicreds/main.go +++ b/cmd/unicreds/main.go @@ -16,6 +16,8 @@ var ( alias = app.Flag("alias", "KMS key alias.").Default("alias/credstash").String() // commands + cmdSetup = app.Command("setup", "Setup the dynamodb table used to store credentials.") + cmdGet = app.Command("get", "Get a credential from the store.") cmdGetName = cmdGet.Arg("credential", "The name of the credential to get.").Required().String() @@ -39,6 +41,11 @@ func main() { app.Version(Version) switch kingpin.MustParse(app.Parse(os.Args[1:])) { + case cmdSetup.FullCommand(): + err := unicreds.Setup() + if err != nil { + printFatalError(err) + } case cmdGet.FullCommand(): cred, err := unicreds.GetSecret(*cmdGetName) if err != nil { diff --git a/ds.go b/ds.go index 279a0f3..92a9454 100644 --- a/ds.go +++ b/ds.go @@ -51,8 +51,8 @@ type DecryptedCredential struct { Secret string } -// CreateDBTable create the table which stores credentials -func CreateDBTable() (err error) { +// Setup create the table which stores credentials +func Setup() (err error) { res, err := dynamoSvc.CreateTable(&dynamodb.CreateTableInput{ AttributeDefinitions: []*dynamodb.AttributeDefinition{