Skip to content

Commit

Permalink
better rename for options with multiple values
Browse files Browse the repository at this point in the history
Signed-off-by: Jeromy Cannon <[email protected]>
  • Loading branch information
jeromy-cannon committed Oct 2, 2023
1 parent db5283d commit 7c5b663
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ public final class HelmExecutionBuilder {
private final HashMap<String, String> arguments;

/**
* The list of key value pairs where the value is a list of values for the given key.
* The list of options and a list of their one or more values.
*/
private final List<KeyValuePair<String, List<String>>> keyListOfValuesPairList;
private final List<KeyValuePair<String, List<String>>> optionsWithMultipleValues;

/**
* The flags to be passed to the helm command.
Expand Down Expand Up @@ -81,7 +81,7 @@ public HelmExecutionBuilder(final Path helmExecutable) {
this.helmExecutable = Objects.requireNonNull(helmExecutable, "helmExecutable must not be null");
this.subcommands = new ArrayList<>();
this.arguments = new HashMap<>();
this.keyListOfValuesPairList = new ArrayList<>();
this.optionsWithMultipleValues = new ArrayList<>();
this.positionals = new ArrayList<>();
this.flags = new ArrayList<>();
this.environmentVariables = new HashMap<>();
Expand Down Expand Up @@ -120,18 +120,18 @@ public HelmExecutionBuilder argument(final String name, final String value) {
}

/**
* Adds a key with a provided list of values to the helm command. This is used for options that have can have
* multiple values for a single key. (e.g. --set and --values)
* Adds an option with a provided list of values to the helm command. This is used for options that have can have
* multiple values for a single option. (e.g. --set and --values)
*
* @param name the key for the key/value pair.
* @param value the list of values for the given key.
* @param name the name of the option.
* @param value the list of values for the given option.
* @return this builder.
* @throws NullPointerException if either {@code name} or {@code value} is {@code null}.
*/
public HelmExecutionBuilder keyListOfValuesPair(final String name, final List<String> value) {
public HelmExecutionBuilder optionsWithMultipleValues(final String name, final List<String> value) {
Objects.requireNonNull(name, NAME_MUST_NOT_BE_NULL);
Objects.requireNonNull(value, VALUE_MUST_NOT_BE_NULL);
this.keyListOfValuesPairList.add(new KeyValuePair<>(name, value));
this.optionsWithMultipleValues.add(new KeyValuePair<>(name, value));
return this;
}

Expand Down Expand Up @@ -225,7 +225,7 @@ private String[] buildCommand() {
command.add(value);
});

keyListOfValuesPairList.forEach(entry -> entry.value().forEach(value -> {
optionsWithMultipleValues.forEach(entry -> entry.value().forEach(value -> {
command.add(String.format("--%s", entry.key()));
command.add(value);
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public void apply(final HelmExecutionBuilder builder) {
}

if (set() != null) {
builder.keyListOfValuesPair("set", set());
builder.optionsWithMultipleValues("set", set());
}

if (timeout() != null) {
Expand All @@ -110,7 +110,7 @@ public void apply(final HelmExecutionBuilder builder) {
}

if (values() != null) {
builder.keyListOfValuesPair("values", values());
builder.optionsWithMultipleValues("values", values());
}

if (version() != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@

class HelmExecutionBuilderTest {
@Test
@DisplayName("Test keyListOfValuesPair null checks")
void testKeyListOfValuesPairNullChecks() {
@DisplayName("Test optionsWithMultipleValues null checks")
void testOptionsWithMultipleValuesNullChecks() {
HelmExecutionBuilder builder = new HelmExecutionBuilder(new File(".").toPath());
assertThrows(NullPointerException.class, () -> {
builder.keyListOfValuesPair(null, null);
builder.optionsWithMultipleValues(null, null);
});
assertThrows(NullPointerException.class, () -> {
builder.keyListOfValuesPair("test string", null);
builder.optionsWithMultipleValues("test string", null);
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,6 @@ void testInstallChartOptionsBuilder() {

options.apply(builderMock);

verify(builderMock, times(2)).keyListOfValuesPair(anyString(), anyList());
verify(builderMock, times(2)).optionsWithMultipleValues(anyString(), anyList());
}
}

0 comments on commit 7c5b663

Please sign in to comment.