From b8a5b9adf126086be373af727e2174244bd0a15a Mon Sep 17 00:00:00 2001 From: Louis Ruch Date: Mon, 16 Nov 2020 13:51:11 -0800 Subject: [PATCH] Create common errorID generation (#788) --- Makefile | 4 ++++ scripts/errorid.go | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 scripts/errorid.go diff --git a/Makefile b/Makefile index e31630a3c..0a86391f7 100644 --- a/Makefile +++ b/Makefile @@ -27,6 +27,10 @@ dev: build-ui-ifne @echo "==> Building Boundary with dev and UI features enabled" @CGO_ENABLED=$(CGO_ENABLED) BUILD_TAGS='$(BUILD_TAGS)' BOUNDARY_DEV_BUILD=1 sh -c "'$(CURDIR)/scripts/build.sh'" +rand: + @echo "==> Generating random boundary error ID" + @go run scripts/errorid.go + bin: BUILD_TAGS+=ui bin: build-ui @echo "==> Building Boundary with UI features enabled" diff --git a/scripts/errorid.go b/scripts/errorid.go new file mode 100644 index 000000000..28dc6286a --- /dev/null +++ b/scripts/errorid.go @@ -0,0 +1,19 @@ +package main + +import ( + "fmt" + "os" + + "github.com/hashicorp/vault/sdk/helper/base62" +) + +const idLength = 10 + +func main() { + rand, err := base62.Random(idLength) + if err != nil { + fmt.Printf("failed to generate error ID: %v\n", err) + os.Exit(1) + } + fmt.Println(rand) +}