github.com/vchain-us/vcn@v0.9.11-0.20210921212052-a2484d23c0b3/pkg/meta/stage.go (about) 1 /* 2 * Copyright (c) 2018-2020 vChain, Inc. All Rights Reserved. 3 * This software is released under GPL3. 4 * The full license information can be found under: 5 * https://www.gnu.org/licenses/gpl-3.0.en.html 6 * 7 */ 8 9 package meta 10 11 import ( 12 "log" 13 "os" 14 ) 15 16 // Stage is the type for all possible stage values 17 type Stage int64 18 19 // Allowed stage values 20 const ( 21 StageProduction Stage = 0 22 StageStaging Stage = 1 23 StageTest Stage = 2 24 ) 25 26 // StageEnvironment returns the current Stage value 27 func StageEnvironment() Stage { 28 switch os.Getenv("STAGE") { 29 case "PRODUCTION": 30 return StageProduction 31 case "STAGING": 32 return StageStaging 33 case "TEST": 34 return StageTest 35 default: 36 return StageProduction 37 } 38 } 39 40 // String returns the name of the stage as string 41 func (s Stage) String() string { 42 switch s { 43 case StageProduction: 44 return "PRODUCTION" 45 case StageStaging: 46 return "STAGING" 47 case StageTest: 48 return "TEST" 49 default: 50 log.Fatal("unsupported stage", int64(s)) 51 return "" 52 } 53 }