Skip to content

Commit

Permalink
deploymentLevel mandatory in pipeline files
Browse files Browse the repository at this point in the history
adapt the schema to demand a `deploymentLevel` for ARM steps.
followup for #1035
  • Loading branch information
geoberle committed Jan 7, 2025
1 parent 3c8c9e4 commit 077b49f
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 14 deletions.
12 changes: 6 additions & 6 deletions tooling/templatize/internal/end2end/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func TestE2EArmDeploy(t *testing.T) {
tmpDir := t.TempDir()

e2eImpl := newE2E(tmpDir)
e2eImpl.AddStep(pipeline.NewARMStep("test", "test.bicep", "test.bicepparm"), 0)
e2eImpl.AddStep(pipeline.NewARMStep("test", "test.bicep", "test.bicepparm", "ResourceGroup"), 0)
cleanup := e2eImpl.UseRandomRG()
defer func() {
err := cleanup()
Expand Down Expand Up @@ -149,7 +149,7 @@ func TestE2EArmDeployWithOutput(t *testing.T) {

e2eImpl := newE2E(tmpDir)

e2eImpl.AddStep(pipeline.NewARMStep("createZone", "test.bicep", "test.bicepparm"), 0)
e2eImpl.AddStep(pipeline.NewARMStep("createZone", "test.bicep", "test.bicepparm", "ResourceGroup"), 0)

e2eImpl.AddStep(pipeline.NewShellStep(
"readInput", "echo ${zoneName} > env.txt",
Expand Down Expand Up @@ -192,8 +192,8 @@ func TestE2EArmDeployWithOutputToArm(t *testing.T) {
tmpDir := t.TempDir()

e2eImpl := newE2E(tmpDir)
e2eImpl.AddStep(pipeline.NewARMStep("parameterA", "testa.bicep", "testa.bicepparm"), 0)
e2eImpl.AddStep(pipeline.NewARMStep("parameterB", "testb.bicep", "testb.bicepparm").WithVariables(pipeline.Variable{
e2eImpl.AddStep(pipeline.NewARMStep("parameterA", "testa.bicep", "testa.bicepparm", "ResourceGroup"), 0)
e2eImpl.AddStep(pipeline.NewARMStep("parameterB", "testb.bicep", "testb.bicepparm", "ResourceGroup").WithVariables(pipeline.Variable{
Name: "parameterB",
Input: &pipeline.Input{
Name: "parameterA",
Expand Down Expand Up @@ -253,7 +253,7 @@ func TestE2EArmDeployWithOutputRGOverlap(t *testing.T) {
tmpDir := t.TempDir()

e2eImpl := newE2E(tmpDir)
e2eImpl.AddStep(pipeline.NewARMStep("parameterA", "testa.bicep", "testa.bicepparm"), 0)
e2eImpl.AddStep(pipeline.NewARMStep("parameterA", "testa.bicep", "testa.bicepparm", "ResourceGroup"), 0)

e2eImpl.AddResourceGroup()

Expand Down Expand Up @@ -296,7 +296,7 @@ func TestE2EArmDeploySubscriptionScope(t *testing.T) {
tmpDir := t.TempDir()

e2eImpl := newE2E(tmpDir)
e2eImpl.AddStep(pipeline.NewARMStep("parameterA", "testa.bicep", "testa.bicepparm").WithDeploymentLevel("Subscription"), 0)
e2eImpl.AddStep(pipeline.NewARMStep("parameterA", "testa.bicep", "testa.bicepparm", "Subscription"), 0)
rgName := GenerateRandomRGName()
e2eImpl.AddBicepTemplate(fmt.Sprintf(`
targetScope='subscription'
Expand Down
2 changes: 1 addition & 1 deletion tooling/templatize/pkg/pipeline/inspect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func TestInspectVars(t *testing.T) {
},
{
name: "failed action",
caseStep: NewARMStep("step", "test.bicep", "test.bicepparam"),
caseStep: NewARMStep("step", "test.bicep", "test.bicepparam", "ResourceGroup"),
err: "inspecting step variables not implemented for action type ARM",
},
{
Expand Down
3 changes: 2 additions & 1 deletion tooling/templatize/pkg/pipeline/pipeline.schema.v1.json
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,8 @@
},
"required": [
"template",
"parameters"
"parameters",
"deploymentLevel"
]
},
{
Expand Down
8 changes: 2 additions & 6 deletions tooling/templatize/pkg/pipeline/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,14 +163,15 @@ func (s *ShellStep) WithOutputFunc(outputFunc outPutHandler) *ShellStep {
return s
}

func NewARMStep(name string, template string, parameters string) *ARMStep {
func NewARMStep(name string, template string, parameters string, deploymentLevel string) *ARMStep {
return &ARMStep{
StepMeta: StepMeta{
Name: name,
Action: "ARM",
},
Template: template,
Parameters: parameters,
DeploymentLevel: deploymentLevel,
}
}

Expand All @@ -184,11 +185,6 @@ func (s *ARMStep) WithVariables(variables ...Variable) *ARMStep {
return s
}

func (s *ARMStep) WithDeploymentLevel(deploymentLevel string) *ARMStep {
s.DeploymentLevel = deploymentLevel
return s
}

type ARMStep struct {
StepMeta `yaml:",inline"`
Command string `yaml:"command,omitempty"`
Expand Down
1 change: 1 addition & 0 deletions tooling/templatize/testdata/pipeline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ resourceGroups:
action: ARM
template: templates/svc-cluster.bicep
parameters: test.bicepparam
deploymentLevel: ResourceGroup
- name: DelegateChildZoneBase
action: DelegateChildZoneExtension
parentZoneName:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ resourceGroups:
action: ARM
template: templates/svc-cluster.bicep
parameters: ev2-precompiled-test.bicepparam
deploymentLevel: ResourceGroup
- name: DelegateChildZoneBase
action: DelegateChildZoneExtension
dependsOn:
Expand Down
1 change: 1 addition & 0 deletions tooling/templatize/testdata/zz_fixture_TestRawOptions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ resourceGroups:
action: ARM
template: templates/svc-cluster.bicep
parameters: test.bicepparam
deploymentLevel: ResourceGroup
- name: DelegateChildZoneBase
action: DelegateChildZoneExtension
parentZoneName:
Expand Down

0 comments on commit 077b49f

Please sign in to comment.