use of com.walmartlabs.concord.runtime.v2.sdk.Variables in project concord-plugins by walmartlabs.
the class ConfluenceTaskV2 method execute.
@Override
public TaskResult execute(Variables input) {
Result result = new ConfluenceTaskCommon(context.workingDirectory(), context.variables().toMap()).execute(TaskParams.of(input, context.defaultVariables().toMap()));
TaskResult.SimpleResult taskResult = TaskResult.of(result.ok, result.error);
if (result.pageId != null) {
taskResult.value("pageId", result.pageId);
}
if (result.childId != null) {
taskResult.value("childId", result.childId);
}
if (result.data != null) {
taskResult.value("data", result.data);
}
return taskResult;
}
use of com.walmartlabs.concord.runtime.v2.sdk.Variables in project concord-plugins by walmartlabs.
the class TaskParams method of.
public static TaskParams of(Variables input, Map<String, Object> defaults) {
Variables variables = merge(input, defaults);
Action action = new TaskParams(variables).action();
switch(action) {
case CPU:
{
return new CpuParams(variables);
}
case MEMORY:
{
return new MemoryParams(variables);
}
case DISK:
{
return new DiskParams(variables);
}
case IO:
{
return new IOParams(variables);
}
case SHUTDOWN:
{
return new ShutdownParams(variables);
}
case TIMETRAVEL:
{
return new TimeTravelParams(variables);
}
case PROCESSKILLER:
{
return new ProcessKiller(variables);
}
case BLACKHOLE:
{
return new BlackHoleParams(variables);
}
case DNS:
{
return new DnsParams(variables);
}
case LATENCY:
{
return new LatencyParams(variables);
}
case PACKETLOSS:
{
return new PacketLossParams(variables);
}
case HALT:
{
return new HaltParams(variables);
}
default:
throw new IllegalArgumentException("Unsupported action type: " + action);
}
}
use of com.walmartlabs.concord.runtime.v2.sdk.Variables in project concord-plugins by walmartlabs.
the class HashiVaultTaskV2Test method testCubbyV2.
@Test
public void testCubbyV2() throws Exception {
Map<String, Object> varMap = new HashMap<>();
varMap.put("path", "cubbyhole/hello");
Variables vars = new MapBackedVariables(varMap);
SimpleResult result = getTask(true).execute(vars);
Assert.assertTrue(result.ok());
final Map<String, Object> data = MapUtils.assertMap(result.values(), "data");
assertEquals("cubbyVal", data.get("cubbyKey"));
}
use of com.walmartlabs.concord.runtime.v2.sdk.Variables in project concord-plugins by walmartlabs.
the class HashiVaultTaskV2Test method testKvV2.
@Test
public void testKvV2() throws Exception {
Map<String, Object> varMap = new HashMap<>();
varMap.put("path", "secret/testing");
Variables vars = new MapBackedVariables(varMap);
SimpleResult result = getTask(true).execute(vars);
Assert.assertTrue(result.ok());
final Map<String, Object> data = MapUtils.assertMap(result.values(), "data");
assertEquals("password1", data.get("top_secret"));
assertEquals("dbpassword1", data.get("db_password"));
}
use of com.walmartlabs.concord.runtime.v2.sdk.Variables in project concord-plugins by walmartlabs.
the class HashiVaultTaskV2Test method writeAndRead.
private void writeAndRead(String path, String prefix) throws Exception {
HashiVaultTask task = getTask(true);
Map<String, Object> vars1 = new HashMap<>();
vars1.put("action", "writeKV");
vars1.put("path", path);
Map<String, Object> kvPairs = new HashMap<>(2);
kvPairs.put("key1", prefix + "Value1");
kvPairs.put("key2", prefix + "Value2");
vars1.put("kvPairs", kvPairs);
Variables input1 = new MapBackedVariables(vars1);
SimpleResult writeResult = task.execute(input1);
assertTrue(writeResult.ok());
// -- now get the values back
// resets context
task = getTask(true);
Map<String, Object> vars2 = new HashMap<>();
vars2.put("action", "readKV");
vars2.put("path", path);
Variables input2 = new MapBackedVariables(vars2);
SimpleResult readResult = task.execute(input2);
assertTrue(readResult.ok());
Map<String, Object> data = MapUtils.getMap(readResult.values(), "data", Collections.emptyMap());
assertEquals(prefix + "Value1", MapUtils.getString(data, "key1"));
assertEquals(prefix + "Value2", MapUtils.getString(data, "key2"));
}
Aggregations