Search in sources :

Example 36 with Variables

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 SENDMESSAGE:
            {
                return new SendMessageParams(variables);
            }
        default:
            throw new IllegalArgumentException("Unsupported action type: " + action);
    }
}
Also used : MapBackedVariables(com.walmartlabs.concord.runtime.v2.sdk.MapBackedVariables) Variables(com.walmartlabs.concord.runtime.v2.sdk.Variables)

Example 37 with Variables

use of com.walmartlabs.concord.runtime.v2.sdk.Variables in project concord-plugins by walmartlabs.

the class TerraformTaskV2 method execute.

@Override
public TaskResult execute(Variables input) throws Exception {
    Path workDir = ctx.workingDirectory();
    Map<String, Object> cfg = createCfg(workDir, input, ctx.defaultVariables());
    boolean debug = MapUtils.get(cfg, TaskConstants.DEBUG_KEY, false, Boolean.class);
    Action action = getAction(cfg);
    // configure the state backend and populate the environment with necessary parameters
    Backend backend = new BackendFactoryV2(ctx, apiClient, lockService).getBackend(cfg);
    Map<String, String> env = getEnv(cfg, backend);
    // configure the environment to support Terraform's git modules using Concord Secrets for authentication
    GitSshWrapper.SecretProvider secretProvider = (orgName, secretName, password) -> {
        SecretService.KeyPair result = secretService.exportKeyAsFile(orgName, secretName, password);
        return result.privateKey();
    };
    GitSshWrapper gitSshWrapper = GitSshWrapper.createFrom(secretProvider, workDir, cfg, debug);
    Map<String, String> baseEnv = gitSshWrapper.updateEnv(workDir, new HashMap<>());
    // configure the Terraform's binary
    TerraformBinaryResolver binaryResolver = new TerraformBinaryResolver(cfg, workDir, debug, url -> dependencyManager.resolve(URI.create(url)));
    Terraform terraform = new Terraform(binaryResolver, debug, baseEnv);
    if (debug) {
        terraform.exec(workDir, "version", "version");
    }
    try {
        TerraformActionResult result = TerraformTaskCommon.execute(terraform, action, backend, workDir, cfg, env);
        return convertResult(result);
    } finally {
        gitSshWrapper.cleanup();
    }
}
Also used : Path(java.nio.file.Path) MapUtils(com.walmartlabs.concord.sdk.MapUtils) BackendFactoryV2(com.walmartlabs.concord.plugins.terraform.backend.BackendFactoryV2) TerraformTaskCommon.getAction(com.walmartlabs.concord.plugins.terraform.TerraformTaskCommon.getAction) HashMap(java.util.HashMap) ApiClient(com.walmartlabs.concord.ApiClient) com.walmartlabs.concord.runtime.v2.sdk(com.walmartlabs.concord.runtime.v2.sdk) Inject(javax.inject.Inject) TerraformTaskCommon.getEnv(com.walmartlabs.concord.plugins.terraform.TerraformTaskCommon.getEnv) Map(java.util.Map) TerraformActionResult(com.walmartlabs.concord.plugins.terraform.actions.TerraformActionResult) Named(javax.inject.Named) URI(java.net.URI) Path(java.nio.file.Path) Collections(java.util.Collections) Backend(com.walmartlabs.concord.plugins.terraform.backend.Backend) TerraformTaskCommon.getAction(com.walmartlabs.concord.plugins.terraform.TerraformTaskCommon.getAction) Backend(com.walmartlabs.concord.plugins.terraform.backend.Backend) TerraformActionResult(com.walmartlabs.concord.plugins.terraform.actions.TerraformActionResult) BackendFactoryV2(com.walmartlabs.concord.plugins.terraform.backend.BackendFactoryV2)

Example 38 with Variables

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 PUTOBJECT:
            {
                return new PutObjectParams(variables);
            }
        case GETOBJECT:
            {
                return new GetObjectParams(variables);
            }
        default:
            throw new IllegalArgumentException("Unsupported action type: " + action);
    }
}
Also used : MapBackedVariables(com.walmartlabs.concord.runtime.v2.sdk.MapBackedVariables) Variables(com.walmartlabs.concord.runtime.v2.sdk.Variables)

Aggregations

Variables (com.walmartlabs.concord.runtime.v2.sdk.Variables)24 MapBackedVariables (com.walmartlabs.concord.runtime.v2.sdk.MapBackedVariables)16 HashMap (java.util.HashMap)7 Test (org.junit.Test)6 SimpleResult (com.walmartlabs.concord.runtime.v2.sdk.TaskResult.SimpleResult)5 Path (java.nio.file.Path)4 Map (java.util.Map)4 TaskProviders (com.walmartlabs.concord.runtime.v2.runner.tasks.TaskProviders)3 UpdateLocalsCommand (com.walmartlabs.concord.runtime.v2.runner.vm.UpdateLocalsCommand)3 TaskResult (com.walmartlabs.concord.runtime.v2.sdk.TaskResult)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 ProcessDefinition (com.walmartlabs.concord.runtime.v2.model.ProcessDefinition)2 ExpressionEvaluator (com.walmartlabs.concord.runtime.v2.runner.el.ExpressionEvaluator)2 com.walmartlabs.concord.runtime.v2.sdk (com.walmartlabs.concord.runtime.v2.sdk)2 ProcessConfiguration (com.walmartlabs.concord.runtime.v2.sdk.ProcessConfiguration)2 Inject (javax.inject.Inject)2 Named (javax.inject.Named)2 Injector (com.google.inject.Injector)1 ApiClient (com.walmartlabs.concord.ApiClient)1 DependencyManager (com.walmartlabs.concord.dependencymanager.DependencyManager)1