Skip to content

Commit

Permalink
Move creating product method before GetParamsFor* to avoid attempting…
Browse files Browse the repository at this point in the history
… to fetch versions before mirror URL default is set

Only update mirror URL, if it's not already been defined by the user

Issue #315
  • Loading branch information
MatthewJohn committed May 29, 2024
1 parent d04ce60 commit 858380b
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions lib/param_parsing/parameters.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,21 @@ func GetParameters() Params {
}
}

// Set defaults based on product
// This must be performed after TOML file, to obtain product.
// But the mirror URL, if set to default product URL,
// is used by some of the version getter methods, to
// obtain list of versions.
product := lib.GetProductById(params.Product)
if product == nil {
logger.Fatalf("Invalid \"product\" configuration value: %q", params.Product)
} else { // Use else as there is a warning that params maybe nil, as it does not see Fatalf as a break condition
if params.MirrorURL == "" {
params.MirrorURL = product.GetDefaultMirrorUrl()
}
params.ProductEntity = product
}

if tfSwitchFileExists(params) {
params, err = GetParamsFromTfSwitch(params)
if err != nil {
Expand Down Expand Up @@ -115,15 +130,6 @@ func GetParameters() Params {

params = GetParamsFromEnvironment(params)

// Set defaults based on product
product := lib.GetProductById(params.Product)
if product == nil {
logger.Fatalf("Invalid \"product\" configuration value: %q", params.Product)
} else { // Use else as there is a warning that params maybe nil, as it does not see Fatalf as a break condition
params.MirrorURL = product.GetDefaultMirrorUrl()
params.ProductEntity = product
}

// Logger config was changed by the config files. Reinitialise.
if params.LogLevel != oldLogLevel {
logger = lib.InitLogger(params.LogLevel)
Expand Down

0 comments on commit 858380b

Please sign in to comment.