mirror of
https://github.com/kemko/nomad.git
synced 2026-01-06 10:25:42 +03:00
Signed-off-by: Yoan Blanc <yoan@dosimple.ch>
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
package nomad
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
@@ -10,6 +11,9 @@ import (
|
||||
vapi "github.com/hashicorp/vault/api"
|
||||
)
|
||||
|
||||
// ErrMultipleNamespaces is send when multiple namespaces are used in the OSS setup
|
||||
var ErrMultipleNamespaces = errors.New("multiple vault namespaces requires Nomad Enterprise")
|
||||
|
||||
// enforceSubmitJob is used to check any Sentinel policies for the submit-job scope
|
||||
func (j *Job) enforceSubmitJob(override bool, job *structs.Job) (error, error) {
|
||||
return nil, nil
|
||||
@@ -51,7 +55,7 @@ func (j *Job) multiVaultNamespaceValidation(
|
||||
) error {
|
||||
requestedNamespaces := structs.VaultNamespaceSet(policies)
|
||||
if len(requestedNamespaces) > 0 {
|
||||
return fmt.Errorf("multiple vault namespaces requires Nomad Enterprise, Namespaces: %s", strings.Join(requestedNamespaces, ", "))
|
||||
return fmt.Errorf("%w, Namespaces: %s", ErrMultipleNamespaces, strings.Join(requestedNamespaces, ", "))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -1736,8 +1736,9 @@ func TestJobEndpoint_Register_Vault_MultiNamespaces(t *testing.T) {
|
||||
var resp structs.JobRegisterResponse
|
||||
err := msgpackrpc.CallWithCodec(codec, "Job.Register", req, &resp)
|
||||
// OSS or Ent check
|
||||
if s1.EnterpriseState.Features() == 0 {
|
||||
require.Contains(t, err.Error(), "multiple vault namespaces requires Nomad Enterprise")
|
||||
if err != nil && s1.EnterpriseState.Features() == 0 {
|
||||
// errors.Is cannot be used because the RPC call break error wrapping.
|
||||
require.Contains(t, err.Error(), ErrMultipleNamespaces.Error())
|
||||
} else {
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user