Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions qDup-core/src/main/java/io/hyperfoil/tools/qdup/QDup.java
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ public boolean run() {
if (!getStateProps().isEmpty()) {
getStateProps().forEach((k, v) -> {
if (v != null && !v.toString().trim().isEmpty()) {
runConfigBuilder.forceRunState(k.toString(), v.toString());
runConfigBuilder.forceRunState(k.toString(), v.toString(),false);
}
});
}
Expand All @@ -559,7 +559,7 @@ public boolean run() {
if (!getRemoveStateProperties().isEmpty()) {
getRemoveStateProperties().forEach((k, v) -> {
if (k != null) {
runConfigBuilder.forceRunState(k.toString(), "");
runConfigBuilder.forceRunState(k.toString(), "",false);
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -367,8 +367,8 @@ private void addRoleScript(String role, String script, Map<String, String> with,
}
target.put(role, cmd);
}
public void forceRunState(String key, Object value) {
state.set(key, value);
public void forceRunState(String key, Object value,boolean autoConvert) {
state.set(key, value,autoConvert);
}

public void setRunState(String key, Object value) {
Expand Down
4 changes: 2 additions & 2 deletions qDup/src/main/java/io/hyperfoil/tools/qdup/cli/QDup.java
Original file line number Diff line number Diff line change
Expand Up @@ -242,14 +242,14 @@ public Integer call() throws Exception {
if(stateParameters!=null && !stateParameters.isEmpty()){
stateParameters.forEach((k,v)->{
if (v != null && !v.toString().trim().isEmpty()) {
runConfigBuilder.forceRunState(k.toString(), v.toString());
runConfigBuilder.forceRunState(k.toString(), v.toString(),false);
}
});
}
if(removeStateParameters!=null && !removeStateParameters.isEmpty()){
removeStateParameters.forEach((k)->{
if (k != null) {
runConfigBuilder.forceRunState(k, "");
runConfigBuilder.forceRunState(k, "", false);
}
});
}
Expand Down
31 changes: 31 additions & 0 deletions qDup/src/test/java/io/hyperfoil/tools/qdup/cli/QDupTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.github.dockerjava.api.model.Device;
import io.hyperfoil.tools.qdup.Host;
import io.hyperfoil.tools.qdup.config.yaml.HostDefinition;
import io.hyperfoil.tools.yaup.json.Json;
import io.quarkus.test.junit.main.LaunchResult;
import io.quarkus.test.junit.main.QuarkusMainLauncher;
import io.quarkus.test.junit.main.QuarkusMainTest;
Expand Down Expand Up @@ -110,6 +111,36 @@ public void no_arg_help(QuarkusMainLauncher launcher) {
assertTrue(result.getErrorOutput().contains("Usage:"),result.getErrorOutput());
}

@Test
public void state_should_not_autoconvert(QuarkusMainLauncher launcher) throws IOException {
Path configPath = Files.writeString(File.createTempFile("qdup",".yaml").toPath(),
"""
scripts:
doit:
- sh: echo ${{VERSION}}
hosts:
target: HOST_TARGET
roles:
doit:
hosts:
- target
run-scripts:
- doit
""".replaceAll("HOST_TARGET",getHost().toString()));
configPath.toFile().deleteOnExit();
LaunchResult result = launcher.launch("--fullPath","/tmp","--identity",getIdentity(),"-S","VERSION=3.20",configPath.toString());
assertEquals(0,result.exitCode());
System.out.println(result.getErrorOutput());

File runJson = new File("/tmp/run.json");
assertTrue(runJson.exists());
Json content = Json.fromFile(runJson.toPath().toAbsolutePath().toString());
assertNotNull(content);

assertEquals("3.20",content.getJson("state").getString("VERSION"));

}

@Test
public void whoami(QuarkusMainLauncher launcher) throws IOException {
Path configPath = Files.writeString(File.createTempFile("qdup",".yaml").toPath(),
Expand Down
Loading