Skip to content

Commit

Permalink
refactor!: Renamed credentials to key file
Browse files Browse the repository at this point in the history
  • Loading branch information
Julien Ruaux committed Jan 16, 2023
1 parent 9523459 commit e78a177
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@
public class GcsOptions {

@Option(names = "--gcs-key-file", description = "GCS private key (e.g. /usr/local/key.json).", paramLabel = "<file>")
private Optional<File> credentials = Optional.empty();
private Optional<File> keyFile = Optional.empty();
@Option(names = "--gcs-project", description = "GCP project id.", paramLabel = "<id>")
private Optional<String> projectId = Optional.empty();
@Option(names = "--gcs-key", arity = "0..1", interactive = true, description = "GCS Base64 encoded key.", paramLabel = "<key>")
private Optional<String> encodedKey = Optional.empty();

public void setCredentials(File credentials) {
this.credentials = Optional.of(credentials);
public void setKeyFile(File credentials) {
this.keyFile = Optional.of(credentials);
}

public void setProjectId(String projectId) {
Expand All @@ -42,8 +42,8 @@ public void setEncodedKey(String encodedKey) {
public GoogleStorageResource resource(String locationUri, boolean readOnly) throws IOException {
StorageOptions.Builder builder = StorageOptions.newBuilder().setProjectId(ServiceOptions.getDefaultProjectId())
.setHeaderProvider(new UserAgentHeaderProvider(GcpStorageAutoConfiguration.class));
if (credentials.isPresent()) {
builder.setCredentials(GoogleCredentials.fromStream(Files.newInputStream(credentials.get().toPath()))
if (keyFile.isPresent()) {
builder.setCredentials(GoogleCredentials.fromStream(Files.newInputStream(keyFile.get().toPath()))
.createScoped((readOnly ? GcpScope.STORAGE_READ_ONLY : GcpScope.STORAGE_READ_WRITE).getUrl()));
}
if (encodedKey.isPresent()) {
Expand All @@ -56,8 +56,7 @@ public GoogleStorageResource resource(String locationUri, boolean readOnly) thro

@Override
public String toString() {
return "GcsOptions [credentials=" + credentials + ", projectId=" + projectId + ", encodedKey=" + encodedKey
+ "]";
return "GcsOptions [credentials=" + keyFile + ", projectId=" + projectId + ", encodedKey=" + encodedKey + "]";
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.time.Duration;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeoutException;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;

Expand Down Expand Up @@ -84,7 +85,7 @@ protected <I, O> FaultTolerantStepBuilder<I, O> step(SimpleStepBuilder<I, O> ste
LimitCheckingItemSkipPolicy limitSkipPolicy = (LimitCheckingItemSkipPolicy) skipPolicy;
limitSkipPolicy.setSkippableExceptionMap(
Stream.of(RedisCommandExecutionException.class, RedisCommandTimeoutException.class,
TimeoutException.class).collect(Collectors.toMap(t -> t, t -> true)));
TimeoutException.class).collect(Collectors.toMap(Function.identity(), t -> true)));
}
return step.faultTolerant().skipPolicy(options.getSkipPolicy().getSkipPolicy());
}
Expand Down

0 comments on commit e78a177

Please sign in to comment.