diff --git a/grails-app/controllers/com/netflix/asgard/GroupCreateCommand.groovy b/grails-app/controllers/com/netflix/asgard/GroupCreateCommand.groovy index 2dd11c82..617f44d0 100644 --- a/grails-app/controllers/com/netflix/asgard/GroupCreateCommand.groovy +++ b/grails-app/controllers/com/netflix/asgard/GroupCreateCommand.groovy @@ -27,6 +27,7 @@ import grails.validation.Validateable String stack String newStack String detail + String devPhase String chaosMonkey String region String imageId @@ -35,6 +36,15 @@ import grails.validation.Validateable static constraints = { + devPhase(nullable: true, validator: { value, command -> + if (value && !Relationships.checkName(value)) { + return "devPhase.illegalChar" + } + if (Relationships.usesReservedFormat(value)) { + return "name.usesReservedFormat" + } + }) + appName(nullable: false, blank: false, validator: { value, command -> if (!Relationships.checkName(value)) { return "application.name.illegalChar" diff --git a/grails-app/i18n/messages.properties b/grails-app/i18n/messages.properties index ece1a386..7b4c80fe 100644 --- a/grails-app/i18n/messages.properties +++ b/grails-app/i18n/messages.properties @@ -56,6 +56,8 @@ groupName.exists=There is already an auto scaling group named {3} stack.illegalChar=The new stack field must be empty or consist of alphanumeric characters stack.matchesNewStack=You cannot use both an existing stack and a new stack +devPhase.illegalChar=DevPhase can only contain letters, numbers, underscores, and dots + name.usesReservedFormat=The format "v###" (where # is any digit) and the format "[a-z]0" (where [a-z] is any letter) are reserved. Please use a different name. snapshotCommand.volumeSize.matches.error=Volume size must be an integer diff --git a/test/unit/com/netflix/asgard/GroupCreateCommandSpec.groovy b/test/unit/com/netflix/asgard/GroupCreateCommandSpec.groovy index 78dec294..46d01a66 100644 --- a/test/unit/com/netflix/asgard/GroupCreateCommandSpec.groovy +++ b/test/unit/com/netflix/asgard/GroupCreateCommandSpec.groovy @@ -132,6 +132,23 @@ class GroupCreateCommandSpec extends Specification { 'blah-v305' | 'name.usesReservedFormat' } + @Unroll("""should validate devPhase input '#devPhase' with error code '#error'""") + def 'devPhase constraints'() { + cmd.stack = 'iphone' + cmd.devPhase = devPhase + + when: + cmd.validate() + + then: + cmd.errors.devPhase == error + + where: + devPhase | error + 'v305' | 'name.usesReservedFormat' + 'foo-bar' | 'devPhase.illegalChar' + } + @Unroll("""should validate chaosMonkey input '#chaosMonkey' with error code '#error' when requestedFromGui is \ '#requestedFromGui' and isChaosMonkeyActive is '#isChaosMonkeyActive' and optLevel is '#optLevel'""") def 'chaosMonkey constraints'() {