HashiCorp Nomad

v0.3.0 published on Tuesday, Sep 27, 2022 by Pulumi

getJobParser

Parse a HCL jobspec and produce the equivalent JSON encoded job.

Example Usage

using System.Collections.Generic;
using System.IO;
using Pulumi;
using Nomad = Pulumi.Nomad;

return await Deployment.RunAsync(() => 
{
    var myJob = Nomad.GetJobParser.Invoke(new()
    {
        Hcl = File.ReadAllText($"{path.Module}/jobspec.hcl"),
        Canonicalize = false,
    });

});
package main

import (
	"fmt"
	"io/ioutil"

	"github.com/pulumi/pulumi-nomad/sdk/go/nomad"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func readFileOrPanic(path string) pulumi.StringPtrInput {
	data, err := ioutil.ReadFile(path)
	if err != nil {
		panic(err.Error())
	}
	return pulumi.String(string(data))
}

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := nomad.GetJobParser(ctx, &GetJobParserArgs{
			Hcl:          readFileOrPanic(fmt.Sprintf("%v/jobspec.hcl", path.Module)),
			Canonicalize: pulumi.BoolRef(false),
		}, nil)
		if err != nil {
			return err
		}
		return nil
	})
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.nomad.NomadFunctions;
import com.pulumi.nomad.inputs.GetJobParserArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        final var myJob = NomadFunctions.getJobParser(GetJobParserArgs.builder()
            .hcl(Files.readString(Paths.get(String.format("%s/jobspec.hcl", path.module()))))
            .canonicalize(false)
            .build());

    }
}
import pulumi
import pulumi_nomad as nomad

my_job = nomad.get_job_parser(hcl=(lambda path: open(path).read())(f"{path['module']}/jobspec.hcl"),
    canonicalize=False)
import * as pulumi from "@pulumi/pulumi";
import * as fs from "fs";
import * as nomad from "@pulumi/nomad";

const myJob = nomad.getJobParser({
    hcl: fs.readFileSync(`${path.module}/jobspec.hcl`),
    canonicalize: false,
});

Coming soon!

Using getJobParser

Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.

function getJobParser(args: GetJobParserArgs, opts?: InvokeOptions): Promise<GetJobParserResult>
function getJobParserOutput(args: GetJobParserOutputArgs, opts?: InvokeOptions): Output<GetJobParserResult>
def get_job_parser(canonicalize: Optional[bool] = None,
                   hcl: Optional[str] = None,
                   opts: Optional[InvokeOptions] = None) -> GetJobParserResult
def get_job_parser_output(canonicalize: Optional[pulumi.Input[bool]] = None,
                   hcl: Optional[pulumi.Input[str]] = None,
                   opts: Optional[InvokeOptions] = None) -> Output[GetJobParserResult]
func GetJobParser(ctx *Context, args *GetJobParserArgs, opts ...InvokeOption) (*GetJobParserResult, error)
func GetJobParserOutput(ctx *Context, args *GetJobParserOutputArgs, opts ...InvokeOption) GetJobParserResultOutput

> Note: This function is named GetJobParser in the Go SDK.

public static class GetJobParser 
{
    public static Task<GetJobParserResult> InvokeAsync(GetJobParserArgs args, InvokeOptions? opts = null)
    public static Output<GetJobParserResult> Invoke(GetJobParserInvokeArgs args, InvokeOptions? opts = null)
}
public static CompletableFuture<GetJobParserResult> getJobParser(GetJobParserArgs args, InvokeOptions options)
// Output-based functions aren't available in Java yet
Fn::Invoke:
  Function: nomad:index/getJobParser:getJobParser
  Arguments:
    # Arguments dictionary

The following arguments are supported:

Hcl string
Canonicalize bool
Hcl string
Canonicalize bool
hcl String
canonicalize Boolean
hcl string
canonicalize boolean
hcl String
canonicalize Boolean

getJobParser Result

The following output properties are available:

Hcl string
Id string

The provider-assigned unique ID for this managed resource.

Json string
Canonicalize bool
Hcl string
Id string

The provider-assigned unique ID for this managed resource.

Json string
Canonicalize bool
hcl String
id String

The provider-assigned unique ID for this managed resource.

json String
canonicalize Boolean
hcl string
id string

The provider-assigned unique ID for this managed resource.

json string
canonicalize boolean
hcl str
id str

The provider-assigned unique ID for this managed resource.

json str
canonicalize bool
hcl String
id String

The provider-assigned unique ID for this managed resource.

json String
canonicalize Boolean

Package Details

Repository
https://github.com/pulumi/pulumi-nomad
License
Apache-2.0
Notes

This Pulumi package is based on the nomad Terraform Provider.