2023-04-10 15:36:59 +00:00
|
|
|
// Copyright (c) HashiCorp, Inc.
|
|
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
|
|
|
2022-04-05 18:18:10 +00:00
|
|
|
//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
|
|
|
|
}
|