Skip to content

Commit

Permalink
move
Browse files Browse the repository at this point in the history
Signed-off-by: Gerd Oberlechner <[email protected]>
  • Loading branch information
geoberle committed Nov 13, 2024
1 parent 12b1c11 commit 681103d
Show file tree
Hide file tree
Showing 15 changed files with 64 additions and 232 deletions.
2 changes: 1 addition & 1 deletion tooling/templatize/cmd/generate/cmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/stretchr/testify/assert"

options "github.com/Azure/ARO-HCP/tooling/templatize/cmd"
"github.com/Azure/ARO-HCP/tooling/templatize/internal/config"
"github.com/Azure/ARO-HCP/tooling/templatize/pkg/config"
)

func TestExecuteTemplate(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion tooling/templatize/cmd/generate/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/spf13/cobra"

options "github.com/Azure/ARO-HCP/tooling/templatize/cmd"
"github.com/Azure/ARO-HCP/tooling/templatize/internal/ev2"
"github.com/Azure/ARO-HCP/tooling/templatize/pkg/ev2"
)

func DefaultGenerationOptions() *RawGenerationOptions {
Expand Down
2 changes: 1 addition & 1 deletion tooling/templatize/cmd/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/spf13/cobra"
"k8s.io/apimachinery/pkg/util/sets"

"github.com/Azure/ARO-HCP/tooling/templatize/internal/config"
"github.com/Azure/ARO-HCP/tooling/templatize/pkg/config"
)

func DefaultOptions() *RawOptions {
Expand Down
2 changes: 1 addition & 1 deletion tooling/templatize/cmd/rolloutoptions.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (

"github.com/spf13/cobra"

"github.com/Azure/ARO-HCP/tooling/templatize/internal/config"
"github.com/Azure/ARO-HCP/tooling/templatize/pkg/config"
)

func DefaultRolloutOptions() *RawRolloutOptions {
Expand Down
4 changes: 2 additions & 2 deletions tooling/templatize/cmd/run/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"github.com/spf13/cobra"

options "github.com/Azure/ARO-HCP/tooling/templatize/cmd"
"github.com/Azure/ARO-HCP/tooling/templatize/internal/config"
"github.com/Azure/ARO-HCP/tooling/templatize/internal/pipeline"
"github.com/Azure/ARO-HCP/tooling/templatize/pkg/config"
"github.com/Azure/ARO-HCP/tooling/templatize/pkg/pipeline"
)

func DefaultOptions() *RawRunOptions {
Expand Down
94 changes: 0 additions & 94 deletions tooling/templatize/internal/ev2/scopebinding.go

This file was deleted.

130 changes: 0 additions & 130 deletions tooling/templatize/internal/ev2/serviceconfig.go

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import (
"fmt"
"testing"

"github.com/Azure/ARO-HCP/tooling/templatize/internal/config"
"gotest.tools/assert"

"github.com/Azure/ARO-HCP/tooling/templatize/pkg/config"
)

func TestMapping(t *testing.T) {
Expand Down
55 changes: 55 additions & 0 deletions tooling/templatize/pkg/ev2/utils.go
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
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armsubscriptions"
"gopkg.in/yaml.v3"

"github.com/Azure/ARO-HCP/tooling/templatize/internal/config"
"github.com/Azure/ARO-HCP/tooling/templatize/pkg/config"
)

func LoadPipeline(path string, vars config.Variables) (*Pipeline, error) {
Expand Down
File renamed without changes.

0 comments on commit 681103d

Please sign in to comment.