Samrat002 commented on code in PR #27788: URL: https://github.com/apache/flink/pull/27788#discussion_r3023426173
########## flink-filesystems/flink-s3-fs-native/src/main/java/org/apache/flink/fs/s3native/S3BucketConfig.java: ########## @@ -0,0 +1,322 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.flink.fs.s3native; + +import org.apache.flink.annotation.Internal; +import org.apache.flink.configuration.IllegalConfigurationException; + +import javax.annotation.Nullable; + +import java.util.Objects; + +/** + * Immutable, bucket-specific S3 configuration overrides. + * + * <p>Null values indicate inheritance from global configuration. Only explicitly configured values + * are non-null. Configuration format: {@code s3.bucket.<bucket-name>.<property>} + * + * <p>Validates that credentials (access-key/secret-key) are either both set or both absent. + */ +@Internal +final class S3BucketConfig { + + private final String bucketName; + @Nullable private final String region; + @Nullable private final String endpoint; + @Nullable private final Boolean pathStyleAccess; + @Nullable private final String accessKey; + @Nullable private final String secretKey; + @Nullable private final String sseType; + @Nullable private final String sseKmsKeyId; + @Nullable private final String assumeRoleArn; + @Nullable private final String assumeRoleExternalId; + @Nullable private final String assumeRoleSessionName; + @Nullable private final Integer assumeRoleSessionDurationSeconds; + @Nullable private final String credentialsProvider; + + private S3BucketConfig(Builder builder) { + this.bucketName = builder.bucketName; + this.region = builder.region; + this.endpoint = builder.endpoint; + this.pathStyleAccess = builder.pathStyleAccess; + this.accessKey = builder.accessKey; + this.secretKey = builder.secretKey; + this.sseType = builder.sseType; + this.sseKmsKeyId = builder.sseKmsKeyId; + this.assumeRoleArn = builder.assumeRoleArn; + this.assumeRoleExternalId = builder.assumeRoleExternalId; + this.assumeRoleSessionName = builder.assumeRoleSessionName; + this.assumeRoleSessionDurationSeconds = builder.assumeRoleSessionDurationSeconds; + this.credentialsProvider = builder.credentialsProvider; + } + + String getBucketName() { + return bucketName; + } + + @Nullable + String getRegion() { + return region; + } + + @Nullable + String getEndpoint() { + return endpoint; + } + + @Nullable + Boolean getPathStyleAccess() { + return pathStyleAccess; + } + + @Nullable + String getAccessKey() { + return accessKey; + } + + @Nullable + String getSecretKey() { + return secretKey; + } + + @Nullable + String getSseType() { + return sseType; + } + + @Nullable + String getSseKmsKeyId() { + return sseKmsKeyId; + } + + @Nullable + String getAssumeRoleArn() { + return assumeRoleArn; + } + + @Nullable + String getAssumeRoleExternalId() { + return assumeRoleExternalId; + } + + @Nullable + String getAssumeRoleSessionName() { + return assumeRoleSessionName; + } + + @Nullable + Integer getAssumeRoleSessionDurationSeconds() { + return assumeRoleSessionDurationSeconds; + } + + @Nullable + String getCredentialsProvider() { + return credentialsProvider; + } + + boolean hasAnyOverride() { + return region != null + || endpoint != null + || pathStyleAccess != null + || accessKey != null + || secretKey != null + || sseType != null + || sseKmsKeyId != null + || assumeRoleArn != null + || assumeRoleExternalId != null + || assumeRoleSessionName != null + || assumeRoleSessionDurationSeconds != null + || credentialsProvider != null; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + S3BucketConfig that = (S3BucketConfig) o; + return Objects.equals(bucketName, that.bucketName) + && Objects.equals(region, that.region) + && Objects.equals(endpoint, that.endpoint) + && Objects.equals(pathStyleAccess, that.pathStyleAccess) + && Objects.equals(accessKey, that.accessKey) + && Objects.equals(secretKey, that.secretKey) + && Objects.equals(sseType, that.sseType) + && Objects.equals(sseKmsKeyId, that.sseKmsKeyId) + && Objects.equals(assumeRoleArn, that.assumeRoleArn) + && Objects.equals(assumeRoleExternalId, that.assumeRoleExternalId) + && Objects.equals(assumeRoleSessionName, that.assumeRoleSessionName) + && Objects.equals( + assumeRoleSessionDurationSeconds, that.assumeRoleSessionDurationSeconds) + && Objects.equals(credentialsProvider, that.credentialsProvider); + } + + @Override + public int hashCode() { + return Objects.hash( + bucketName, + region, + endpoint, + pathStyleAccess, + accessKey, + secretKey, + sseType, + sseKmsKeyId, + assumeRoleArn, + assumeRoleExternalId, + assumeRoleSessionName, + assumeRoleSessionDurationSeconds, + credentialsProvider); + } + + @Override + public String toString() { Review Comment: Fixed the toString() to properly close quotes on each field independently. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
