Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/resources/mta.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ EOT
- `mtar_url` (String) The remote URL where the MTA archive is present
- `namespace` (String) The namespace of the MTA. Should be of valid host format
- `source_code_hash` (String) SHA256 hash of the file specified. Terraform relies on this to detect the file changes.
- `version_rule` (String) The rule to apply to determine how the application version number is used to trigger an application-update deployment operation.

### Read-Only

Expand Down
4 changes: 4 additions & 0 deletions internal/provider/datasource_mtas_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ type MtaResourceModelPtr struct {
Id *string
SourceCodeHash *string
DeployStrategy *string
VersionRule *string
}

func hclDataSourceMtas(mdsmp *MtasDataSourceModelPtr) string {
Expand Down Expand Up @@ -103,6 +104,9 @@ func hclResourceMta(mrmp *MtaResourceModelPtr) string {
{{if .DeployStrategy}}
deploy_strategy = "{{.DeployStrategy}}"
{{- end -}}
{{if .VersionRule}}
version_rule = "{{.VersionRule}}"
{{- end -}}
{{if .DeployUrl}}
deploy_url = "{{.DeployUrl}}"
{{- end }}
Expand Down
11 changes: 11 additions & 0 deletions internal/provider/resource_mta.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,13 @@ __Note:__
stringvalidator.OneOf("deploy", "blue-green-deploy"),
},
},
"version_rule": schema.StringAttribute{
MarkdownDescription: "The rule to apply to determine how the application version number is used to trigger an application-update deployment operation.",
Optional: true,
Validators: []validator.String{
stringvalidator.OneOf("HIGHER", "SAME_HIGHER", "ALL"),
},
},
"mta": schema.SingleNestedAttribute{
MarkdownDescription: "contains the details of the MTA object",
Computed: true,
Expand Down Expand Up @@ -380,6 +387,10 @@ func (r *mtaResource) upsert(ctx context.Context, reqPlan *tfsdk.Plan, reqState
operationParams.ProcessType = "DEPLOY"
}

if !mtarType.VersionRule.IsNull() {
operationParams.Parameters["versionRule"] = mtarType.VersionRule.ValueString()
}

if extensionDescriptors != "" {
operationParams.Parameters["mtaExtDescriptorId"] = extensionDescriptors
}
Expand Down
5 changes: 5 additions & 0 deletions internal/provider/resource_mta_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ func TestMtaResource_Configure(t *testing.T) {
sourceCodeHash = "fca8f8d1c499a1d0561c274ab974faf09355d513bb36475fe67577d850562801"
normalDeploy = "deploy"
bgDeploy = "blue-green-deploy"
versionRuleAll = "ALL"
extensionDescriptorsString = `[
<<EOT
_schema-version: 3.3.0
Expand Down Expand Up @@ -69,6 +70,7 @@ EOT
Space: strtostrptr(spaceGuid),
Namespace: strtostrptr(namespace),
DeployStrategy: strtostrptr(normalDeploy),
VersionRule: strtostrptr(versionRuleAll),
}),
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttr(resourceName, "mtar_path", mtarPath),
Expand Down Expand Up @@ -126,6 +128,7 @@ EOT
Namespace: strtostrptr(namespace),
ExtensionDescriptors: strtostrptr(extensionDescriptors),
DeployStrategy: strtostrptr(normalDeploy),
VersionRule: strtostrptr(versionRuleAll),
}),
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttr(resourceName, "mtar_path", mtarPath2),
Expand All @@ -143,6 +146,7 @@ EOT
ExtensionDescriptors: strtostrptr(extensionDescriptors),
SourceCodeHash: strtostrptr(sourceCodeHash),
DeployStrategy: strtostrptr(bgDeploy),
VersionRule: strtostrptr(versionRuleAll),
}),
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttr(resourceName, "mtar_path", mtarPath2),
Expand All @@ -161,6 +165,7 @@ EOT
ExtensionDescriptorsString: strtostrptr(extensionDescriptorsString),
SourceCodeHash: strtostrptr(sourceCodeHash),
DeployStrategy: strtostrptr(bgDeploy),
VersionRule: strtostrptr(versionRuleAll),
}),
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttr(resourceName, "mtar_path", mtarPath2),
Expand Down
1 change: 1 addition & 0 deletions internal/provider/types_mta.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ type MtarType struct {
Id types.String `tfsdk:"id"`
SourceCodeHash types.String `tfsdk:"source_code_hash"`
DeployStrategy types.String `tfsdk:"deploy_strategy"`
VersionRule types.String `tfsdk:"version_rule"`
}

type MtasDataSourceType struct {
Expand Down
Loading