Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypedSDK - add filtering tag for removed schema items #23415

Merged
merged 6 commits into from
Oct 9, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
6 changes: 5 additions & 1 deletion internal/sdk/resource_encode.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ package sdk
import (
"fmt"
"reflect"
"strings"

"github.com/hashicorp/terraform-provider-azurerm/internal/features"
)

// Encode will encode the specified object into the Terraform State
Expand Down Expand Up @@ -51,7 +54,8 @@ func recurse(objType reflect.Type, objVal reflect.Value, fieldName string, debug
for i := 0; i < objType.NumField(); i++ {
field := objType.Field(i)
fieldVal := objVal.Field(i)
if tfschemaTag, exists := field.Tag.Lookup("tfschema"); exists {
if tfschemaTag, exists := field.Tag.Lookup("tfschema"); exists && !(strings.HasSuffix(tfschemaTag, ",majorVersionRemoved") && features.FourPointOh()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be a contains - and/or we should probably split the tags on ,?

tfschemaTag = strings.TrimSuffix(tfschemaTag, ",majorVersionRemoved")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps removedInNextMajorVersion would be clearer?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually could we also document this in the README too?

switch field.Type.Kind() {
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
iv := fieldVal.Int()
Expand Down
10 changes: 5 additions & 5 deletions internal/services/appservice/helpers/app_stack.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ const (

type ApplicationStackWindows struct {
CurrentStack string `tfschema:"current_stack"`
DockerContainerName string `tfschema:"docker_container_name"`
DockerContainerRegistry string `tfschema:"docker_container_registry"`
DockerContainerTag string `tfschema:"docker_container_tag"`
DockerContainerName string `tfschema:"docker_container_name,majorVersionRemoved"`
DockerContainerRegistry string `tfschema:"docker_container_registry,majorVersionRemoved"`
DockerContainerTag string `tfschema:"docker_container_tag,majorVersionRemoved"`
JavaContainer string `tfschema:"java_container"`
JavaContainerVersion string `tfschema:"java_container_version"`
JavaEmbeddedServer bool `tfschema:"java_embedded_server_enabled"`
Expand Down Expand Up @@ -418,8 +418,8 @@ type ApplicationStackLinux struct {
JavaVersion string `tfschema:"java_version"`
JavaServer string `tfschema:"java_server"`
JavaServerVersion string `tfschema:"java_server_version"`
DockerImageTag string `tfschema:"docker_image_tag"`
DockerImage string `tfschema:"docker_image"`
DockerImageTag string `tfschema:"docker_image_tag,majorVersionRemoved"`
DockerImage string `tfschema:"docker_image,majorVersionRemoved"`
RubyVersion string `tfschema:"ruby_version"`

DockerRegistryUrl string `tfschema:"docker_registry_url"`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ type Linux struct {
ExcludedPackages []string `tfschema:"excluded_packages"`
IncludedPackages []string `tfschema:"included_packages"`

Classification string `tfschema:"classification_included"` // Deprecated use Classifications instead
Classification string `tfschema:"classification_included,majorVersionRemoved"`
}

type MonthlyOccurrence struct {
Expand Down Expand Up @@ -111,8 +111,7 @@ type Windows struct {
IncludedKbs []string `tfschema:"included_knowledge_base_numbers"`
RebootSetting string `tfschema:"reboot"`

Classification string `tfschema:"classification_included"` // Deprecated use Classifications instead

Classification string `tfschema:"classification_included,majorVersionRemoved"`
}

type SoftwareUpdateConfigurationModel struct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ type SiteRecoveryReplicationRecoveryPlanModel struct {
ShutdownRecoveryGroup []GenericRecoveryGroupModel `tfschema:"shutdown_recovery_group"`
FailoverRecoveryGroup []GenericRecoveryGroupModel `tfschema:"failover_recovery_group"`
BootRecoveryGroup []BootRecoveryGroupModel `tfschema:"boot_recovery_group"`
RecoveryGroup []RecoveryGroupModel `tfschema:"recovery_group"`
RecoveryGroup []RecoveryGroupModel `tfschema:"recovery_group,majorVersionRemoved"`
RecoveryVaultId string `tfschema:"recovery_vault_id"`
SourceRecoveryFabricId string `tfschema:"source_recovery_fabric_id"`
TargetRecoveryFabricId string `tfschema:"target_recovery_fabric_id"`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import (
)

type SecurityInsightsSentinelOnboardingStateModel struct {
ResourceGroupName string `tfschema:"resource_group_name"`
WorkspaceName string `tfschema:"workspace_name"`
ResourceGroupName string `tfschema:"resource_group_name,majorVersionRemoved"`
WorkspaceName string `tfschema:"workspace_name,majorVersionRemoved"`
CustomerManagedKeyEnabled bool `tfschema:"customer_managed_key_enabled"`
WorkspaceId string `tfschema:"workspace_id"`
}
Expand Down
Loading