Add check for missing `path` in client `host_volume` config (#17393)
This commit is contained in:
parent
2d16ec6c6f
commit
7c7f2d00bb
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue