open-nomad/nomad/job_endpoint_hook_vault_oss.go

30 lines
654 B
Go

// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
//go:build !ent
// +build !ent
package nomad
import (
"fmt"
"strings"
"github.com/hashicorp/nomad/nomad/structs"
vapi "github.com/hashicorp/vault/api"
)
// validateNamespaces returns an error if the job contains multiple Vault
// namespaces.
func (jobVaultHook) validateNamespaces(
blocks map[string]map[string]*structs.Vault,
token *vapi.Secret,
) error {
requestedNamespaces := structs.VaultNamespaceSet(blocks)
if len(requestedNamespaces) > 0 {
return fmt.Errorf("%w, Namespaces: %s", ErrMultipleNamespaces, strings.Join(requestedNamespaces, ", "))
}
return nil
}