Skip to content

Commit

Permalink
clean up - remove FourPointOhBeta code (hashicorp#27941)
Browse files Browse the repository at this point in the history
* remove feature flagged FourPointOhBeta code

* add back 4.0 relevant code
  • Loading branch information
stephybun authored Nov 11, 2024
1 parent 6bb8484 commit e6da511
Show file tree
Hide file tree
Showing 12 changed files with 156 additions and 1,283 deletions.
6 changes: 0 additions & 6 deletions internal/services/compute/shared_image_version_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (
"github.com/hashicorp/go-azure-helpers/resourcemanager/tags"
"github.com/hashicorp/go-azure-sdk/resource-manager/compute/2022-03-03/galleryimageversions"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
"github.com/hashicorp/terraform-provider-azurerm/internal/features"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/compute/validate"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk"
"github.com/hashicorp/terraform-provider-azurerm/internal/timeouts"
Expand Down Expand Up @@ -190,11 +189,6 @@ func obtainImage(client *galleryimageversions.GalleryImageVersionsClient, ctx co
}
}

if !features.FourPointOhBeta() {
image := images[len(images)-1]
return &image, nil
}

for i := len(images) - 1; i >= 0; i-- {
if prop := images[i].Properties; prop == nil || prop.PublishingProfile == nil || prop.PublishingProfile.ExcludeFromLatest == nil || !*prop.PublishingProfile.ExcludeFromLatest {
return &(images[i]), nil
Expand Down
343 changes: 38 additions & 305 deletions internal/services/containers/container_registry_resource.go

Large diffs are not rendered by default.

284 changes: 0 additions & 284 deletions internal/services/containers/container_registry_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"github.com/hashicorp/terraform-provider-azurerm/internal/acceptance"
"github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
"github.com/hashicorp/terraform-provider-azurerm/internal/features"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk"
"github.com/hashicorp/terraform-provider-azurerm/utils"
)
Expand Down Expand Up @@ -257,38 +256,6 @@ func TestAccContainerRegistry_networkAccessProfileUpdate(t *testing.T) {
})
}

func TestAccContainerRegistry_policies(t *testing.T) {
if features.FourPointOhBeta() {
t.Skip("Skipping in 4.0 since policy updates are tested in the update test using the new properties")
}
data := acceptance.BuildTestData(t, "azurerm_container_registry", "test")
r := ContainerRegistryResource{}

data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.policies(data, 10),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep(),
{
Config: r.policies(data, 20),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep(),
{
Config: r.policies_downgradeUpdate(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep(),
})
}

func TestAccContainerRegistry_zoneRedundancy(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_container_registry", "test")
r := ContainerRegistryResource{}
Expand Down Expand Up @@ -451,29 +418,6 @@ func (t ContainerRegistryResource) Exists(ctx context.Context, clients *clients.
}

func (ContainerRegistryResource) basic(data acceptance.TestData) string {
if !features.FourPointOhBeta() {
return fmt.Sprintf(`
provider "azurerm" {
features {}
}
resource "azurerm_resource_group" "test" {
name = "acctestRG-acr-%d"
location = "%s"
}
resource "azurerm_container_registry" "test" {
name = "testacccr%d"
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
sku = "Basic"
# make sure network_rule_set is empty for basic SKU
# premium SKU will automatically populate network_rule_set.default_action to allow
network_rule_set = []
}
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger)
}
return fmt.Sprintf(`
provider "azurerm" {
features {}
Expand Down Expand Up @@ -528,48 +472,6 @@ resource "azurerm_container_registry" "import" {
}

func (ContainerRegistryResource) complete(data acceptance.TestData) string {
if !features.FourPointOhBeta() {
return fmt.Sprintf(`
provider "azurerm" {
features {}
}
resource "azurerm_resource_group" "test" {
name = "acctestRG-acr-%[2]d"
location = "%[1]s"
}
resource "azurerm_container_registry" "test" {
name = "testacccr%[2]d"
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
admin_enabled = true
sku = "Premium"
identity {
type = "SystemAssigned"
}
public_network_access_enabled = false
quarantine_policy_enabled = true
retention_policy {
enabled = true
days = 10
}
trust_policy {
enabled = true
}
export_policy_enabled = false
anonymous_pull_enabled = true
data_endpoint_enabled = true
network_rule_bypass_option = "None"
tags = {
environment = "production"
}
}
`, data.Locations.Primary, data.RandomInteger)
}
return fmt.Sprintf(`
provider "azurerm" {
features {}
Expand Down Expand Up @@ -608,61 +510,6 @@ resource "azurerm_container_registry" "test" {
}

func (ContainerRegistryResource) completeUpdated(data acceptance.TestData) string {
if !features.FourPointOhBeta() {
return fmt.Sprintf(`
provider "azurerm" {
features {}
}
resource "azurerm_resource_group" "test" {
name = "acctestRG-acr-%[2]d"
location = "%[1]s"
}
resource "azurerm_user_assigned_identity" "test" {
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
name = "testaccuai%[2]d"
}
resource "azurerm_container_registry" "test" {
name = "testacccr%[2]d"
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
admin_enabled = true
sku = "Premium"
identity {
type = "UserAssigned"
identity_ids = [
azurerm_user_assigned_identity.test.id
]
}
public_network_access_enabled = true
quarantine_policy_enabled = false
retention_policy {
enabled = true
days = 15
}
trust_policy {
enabled = false
}
export_policy_enabled = true
anonymous_pull_enabled = false
data_endpoint_enabled = false
network_rule_bypass_option = "AzureServices"
tags = {
environment = "production"
oompa = "loompa"
}
}
`, data.Locations.Primary, data.RandomInteger)
}

return fmt.Sprintf(`
provider "azurerm" {
features {}
Expand Down Expand Up @@ -713,35 +560,6 @@ resource "azurerm_container_registry" "test" {
}

func (ContainerRegistryResource) downgradeSku(data acceptance.TestData) string {
if !features.FourPointOhBeta() {
return fmt.Sprintf(`
provider "azurerm" {
features {}
}
resource "azurerm_resource_group" "test" {
name = "acctestRG-acr-%[2]d"
location = "%[1]s"
}
resource "azurerm_container_registry" "test" {
name = "testacccr%[2]d"
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
admin_enabled = true
sku = "Basic"
identity {
type = "SystemAssigned"
}
retention_policy {}
trust_policy {}
network_rule_set = []
}
`, data.Locations.Primary, data.RandomInteger)
}
return fmt.Sprintf(`
provider "azurerm" {
features {}
Expand Down Expand Up @@ -951,74 +769,6 @@ resource "azurerm_container_registry" "test" {
`, data.RandomInteger, data.Locations.Primary, sku)
}

func (ContainerRegistryResource) policies(data acceptance.TestData, days int) string {
return fmt.Sprintf(`
provider "azurerm" {
features {}
}
resource "azurerm_resource_group" "test" {
name = "acctestRG-acr-%d"
location = "%s"
}
resource "azurerm_container_registry" "test" {
name = "acctestACR%d"
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
admin_enabled = false
sku = "Premium"
quarantine_policy_enabled = true
retention_policy {
days = %d
enabled = true
}
trust_policy {
enabled = true
}
export_policy_enabled = false
public_network_access_enabled = false
tags = {
Environment = "Production"
}
}
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, days)
}

func (ContainerRegistryResource) policies_downgradeUpdate(data acceptance.TestData) string {
return fmt.Sprintf(`
provider "azurerm" {
features {}
}
resource "azurerm_resource_group" "test" {
name = "acctestRG-acr-%d"
location = "%s"
}
resource "azurerm_container_registry" "test" {
name = "acctestACR%d"
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
admin_enabled = false
sku = "Basic"
network_rule_set = []
retention_policy {}
trust_policy {}
tags = {
Environment = "Production"
}
}
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger)
}

func (ContainerRegistryResource) zoneRedundancy(data acceptance.TestData) string {
return fmt.Sprintf(`
provider "azurerm" {
Expand Down Expand Up @@ -1148,40 +898,6 @@ resource "azurerm_container_registry" "test" {
func (ContainerRegistryResource) encryptionEnabled(data acceptance.TestData) string {
template := ContainerRegistryResource{}.encryptionTemplate(data)

if !features.FourPointOhBeta() {
return fmt.Sprintf(`
%s
resource "azurerm_key_vault_key" "test" {
name = "acctestkvkey%[3]s"
key_vault_id = azurerm_key_vault.test.id
key_type = "RSA"
key_size = 2048
key_opts = ["decrypt", "encrypt", "sign", "unwrapKey", "verify", "wrapKey"]
}
resource "azurerm_container_registry" "test" {
name = "testacccr%[2]d"
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
sku = "Premium"
identity {
type = "UserAssigned"
identity_ids = [
azurerm_user_assigned_identity.test.id
]
}
encryption {
enabled = true
identity_client_id = azurerm_user_assigned_identity.test.client_id
key_vault_key_id = azurerm_key_vault_key.test.id
}
}
`, template, data.RandomInteger, data.RandomString)
}

return fmt.Sprintf(`
%s
Expand Down
Loading

0 comments on commit e6da511

Please sign in to comment.