-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Gerd Oberlechner <[email protected]>
- Loading branch information
Showing
15 changed files
with
64 additions
and
232 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package ev2 | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/Azure/ARO-HCP/tooling/templatize/pkg/config" | ||
) | ||
|
||
func NewEv2EvaluationContext() *config.ConfigEvaluationContext { | ||
return &config.ConfigEvaluationContext{ | ||
Region: "$location()", | ||
RegionShort: "$(regionShortName)", | ||
Stamp: "$stamp()", | ||
} | ||
} | ||
|
||
// GetGlobalServiceConfigVariables returns all configuration variables for a cloud and deployment environment. | ||
// The variable values are formatted to support EV2 $location(), $stamp() and $(serviceConfigVar) variables. | ||
func GetServiceConfigVariables(configProvider config.ConfigProvider, cloud, deployEnv string) (config.Variables, error) { | ||
return configProvider.GetVariables(cloud, deployEnv, "", NewEv2EvaluationContext()) | ||
} | ||
|
||
// GetRegionalServiceConfigVariableOverrides returns the regional overrides for each region in a cloud and deployment | ||
// environment. The variable values are formatted to support EV2 $location(), $stamp() and $(serviceConfigVar) variables. | ||
func GetRegionalServiceConfigVariableOverrides(configProvider config.ConfigProvider, cloud, deployEnv string) (map[string]config.Variables, error) { | ||
regions, err := configProvider.GetRegions(cloud, deployEnv) | ||
if err != nil { | ||
return nil, err | ||
} | ||
overrides := make(map[string]config.Variables) | ||
for _, region := range regions { | ||
regionOverrides, err := configProvider.GetRegionOverrides(cloud, deployEnv, region, NewEv2EvaluationContext()) | ||
if err != nil { | ||
return nil, err | ||
} | ||
overrides[region] = regionOverrides | ||
} | ||
return overrides, nil | ||
} | ||
|
||
// ScopeBindingVariables retrieves and processes configuration variables for a given cloud and deployment environment. | ||
// It uses the provided configProvider to fetch the variables, flattens them into a __VAR__ = $config(var) formatted | ||
// map. | ||
func ScopeBindingVariables(configProvider config.ConfigProvider, cloud, deployEnv string) (map[string]string, error) { | ||
vars, err := configProvider.GetVariables(cloud, deployEnv, "", NewEv2EvaluationContext()) | ||
if err != nil { | ||
return nil, err | ||
} | ||
flattened, _ := EV2Mapping(vars, []string{}) | ||
variables := make(map[string]string) | ||
for key, value := range flattened { | ||
variables[key] = fmt.Sprintf("$config(%s)", value) | ||
} | ||
return variables, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.