Skip to content

Commit

Permalink
fix issue Netflix#338: Make devPhase part of groupName
Browse files Browse the repository at this point in the history
  • Loading branch information
mkrogemann committed Jul 19, 2013
1 parent 768d484 commit e1c18b7
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import grails.validation.Validateable
String stack
String newStack
String detail
String devPhase
String chaosMonkey
String region
String imageId
Expand All @@ -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"
Expand Down
2 changes: 2 additions & 0 deletions grails-app/i18n/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 17 additions & 0 deletions test/unit/com/netflix/asgard/GroupCreateCommandSpec.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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'() {
Expand Down

0 comments on commit e1c18b7

Please sign in to comment.