Nomad v2.3.2 published on Wednesday, Aug 14, 2024 by Pulumi
nomad.getNamespaces
Explore with Pulumi AI
Retrieve a list of namespaces available in Nomad.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as nomad from "@pulumi/nomad";
export = async () => {
const namespaces = await nomad.getNamespaces({});
const namespace: nomad.AclPolicy[] = [];
for (const range = {value: 0}; range.value < namespaces.namespaces.length; range.value++) {
namespace.push(new nomad.AclPolicy(`namespace-${range.value}`, {
name: `namespace-${namespaces[range.value]}`,
description: `Write to the namespace ${namespaces[range.value]}`,
rulesHcl: `namespace "${namespaces[range.value]}" {
policy = "write"
}
`,
}));
}
}
import pulumi
import pulumi_nomad as nomad
namespaces = nomad.get_namespaces()
namespace = []
for range in [{"value": i} for i in range(0, len(namespaces.namespaces))]:
namespace.append(nomad.AclPolicy(f"namespace-{range['value']}",
name=f"namespace-{namespaces[range['value']]}",
description=f"Write to the namespace {namespaces[range['value']]}",
rules_hcl=f"""namespace "{namespaces[range["value"]]}" {{
policy = "write"
}}
"""))
package main
import (
"fmt"
"github.com/pulumi/pulumi-nomad/sdk/v2/go/nomad"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
namespaces, err := nomad.GetNamespaces(ctx, nil, nil)
if err != nil {
return err
}
var namespace []*nomad.AclPolicy
for index := 0; index < int(len(namespaces.Namespaces)); index++ {
key0 := index
val0 := index
__res, err := nomad.NewAclPolicy(ctx, fmt.Sprintf("namespace-%v", key0), &nomad.AclPolicyArgs{
Name: pulumi.Sprintf("namespace-%v", namespaces[val0]),
Description: pulumi.Sprintf("Write to the namespace %v", namespaces[val0]),
RulesHcl: pulumi.Sprintf("namespace \"%v\" {\n policy = \"write\"\n}\n", namespaces[val0]),
})
if err != nil {
return err
}
namespace = append(namespace, __res)
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Pulumi;
using Nomad = Pulumi.Nomad;
return await Deployment.RunAsync(async() =>
{
var namespaces = await Nomad.GetNamespaces.InvokeAsync();
var @namespace = new List<Nomad.AclPolicy>();
for (var rangeIndex = 0; rangeIndex < namespaces.Namespaces.Length; rangeIndex++)
{
var range = new { Value = rangeIndex };
@namespace.Add(new Nomad.AclPolicy($"namespace-{range.Value}", new()
{
Name = $"namespace-{namespaces[range.Value]}",
Description = $"Write to the namespace {namespaces[range.Value]}",
RulesHcl = @$"namespace ""{namespaces[range.Value]}"" {{
policy = ""write""
}}
",
}));
}
});
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.AclPolicy;
import com.pulumi.nomad.AclPolicyArgs;
import com.pulumi.codegen.internal.KeyedValue;
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 namespaces = NomadFunctions.getNamespaces();
for (var i = 0; i < namespaces.applyValue(getNamespacesResult -> getNamespacesResult.namespaces()).length(); i++) {
new AclPolicy("namespace-" + i, AclPolicyArgs.builder()
.name(String.format("namespace-%s", namespaces.applyValue(getNamespacesResult -> getNamespacesResult)[range.value()]))
.description(String.format("Write to the namespace %s", namespaces.applyValue(getNamespacesResult -> getNamespacesResult)[range.value()]))
.rulesHcl("""
namespace "%s" {
policy = "write"
}
", namespaces.applyValue(getNamespacesResult -> getNamespacesResult)[range.value()]))
.build());
}
}
}
Coming soon!
Using getNamespaces
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 getNamespaces(opts?: InvokeOptions): Promise<GetNamespacesResult>
function getNamespacesOutput(opts?: InvokeOptions): Output<GetNamespacesResult>
def get_namespaces(opts: Optional[InvokeOptions] = None) -> GetNamespacesResult
def get_namespaces_output(opts: Optional[InvokeOptions] = None) -> Output[GetNamespacesResult]
func GetNamespaces(ctx *Context, opts ...InvokeOption) (*GetNamespacesResult, error)
func GetNamespacesOutput(ctx *Context, opts ...InvokeOption) GetNamespacesResultOutput
> Note: This function is named GetNamespaces
in the Go SDK.
public static class GetNamespaces
{
public static Task<GetNamespacesResult> InvokeAsync(InvokeOptions? opts = null)
public static Output<GetNamespacesResult> Invoke(InvokeOptions? opts = null)
}
public static CompletableFuture<GetNamespacesResult> getNamespaces(InvokeOptions options)
// Output-based functions aren't available in Java yet
fn::invoke:
function: nomad:index/getNamespaces:getNamespaces
arguments:
# arguments dictionary
getNamespaces Result
The following output properties are available:
- Id string
- The provider-assigned unique ID for this managed resource.
- Namespaces List<string>
(list of strings)
- a list of namespaces available in the cluster.
- Id string
- The provider-assigned unique ID for this managed resource.
- Namespaces []string
(list of strings)
- a list of namespaces available in the cluster.
- id String
- The provider-assigned unique ID for this managed resource.
- namespaces List<String>
(list of strings)
- a list of namespaces available in the cluster.
- id string
- The provider-assigned unique ID for this managed resource.
- namespaces string[]
(list of strings)
- a list of namespaces available in the cluster.
- id str
- The provider-assigned unique ID for this managed resource.
- namespaces Sequence[str]
(list of strings)
- a list of namespaces available in the cluster.
- id String
- The provider-assigned unique ID for this managed resource.
- namespaces List<String>
(list of strings)
- a list of namespaces available in the cluster.
Package Details
- Repository
- HashiCorp Nomad pulumi/pulumi-nomad
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
nomad
Terraform Provider.