Skip to content

Commit

Permalink
CR feedback to use preconditions to check args
Browse files Browse the repository at this point in the history
  • Loading branch information
eschultink committed Oct 21, 2024
1 parent 02ae08f commit b1cb95e
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.bettercloud.vault.response.LogicalResponse;
import com.bettercloud.vault.response.LookupResponse;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.base.Preconditions;
import dagger.assisted.Assisted;
import dagger.assisted.AssistedInject;
import lombok.Getter;
Expand Down Expand Up @@ -129,9 +130,7 @@ public VaultConfigService init() {
@SneakyThrows
@Override
public void putConfigProperty(ConfigProperty property, String value) {
if (property.isEnvVarOnly()) {
throw new IllegalArgumentException("Can't put env-only config property: " + property);
}
Preconditions.checkArgument(!property.isEnvVarOnly(), "Can't put env-only config property: " + property);

vault.logical()
.write(path(property), Map.of(VALUE_FIELD, value));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,7 @@ public class ParameterStoreConfigService implements SecretStore, LockService {

@Override
public void putConfigProperty(ConfigProperty property, String value) {
if (property.isEnvVarOnly()) {
throw new IllegalArgumentException("Can't put env-only config property: " + property);
}
Preconditions.checkArgument(!property.isEnvVarOnly(), "Can't put env-only config property: " + property);

String key = parameterName(property);
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import co.worklytics.psoxy.gateway.SecretStore;
import co.worklytics.psoxy.gateway.impl.EnvVarsConfigService;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Preconditions;
import dagger.assisted.Assisted;
import dagger.assisted.AssistedInject;
import lombok.Getter;
Expand Down Expand Up @@ -48,9 +49,8 @@ public class SecretsManagerSecretStore implements SecretStore {

@Override
public void putConfigProperty(ConfigProperty property, String value) {
if (property.isEnvVarOnly()) {
throw new IllegalArgumentException("Can't put env-only config property: " + property);
}
Preconditions.checkArgument(!property.isEnvVarOnly(), "Can't put env-only config property: " + property);

String id = secretId(property);
try {
PutSecretValueRequest request = PutSecretValueRequest.builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,7 @@ public SecretManagerConfigService(@Assisted("projectId") @NonNull String project

@Override
public void putConfigProperty(ConfigProperty property, String value) {
if (property.isEnvVarOnly()) {
throw new IllegalArgumentException("Can't put env-only config property: " + property);
}
Preconditions.checkArgument(!property.isEnvVarOnly(), "Can't put env-only config property: " + property);

String key = parameterName(property);
SecretName secretName = SecretName.of(projectId, key);
Expand Down

0 comments on commit b1cb95e

Please sign in to comment.