Skip to content

Commit

Permalink
reverts push sequence to 3 digits only (#31)
Browse files Browse the repository at this point in the history
reverts 5a8ef31
reverts c2c5e46
  • Loading branch information
cfieber authored Mar 13, 2020
1 parent 128a499 commit 0f36601
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 53 deletions.
2 changes: 1 addition & 1 deletion src/main/java/com/netflix/frigga/NameConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public interface NameConstants {
String NAME_CHARS = "a-zA-Z0-9._";
String EXTENDED_NAME_CHARS = NAME_CHARS + "~\\^";
String NAME_HYPHEN_CHARS = "-" + EXTENDED_NAME_CHARS;
String PUSH_FORMAT = "v([0-9]+)";
String PUSH_FORMAT = "v([0-9]{3})";

String COUNTRIES_KEY = "c";
String DEV_PHASE_KEY = "d";
Expand Down
6 changes: 1 addition & 5 deletions src/main/java/com/netflix/frigga/Names.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,7 @@ protected Names(String name) {
push = hasPush ? pushMatcher.group(2) : null;
String sequenceString = hasPush ? pushMatcher.group(3) : null;
if (sequenceString != null) {
try {
sequence = Integer.parseInt(sequenceString);
} catch (NumberFormatException e) {
// This is fine.
}
sequence = Integer.parseInt(sequenceString);
}
app = nameMatcher.group(1);
stack = checkEmpty(nameMatcher.group(2));
Expand Down
61 changes: 14 additions & 47 deletions src/test/groovy/com/netflix/frigga/NamesSpec.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -125,51 +125,29 @@ class NamesSpec extends Specification {
406 == names.sequence

when:
names = Names.parseName("api-test-A-v40600")
names = Names.parseName("api-test-~A-v004")
then:
"api-test-A-v40600" == names.group
"api-test-A" == names.cluster
"api" == names.app
"test" == names.stack
"A" == names.detail
"v40600" == names.push
40600 == names.sequence

when:
names = Names.parseName("api-test-A-v4")
then:
"api-test-A-v4" == names.group
"api-test-A" == names.cluster
"api" == names.app
"test" == names.stack
"A" == names.detail
"v4" == names.push
4 == names.sequence

when:
names = Names.parseName("api-test-~A-v4")
then:
"api-test-~A-v4" == names.group
"api-test-~A-v004" == names.group
"api-test-~A" == names.cluster
"api" == names.app
"test" == names.stack
"~A" == names.detail
"v4" == names.push
"v004" == names.push
4 == names.sequence

when:
names = Names.parseName("api-test-^A-v4")
names = Names.parseName("api-test-^A-v004")
then:
"api-test-^A-v4" == names.group
"api-test-^A-v004" == names.group
"api-test-^A" == names.cluster
"api" == names.app
"test" == names.stack
"^A" == names.detail
"v4" == names.push
"v004" == names.push
4 == names.sequence

when:
names = Names.parseName("api-^test-A-v4")
names = Names.parseName("api-^test-A-v004")
then:
null == names.group
null == names.cluster
Expand All @@ -180,7 +158,7 @@ class NamesSpec extends Specification {
null == names.sequence

when:
names = Names.parseName("api-~test-A-v4")
names = Names.parseName("api-~test-A-v004")
then:
null == names.group
null == names.cluster
Expand All @@ -191,25 +169,25 @@ class NamesSpec extends Specification {
null == names.sequence

when:
names = Names.parseName("api--~A-v4")
names = Names.parseName("api--~A-v004")
then:
"api--~A-v4" == names.group
"api--~A-v004" == names.group
"api--~A" == names.cluster
"api" == names.app
null == names.stack
"~A" == names.detail
"v4" == names.push
"v004" == names.push
4 == names.sequence

when:
names = Names.parseName("api--^A-v4")
names = Names.parseName("api--^A-v004")
then:
"api--^A-v4" == names.group
"api--^A-v004" == names.group
"api--^A" == names.cluster
"api" == names.app
null == names.stack
"^A" == names.detail
"v4" == names.push
"v004" == names.push
4 == names.sequence

when:
Expand Down Expand Up @@ -448,15 +426,4 @@ class NamesSpec extends Specification {
null == names.redBlackSwap
null == names.zone
}

def "should not crash on invalid sequence"() {
when:
Names names = Names.parseName("acme-eks-cluster-v220191017081605302100000002")

then:
names.app == "acme"
names.stack == "eks"
names.detail == "cluster"
names.sequence == null
}
}

0 comments on commit 0f36601

Please sign in to comment.