HashiCorp Nomad

v0.2.1 published on Tuesday, Dec 7, 2021 by Pulumi

getJobParser

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

Example Usage

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

class MyStack : Stack
{
    public MyStack()
    {
        var myJob = Output.Create(Nomad.GetJobParser.InvokeAsync(new Nomad.GetJobParserArgs
        {
            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 {
		opt0 := false
		_, err := nomad.GetJobParser(ctx, &GetJobParserArgs{
			Hcl:          readFileOrPanic(fmt.Sprintf("%v%v", path.Module, "/jobspec.hcl")),
			Canonicalize: &opt0,
		}, nil)
		if err != nil {
			return err
		}
		return nil
	})
}
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 nomad from "@pulumi/nomad";
import * from "fs";

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

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)
}

The following arguments are supported:

Hcl string
Canonicalize bool
Hcl string
Canonicalize bool
hcl string
canonicalize boolean
hcl str
canonicalize bool

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 str
id str
The provider-assigned unique ID for this managed resource.
json str
canonicalize bool

Package Details

Repository
https://github.com/pulumi/pulumi-nomad
License
Apache-2.0
Notes
This Pulumi package is based on the nomad Terraform Provider.