Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix issue #338: Make devPhase part of groupName #345

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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