mirror of
https://github.com/kemko/nomad.git
synced 2026-01-01 16:05:42 +03:00
config: fix panic in job using Vault cluster not in agent config. (#22227)
This commit is contained in:
3
.changelog/22227.txt
Normal file
3
.changelog/22227.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
```release-note:bug
|
||||
config: Fixed a panic triggered by registering a job specifying a Vault cluster that has not been configured within the server
|
||||
```
|
||||
@@ -57,4 +57,13 @@ func TestJobEndpointHook_VaultCE(t *testing.T) {
|
||||
warnings, err := hook.Validate(job)
|
||||
must.Len(t, 0, warnings)
|
||||
must.NoError(t, err)
|
||||
|
||||
// Attempt to validate a job which details a Vault cluster name which has
|
||||
// no configuration mapping within the server config.
|
||||
mockJob2 := mock.Job()
|
||||
mockJob2.TaskGroups[0].Tasks[0].Vault = &structs.Vault{Cluster: "does-not-exist"}
|
||||
|
||||
warnings, err = hook.Validate(mockJob2)
|
||||
must.Nil(t, warnings)
|
||||
must.EqError(t, err, `Vault "does-not-exist" not enabled but used in the job`)
|
||||
}
|
||||
|
||||
@@ -137,6 +137,9 @@ func DefaultVaultConfig() *VaultConfig {
|
||||
|
||||
// IsEnabled returns whether the config enables Vault integration
|
||||
func (c *VaultConfig) IsEnabled() bool {
|
||||
if c == nil {
|
||||
return false
|
||||
}
|
||||
return c.Enabled != nil && *c.Enabled
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user