package util import ( "errors" "strings" ) var stagingLab = []int{ 349763, 349769, 349764, 493088, 493100, 493101, 741736, 349760, 349759, 349767, 689680, 689684, 349761, 349768, 349983, 349979, 349977, 349978, 824366, } func EnvironmentValidation(device int, env string) error { // If there is no environment variable, assume a production environment if env == "" { return errors.New("No ENVIRONMENT variable defined") } if IsProduction(env) { return nil } if IsTestDevice(device) { return nil } return errors.New("App deployed in staging and staging device not used.") } // IsProduction is a method to test if the production flag // is existent within the container. func IsProduction(env string) bool { if strings.Contains(strings.ToLower(env), "prod") { return true } return false } // IsStaging is a method to test if the production flag // is existent within the container. func IsStaging(env string) bool { if strings.Contains(strings.ToLower(env), "prod") { return false } return true } // isTestDevice method will return a boolean of true if the target device // is part of the range of lab devices. Otherwise, a false is returned func IsTestDevice(d int) bool { // Check if the target device is a lab device, if so, bypass // any further safety checks. for _, i := range stagingLab { if i == d { return true } } return false }