From abd0ec2f55745a62f84b6d981b82685c77fd71d6 Mon Sep 17 00:00:00 2001 From: Jan-Hendrik Boll Date: Tue, 3 Dec 2024 14:06:15 +0100 Subject: [PATCH 01/13] Add Output handling Makes it possible to pass output of ARM steps into Shell steps as environment variables. --- .../templatize/internal/end2end/e2e_test.go | 83 +++++++++++++++++++ tooling/templatize/pkg/pipeline/arm.go | 68 ++++++++++----- tooling/templatize/pkg/pipeline/run.go | 53 ++++++++++-- tooling/templatize/pkg/pipeline/run_test.go | 20 ++++- tooling/templatize/pkg/pipeline/shell.go | 18 +++- tooling/templatize/pkg/pipeline/shell_test.go | 25 +++++- tooling/templatize/pkg/pipeline/types.go | 5 +- 7 files changed, 237 insertions(+), 35 deletions(-) diff --git a/tooling/templatize/internal/end2end/e2e_test.go b/tooling/templatize/internal/end2end/e2e_test.go index 8e6c4e877..60be9b3e3 100644 --- a/tooling/templatize/internal/end2end/e2e_test.go +++ b/tooling/templatize/internal/end2end/e2e_test.go @@ -143,3 +143,86 @@ param zoneName = 'e2etestarmdeploy.foo.bar.example.com' _, err = rgDelResponse.PollUntilDone(context.Background(), nil) assert.NilError(t, err) } + +func TestE2EShell(t *testing.T) { + if !shouldRunE2E() { + t.Skip("Skipping end-to-end tests") + } + + tmpDir := t.TempDir() + + e2eImpl := newE2E(tmpDir) + + e2eImpl.AddStep(pipeline.Step{ + Name: "readInput", + Action: "Shell", + Command: "/usr/bin/echo ${PWD} > env.txt", + }) + + persistAndRun(t, &e2eImpl) + + io, err := os.ReadFile(tmpDir + "/env.txt") + assert.NilError(t, err) + assert.Equal(t, string(io), tmpDir+"\n") +} + +func TestE2EArmDeployWithOutput(t *testing.T) { + if !shouldRunE2E() { + t.Skip("Skipping end-to-end tests") + } + + tmpDir := t.TempDir() + + e2eImpl := newE2E(tmpDir) + e2eImpl.AddStep(pipeline.Step{ + Name: "createZone", + Action: "ARM", + Template: "test.bicep", + Parameters: "test.bicepparm", + }) + + e2eImpl.AddStep(pipeline.Step{ + Name: "readInput", + Action: "Shell", + Command: "echo ${zoneName} > env.txt", + Inputs: []pipeline.Input{ + { + Name: "zoneName", + Step: "createZone", + Output: "zoneName", + Type: "string", + }, + }, + }) + + e2eImpl.UseRandomRG() + + e2eImpl.bicepFile = ` +param zoneName string +output zoneName string = zoneName` + e2eImpl.paramFile = ` +using 'test.bicep' +param zoneName = 'e2etestarmdeploy.foo.bar.example.com' +` + + persistAndRun(t, &e2eImpl) + + io, err := os.ReadFile(tmpDir + "/env.txt") + assert.NilError(t, err) + assert.Equal(t, string(io), "e2etestarmdeploy.foo.bar.example.com\n") + + subsriptionID, err := pipeline.LookupSubscriptionID(context.Background(), "ARO Hosted Control Planes (EA Subscription 1)") + assert.NilError(t, err) + + cred, err := azidentity.NewDefaultAzureCredential(nil) + assert.NilError(t, err) + + rgClient, err := armresources.NewResourceGroupsClient(subsriptionID, cred, nil) + assert.NilError(t, err) + + rgDelResponse, err := rgClient.BeginDelete(context.Background(), e2eImpl.rgName, nil) + assert.NilError(t, err) + + _, err = rgDelResponse.PollUntilDone(context.Background(), nil) + assert.NilError(t, err) +} diff --git a/tooling/templatize/pkg/pipeline/arm.go b/tooling/templatize/pkg/pipeline/arm.go index 888bce862..c2b05aab8 100644 --- a/tooling/templatize/pkg/pipeline/arm.go +++ b/tooling/templatize/pkg/pipeline/arm.go @@ -10,56 +10,78 @@ import ( "github.com/go-logr/logr" ) -func (s *Step) runArmStep(ctx context.Context, executionTarget ExecutionTarget, options *PipelineRunOptions) error { +type armClient struct { + creds *azidentity.DefaultAzureCredential + SubscriptionID string + Region string +} + +func newArmClient(subscriptionID, region string) *armClient { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + return nil + } + return &armClient{ + creds: cred, + SubscriptionID: subscriptionID, + Region: region, + } +} + +func (a *armClient) runArmStep(ctx context.Context, options *PipelineRunOptions, deploymentName string, rgName string, paramterFile string, input map[string]output) (output, error) { logger := logr.FromContextOrDiscard(ctx) // Transform Bicep to ARM - deploymentProperties, err := transformBicepToARM(ctx, s.Parameters, options.Vars) + deploymentProperties, err := transformBicepToARM(ctx, paramterFile, options.Vars) if err != nil { - return fmt.Errorf("failed to transform Bicep to ARM: %w", err) + return nil, fmt.Errorf("failed to transform Bicep to ARM: %w", err) } // Create the deployment - deploymentName := s.Name deployment := armresources.Deployment{ Properties: deploymentProperties, } // Ensure resourcegroup exists - err = s.ensureResourceGroupExists(ctx, executionTarget) + err = a.ensureResourceGroupExists(ctx, rgName) if err != nil { - return fmt.Errorf("failed to ensure resource group exists: %w", err) + return nil, fmt.Errorf("failed to ensure resource group exists: %w", err) } // TODO handle dry-run // Run deployment - cred, err := azidentity.NewDefaultAzureCredential(nil) + client, err := armresources.NewDeploymentsClient(a.SubscriptionID, a.creds, nil) if err != nil { - return fmt.Errorf("failed to obtain a credential: %w", err) - } - - client, err := armresources.NewDeploymentsClient(executionTarget.GetSubscriptionID(), cred, nil) - if err != nil { - return fmt.Errorf("failed to create deployments client: %w", err) + return nil, fmt.Errorf("failed to create deployments client: %w", err) } - poller, err := client.BeginCreateOrUpdate(ctx, executionTarget.GetResourceGroup(), deploymentName, deployment, nil) + poller, err := client.BeginCreateOrUpdate(ctx, rgName, deploymentName, deployment, nil) if err != nil { - return fmt.Errorf("failed to create deployment: %w", err) + return nil, fmt.Errorf("failed to create deployment: %w", err) } logger.Info("Deployment started", "deployment", deploymentName) // Wait for completion resp, err := poller.PollUntilDone(ctx, nil) if err != nil { - return fmt.Errorf("failed to wait for deployment completion: %w", err) + return nil, fmt.Errorf("failed to wait for deployment completion: %w", err) } logger.Info("Deployment finished successfully", "deployment", deploymentName, "responseId", *resp.ID) - return nil + + if resp.Properties.Outputs != nil { + if outputMap, ok := resp.Properties.Outputs.(map[string]any); ok { + returnMap := armOutput{} + for k, v := range outputMap { + returnMap[k] = v + } + return returnMap, nil + } + } + return nil, nil } -func (s *Step) ensureResourceGroupExists(ctx context.Context, executionTarget ExecutionTarget) error { +func (a *armClient) ensureResourceGroupExists(ctx context.Context, rgName string) error { // Create a new Azure identity client cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -67,7 +89,7 @@ func (s *Step) ensureResourceGroupExists(ctx context.Context, executionTarget Ex } // Create a new ARM client - client, err := armresources.NewResourceGroupsClient(executionTarget.GetSubscriptionID(), cred, nil) + client, err := armresources.NewResourceGroupsClient(a.SubscriptionID, cred, nil) if err != nil { return fmt.Errorf("failed to create ARM client: %w", err) } @@ -77,14 +99,14 @@ func (s *Step) ensureResourceGroupExists(ctx context.Context, executionTarget Ex tags := map[string]*string{ "persist": to.Ptr("true"), } - _, err = client.Get(ctx, executionTarget.GetResourceGroup(), nil) + _, err = client.Get(ctx, rgName, nil) if err != nil { // Create the resource group resourceGroup := armresources.ResourceGroup{ - Location: to.Ptr(executionTarget.GetRegion()), + Location: to.Ptr(a.Region), Tags: tags, } - _, err = client.CreateOrUpdate(ctx, executionTarget.GetResourceGroup(), resourceGroup, nil) + _, err = client.CreateOrUpdate(ctx, rgName, resourceGroup, nil) if err != nil { return fmt.Errorf("failed to create resource group: %w", err) } @@ -92,7 +114,7 @@ func (s *Step) ensureResourceGroupExists(ctx context.Context, executionTarget Ex patchResourceGroup := armresources.ResourceGroupPatchable{ Tags: tags, } - _, err = client.Update(ctx, executionTarget.GetResourceGroup(), patchResourceGroup, nil) + _, err = client.Update(ctx, rgName, patchResourceGroup, nil) if err != nil { return fmt.Errorf("failed to update resource group: %w", err) } diff --git a/tooling/templatize/pkg/pipeline/run.go b/tooling/templatize/pkg/pipeline/run.go index 492522665..d84dddadb 100644 --- a/tooling/templatize/pkg/pipeline/run.go +++ b/tooling/templatize/pkg/pipeline/run.go @@ -46,6 +46,30 @@ type PipelineRunOptions struct { SubsciptionLookupFunc subsciptionLookup } +type armOutput map[string]any + +type output interface { + GetValue(key string) (*outPutValue, error) +} + +type outPutValue struct { + Type string `yaml:"type"` + Value any `yaml:"value"` +} + +func (o armOutput) GetValue(key string) (*outPutValue, error) { + if v, ok := o[key]; ok { + if innerValue, innerConversionOk := v.(map[string]any); innerConversionOk { + returnValue := outPutValue{ + Type: innerValue["type"].(string), + Value: innerValue["value"], + } + return &returnValue, nil + } + } + return nil, fmt.Errorf("key %q not found", key) +} + func (p *Pipeline) Run(ctx context.Context, options *PipelineRunOptions) error { logger := logr.FromContextOrDiscard(ctx) @@ -94,6 +118,8 @@ func (p *Pipeline) Run(ctx context.Context, options *PipelineRunOptions) error { func (rg *ResourceGroup) run(ctx context.Context, options *PipelineRunOptions, executionTarget ExecutionTarget) error { logger := logr.FromContextOrDiscard(ctx) + outPuts := make(map[string]output) + kubeconfigFile, err := executionTarget.KubeConfig(ctx) if kubeconfigFile != "" { defer func() { @@ -107,7 +133,7 @@ func (rg *ResourceGroup) run(ctx context.Context, options *PipelineRunOptions, e for _, step := range rg.Steps { // execute - err := step.run( + output, err := step.run( logr.NewContext( ctx, logger.WithValues( @@ -119,18 +145,22 @@ func (rg *ResourceGroup) run(ctx context.Context, options *PipelineRunOptions, e ), kubeconfigFile, executionTarget, options, + outPuts, ) if err != nil { return err } + if output != nil { + outPuts[step.Name] = output + } } return nil } -func (s *Step) run(ctx context.Context, kubeconfigFile string, executionTarget ExecutionTarget, options *PipelineRunOptions) error { +func (s *Step) run(ctx context.Context, kubeconfigFile string, executionTarget ExecutionTarget, options *PipelineRunOptions, outPuts map[string]output) (output, error) { if options.Step != "" && s.Name != options.Step { // skip steps that don't match the specified step name - return nil + return nil, nil } fmt.Println("\n---------------------") if options.DryRun { @@ -141,11 +171,22 @@ func (s *Step) run(ctx context.Context, kubeconfigFile string, executionTarget E switch s.Action { case "Shell": - return s.runShellStep(ctx, kubeconfigFile, options) + return nil, s.runShellStep(ctx, kubeconfigFile, options, outPuts) case "ARM": - return s.runArmStep(ctx, executionTarget, options) + a := newArmClient(executionTarget.GetSubscriptionID(), executionTarget.GetRegion()) + if a == nil { + return nil, fmt.Errorf("failed to create ARM client") + } + output, err := a.runArmStep(ctx, options, s.Name, executionTarget.GetResourceGroup(), s.Parameters, outPuts) + if err != nil { + return nil, fmt.Errorf("failed to run ARM step: %w", err) + } + if output != nil { + return output, nil + } + return nil, nil default: - return fmt.Errorf("unsupported action type %q", s.Action) + return nil, fmt.Errorf("unsupported action type %q", s.Action) } } diff --git a/tooling/templatize/pkg/pipeline/run_test.go b/tooling/templatize/pkg/pipeline/run_test.go index 41992e6b9..1c2b992c2 100644 --- a/tooling/templatize/pkg/pipeline/run_test.go +++ b/tooling/templatize/pkg/pipeline/run_test.go @@ -17,7 +17,7 @@ func TestStepRun(t *testing.T) { fooundOutput = output }, } - err := s.run(context.Background(), "", &executionTargetImpl{}, &PipelineRunOptions{}) + _, err := s.run(context.Background(), "", &executionTargetImpl{}, &PipelineRunOptions{}, nil) assert.NilError(t, err) assert.Equal(t, fooundOutput, "hello\n") } @@ -27,11 +27,11 @@ func TestStepRunSkip(t *testing.T) { Name: "step", } // this should skip - err := s.run(context.Background(), "", &executionTargetImpl{}, &PipelineRunOptions{Step: "skip"}) + _, err := s.run(context.Background(), "", &executionTargetImpl{}, &PipelineRunOptions{Step: "skip"}, nil) assert.NilError(t, err) // this should fail - err = s.run(context.Background(), "", &executionTargetImpl{}, &PipelineRunOptions{Step: "step"}) + _, err = s.run(context.Background(), "", &executionTargetImpl{}, &PipelineRunOptions{Step: "step"}, nil) assert.Error(t, err, "unsupported action type \"\"") } @@ -280,3 +280,17 @@ func TestPipelineRun(t *testing.T) { assert.NilError(t, err) assert.Equal(t, foundOutput, "hello\n") } + +func TestArmGetValue(t *testing.T) { + output := armOutput{ + "zoneName": map[string]any{ + "type": "String", + "value": "test", + }, + } + + value, err := output.GetValue("zoneName") + assert.Equal(t, value.Value, "test") + assert.Equal(t, value.Type, "String") + assert.NilError(t, err) +} diff --git a/tooling/templatize/pkg/pipeline/shell.go b/tooling/templatize/pkg/pipeline/shell.go index 48730b94e..d4604ddd4 100644 --- a/tooling/templatize/pkg/pipeline/shell.go +++ b/tooling/templatize/pkg/pipeline/shell.go @@ -3,6 +3,7 @@ package pipeline import ( "context" "fmt" + "log" "maps" "os/exec" @@ -34,7 +35,7 @@ func buildBashScript(command string) string { return fmt.Sprintf("set -o errexit -o nounset -o pipefail\n%s", command) } -func (s *Step) runShellStep(ctx context.Context, kubeconfigFile string, options *PipelineRunOptions) error { +func (s *Step) runShellStep(ctx context.Context, kubeconfigFile string, options *PipelineRunOptions, inputs map[string]output) error { if s.outputFunc == nil { s.outputFunc = func(output string) { fmt.Println(output) @@ -52,6 +53,7 @@ func (s *Step) runShellStep(ctx context.Context, kubeconfigFile string, options envVars := utils.GetOsVariable() maps.Copy(envVars, stepVars) + maps.Copy(envVars, s.addInputVars(inputs)) // execute the command cmd, skipCommand := s.createCommand(ctx, options.DryRun, envVars) if skipCommand { @@ -74,6 +76,20 @@ func (s *Step) runShellStep(ctx context.Context, kubeconfigFile string, options return nil } +func (s *Step) addInputVars(inputs map[string]output) map[string]string { + envVars := make(map[string]string) + for _, i := range s.Inputs { + if v, found := inputs[i.Step]; found { + value, err := v.GetValue(i.Output) + if err != nil { + log.Fatal(err) + } + envVars[i.Name] = utils.AnyToString(value.Value) + } + } + return envVars +} + func (s *Step) mapStepVariables(vars config.Variables) (map[string]string, error) { envVars := make(map[string]string) for _, e := range s.Env { diff --git a/tooling/templatize/pkg/pipeline/shell_test.go b/tooling/templatize/pkg/pipeline/shell_test.go index 5fe18ef87..20645e9e1 100644 --- a/tooling/templatize/pkg/pipeline/shell_test.go +++ b/tooling/templatize/pkg/pipeline/shell_test.go @@ -192,7 +192,7 @@ func TestRunShellStep(t *testing.T) { } for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { - err := tc.step.runShellStep(context.Background(), "", &PipelineRunOptions{}) + err := tc.step.runShellStep(context.Background(), "", &PipelineRunOptions{}, map[string]output{}) if tc.err != "" { assert.ErrorContains(t, err, tc.err) } else { @@ -201,3 +201,26 @@ func TestRunShellStep(t *testing.T) { }) } } + +func TestAddInputVars(t *testing.T) { + mapOutput := map[string]output{} + mapOutput["step1"] = armOutput{ + "output1": map[string]any{ + "type": "String", + "value": "value1", + }, + } + s := &Step{ + Name: "step2", + Inputs: []Input{ + { + Name: "input1", + Step: "step1", + Output: "output1", + }, + }, + } + + envVars := s.addInputVars(mapOutput) + assert.DeepEqual(t, envVars, map[string]string{"input1": "value1"}) +} diff --git a/tooling/templatize/pkg/pipeline/types.go b/tooling/templatize/pkg/pipeline/types.go index 2d1888f97..ddd8392f2 100644 --- a/tooling/templatize/pkg/pipeline/types.go +++ b/tooling/templatize/pkg/pipeline/types.go @@ -1,6 +1,8 @@ package pipeline -import "context" +import ( + "context" +) type subsciptionLookup func(context.Context, string) (string, error) @@ -49,4 +51,5 @@ type Input struct { Name string `yaml:"name"` Step string `yaml:"step"` Output string `yaml:"output"` + Type string `yaml:"type,omitempty"` } From 6e10b7a881a5ee199e95172717229678aa273793 Mon Sep 17 00:00:00 2001 From: Jan-Hendrik Boll Date: Tue, 3 Dec 2024 14:18:05 +0100 Subject: [PATCH 02/13] Increase timeout --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index c9b405af9..46d0a6ad4 100644 --- a/Makefile +++ b/Makefile @@ -15,7 +15,7 @@ all: test lint # There is currently no convenient way to run tests against a whole Go workspace # https://github.com/golang/go/issues/50745 test: - go list -f '{{.Dir}}/...' -m |RUN_TEMPLATIZE_E2E=true xargs go test -timeout 120s -tags=$(GOTAGS) -cover + go list -f '{{.Dir}}/...' -m |RUN_TEMPLATIZE_E2E=true xargs go test -timeout 1200s -tags=$(GOTAGS) -cover .PHONY: test # There is currently no convenient way to run golangci-lint against a whole Go workspace From caa98e9f69174b3bb3010d7b34389efd3aa11acc Mon Sep 17 00:00:00 2001 From: Jan-Hendrik Boll Date: Tue, 3 Dec 2024 16:31:13 +0100 Subject: [PATCH 03/13] Add input to ARM steps --- tooling/templatize/internal/end2end/e2e.go | 85 ++++++++++--- .../templatize/internal/end2end/e2e_test.go | 114 ++++++++++++------ tooling/templatize/pkg/pipeline/arm.go | 10 +- tooling/templatize/pkg/pipeline/bicep.go | 17 ++- tooling/templatize/pkg/pipeline/run.go | 17 ++- tooling/templatize/pkg/pipeline/run_test.go | 22 ++++ tooling/templatize/pkg/pipeline/shell.go | 20 +-- tooling/templatize/pkg/pipeline/shell_test.go | 23 ---- 8 files changed, 204 insertions(+), 104 deletions(-) diff --git a/tooling/templatize/internal/end2end/e2e.go b/tooling/templatize/internal/end2end/e2e.go index a7149116c..79f5792ca 100644 --- a/tooling/templatize/internal/end2end/e2e.go +++ b/tooling/templatize/internal/end2end/e2e.go @@ -1,6 +1,7 @@ package testutil import ( + "context" "fmt" "math/rand/v2" "os" @@ -9,6 +10,8 @@ import ( "github.com/Azure/ARO-HCP/tooling/templatize/pkg/config" "github.com/Azure/ARO-HCP/tooling/templatize/pkg/pipeline" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources" ) var defaultRgName = "hcp-templatize" @@ -19,21 +22,28 @@ func shouldRunE2E() bool { type E2E interface { SetConfig(updates config.Variables) - UseRandomRG() + UseRandomRG() func() error + AddBicepTemplate(template, templateFileName, paramfile, paramfileName string) AddStep(step pipeline.Step) SetOSArgs() Persist() error } +type bicepTemplate struct { + bicepFile string + bicepFileName string + paramFile string + paramFileName string +} + type e2eImpl struct { - config config.Variables - makefile string - pipeline pipeline.Pipeline - bicepFile string - paramFile string - schema string - tmpdir string - rgName string + config config.Variables + makefile string + pipeline pipeline.Pipeline + biceps []bicepTemplate + schema string + tmpdir string + rgName string } var _ E2E = &e2eImpl{} @@ -71,13 +81,14 @@ func newE2E(tmpdir string) e2eImpl { }, }, rgName: defaultRgName, + biceps: []bicepTemplate{}, } imp.SetOSArgs() return imp } -func (e *e2eImpl) UseRandomRG() { +func (e *e2eImpl) UseRandomRG() func() error { chars := []rune("abcdefghijklmnopqrstuvwxyz0123456789") rg := "templatize-e2e-" @@ -87,6 +98,30 @@ func (e *e2eImpl) UseRandomRG() { } e.rgName = rg e.SetConfig(config.Variables{"defaults": config.Variables{"rg": rg}}) + + return func() error { + subsriptionID, err := pipeline.LookupSubscriptionID(context.Background(), "ARO Hosted Control Planes (EA Subscription 1)") + if err != nil { + return err + } + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + return err + } + rgClient, err := armresources.NewResourceGroupsClient(subsriptionID, cred, nil) + if err != nil { + return err + } + rgDelResponse, err := rgClient.BeginDelete(context.Background(), e.rgName, nil) + if err != nil { + return err + } + _, err = rgDelResponse.PollUntilDone(context.Background(), nil) + if err != nil { + return err + } + return nil + } } func (e *e2eImpl) SetOSArgs() { @@ -111,16 +146,28 @@ func (e *e2eImpl) SetConfig(updates config.Variables) { config.MergeVariables(e.config, updates) } -func (e *e2eImpl) Persist() error { - if e.bicepFile != "" && e.paramFile != "" { - err := os.WriteFile(e.tmpdir+"/test.bicep", []byte(e.bicepFile), 0644) - if err != nil { - return err - } +func (e *e2eImpl) AddBicepTemplate(template, templateFileName, paramfile, paramfileName string) { + e.biceps = append(e.biceps, bicepTemplate{ + bicepFile: template, + bicepFileName: templateFileName, + paramFile: paramfile, + paramFileName: paramfileName, + }) +} - err = os.WriteFile(e.tmpdir+"/test.bicepparm", []byte(e.paramFile), 0644) - if err != nil { - return err +func (e *e2eImpl) Persist() error { + if len(e.biceps) != 0 { + for _, b := range e.biceps { + + err := os.WriteFile(e.tmpdir+"/"+b.bicepFileName, []byte(b.bicepFile), 0644) + if err != nil { + return err + } + + err = os.WriteFile(e.tmpdir+"/"+b.paramFileName, []byte(b.paramFile), 0644) + if err != nil { + return err + } } } diff --git a/tooling/templatize/internal/end2end/e2e_test.go b/tooling/templatize/internal/end2end/e2e_test.go index 60be9b3e3..ba1cbf574 100644 --- a/tooling/templatize/internal/end2end/e2e_test.go +++ b/tooling/templatize/internal/end2end/e2e_test.go @@ -13,7 +13,6 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dns/armdns" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources" ) func persistAndRun(t *testing.T, e2eImpl E2E) { @@ -95,18 +94,20 @@ func TestE2EArmDeploy(t *testing.T) { Parameters: "test.bicepparm", }) - e2eImpl.UseRandomRG() + cleanup := e2eImpl.UseRandomRG() + defer cleanup() - e2eImpl.bicepFile = ` + bicepFile := ` param zoneName string resource symbolicname 'Microsoft.Network/dnsZones@2018-05-01' = { location: 'global' name: zoneName }` - e2eImpl.paramFile = ` + paramFile := ` using 'test.bicep' param zoneName = 'e2etestarmdeploy.foo.bar.example.com' ` + e2eImpl.AddBicepTemplate(bicepFile, "test.bicep", paramFile, "test.bicepparm") persistAndRun(t, &e2eImpl) @@ -117,31 +118,12 @@ param zoneName = 'e2etestarmdeploy.foo.bar.example.com' cred, err := azidentity.NewDefaultAzureCredential(nil) assert.NilError(t, err) - rgClient, err := armresources.NewResourceGroupsClient(subsriptionID, cred, nil) - assert.NilError(t, err) - - existence, err := rgClient.CheckExistence(context.Background(), e2eImpl.rgName, nil) - assert.NilError(t, err) - assert.Assert(t, existence.Success) - zonesClient, err := armdns.NewZonesClient(subsriptionID, cred, nil) assert.NilError(t, err) zoneResp, err := zonesClient.Get(context.Background(), e2eImpl.rgName, "e2etestarmdeploy.foo.bar.example.com", nil) assert.NilError(t, err) assert.Equal(t, *zoneResp.Name, "e2etestarmdeploy.foo.bar.example.com") - - delResponse, err := zonesClient.BeginDelete(context.Background(), e2eImpl.rgName, "e2etestarmdeploy.foo.bar.example.com", nil) - assert.NilError(t, err) - - _, err = delResponse.PollUntilDone(context.Background(), nil) - assert.NilError(t, err) - - rgDelResponse, err := rgClient.BeginDelete(context.Background(), e2eImpl.rgName, nil) - assert.NilError(t, err) - - _, err = rgDelResponse.PollUntilDone(context.Background(), nil) - assert.NilError(t, err) } func TestE2EShell(t *testing.T) { @@ -195,34 +177,94 @@ func TestE2EArmDeployWithOutput(t *testing.T) { }, }) - e2eImpl.UseRandomRG() + cleanup := e2eImpl.UseRandomRG() + defer cleanup() - e2eImpl.bicepFile = ` + bicepFile := ` param zoneName string output zoneName string = zoneName` - e2eImpl.paramFile = ` + paramFile := ` using 'test.bicep' param zoneName = 'e2etestarmdeploy.foo.bar.example.com' ` - + e2eImpl.AddBicepTemplate(bicepFile, "test.bicep", paramFile, "test.bicepparm") persistAndRun(t, &e2eImpl) io, err := os.ReadFile(tmpDir + "/env.txt") assert.NilError(t, err) assert.Equal(t, string(io), "e2etestarmdeploy.foo.bar.example.com\n") +} - subsriptionID, err := pipeline.LookupSubscriptionID(context.Background(), "ARO Hosted Control Planes (EA Subscription 1)") - assert.NilError(t, err) +func TestE2EArmDeployWithOutputToArm(t *testing.T) { + if !shouldRunE2E() { + t.Skip("Skipping end-to-end tests") + } - cred, err := azidentity.NewDefaultAzureCredential(nil) - assert.NilError(t, err) + tmpDir := t.TempDir() - rgClient, err := armresources.NewResourceGroupsClient(subsriptionID, cred, nil) - assert.NilError(t, err) + e2eImpl := newE2E(tmpDir) + e2eImpl.AddStep(pipeline.Step{ + Name: "parameterA", + Action: "ARM", + Template: "testa.bicep", + Parameters: "testa.bicepparm", + }) - rgDelResponse, err := rgClient.BeginDelete(context.Background(), e2eImpl.rgName, nil) - assert.NilError(t, err) + e2eImpl.AddStep(pipeline.Step{ + Name: "parameterB", + Action: "ARM", + Template: "testb.bicep", + Parameters: "testb.bicepparm", + Inputs: []pipeline.Input{ + { + Name: "parameterB", + Step: "parameterA", + Output: "parameterA", + Type: "string", + }, + }, + }) - _, err = rgDelResponse.PollUntilDone(context.Background(), nil) + e2eImpl.AddStep(pipeline.Step{ + Name: "readInput", + Action: "Shell", + Command: []string{"/bin/sh", "-c", "echo ${end} > env.txt"}, + Inputs: []pipeline.Input{ + { + Name: "end", + Step: "parameterB", + Output: "parameterC", + Type: "string", + }, + }, + }) + + e2eImpl.AddBicepTemplate(` +param parameterA string +output parameterA string = parameterA`, + "testa.bicep", + ` +using 'testa.bicep' +param parameterA = 'Hello Bicep'`, + "testa.bicepparm") + + e2eImpl.AddBicepTemplate(` +param parameterB string +output parameterC string = parameterB +`, + "testb.bicep", + ` +using 'testb.bicep' +param parameterB = '{{ .parameterB }}' +`, + "testb.bicepparm") + + cleanup := e2eImpl.UseRandomRG() + defer cleanup() + + persistAndRun(t, &e2eImpl) + + io, err := os.ReadFile(tmpDir + "/env.txt") assert.NilError(t, err) + assert.Equal(t, string(io), "Hello Bicep\n") } diff --git a/tooling/templatize/pkg/pipeline/arm.go b/tooling/templatize/pkg/pipeline/arm.go index c2b05aab8..e6efb8c22 100644 --- a/tooling/templatize/pkg/pipeline/arm.go +++ b/tooling/templatize/pkg/pipeline/arm.go @@ -28,11 +28,11 @@ func newArmClient(subscriptionID, region string) *armClient { } } -func (a *armClient) runArmStep(ctx context.Context, options *PipelineRunOptions, deploymentName string, rgName string, paramterFile string, input map[string]output) (output, error) { +func (a *armClient) runArmStep(ctx context.Context, options *PipelineRunOptions, rgName string, step *Step, input map[string]output) (output, error) { logger := logr.FromContextOrDiscard(ctx) // Transform Bicep to ARM - deploymentProperties, err := transformBicepToARM(ctx, paramterFile, options.Vars) + deploymentProperties, err := transformBicepToARM(ctx, step.Parameters, options.Vars, addInputVars(step.Inputs, input)) if err != nil { return nil, fmt.Errorf("failed to transform Bicep to ARM: %w", err) } @@ -56,18 +56,18 @@ func (a *armClient) runArmStep(ctx context.Context, options *PipelineRunOptions, return nil, fmt.Errorf("failed to create deployments client: %w", err) } - poller, err := client.BeginCreateOrUpdate(ctx, rgName, deploymentName, deployment, nil) + poller, err := client.BeginCreateOrUpdate(ctx, rgName, step.Name, deployment, nil) if err != nil { return nil, fmt.Errorf("failed to create deployment: %w", err) } - logger.Info("Deployment started", "deployment", deploymentName) + logger.Info("Deployment started", "deployment", step.Name) // Wait for completion resp, err := poller.PollUntilDone(ctx, nil) if err != nil { return nil, fmt.Errorf("failed to wait for deployment completion: %w", err) } - logger.Info("Deployment finished successfully", "deployment", deploymentName, "responseId", *resp.ID) + logger.Info("Deployment finished successfully", "deployment", step.Name, "responseId", *resp.ID) if resp.Properties.Outputs != nil { if outputMap, ok := resp.Properties.Outputs.(map[string]any); ok { diff --git a/tooling/templatize/pkg/pipeline/bicep.go b/tooling/templatize/pkg/pipeline/bicep.go index 7b8ca60d5..1b4848890 100644 --- a/tooling/templatize/pkg/pipeline/bicep.go +++ b/tooling/templatize/pkg/pipeline/bicep.go @@ -14,11 +14,20 @@ import ( "github.com/Azure/ARO-HCP/tooling/templatize/pkg/config" ) -func transformBicepToARM(ctx context.Context, bicepParameterTemplateFile string, vars config.Variables) (*armresources.DeploymentProperties, error) { +func transformBicepToARM(ctx context.Context, bicepParameterTemplateFile string, vars config.Variables, inputs map[string]any) (*armresources.DeploymentProperties, error) { // preprocess bicep parameter file and store it - bicepParamContent, error := config.PreprocessFile(bicepParameterTemplateFile, vars) - if error != nil { - return nil, fmt.Errorf("failed to preprocess file: %w", error) + + combinedVars := make(map[string]any) + for k, v := range vars { + combinedVars[k] = v + } + for k, v := range inputs { + combinedVars[k] = v + } + + bicepParamContent, err := config.PreprocessFile(bicepParameterTemplateFile, combinedVars) + if err != nil { + return nil, fmt.Errorf("failed to preprocess file: %w", err) } bicepParamBaseDir := filepath.Dir(bicepParameterTemplateFile) bicepParamFile, err := os.CreateTemp(bicepParamBaseDir, "bicep-params-*.bicepparam") diff --git a/tooling/templatize/pkg/pipeline/run.go b/tooling/templatize/pkg/pipeline/run.go index d84dddadb..4449234a8 100644 --- a/tooling/templatize/pkg/pipeline/run.go +++ b/tooling/templatize/pkg/pipeline/run.go @@ -3,6 +3,7 @@ package pipeline import ( "context" "fmt" + "log" "os" "path/filepath" "strings" @@ -177,7 +178,7 @@ func (s *Step) run(ctx context.Context, kubeconfigFile string, executionTarget E if a == nil { return nil, fmt.Errorf("failed to create ARM client") } - output, err := a.runArmStep(ctx, options, s.Name, executionTarget.GetResourceGroup(), s.Parameters, outPuts) + output, err := a.runArmStep(ctx, options, executionTarget.GetResourceGroup(), s, outPuts) if err != nil { return nil, fmt.Errorf("failed to run ARM step: %w", err) } @@ -244,3 +245,17 @@ func (rg *ResourceGroup) Validate() error { } return nil } + +func addInputVars(configuredInputs []Input, inputs map[string]output) map[string]any { + envVars := make(map[string]any) + for _, i := range configuredInputs { + if v, found := inputs[i.Step]; found { + value, err := v.GetValue(i.Output) + if err != nil { + log.Fatal(err) + } + envVars[i.Name] = value.Value + } + } + return envVars +} diff --git a/tooling/templatize/pkg/pipeline/run_test.go b/tooling/templatize/pkg/pipeline/run_test.go index 1c2b992c2..5b9b82147 100644 --- a/tooling/templatize/pkg/pipeline/run_test.go +++ b/tooling/templatize/pkg/pipeline/run_test.go @@ -294,3 +294,25 @@ func TestArmGetValue(t *testing.T) { assert.Equal(t, value.Type, "String") assert.NilError(t, err) } + +func TestAddInputVars(t *testing.T) { + mapOutput := map[string]output{} + mapOutput["step1"] = armOutput{ + "output1": map[string]any{ + "type": "String", + "value": "value1", + }, + } + s := &Step{ + Inputs: []Input{ + { + Name: "input1", + Step: "step1", + Output: "output1", + }, + }, + } + + envVars := addInputVars(s.Inputs, mapOutput) + assert.DeepEqual(t, envVars, map[string]any{"input1": "value1"}) +} diff --git a/tooling/templatize/pkg/pipeline/shell.go b/tooling/templatize/pkg/pipeline/shell.go index d4604ddd4..3bf1a8716 100644 --- a/tooling/templatize/pkg/pipeline/shell.go +++ b/tooling/templatize/pkg/pipeline/shell.go @@ -3,7 +3,6 @@ package pipeline import ( "context" "fmt" - "log" "maps" "os/exec" @@ -53,7 +52,10 @@ func (s *Step) runShellStep(ctx context.Context, kubeconfigFile string, options envVars := utils.GetOsVariable() maps.Copy(envVars, stepVars) - maps.Copy(envVars, s.addInputVars(inputs)) + + for k, v := range addInputVars(s.Inputs, inputs) { + envVars[k] = utils.AnyToString(v) + } // execute the command cmd, skipCommand := s.createCommand(ctx, options.DryRun, envVars) if skipCommand { @@ -76,20 +78,6 @@ func (s *Step) runShellStep(ctx context.Context, kubeconfigFile string, options return nil } -func (s *Step) addInputVars(inputs map[string]output) map[string]string { - envVars := make(map[string]string) - for _, i := range s.Inputs { - if v, found := inputs[i.Step]; found { - value, err := v.GetValue(i.Output) - if err != nil { - log.Fatal(err) - } - envVars[i.Name] = utils.AnyToString(value.Value) - } - } - return envVars -} - func (s *Step) mapStepVariables(vars config.Variables) (map[string]string, error) { envVars := make(map[string]string) for _, e := range s.Env { diff --git a/tooling/templatize/pkg/pipeline/shell_test.go b/tooling/templatize/pkg/pipeline/shell_test.go index 20645e9e1..242e9020e 100644 --- a/tooling/templatize/pkg/pipeline/shell_test.go +++ b/tooling/templatize/pkg/pipeline/shell_test.go @@ -201,26 +201,3 @@ func TestRunShellStep(t *testing.T) { }) } } - -func TestAddInputVars(t *testing.T) { - mapOutput := map[string]output{} - mapOutput["step1"] = armOutput{ - "output1": map[string]any{ - "type": "String", - "value": "value1", - }, - } - s := &Step{ - Name: "step2", - Inputs: []Input{ - { - Name: "input1", - Step: "step1", - Output: "output1", - }, - }, - } - - envVars := s.addInputVars(mapOutput) - assert.DeepEqual(t, envVars, map[string]string{"input1": "value1"}) -} From b0a8a894b18e5ae5f07c37a98a893b2e9d20549a Mon Sep 17 00:00:00 2001 From: Jan-Hendrik Boll Date: Tue, 3 Dec 2024 16:45:20 +0100 Subject: [PATCH 04/13] Lint fixes --- tooling/templatize/internal/end2end/e2e.go | 8 +++++--- tooling/templatize/internal/end2end/e2e_test.go | 16 ++++++++++++---- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/tooling/templatize/internal/end2end/e2e.go b/tooling/templatize/internal/end2end/e2e.go index 79f5792ca..7a39ccfed 100644 --- a/tooling/templatize/internal/end2end/e2e.go +++ b/tooling/templatize/internal/end2end/e2e.go @@ -3,15 +3,17 @@ package testutil import ( "context" "fmt" - "math/rand/v2" "os" + "math/rand/v2" + "gopkg.in/yaml.v2" - "github.com/Azure/ARO-HCP/tooling/templatize/pkg/config" - "github.com/Azure/ARO-HCP/tooling/templatize/pkg/pipeline" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources" + + "github.com/Azure/ARO-HCP/tooling/templatize/pkg/config" + "github.com/Azure/ARO-HCP/tooling/templatize/pkg/pipeline" ) var defaultRgName = "hcp-templatize" diff --git a/tooling/templatize/internal/end2end/e2e_test.go b/tooling/templatize/internal/end2end/e2e_test.go index ba1cbf574..e8fa29212 100644 --- a/tooling/templatize/internal/end2end/e2e_test.go +++ b/tooling/templatize/internal/end2end/e2e_test.go @@ -95,7 +95,10 @@ func TestE2EArmDeploy(t *testing.T) { }) cleanup := e2eImpl.UseRandomRG() - defer cleanup() + defer func() { + err := cleanup() + assert.NilError(t, err) + }() bicepFile := ` param zoneName string @@ -178,7 +181,10 @@ func TestE2EArmDeployWithOutput(t *testing.T) { }) cleanup := e2eImpl.UseRandomRG() - defer cleanup() + defer func() { + err := cleanup() + assert.NilError(t, err) + }() bicepFile := ` param zoneName string @@ -260,8 +266,10 @@ param parameterB = '{{ .parameterB }}' "testb.bicepparm") cleanup := e2eImpl.UseRandomRG() - defer cleanup() - + defer func() { + err := cleanup() + assert.NilError(t, err) + }() persistAndRun(t, &e2eImpl) io, err := os.ReadFile(tmpDir + "/env.txt") From 5cdc40c34abe9b3642f9820a685d8c6cf72d5be1 Mon Sep 17 00:00:00 2001 From: Jan-Hendrik Boll Date: Wed, 4 Dec 2024 11:08:52 +0100 Subject: [PATCH 05/13] Update tooling/templatize/pkg/pipeline/run.go Co-authored-by: Gerd Oberlechner --- tooling/templatize/pkg/pipeline/run.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tooling/templatize/pkg/pipeline/run.go b/tooling/templatize/pkg/pipeline/run.go index 4449234a8..a0ed8aed9 100644 --- a/tooling/templatize/pkg/pipeline/run.go +++ b/tooling/templatize/pkg/pipeline/run.go @@ -182,10 +182,7 @@ func (s *Step) run(ctx context.Context, kubeconfigFile string, executionTarget E if err != nil { return nil, fmt.Errorf("failed to run ARM step: %w", err) } - if output != nil { - return output, nil - } - return nil, nil + return output, nil default: return nil, fmt.Errorf("unsupported action type %q", s.Action) } From ecf421aae58bb0d8547b0ff87509b499c1de2c3e Mon Sep 17 00:00:00 2001 From: Jan-Hendrik Boll Date: Wed, 4 Dec 2024 13:23:25 +0100 Subject: [PATCH 06/13] Do not wait for deletion of test RGs --- tooling/templatize/internal/end2end/e2e.go | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/tooling/templatize/internal/end2end/e2e.go b/tooling/templatize/internal/end2end/e2e.go index 7a39ccfed..6edb6d387 100644 --- a/tooling/templatize/internal/end2end/e2e.go +++ b/tooling/templatize/internal/end2end/e2e.go @@ -114,15 +114,8 @@ func (e *e2eImpl) UseRandomRG() func() error { if err != nil { return err } - rgDelResponse, err := rgClient.BeginDelete(context.Background(), e.rgName, nil) - if err != nil { - return err - } - _, err = rgDelResponse.PollUntilDone(context.Background(), nil) - if err != nil { - return err - } - return nil + _, err = rgClient.BeginDelete(context.Background(), e.rgName, nil) + return err } } From 2bd64cfd02a7c3fd45e6ae8b6503f5f6e5483894 Mon Sep 17 00:00:00 2001 From: Jan-Hendrik Boll Date: Thu, 5 Dec 2024 09:21:55 +0100 Subject: [PATCH 07/13] Missing fix after rebase --- tooling/templatize/internal/end2end/e2e_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tooling/templatize/internal/end2end/e2e_test.go b/tooling/templatize/internal/end2end/e2e_test.go index e8fa29212..7ce0fc661 100644 --- a/tooling/templatize/internal/end2end/e2e_test.go +++ b/tooling/templatize/internal/end2end/e2e_test.go @@ -234,7 +234,7 @@ func TestE2EArmDeployWithOutputToArm(t *testing.T) { e2eImpl.AddStep(pipeline.Step{ Name: "readInput", Action: "Shell", - Command: []string{"/bin/sh", "-c", "echo ${end} > env.txt"}, + Command: "echo ${end} > env.txt", Inputs: []pipeline.Input{ { Name: "end", From d5b1d54f9f83819bf151e3f489b70f56838774d6 Mon Sep 17 00:00:00 2001 From: Jan-Hendrik Boll Date: Thu, 5 Dec 2024 09:36:23 +0100 Subject: [PATCH 08/13] Review remarks --- tooling/templatize/pkg/pipeline/arm.go | 6 +++++- tooling/templatize/pkg/pipeline/run.go | 13 +++++++------ tooling/templatize/pkg/pipeline/run_test.go | 10 +++++++++- tooling/templatize/pkg/pipeline/shell.go | 6 +++++- 4 files changed, 26 insertions(+), 9 deletions(-) diff --git a/tooling/templatize/pkg/pipeline/arm.go b/tooling/templatize/pkg/pipeline/arm.go index e6efb8c22..3bf221237 100644 --- a/tooling/templatize/pkg/pipeline/arm.go +++ b/tooling/templatize/pkg/pipeline/arm.go @@ -31,8 +31,12 @@ func newArmClient(subscriptionID, region string) *armClient { func (a *armClient) runArmStep(ctx context.Context, options *PipelineRunOptions, rgName string, step *Step, input map[string]output) (output, error) { logger := logr.FromContextOrDiscard(ctx) + inputValues, err := getInputValues(step.Inputs, input) + if err != nil { + return nil, fmt.Errorf("failed to get input values: %w", err) + } // Transform Bicep to ARM - deploymentProperties, err := transformBicepToARM(ctx, step.Parameters, options.Vars, addInputVars(step.Inputs, input)) + deploymentProperties, err := transformBicepToARM(ctx, step.Parameters, options.Vars, inputValues) if err != nil { return nil, fmt.Errorf("failed to transform Bicep to ARM: %w", err) } diff --git a/tooling/templatize/pkg/pipeline/run.go b/tooling/templatize/pkg/pipeline/run.go index a0ed8aed9..3b3d99a4f 100644 --- a/tooling/templatize/pkg/pipeline/run.go +++ b/tooling/templatize/pkg/pipeline/run.go @@ -3,7 +3,6 @@ package pipeline import ( "context" "fmt" - "log" "os" "path/filepath" "strings" @@ -243,16 +242,18 @@ func (rg *ResourceGroup) Validate() error { return nil } -func addInputVars(configuredInputs []Input, inputs map[string]output) map[string]any { - envVars := make(map[string]any) +func getInputValues(configuredInputs []Input, inputs map[string]output) (map[string]any, error) { + values := make(map[string]any) for _, i := range configuredInputs { if v, found := inputs[i.Step]; found { value, err := v.GetValue(i.Output) if err != nil { - log.Fatal(err) + return nil, fmt.Errorf("failed to get value for input %s.%s: %w", i.Step, i.Output, err) } - envVars[i.Name] = value.Value + values[i.Name] = value.Value + } else { + return nil, fmt.Errorf("step %s not found in provided outputs", i.Step) } } - return envVars + return values, nil } diff --git a/tooling/templatize/pkg/pipeline/run_test.go b/tooling/templatize/pkg/pipeline/run_test.go index 5b9b82147..92302f8c8 100644 --- a/tooling/templatize/pkg/pipeline/run_test.go +++ b/tooling/templatize/pkg/pipeline/run_test.go @@ -313,6 +313,14 @@ func TestAddInputVars(t *testing.T) { }, } - envVars := addInputVars(s.Inputs, mapOutput) + envVars, err := getInputValues(s.Inputs, mapOutput) + assert.NilError(t, err) assert.DeepEqual(t, envVars, map[string]any{"input1": "value1"}) + + _, err = getInputValues([]Input{ + { + Step: "foobar", + }, + }, mapOutput) + assert.Error(t, err, "step foobar not found in provided outputs") } diff --git a/tooling/templatize/pkg/pipeline/shell.go b/tooling/templatize/pkg/pipeline/shell.go index 3bf1a8716..c3943d170 100644 --- a/tooling/templatize/pkg/pipeline/shell.go +++ b/tooling/templatize/pkg/pipeline/shell.go @@ -53,7 +53,11 @@ func (s *Step) runShellStep(ctx context.Context, kubeconfigFile string, options maps.Copy(envVars, stepVars) - for k, v := range addInputVars(s.Inputs, inputs) { + inputValues, err := getInputValues(s.Inputs, inputs) + if err != nil { + return fmt.Errorf("failed to get input values: %w", err) + } + for k, v := range inputValues { envVars[k] = utils.AnyToString(v) } // execute the command From 00cb9ee95a9d3d92fab5928f70e5409f9d56c798 Mon Sep 17 00:00:00 2001 From: Jan-Hendrik Boll Date: Thu, 5 Dec 2024 10:29:14 +0100 Subject: [PATCH 09/13] Refactor Data structures to align to format designed together with MSFT --- .../templatize/internal/end2end/e2e_test.go | 35 ++++++++++--------- tooling/templatize/pkg/pipeline/arm.go | 2 +- .../templatize/pkg/pipeline/inspect_test.go | 4 +-- tooling/templatize/pkg/pipeline/run.go | 20 ++++++----- tooling/templatize/pkg/pipeline/run_test.go | 18 +++++----- tooling/templatize/pkg/pipeline/shell.go | 18 +++++----- tooling/templatize/pkg/pipeline/shell_test.go | 8 ++--- tooling/templatize/pkg/pipeline/types.go | 32 ++++++++--------- 8 files changed, 71 insertions(+), 66 deletions(-) diff --git a/tooling/templatize/internal/end2end/e2e_test.go b/tooling/templatize/internal/end2end/e2e_test.go index 7ce0fc661..f0ea26cd5 100644 --- a/tooling/templatize/internal/end2end/e2e_test.go +++ b/tooling/templatize/internal/end2end/e2e_test.go @@ -38,7 +38,7 @@ func TestE2EMake(t *testing.T) { Name: "test", Action: "Shell", Command: "make test", - Env: []pipeline.EnvVar{ + Variables: []pipeline.Variables{ { Name: "TEST_ENV", ConfigRef: "test_env", @@ -170,12 +170,13 @@ func TestE2EArmDeployWithOutput(t *testing.T) { Name: "readInput", Action: "Shell", Command: "echo ${zoneName} > env.txt", - Inputs: []pipeline.Input{ + Variables: []pipeline.Variables{ { - Name: "zoneName", - Step: "createZone", - Output: "zoneName", - Type: "string", + Name: "zoneName", + Input: &pipeline.Input{ + Name: "zoneName", + Step: "createZone", + }, }, }, }) @@ -221,12 +222,13 @@ func TestE2EArmDeployWithOutputToArm(t *testing.T) { Action: "ARM", Template: "testb.bicep", Parameters: "testb.bicepparm", - Inputs: []pipeline.Input{ + Variables: []pipeline.Variables{ { - Name: "parameterB", - Step: "parameterA", - Output: "parameterA", - Type: "string", + Name: "parameterB", + Input: &pipeline.Input{ + Name: "parameterA", + Step: "parameterA", + }, }, }, }) @@ -235,12 +237,13 @@ func TestE2EArmDeployWithOutputToArm(t *testing.T) { Name: "readInput", Action: "Shell", Command: "echo ${end} > env.txt", - Inputs: []pipeline.Input{ + Variables: []pipeline.Variables{ { - Name: "end", - Step: "parameterB", - Output: "parameterC", - Type: "string", + Name: "end", + Input: &pipeline.Input{ + Name: "parameterC", + Step: "parameterB", + }, }, }, }) diff --git a/tooling/templatize/pkg/pipeline/arm.go b/tooling/templatize/pkg/pipeline/arm.go index 3bf221237..5e72e312a 100644 --- a/tooling/templatize/pkg/pipeline/arm.go +++ b/tooling/templatize/pkg/pipeline/arm.go @@ -31,7 +31,7 @@ func newArmClient(subscriptionID, region string) *armClient { func (a *armClient) runArmStep(ctx context.Context, options *PipelineRunOptions, rgName string, step *Step, input map[string]output) (output, error) { logger := logr.FromContextOrDiscard(ctx) - inputValues, err := getInputValues(step.Inputs, input) + inputValues, err := getInputValues(step.Variables, input) if err != nil { return nil, fmt.Errorf("failed to get input values: %w", err) } diff --git a/tooling/templatize/pkg/pipeline/inspect_test.go b/tooling/templatize/pkg/pipeline/inspect_test.go index dc308715e..049c2a79d 100644 --- a/tooling/templatize/pkg/pipeline/inspect_test.go +++ b/tooling/templatize/pkg/pipeline/inspect_test.go @@ -23,7 +23,7 @@ func TestInspectVars(t *testing.T) { name: "basic", caseStep: &Step{ Action: "Shell", - Env: []EnvVar{ + Variables: []Variables{ { Name: "FOO", ConfigRef: "foo", @@ -42,7 +42,7 @@ func TestInspectVars(t *testing.T) { name: "makefile", caseStep: &Step{ Action: "Shell", - Env: []EnvVar{ + Variables: []Variables{ { Name: "FOO", ConfigRef: "foo", diff --git a/tooling/templatize/pkg/pipeline/run.go b/tooling/templatize/pkg/pipeline/run.go index 3b3d99a4f..cdbed0fa6 100644 --- a/tooling/templatize/pkg/pipeline/run.go +++ b/tooling/templatize/pkg/pipeline/run.go @@ -242,17 +242,19 @@ func (rg *ResourceGroup) Validate() error { return nil } -func getInputValues(configuredInputs []Input, inputs map[string]output) (map[string]any, error) { +func getInputValues(configuredVariables []Variables, inputs map[string]output) (map[string]any, error) { values := make(map[string]any) - for _, i := range configuredInputs { - if v, found := inputs[i.Step]; found { - value, err := v.GetValue(i.Output) - if err != nil { - return nil, fmt.Errorf("failed to get value for input %s.%s: %w", i.Step, i.Output, err) + for _, i := range configuredVariables { + if i.Input != nil { + if v, found := inputs[i.Input.Step]; found { + value, err := v.GetValue(i.Input.Name) + if err != nil { + return nil, fmt.Errorf("failed to get value for input %s.%s: %w", i.Input.Step, i.Input.Name, err) + } + values[i.Name] = value.Value + } else { + return nil, fmt.Errorf("step %s not found in provided outputs", i.Input.Step) } - values[i.Name] = value.Value - } else { - return nil, fmt.Errorf("step %s not found in provided outputs", i.Step) } } return values, nil diff --git a/tooling/templatize/pkg/pipeline/run_test.go b/tooling/templatize/pkg/pipeline/run_test.go index 92302f8c8..b5f9e18b6 100644 --- a/tooling/templatize/pkg/pipeline/run_test.go +++ b/tooling/templatize/pkg/pipeline/run_test.go @@ -304,22 +304,22 @@ func TestAddInputVars(t *testing.T) { }, } s := &Step{ - Inputs: []Input{ - { - Name: "input1", - Step: "step1", - Output: "output1", + Variables: []Variables{{ + Name: "input1", + Input: &Input{ + Name: "output1", + Step: "step1", }, }, - } + }} - envVars, err := getInputValues(s.Inputs, mapOutput) + envVars, err := getInputValues(s.Variables, mapOutput) assert.NilError(t, err) assert.DeepEqual(t, envVars, map[string]any{"input1": "value1"}) - _, err = getInputValues([]Input{ + _, err = getInputValues([]Variables{ { - Step: "foobar", + Input: &Input{Step: "foobar"}, }, }, mapOutput) assert.Error(t, err, "step foobar not found in provided outputs") diff --git a/tooling/templatize/pkg/pipeline/shell.go b/tooling/templatize/pkg/pipeline/shell.go index c3943d170..0427c8dc0 100644 --- a/tooling/templatize/pkg/pipeline/shell.go +++ b/tooling/templatize/pkg/pipeline/shell.go @@ -15,13 +15,13 @@ import ( func (s *Step) createCommand(ctx context.Context, dryRun bool, envVars map[string]string) (*exec.Cmd, bool) { var scriptCommand string = s.Command if dryRun { - if s.DryRun.Command == "" && s.DryRun.EnvVars == nil { + if s.DryRun.Command == "" && s.DryRun.Variables == nil { return nil, true } if s.DryRun.Command != "" { scriptCommand = s.DryRun.Command } - for _, e := range s.DryRun.EnvVars { + for _, e := range s.DryRun.Variables { envVars[e.Name] = e.Value } } @@ -53,7 +53,7 @@ func (s *Step) runShellStep(ctx context.Context, kubeconfigFile string, options maps.Copy(envVars, stepVars) - inputValues, err := getInputValues(s.Inputs, inputs) + inputValues, err := getInputValues(s.Variables, inputs) if err != nil { return fmt.Errorf("failed to get input values: %w", err) } @@ -84,12 +84,14 @@ func (s *Step) runShellStep(ctx context.Context, kubeconfigFile string, options func (s *Step) mapStepVariables(vars config.Variables) (map[string]string, error) { envVars := make(map[string]string) - for _, e := range s.Env { - value, found := vars.GetByPath(e.ConfigRef) - if !found { - return nil, fmt.Errorf("failed to lookup config reference %s for %s", e.ConfigRef, e.Name) + for _, e := range s.Variables { + if e.ConfigRef != "" { // not all Variables are Environment variables + value, found := vars.GetByPath(e.ConfigRef) + if !found { + return nil, fmt.Errorf("failed to lookup config reference %s for %s", e.ConfigRef, e.Name) + } + envVars[e.Name] = utils.AnyToString(value) } - envVars[e.Name] = utils.AnyToString(value) } return envVars, nil } diff --git a/tooling/templatize/pkg/pipeline/shell_test.go b/tooling/templatize/pkg/pipeline/shell_test.go index 242e9020e..fd46f7823 100644 --- a/tooling/templatize/pkg/pipeline/shell_test.go +++ b/tooling/templatize/pkg/pipeline/shell_test.go @@ -45,7 +45,7 @@ func TestCreateCommand(t *testing.T) { step: &Step{ Command: "/usr/bin/echo", DryRun: DryRun{ - EnvVars: []EnvVar{ + Variables: []Variables{ { Name: "DRY_RUN", Value: "true", @@ -96,7 +96,7 @@ func TestMapStepVariables(t *testing.T) { "FOO": "bar", }, step: Step{ - Env: []EnvVar{ + Variables: []Variables{ { Name: "BAZ", ConfigRef: "FOO", @@ -111,7 +111,7 @@ func TestMapStepVariables(t *testing.T) { name: "missing", vars: config.Variables{}, step: Step{ - Env: []EnvVar{ + Variables: []Variables{ { ConfigRef: "FOO", }, @@ -125,7 +125,7 @@ func TestMapStepVariables(t *testing.T) { "FOO": 42, }, step: Step{ - Env: []EnvVar{ + Variables: []Variables{ { Name: "BAZ", ConfigRef: "FOO", diff --git a/tooling/templatize/pkg/pipeline/types.go b/tooling/templatize/pkg/pipeline/types.go index ddd8392f2..25a25df68 100644 --- a/tooling/templatize/pkg/pipeline/types.go +++ b/tooling/templatize/pkg/pipeline/types.go @@ -23,33 +23,31 @@ type ResourceGroup struct { type outPutHandler func(string) type Step struct { - Name string `yaml:"name"` - Action string `yaml:"action"` - Command string `yaml:"command,omitempty"` - Env []EnvVar `yaml:"env,omitempty"` - Template string `yaml:"template,omitempty"` - Parameters string `yaml:"parameters,omitempty"` - DependsOn []string `yaml:"dependsOn,omitempty"` - DryRun DryRun `yaml:"dryRun,omitempty"` - Inputs []Input `yaml:"inputs,omitempty"` - DeploymentLevel string `yaml:"deploymentLevel,omitempty"` + Name string `yaml:"name"` + Action string `yaml:"action"` + Command string `yaml:"command,omitempty"` + Variables []Variables `yaml:"env,omitempty"` + Template string `yaml:"template,omitempty"` + Parameters string `yaml:"parameters,omitempty"` + DependsOn []string `yaml:"dependsOn,omitempty"` + DryRun DryRun `yaml:"dryRun,omitempty"` + DeploymentLevel string `yaml:"deploymentLevel,omitempty"` outputFunc outPutHandler } type DryRun struct { - EnvVars []EnvVar `yaml:"envVars,omitempty"` - Command string `yaml:"command,omitempty"` + Variables []Variables `yaml:"envVars,omitempty"` + Command string `yaml:"command,omitempty"` } -type EnvVar struct { +type Variables struct { Name string `yaml:"name"` ConfigRef string `yaml:"configRef,omitempty"` Value string `yaml:"value,omitempty"` + Input *Input `yaml:"inputs,omitempty"` } type Input struct { - Name string `yaml:"name"` - Step string `yaml:"step"` - Output string `yaml:"output"` - Type string `yaml:"type,omitempty"` + Name string `yaml:"name"` + Step string `yaml:"step"` } From 4bfcbfde62e0900b19069c9252f75177fd4c9f61 Mon Sep 17 00:00:00 2001 From: Jan-Hendrik Boll Date: Thu, 5 Dec 2024 10:31:57 +0100 Subject: [PATCH 10/13] Singular for Variable type --- .../templatize/internal/end2end/e2e_test.go | 8 +++---- .../templatize/pkg/pipeline/inspect_test.go | 4 ++-- tooling/templatize/pkg/pipeline/run.go | 2 +- tooling/templatize/pkg/pipeline/run_test.go | 4 ++-- tooling/templatize/pkg/pipeline/shell_test.go | 8 +++---- tooling/templatize/pkg/pipeline/types.go | 24 +++++++++---------- 6 files changed, 25 insertions(+), 25 deletions(-) diff --git a/tooling/templatize/internal/end2end/e2e_test.go b/tooling/templatize/internal/end2end/e2e_test.go index f0ea26cd5..d74625069 100644 --- a/tooling/templatize/internal/end2end/e2e_test.go +++ b/tooling/templatize/internal/end2end/e2e_test.go @@ -38,7 +38,7 @@ func TestE2EMake(t *testing.T) { Name: "test", Action: "Shell", Command: "make test", - Variables: []pipeline.Variables{ + Variables: []pipeline.Variable{ { Name: "TEST_ENV", ConfigRef: "test_env", @@ -170,7 +170,7 @@ func TestE2EArmDeployWithOutput(t *testing.T) { Name: "readInput", Action: "Shell", Command: "echo ${zoneName} > env.txt", - Variables: []pipeline.Variables{ + Variables: []pipeline.Variable{ { Name: "zoneName", Input: &pipeline.Input{ @@ -222,7 +222,7 @@ func TestE2EArmDeployWithOutputToArm(t *testing.T) { Action: "ARM", Template: "testb.bicep", Parameters: "testb.bicepparm", - Variables: []pipeline.Variables{ + Variables: []pipeline.Variable{ { Name: "parameterB", Input: &pipeline.Input{ @@ -237,7 +237,7 @@ func TestE2EArmDeployWithOutputToArm(t *testing.T) { Name: "readInput", Action: "Shell", Command: "echo ${end} > env.txt", - Variables: []pipeline.Variables{ + Variables: []pipeline.Variable{ { Name: "end", Input: &pipeline.Input{ diff --git a/tooling/templatize/pkg/pipeline/inspect_test.go b/tooling/templatize/pkg/pipeline/inspect_test.go index 049c2a79d..744ec4707 100644 --- a/tooling/templatize/pkg/pipeline/inspect_test.go +++ b/tooling/templatize/pkg/pipeline/inspect_test.go @@ -23,7 +23,7 @@ func TestInspectVars(t *testing.T) { name: "basic", caseStep: &Step{ Action: "Shell", - Variables: []Variables{ + Variables: []Variable{ { Name: "FOO", ConfigRef: "foo", @@ -42,7 +42,7 @@ func TestInspectVars(t *testing.T) { name: "makefile", caseStep: &Step{ Action: "Shell", - Variables: []Variables{ + Variables: []Variable{ { Name: "FOO", ConfigRef: "foo", diff --git a/tooling/templatize/pkg/pipeline/run.go b/tooling/templatize/pkg/pipeline/run.go index cdbed0fa6..c376427d4 100644 --- a/tooling/templatize/pkg/pipeline/run.go +++ b/tooling/templatize/pkg/pipeline/run.go @@ -242,7 +242,7 @@ func (rg *ResourceGroup) Validate() error { return nil } -func getInputValues(configuredVariables []Variables, inputs map[string]output) (map[string]any, error) { +func getInputValues(configuredVariables []Variable, inputs map[string]output) (map[string]any, error) { values := make(map[string]any) for _, i := range configuredVariables { if i.Input != nil { diff --git a/tooling/templatize/pkg/pipeline/run_test.go b/tooling/templatize/pkg/pipeline/run_test.go index b5f9e18b6..650cd402f 100644 --- a/tooling/templatize/pkg/pipeline/run_test.go +++ b/tooling/templatize/pkg/pipeline/run_test.go @@ -304,7 +304,7 @@ func TestAddInputVars(t *testing.T) { }, } s := &Step{ - Variables: []Variables{{ + Variables: []Variable{{ Name: "input1", Input: &Input{ Name: "output1", @@ -317,7 +317,7 @@ func TestAddInputVars(t *testing.T) { assert.NilError(t, err) assert.DeepEqual(t, envVars, map[string]any{"input1": "value1"}) - _, err = getInputValues([]Variables{ + _, err = getInputValues([]Variable{ { Input: &Input{Step: "foobar"}, }, diff --git a/tooling/templatize/pkg/pipeline/shell_test.go b/tooling/templatize/pkg/pipeline/shell_test.go index fd46f7823..a85e6a757 100644 --- a/tooling/templatize/pkg/pipeline/shell_test.go +++ b/tooling/templatize/pkg/pipeline/shell_test.go @@ -45,7 +45,7 @@ func TestCreateCommand(t *testing.T) { step: &Step{ Command: "/usr/bin/echo", DryRun: DryRun{ - Variables: []Variables{ + Variables: []Variable{ { Name: "DRY_RUN", Value: "true", @@ -96,7 +96,7 @@ func TestMapStepVariables(t *testing.T) { "FOO": "bar", }, step: Step{ - Variables: []Variables{ + Variables: []Variable{ { Name: "BAZ", ConfigRef: "FOO", @@ -111,7 +111,7 @@ func TestMapStepVariables(t *testing.T) { name: "missing", vars: config.Variables{}, step: Step{ - Variables: []Variables{ + Variables: []Variable{ { ConfigRef: "FOO", }, @@ -125,7 +125,7 @@ func TestMapStepVariables(t *testing.T) { "FOO": 42, }, step: Step{ - Variables: []Variables{ + Variables: []Variable{ { Name: "BAZ", ConfigRef: "FOO", diff --git a/tooling/templatize/pkg/pipeline/types.go b/tooling/templatize/pkg/pipeline/types.go index 25a25df68..3ae773328 100644 --- a/tooling/templatize/pkg/pipeline/types.go +++ b/tooling/templatize/pkg/pipeline/types.go @@ -23,24 +23,24 @@ type ResourceGroup struct { type outPutHandler func(string) type Step struct { - Name string `yaml:"name"` - Action string `yaml:"action"` - Command string `yaml:"command,omitempty"` - Variables []Variables `yaml:"env,omitempty"` - Template string `yaml:"template,omitempty"` - Parameters string `yaml:"parameters,omitempty"` - DependsOn []string `yaml:"dependsOn,omitempty"` - DryRun DryRun `yaml:"dryRun,omitempty"` - DeploymentLevel string `yaml:"deploymentLevel,omitempty"` + Name string `yaml:"name"` + Action string `yaml:"action"` + Command string `yaml:"command,omitempty"` + Variables []Variable `yaml:"env,omitempty"` + Template string `yaml:"template,omitempty"` + Parameters string `yaml:"parameters,omitempty"` + DependsOn []string `yaml:"dependsOn,omitempty"` + DryRun DryRun `yaml:"dryRun,omitempty"` + DeploymentLevel string `yaml:"deploymentLevel,omitempty"` outputFunc outPutHandler } type DryRun struct { - Variables []Variables `yaml:"envVars,omitempty"` - Command string `yaml:"command,omitempty"` + Variables []Variable `yaml:"envVars,omitempty"` + Command string `yaml:"command,omitempty"` } -type Variables struct { +type Variable struct { Name string `yaml:"name"` ConfigRef string `yaml:"configRef,omitempty"` Value string `yaml:"value,omitempty"` From cb5dea64b5998de424f1f6d01c12e21cb110b89b Mon Sep 17 00:00:00 2001 From: Jan-Hendrik Boll Date: Thu, 5 Dec 2024 12:58:02 +0100 Subject: [PATCH 11/13] Fix yaml references --- tooling/templatize/pkg/pipeline/types.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tooling/templatize/pkg/pipeline/types.go b/tooling/templatize/pkg/pipeline/types.go index 3ae773328..a24dcfae4 100644 --- a/tooling/templatize/pkg/pipeline/types.go +++ b/tooling/templatize/pkg/pipeline/types.go @@ -26,7 +26,7 @@ type Step struct { Name string `yaml:"name"` Action string `yaml:"action"` Command string `yaml:"command,omitempty"` - Variables []Variable `yaml:"env,omitempty"` + Variables []Variable `yaml:"variables,omitempty"` Template string `yaml:"template,omitempty"` Parameters string `yaml:"parameters,omitempty"` DependsOn []string `yaml:"dependsOn,omitempty"` @@ -36,7 +36,7 @@ type Step struct { } type DryRun struct { - Variables []Variable `yaml:"envVars,omitempty"` + Variables []Variable `yaml:"variables,omitempty"` Command string `yaml:"command,omitempty"` } @@ -44,7 +44,7 @@ type Variable struct { Name string `yaml:"name"` ConfigRef string `yaml:"configRef,omitempty"` Value string `yaml:"value,omitempty"` - Input *Input `yaml:"inputs,omitempty"` + Input *Input `yaml:"input,omitempty"` } type Input struct { From 49f37caa2debbb66888dbb0abe5510a8b903bb0e Mon Sep 17 00:00:00 2001 From: Jan-Hendrik Boll Date: Thu, 5 Dec 2024 13:47:14 +0100 Subject: [PATCH 12/13] Update testdata --- tooling/templatize/testdata/pipeline.yaml | 4 ++-- .../zz_fixture_TestProcessPipelineForEV2pipeline.yaml | 4 ++-- tooling/templatize/testdata/zz_fixture_TestRawOptions.yaml | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tooling/templatize/testdata/pipeline.yaml b/tooling/templatize/testdata/pipeline.yaml index ddcbef932..f87e53052 100644 --- a/tooling/templatize/testdata/pipeline.yaml +++ b/tooling/templatize/testdata/pipeline.yaml @@ -8,14 +8,14 @@ resourceGroups: - name: deploy action: Shell command: make deploy - env: + variables: - name: MAESTRO_IMAGE configRef: maestro_image - name: dry-run action: Shell command: make deploy dryRun: - envVars: + variables: - name: DRY_RUN value: "A very dry one" - name: svc diff --git a/tooling/templatize/testdata/zz_fixture_TestProcessPipelineForEV2pipeline.yaml b/tooling/templatize/testdata/zz_fixture_TestProcessPipelineForEV2pipeline.yaml index 177cbc678..7448f9363 100644 --- a/tooling/templatize/testdata/zz_fixture_TestProcessPipelineForEV2pipeline.yaml +++ b/tooling/templatize/testdata/zz_fixture_TestProcessPipelineForEV2pipeline.yaml @@ -8,14 +8,14 @@ resourceGroups: - name: deploy action: Shell command: make deploy - env: + variables: - name: MAESTRO_IMAGE configRef: maestro_image - name: dry-run action: Shell command: make deploy dryRun: - envVars: + variables: - name: DRY_RUN value: A very dry one - name: svc diff --git a/tooling/templatize/testdata/zz_fixture_TestRawOptions.yaml b/tooling/templatize/testdata/zz_fixture_TestRawOptions.yaml index 721438d52..48bd192ec 100644 --- a/tooling/templatize/testdata/zz_fixture_TestRawOptions.yaml +++ b/tooling/templatize/testdata/zz_fixture_TestRawOptions.yaml @@ -8,14 +8,14 @@ resourceGroups: - name: deploy action: Shell command: make deploy - env: + variables: - name: MAESTRO_IMAGE configRef: maestro_image - name: dry-run action: Shell command: make deploy dryRun: - envVars: + variables: - name: DRY_RUN value: "A very dry one" - name: svc From 56250251182ed92e4b8182961ba599cc0342ad95 Mon Sep 17 00:00:00 2001 From: Jan-Hendrik Boll Date: Thu, 5 Dec 2024 14:04:34 +0100 Subject: [PATCH 13/13] Fix pipeline files --- backend/pipeline.yaml | 2 +- frontend/pipeline.yaml | 4 ++-- maestro/server/pipeline.yaml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/backend/pipeline.yaml b/backend/pipeline.yaml index 33f357912..2fb5a91d2 100644 --- a/backend/pipeline.yaml +++ b/backend/pipeline.yaml @@ -8,7 +8,7 @@ resourceGroups: - name: deploy action: Shell command: make deploy - env: + variables: - name: ARO_HCP_IMAGE_ACR configRef: svcAcrName - name: LOCATION diff --git a/frontend/pipeline.yaml b/frontend/pipeline.yaml index 88794bcf5..f342f5302 100644 --- a/frontend/pipeline.yaml +++ b/frontend/pipeline.yaml @@ -9,10 +9,10 @@ resourceGroups: action: Shell command: make deploy dryRun: - envVars: + variables: - name: HELM_DRY_RUN value: "--dry-run=server --debug" - env: + variables: - name: ARO_HCP_IMAGE_ACR configRef: svcAcrName - name: LOCATION diff --git a/maestro/server/pipeline.yaml b/maestro/server/pipeline.yaml index 394a818ce..982799129 100644 --- a/maestro/server/pipeline.yaml +++ b/maestro/server/pipeline.yaml @@ -8,7 +8,7 @@ resourceGroups: - name: deploy action: Shell command: make deploy - env: + variables: - name: EVENTGRID_NAME configRef: maestro.eventGrid.name - name: REGION_RG