-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes to beforeserve to pick up storage array labels and parameters if provided #486
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -147,6 +147,13 @@ type Opts struct { | |
PodmonPort string // to indicates the port to be used for exposing podmon API health | ||
PodmonPollingFreq string // indicates the polling frequency to check array connectivity | ||
TLSCertDir string | ||
StorageArrays []StorageArrayConfig | ||
} | ||
|
||
// StorageArrayConfig represents the configuration of a storage array in the config file | ||
type StorageArrayConfig struct { | ||
Labels map[string]interface{} `yaml:"labels,omitempty"` | ||
Parameters map[string]interface{} `yaml:"parameters,omitempty"` | ||
} | ||
|
||
// NodeConfig defines rules for given node | ||
|
@@ -430,6 +437,29 @@ func (s *service) BeforeServe( | |
} else { | ||
log.Println("No management servers found.") | ||
} | ||
|
||
// Access the storagearrays key (which is a slice of maps) | ||
storageArrays := secretParams.Get("storagearrays").([]interface{}) | ||
// Ensure there's at least one server and extract labels and parameters if any | ||
if len(storageArrays) == 0 { | ||
log.Println("No storage arrays found.") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We start log messages in lowercase. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thought it only applied to error messages. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. following the same syntax as on line 438: |
||
} else { | ||
// cycle through each storage array and extract Labels and Parameters maps | ||
for _, storageArray := range storageArrays { | ||
storageArrayMap := storageArray.(map[string]interface{}) | ||
if storageArrayMap["labels"] == nil { | ||
storageArrayMap["labels"] = make(map[string]interface{}) | ||
} | ||
if storageArrayMap["parameters"] == nil { | ||
storageArrayMap["parameters"] = make(map[string]interface{}) | ||
} | ||
storageArrayConfig := StorageArrayConfig{ | ||
Labels: storageArrayMap["labels"].(map[string]interface{}), | ||
Parameters: storageArrayMap["parameters"].(map[string]interface{}), | ||
} | ||
opts.StorageArrays = append(opts.StorageArrays, storageArrayConfig) | ||
} | ||
} | ||
Comment on lines
+444
to
+462
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you extract this block into a utility function then you make unit testing easier. You can test a lot of use cases. The you can just do something like: opts.StorageArrays = getStorageArrayInfo() or similar. |
||
} | ||
|
||
if chapuser, ok := csictx.LookupEnv(ctx, EnvISCSICHAPUserName); ok { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Won't this panic if "storagearrays" is missing in the secret?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems like it, thanks for that. will fix.