Skip to content

Commit

Permalink
address small concerns
Browse files Browse the repository at this point in the history
  • Loading branch information
skisel-bt committed Oct 13, 2023
1 parent f7fbb51 commit a9fbda9
Showing 1 changed file with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import com.google.protobuf.ByteString;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.jetbrains.annotations.NotNull;

public class GcpSecretManager implements Closeable {

Expand Down Expand Up @@ -99,20 +98,19 @@ public <R> MappedResults<R> mapSecrets(
}

private Iterable<Secret> listSecrets(String projectId, Optional<String> filter) {
ListSecretsRequest request = listSecretsRequest(projectId, filter);
final ListSecretsRequest request = listSecretsRequest(projectId, filter);
return secretManagerServiceClient.listSecrets(request).iterateAll();
}

@NotNull
private static ListSecretsRequest listSecretsRequest(String projectId, Optional<String> filter) {
ListSecretsRequest.Builder builder = ListSecretsRequest.newBuilder();
final ListSecretsRequest.Builder builder = ListSecretsRequest.newBuilder();
builder.setParent(ProjectName.of(projectId).toString());
filter.ifPresent(builder::setFilter);
return builder.build();
}

private Optional<String> fetchStringSecret(String secretName) {
AccessSecretVersionResponse accessSecretVersionResponse = fetchSecret(secretName);
final AccessSecretVersionResponse accessSecretVersionResponse = fetchSecret(secretName);
if (accessSecretVersionResponse.hasPayload()) {
SecretPayload payload = accessSecretVersionResponse.getPayload();
ByteString payloadData = payload.getData();
Expand All @@ -123,7 +121,7 @@ private Optional<String> fetchStringSecret(String secretName) {
}

private AccessSecretVersionResponse fetchSecret(String secretName) {
AccessSecretVersionRequest accessSecretVersionRequest =
final AccessSecretVersionRequest accessSecretVersionRequest =
AccessSecretVersionRequest.newBuilder().setName(secretName + "/versions/latest").build();
return secretManagerServiceClient.accessSecretVersion(accessSecretVersionRequest);
}
Expand Down

0 comments on commit a9fbda9

Please sign in to comment.