From 738ba45bcf0d3d9ec4f46f82f22e1d5d44231083 Mon Sep 17 00:00:00 2001 From: Conner Fromknecht Date: Thu, 20 Sep 2018 03:16:25 -0700 Subject: [PATCH] build/deployment: add prod+dev targets --- build/deployment.go | 36 ++++++++++++++++++++++++++++++++++++ build/deployment_dev.go | 6 ++++++ build/deployment_prod.go | 6 ++++++ 3 files changed, 48 insertions(+) create mode 100644 build/deployment.go create mode 100644 build/deployment_dev.go create mode 100644 build/deployment_prod.go diff --git a/build/deployment.go b/build/deployment.go new file mode 100644 index 00000000..410f7e96 --- /dev/null +++ b/build/deployment.go @@ -0,0 +1,36 @@ +package build + +// DeploymentType is an enum specifying the deployment to compile. +type DeploymentType byte + +const ( + // Development is a deployment that includes extra testing hooks and + // logging configurations. + Development DeploymentType = iota + + // Production is a deployment that strips out testing logic and uses + // Default logging. + Production +) + +// String returns a human readable name for a build type. +func (b DeploymentType) String() string { + switch b { + case Development: + return "development" + case Production: + return "production" + default: + return "unknown" + } +} + +// IsProdBuild returns true if this is a production build. +func IsProdBuild() bool { + return Deployment == Production +} + +// IsDevBuild returns true if this is a development build. +func IsDevBuild() bool { + return Deployment == Development +} diff --git a/build/deployment_dev.go b/build/deployment_dev.go new file mode 100644 index 00000000..fb2bb2b9 --- /dev/null +++ b/build/deployment_dev.go @@ -0,0 +1,6 @@ +// +build dev + +package build + +// Deployment specifies a development build. +const Deployment = Development diff --git a/build/deployment_prod.go b/build/deployment_prod.go new file mode 100644 index 00000000..247f25ae --- /dev/null +++ b/build/deployment_prod.go @@ -0,0 +1,6 @@ +// +build !dev + +package build + +// Deployment specifies a production build. +const Deployment = Production