mirror of
https://github.com/kemko/nomad.git
synced 2026-01-01 16:05:42 +03:00
Add check for missing path in client host_volume config (#17393)
This commit is contained in:
3
.changelog/17393.txt
Normal file
3
.changelog/17393.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
```release-note:improvement
|
||||
cli: Add check for missing host volume `path` in `nomad config validate` command
|
||||
```
|
||||
@@ -393,6 +393,13 @@ func (c *Command) IsValidConfig(config, cmdConfig *Config) bool {
|
||||
}
|
||||
}
|
||||
|
||||
for _, volumeConfig := range config.Client.HostVolumes {
|
||||
if volumeConfig.Path == "" {
|
||||
c.Ui.Error("Missing path in host_volume config")
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
if config.Client.MinDynamicPort < 0 || config.Client.MinDynamicPort > structs.MaxValidPort {
|
||||
c.Ui.Error(fmt.Sprintf("Invalid dynamic port range: min_dynamic_port=%d", config.Client.MinDynamicPort))
|
||||
return false
|
||||
|
||||
@@ -430,6 +430,48 @@ func TestIsValidConfig(t *testing.T) {
|
||||
},
|
||||
err: "client.artifact block invalid: http_read_timeout must be > 0",
|
||||
},
|
||||
{
|
||||
name: "BadHostVolumeConfig",
|
||||
conf: Config{
|
||||
DataDir: "/tmp",
|
||||
Client: &ClientConfig{
|
||||
Enabled: true,
|
||||
HostVolumes: []*structs.ClientHostVolumeConfig{
|
||||
{
|
||||
Name: "test",
|
||||
ReadOnly: true,
|
||||
},
|
||||
{
|
||||
Name: "test",
|
||||
ReadOnly: true,
|
||||
Path: "/random/path",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
err: "Missing path in host_volume config",
|
||||
},
|
||||
{
|
||||
name: "ValidHostVolumeConfig",
|
||||
conf: Config{
|
||||
DataDir: "/tmp",
|
||||
Client: &ClientConfig{
|
||||
Enabled: true,
|
||||
HostVolumes: []*structs.ClientHostVolumeConfig{
|
||||
{
|
||||
Name: "test",
|
||||
ReadOnly: true,
|
||||
Path: "/random/path1",
|
||||
},
|
||||
{
|
||||
Name: "test",
|
||||
ReadOnly: true,
|
||||
Path: "/random/path2",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range cases {
|
||||
|
||||
Reference in New Issue
Block a user