Skip to content

Commit

Permalink
format check on aws region parameter to adhere to kebab case
Browse files Browse the repository at this point in the history
  • Loading branch information
Sachin Karve committed Jul 1, 2024
1 parent 72f616a commit 3448b1a
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/main/java/com/meta/cp4m/S3PreProcessorConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.base.Preconditions;
import com.meta.cp4m.message.Message;
import java.util.Objects;

Expand All @@ -22,6 +23,11 @@ public S3PreProcessorConfig(
@JsonProperty("aws_secret_access_key") String awsSecretAccessKey,
@JsonProperty("region") String region,
@JsonProperty("bucket") String bucket) {

String kebabCase = "^[a-z0-9]+(-[a-z0-9]+)*$";
Preconditions.checkArgument(
bucket.matches(kebabCase), "bucket does not match the aws region format(kebab case) or is empty");

this.name = Objects.requireNonNull(name, "name is a required parameter");
this.awsAccessKeyId = Objects.requireNonNull(awsAccessKeyId, "aws access key is a required parameter");
this.awsSecretAccessKey = Objects.requireNonNull(awsSecretAccessKey, "aws secret access key is a required parameter");
Expand Down

0 comments on commit 3448b1a

Please sign in to comment.