Skip to content

Commit da1579c

Browse files
authored
config: prevent empty values for required configs (#176)
* config: prevent empty values for required configs Fixes #147 Signed-off-by: Abhishek Kumar <[email protected]> * fix Signed-off-by: Abhishek Kumar <[email protected]> --------- Signed-off-by: Abhishek Kumar <[email protected]>
1 parent 939ce65 commit da1579c

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

config/config.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,13 @@ const (
4646
DEFAULT = "default"
4747
)
4848

49+
var nonEmptyConfigKeys = map[string]bool{
50+
"output": true,
51+
"timeout": true,
52+
"profile": true,
53+
"url": true,
54+
}
55+
4956
// DefaultACSAPIEndpoint is the default API endpoint for CloudStack.
5057
const DefaultACSAPIEndpoint = "http://localhost:8080/client/api"
5158

@@ -349,6 +356,10 @@ func (c *Config) LoadProfile(name string) {
349356

350357
// UpdateConfig updates and saves config
351358
func (c *Config) UpdateConfig(key string, value string, update bool) {
359+
if nonEmptyConfigKeys[key] && value == "" {
360+
fmt.Printf("Error: value for '%s' must not be empty\n", key)
361+
return
362+
}
352363
switch key {
353364
case "prompt":
354365
c.Core.Prompt = value

0 commit comments

Comments
 (0)