Skip to content

Commit

Permalink
Add Upgrade Channels to NGINXaaS
Browse files Browse the repository at this point in the history
  • Loading branch information
puneetsarna committed Feb 13, 2024
1 parent 8b60dbb commit 6cf32cf
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 5 deletions.
10 changes: 10 additions & 0 deletions internal/services/nginx/nginx_deployment_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ type DeploymentDataSourceModel struct {
FrontendPublic []FrontendPublic `tfschema:"frontend_public"`
FrontendPrivate []FrontendPrivate `tfschema:"frontend_private"`
NetworkInterface []NetworkInterface `tfschema:"network_interface"`
UpgradeChannel string `tfschema:"automatic_upgrade_channel"`
Tags map[string]string `tfschema:"tags"`
}

Expand Down Expand Up @@ -164,6 +165,11 @@ func (m DeploymentDataSource) Attributes() map[string]*pluginsdk.Schema {
},
},

"automatic_upgrade_channel": {
Type: pluginsdk.TypeString,
Computed: true,
},

"tags": commonschema.TagsDataSource(),
}
}
Expand Down Expand Up @@ -267,6 +273,10 @@ func (m DeploymentDataSource) Read() sdk.ResourceFunc {
if userProfile := props.UserProfile; userProfile != nil && userProfile.PreferredEmail != nil {
output.Email = pointer.ToString(props.UserProfile.PreferredEmail)
}

if autoUpgradeProfile := props.AutoUpgradeProfile; autoUpgradeProfile != nil {

Check failure on line 277 in internal/services/nginx/nginx_deployment_data_source.go

View workflow job for this annotation

GitHub Actions / test

props.AutoUpgradeProfile undefined (type *nginxdeployment.NginxDeploymentProperties has no field or method AutoUpgradeProfile)

Check failure on line 277 in internal/services/nginx/nginx_deployment_data_source.go

View workflow job for this annotation

GitHub Actions / tflint

props.AutoUpgradeProfile undefined (type *nginxdeployment.NginxDeploymentProperties has no field or method AutoUpgradeProfile)

Check failure on line 277 in internal/services/nginx/nginx_deployment_data_source.go

View workflow job for this annotation

GitHub Actions / tflint

props.AutoUpgradeProfile undefined (type *nginxdeployment.NginxDeploymentProperties has no field or method AutoUpgradeProfile)

Check failure on line 277 in internal/services/nginx/nginx_deployment_data_source.go

View workflow job for this annotation

GitHub Actions / golint

props.AutoUpgradeProfile undefined (type *nginxdeployment.NginxDeploymentProperties has no field or method AutoUpgradeProfile)

Check failure on line 277 in internal/services/nginx/nginx_deployment_data_source.go

View workflow job for this annotation

GitHub Actions / detect

props.AutoUpgradeProfile undefined (type *nginxdeployment.NginxDeploymentProperties has no field or method AutoUpgradeProfile)

Check failure on line 277 in internal/services/nginx/nginx_deployment_data_source.go

View workflow job for this annotation

GitHub Actions / document-lint

props.AutoUpgradeProfile undefined (type *nginxdeployment.NginxDeploymentProperties has no field or method AutoUpgradeProfile)

Check failure on line 277 in internal/services/nginx/nginx_deployment_data_source.go

View workflow job for this annotation

GitHub Actions / compatibility-32bit-test

props.AutoUpgradeProfile undefined (type *nginxdeployment.NginxDeploymentProperties has no field or method AutoUpgradeProfile)
output.UpgradeChannel = props.AutoUpgradeProfile.UpgradeChannel

Check failure on line 278 in internal/services/nginx/nginx_deployment_data_source.go

View workflow job for this annotation

GitHub Actions / test

props.AutoUpgradeProfile undefined (type *nginxdeployment.NginxDeploymentProperties has no field or method AutoUpgradeProfile)

Check failure on line 278 in internal/services/nginx/nginx_deployment_data_source.go

View workflow job for this annotation

GitHub Actions / tflint

props.AutoUpgradeProfile undefined (type *nginxdeployment.NginxDeploymentProperties has no field or method AutoUpgradeProfile)

Check failure on line 278 in internal/services/nginx/nginx_deployment_data_source.go

View workflow job for this annotation

GitHub Actions / tflint

props.AutoUpgradeProfile undefined (type *nginxdeployment.NginxDeploymentProperties has no field or method AutoUpgradeProfile)

Check failure on line 278 in internal/services/nginx/nginx_deployment_data_source.go

View workflow job for this annotation

GitHub Actions / golint

props.AutoUpgradeProfile undefined (type *nginxdeployment.NginxDeploymentProperties has no field or method AutoUpgradeProfile)

Check failure on line 278 in internal/services/nginx/nginx_deployment_data_source.go

View workflow job for this annotation

GitHub Actions / detect

props.AutoUpgradeProfile undefined (type *nginxdeployment.NginxDeploymentProperties has no field or method AutoUpgradeProfile)

Check failure on line 278 in internal/services/nginx/nginx_deployment_data_source.go

View workflow job for this annotation

GitHub Actions / document-lint

props.AutoUpgradeProfile undefined (type *nginxdeployment.NginxDeploymentProperties has no field or method AutoUpgradeProfile)

Check failure on line 278 in internal/services/nginx/nginx_deployment_data_source.go

View workflow job for this annotation

GitHub Actions / compatibility-32bit-test

props.AutoUpgradeProfile undefined (type *nginxdeployment.NginxDeploymentProperties has no field or method AutoUpgradeProfile)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ func TestAccNginxDeploymentDataSource_basic(t *testing.T) {
check.That(data.ResourceName).Key("capacity").Exists(),
check.That(data.ResourceName).Key("managed_resource_group").Exists(),
check.That(data.ResourceName).Key("ip_address").Exists(),
check.That(data.ResourceName).Key("automatic_upgrade_channel").Exists(),
),
},
})
Expand Down
24 changes: 24 additions & 0 deletions internal/services/nginx/nginx_deployment_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ type DeploymentModel struct {
FrontendPublic []FrontendPublic `tfschema:"frontend_public"`
FrontendPrivate []FrontendPrivate `tfschema:"frontend_private"`
NetworkInterface []NetworkInterface `tfschema:"network_interface"`
UpgradeChannel string `tfschema:"automatic_upgrade_channel"`
Tags map[string]string `tfschema:"tags"`
}

Expand Down Expand Up @@ -193,6 +194,13 @@ func (m DeploymentResource) Arguments() map[string]*pluginsdk.Schema {
},
},

"automatic_upgrade_channel": {
Type: pluginsdk.TypeString,
Optional: true,
Default: "stable",
ValidateFunc: validation.StringIsNotEmpty,
},

"tags": commonschema.Tags(),
}
}
Expand Down Expand Up @@ -308,6 +316,12 @@ func (m DeploymentResource) Create() sdk.ResourceFunc {
}
}

if model.UpgradeChannel != "" {
prop.AutoUpgradeProfile = &nginxdeployment.AutoUpgradeProfile{
UpgradeChannel: model.UpgradeChannel,

Check failure on line 321 in internal/services/nginx/nginx_deployment_resource.go

View workflow job for this annotation

GitHub Actions / test

prop.AutoUpgradeProfile undefined (type *nginxdeployment.NginxDeploymentProperties has no field or method AutoUpgradeProfile)

Check failure on line 321 in internal/services/nginx/nginx_deployment_resource.go

View workflow job for this annotation

GitHub Actions / test

undefined: nginxdeployment.AutoUpgradeProfile

Check failure on line 321 in internal/services/nginx/nginx_deployment_resource.go

View workflow job for this annotation

GitHub Actions / tflint

prop.AutoUpgradeProfile undefined (type *nginxdeployment.NginxDeploymentProperties has no field or method AutoUpgradeProfile)

Check failure on line 321 in internal/services/nginx/nginx_deployment_resource.go

View workflow job for this annotation

GitHub Actions / tflint

undefined: nginxdeployment.AutoUpgradeProfile

Check failure on line 321 in internal/services/nginx/nginx_deployment_resource.go

View workflow job for this annotation

GitHub Actions / golint

prop.AutoUpgradeProfile undefined (type *nginxdeployment.NginxDeploymentProperties has no field or method AutoUpgradeProfile)

Check failure on line 321 in internal/services/nginx/nginx_deployment_resource.go

View workflow job for this annotation

GitHub Actions / golint

undefined: nginxdeployment.AutoUpgradeProfile

Check failure on line 321 in internal/services/nginx/nginx_deployment_resource.go

View workflow job for this annotation

GitHub Actions / detect

prop.AutoUpgradeProfile undefined (type *nginxdeployment.NginxDeploymentProperties has no field or method AutoUpgradeProfile)

Check failure on line 321 in internal/services/nginx/nginx_deployment_resource.go

View workflow job for this annotation

GitHub Actions / detect

undefined: nginxdeployment.AutoUpgradeProfile

Check failure on line 321 in internal/services/nginx/nginx_deployment_resource.go

View workflow job for this annotation

GitHub Actions / document-lint

prop.AutoUpgradeProfile undefined (type *nginxdeployment.NginxDeploymentProperties has no field or method AutoUpgradeProfile)

Check failure on line 321 in internal/services/nginx/nginx_deployment_resource.go

View workflow job for this annotation

GitHub Actions / document-lint

undefined: nginxdeployment.AutoUpgradeProfile

Check failure on line 321 in internal/services/nginx/nginx_deployment_resource.go

View workflow job for this annotation

GitHub Actions / compatibility-32bit-test

prop.AutoUpgradeProfile undefined (type *nginxdeployment.NginxDeploymentProperties has no field or method AutoUpgradeProfile)

Check failure on line 321 in internal/services/nginx/nginx_deployment_resource.go

View workflow job for this annotation

GitHub Actions / compatibility-32bit-test

undefined: nginxdeployment.AutoUpgradeProfile
}
}

req.Properties = prop

req.Identity, err = identity.ExpandSystemAndUserAssignedMapFromModel(model.Identity)
Expand Down Expand Up @@ -411,6 +425,10 @@ func (m DeploymentResource) Read() sdk.ResourceFunc {
output.Email = pointer.ToString(props.UserProfile.PreferredEmail)
}

if autoUpgradeProfile := props.AutoUpgradeProfile; autoUpgradeProfile != nil {
output.UpgradeChannel = props.AutoUpgradeProfile.UpgradeChannel

Check failure on line 429 in internal/services/nginx/nginx_deployment_resource.go

View workflow job for this annotation

GitHub Actions / test

props.AutoUpgradeProfile undefined (type *nginxdeployment.NginxDeploymentProperties has no field or method AutoUpgradeProfile)

Check failure on line 429 in internal/services/nginx/nginx_deployment_resource.go

View workflow job for this annotation

GitHub Actions / tflint

props.AutoUpgradeProfile undefined (type *nginxdeployment.NginxDeploymentProperties has no field or method AutoUpgradeProfile)

Check failure on line 429 in internal/services/nginx/nginx_deployment_resource.go

View workflow job for this annotation

GitHub Actions / golint

props.AutoUpgradeProfile undefined (type *nginxdeployment.NginxDeploymentProperties has no field or method AutoUpgradeProfile)

Check failure on line 429 in internal/services/nginx/nginx_deployment_resource.go

View workflow job for this annotation

GitHub Actions / detect

props.AutoUpgradeProfile undefined (type *nginxdeployment.NginxDeploymentProperties has no field or method AutoUpgradeProfile)

Check failure on line 429 in internal/services/nginx/nginx_deployment_resource.go

View workflow job for this annotation

GitHub Actions / document-lint

props.AutoUpgradeProfile undefined (type *nginxdeployment.NginxDeploymentProperties has no field or method AutoUpgradeProfile)

Check failure on line 429 in internal/services/nginx/nginx_deployment_resource.go

View workflow job for this annotation

GitHub Actions / compatibility-32bit-test

props.AutoUpgradeProfile undefined (type *nginxdeployment.NginxDeploymentProperties has no field or method AutoUpgradeProfile)
}

Check failure on line 430 in internal/services/nginx/nginx_deployment_resource.go

View workflow job for this annotation

GitHub Actions / test

props.AutoUpgradeProfile undefined (type *nginxdeployment.NginxDeploymentProperties has no field or method AutoUpgradeProfile)

Check failure on line 430 in internal/services/nginx/nginx_deployment_resource.go

View workflow job for this annotation

GitHub Actions / tflint

props.AutoUpgradeProfile undefined (type *nginxdeployment.NginxDeploymentProperties has no field or method AutoUpgradeProfile)

Check failure on line 430 in internal/services/nginx/nginx_deployment_resource.go

View workflow job for this annotation

GitHub Actions / golint

props.AutoUpgradeProfile undefined (type *nginxdeployment.NginxDeploymentProperties has no field or method AutoUpgradeProfile)

Check failure on line 430 in internal/services/nginx/nginx_deployment_resource.go

View workflow job for this annotation

GitHub Actions / detect

props.AutoUpgradeProfile undefined (type *nginxdeployment.NginxDeploymentProperties has no field or method AutoUpgradeProfile)

Check failure on line 430 in internal/services/nginx/nginx_deployment_resource.go

View workflow job for this annotation

GitHub Actions / document-lint

props.AutoUpgradeProfile undefined (type *nginxdeployment.NginxDeploymentProperties has no field or method AutoUpgradeProfile)

Check failure on line 430 in internal/services/nginx/nginx_deployment_resource.go

View workflow job for this annotation

GitHub Actions / compatibility-32bit-test

props.AutoUpgradeProfile undefined (type *nginxdeployment.NginxDeploymentProperties has no field or method AutoUpgradeProfile)

flattenedIdentity, err := identity.FlattenSystemAndUserAssignedMapToModel(model.Identity)
if err != nil {
return fmt.Errorf("flattening `identity`: %v", err)
Expand Down Expand Up @@ -480,6 +498,12 @@ func (m DeploymentResource) Update() sdk.ResourceFunc {
}
}

if meta.ResourceData.HasChange("automatic_upgrade_channel") {
req.Properties.AutoUpgradeProfile = &nginxdeployment.AutoUpgradeProfile{
UpgradeChannel: model.UpgradeChannel,

Check failure on line 503 in internal/services/nginx/nginx_deployment_resource.go

View workflow job for this annotation

GitHub Actions / test

req.Properties.AutoUpgradeProfile undefined (type *nginxdeployment.NginxDeploymentUpdateProperties has no field or method AutoUpgradeProfile)

Check failure on line 503 in internal/services/nginx/nginx_deployment_resource.go

View workflow job for this annotation

GitHub Actions / test

undefined: nginxdeployment.AutoUpgradeProfile

Check failure on line 503 in internal/services/nginx/nginx_deployment_resource.go

View workflow job for this annotation

GitHub Actions / tflint

req.Properties.AutoUpgradeProfile undefined (type *nginxdeployment.NginxDeploymentUpdateProperties has no field or method AutoUpgradeProfile)

Check failure on line 503 in internal/services/nginx/nginx_deployment_resource.go

View workflow job for this annotation

GitHub Actions / tflint

undefined: nginxdeployment.AutoUpgradeProfile

Check failure on line 503 in internal/services/nginx/nginx_deployment_resource.go

View workflow job for this annotation

GitHub Actions / golint

req.Properties.AutoUpgradeProfile undefined (type *nginxdeployment.NginxDeploymentUpdateProperties has no field or method AutoUpgradeProfile)

Check failure on line 503 in internal/services/nginx/nginx_deployment_resource.go

View workflow job for this annotation

GitHub Actions / golint

undefined: nginxdeployment.AutoUpgradeProfile (typecheck)

Check failure on line 503 in internal/services/nginx/nginx_deployment_resource.go

View workflow job for this annotation

GitHub Actions / detect

req.Properties.AutoUpgradeProfile undefined (type *nginxdeployment.NginxDeploymentUpdateProperties has no field or method AutoUpgradeProfile)

Check failure on line 503 in internal/services/nginx/nginx_deployment_resource.go

View workflow job for this annotation

GitHub Actions / detect

undefined: nginxdeployment.AutoUpgradeProfile

Check failure on line 503 in internal/services/nginx/nginx_deployment_resource.go

View workflow job for this annotation

GitHub Actions / document-lint

req.Properties.AutoUpgradeProfile undefined (type *nginxdeployment.NginxDeploymentUpdateProperties has no field or method AutoUpgradeProfile)

Check failure on line 503 in internal/services/nginx/nginx_deployment_resource.go

View workflow job for this annotation

GitHub Actions / document-lint

undefined: nginxdeployment.AutoUpgradeProfile

Check failure on line 503 in internal/services/nginx/nginx_deployment_resource.go

View workflow job for this annotation

GitHub Actions / compatibility-32bit-test

req.Properties.AutoUpgradeProfile undefined (type *nginxdeployment.NginxDeploymentUpdateProperties has no field or method AutoUpgradeProfile)

Check failure on line 503 in internal/services/nginx/nginx_deployment_resource.go

View workflow job for this annotation

GitHub Actions / compatibility-32bit-test

undefined: nginxdeployment.AutoUpgradeProfile
}
}

if err := client.DeploymentsUpdateThenPoll(ctx, *id, req); err != nil {
return fmt.Errorf("updating %s: %v", id, err)
}
Expand Down
11 changes: 6 additions & 5 deletions internal/services/nginx/nginx_deployment_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,12 @@ func (a DeploymentResource) basic(data acceptance.TestData) string {
%s
resource "azurerm_nginx_deployment" "test" {
name = "acctest-%[2]d"
resource_group_name = azurerm_resource_group.test.name
sku = "standard_Monthly"
location = azurerm_resource_group.test.location
diagnose_support_enabled = true
name = "acctest-%[2]d"
resource_group_name = azurerm_resource_group.test.name
sku = "standard_Monthly"
location = azurerm_resource_group.test.location
diagnose_support_enabled = true
automatic_upgrade_channel = "stable"
frontend_public {
ip_address = [azurerm_public_ip.test.id]
Expand Down

0 comments on commit 6cf32cf

Please sign in to comment.