This is an automated email from the ASF dual-hosted git repository.
rohit pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cloudstack-cloudmonkey.git
The following commit(s) were added to refs/heads/main by this push:
new da1579c config: prevent empty values for required configs (#176)
da1579c is described below
commit da1579c4aab8ce9e677fc7f4c5ef1765af06d60b
Author: Abhishek Kumar <[email protected]>
AuthorDate: Mon Aug 11 16:11:43 2025 +0530
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]>
---
config/config.go | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/config/config.go b/config/config.go
index 1619363..bcd3f6f 100644
--- a/config/config.go
+++ b/config/config.go
@@ -46,6 +46,13 @@ const (
DEFAULT = "default"
)
+var nonEmptyConfigKeys = map[string]bool{
+ "output": true,
+ "timeout": true,
+ "profile": true,
+ "url": true,
+}
+
// DefaultACSAPIEndpoint is the default API endpoint for CloudStack.
const DefaultACSAPIEndpoint = "http://localhost:8080/client/api"
@@ -349,6 +356,10 @@ func (c *Config) LoadProfile(name string) {
// UpdateConfig updates and saves config
func (c *Config) UpdateConfig(key string, value string, update bool) {
+ if nonEmptyConfigKeys[key] && value == "" {
+ fmt.Printf("Error: value for '%s' must not be empty\n", key)
+ return
+ }
switch key {
case "prompt":
c.Core.Prompt = value