summaryrefslogtreecommitdiffstats
path: root/config-provisioning
diff options
context:
space:
mode:
Diffstat (limited to 'config-provisioning')
-rw-r--r--config-provisioning/src/main/java/com/yahoo/config/provision/CloudAccount.java13
1 files changed, 9 insertions, 4 deletions
diff --git a/config-provisioning/src/main/java/com/yahoo/config/provision/CloudAccount.java b/config-provisioning/src/main/java/com/yahoo/config/provision/CloudAccount.java
index 0d58c2953b5..11fd352bcc9 100644
--- a/config-provisioning/src/main/java/com/yahoo/config/provision/CloudAccount.java
+++ b/config-provisioning/src/main/java/com/yahoo/config/provision/CloudAccount.java
@@ -12,11 +12,15 @@ import java.util.regex.Pattern;
*/
public class CloudAccount extends PatternedStringWrapper<CloudAccount> {
+ private static final String EMPTY = "";
+ private static final String AWS_ACCOUNT_ID = "[0-9]{12}";
+ private static final String GCP_PROJECT_ID = "[a-z][a-z0-9-]{4,28}[a-z0-9]";
+
/** Empty value. When this is used, either implicitly or explicitly, the zone will use its default account */
- public static final CloudAccount empty = new CloudAccount("");
+ public static final CloudAccount empty = new CloudAccount("", EMPTY, "cloud account");
- private CloudAccount(String value) {
- super(value, Pattern.compile("^([0-9]{12})?$"), "cloud account");
+ private CloudAccount(String value, String regex, String description) {
+ super(value, Pattern.compile("^(" + regex + ")$"), description);
}
public boolean isUnspecified() {
@@ -25,8 +29,9 @@ public class CloudAccount extends PatternedStringWrapper<CloudAccount> {
public static CloudAccount from(String cloudAccount) {
return switch (cloudAccount) {
+ // TODO: Remove "default" as e.g. it is a valid GCP project ID
case "", "default" -> empty;
- default -> new CloudAccount(cloudAccount);
+ default -> new CloudAccount(cloudAccount, AWS_ACCOUNT_ID + "|" + GCP_PROJECT_ID, "cloud account");
};
}