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 - update all int struct properties to int64 #25910

Merged
merged 16 commits into from
May 27, 2024
4 changes: 2 additions & 2 deletions internal/services/appconfiguration/feature_structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,15 @@ type PercentageFeatureFilter struct {

type TargetingGroupParameter struct {
Name string `json:"Name" tfschema:"name"`
RolloutPercentage int `json:"RolloutPercentage" tfschema:"rollout_percentage"`
RolloutPercentage int64 `json:"RolloutPercentage" tfschema:"rollout_percentage"`
}

type TargetingFilterParameters struct {
Audience TargetingFilterAudience `json:"Audience"`
}

type TargetingFilterAudience struct {
DefaultRolloutPercentage int `json:"DefaultRolloutPercentage" tfschema:"default_rollout_percentage"`
DefaultRolloutPercentage int64 `json:"DefaultRolloutPercentage" tfschema:"default_rollout_percentage"`
Users []string `json:"Users" tfschema:"users"`
Groups []TargetingGroupParameter `json:"Groups" tfschema:"groups"`
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ type ApplicationInsightsStandardWebTestResourceModel struct {
ResourceGroupName string `tfschema:"resource_group_name"`
ApplicationInsightsID string `tfschema:"application_insights_id"`
Location string `tfschema:"location"`
Frequency int `tfschema:"frequency"`
Timeout int `tfschema:"timeout"`
Frequency int64 `tfschema:"frequency"`
Timeout int64 `tfschema:"timeout"`
Enabled bool `tfschema:"enabled"`
Retry bool `tfschema:"retry_enabled"`
Request []RequestModel `tfschema:"request"`
Expand All @@ -56,8 +56,8 @@ type RequestModel struct {
}

type ValidationRuleModel struct {
ExpectedStatusCode int `tfschema:"expected_status_code"`
CertificateRemainingLifetime int `tfschema:"ssl_cert_remaining_lifetime"`
ExpectedStatusCode int64 `tfschema:"expected_status_code"`
CertificateRemainingLifetime int64 `tfschema:"ssl_cert_remaining_lifetime"`
SSLCheck bool `tfschema:"ssl_check_enabled"`
Content []ContentModel `tfschema:"content"`
}
Expand Down Expand Up @@ -341,11 +341,11 @@ func (r ApplicationInsightsStandardWebTestResource) Create() sdk.ResourceFunc {
props := webtests.WebTestProperties{
Name: id.WebTestName, // API requires this to be specified despite ARM spec guidance that it should come from the ID
Enabled: pointer.To(model.Enabled),
Frequency: pointer.To(int64(model.Frequency)),
Frequency: pointer.To(model.Frequency),
Kind: webtests.WebTestKindStandard,
SyntheticMonitorId: id.WebTestName,
RetryEnabled: pointer.To(model.Retry),
Timeout: pointer.To(int64(model.Timeout)),
Timeout: pointer.To(model.Timeout),
Locations: expandApplicationInsightsStandardWebTestGeoLocations(model.GeoLocations),
ValidationRules: pointer.To(validations),
Request: expandApplicationInsightsStandardWebTestRequest(model.Request),
Expand Down Expand Up @@ -403,11 +403,11 @@ func (r ApplicationInsightsStandardWebTestResource) Update() sdk.ResourceFunc {
}

if metadata.ResourceData.HasChange("frequency") {
props.Frequency = pointer.To(int64(model.Frequency))
props.Frequency = pointer.To(model.Frequency)
}

if metadata.ResourceData.HasChange("timeout") {
props.Timeout = pointer.To(int64(model.Timeout))
props.Timeout = pointer.To(model.Timeout)
}

props.Enabled = pointer.To(model.Enabled)
Expand Down Expand Up @@ -495,8 +495,8 @@ func (ApplicationInsightsStandardWebTestResource) Read() sdk.ResourceFunc {
state.SyntheticMonitorID = props.SyntheticMonitorId
state.Description = pointer.From(props.Description)
state.Enabled = pointer.From(props.Enabled)
state.Frequency = int(pointer.From(props.Frequency))
state.Timeout = int(pointer.From(props.Timeout))
state.Frequency = pointer.From(props.Frequency)
state.Timeout = pointer.From(props.Timeout)
state.Retry = pointer.From(props.RetryEnabled)
req, err := flattenApplicationInsightsStandardWebTestRequest(props.Request)
if err != nil {
Expand Down Expand Up @@ -641,8 +641,8 @@ func flattenApplicationInsightsStandardWebTestValidations(input *webtests.WebTes
}

result := ValidationRuleModel{
ExpectedStatusCode: int(pointer.From(rules.ExpectedHTTPStatusCode)),
CertificateRemainingLifetime: int(pointer.From(rules.SSLCertRemainingLifetimeCheck)),
ExpectedStatusCode: pointer.From(rules.ExpectedHTTPStatusCode),
CertificateRemainingLifetime: pointer.From(rules.SSLCertRemainingLifetimeCheck),
SSLCheck: pointer.From(rules.SSLCheck),
Content: flattenApplicationInsightsStandardWebTestContentValidations(rules.ContentValidation),
}
Expand Down Expand Up @@ -674,13 +674,13 @@ func expandApplicationInsightsStandardWebTestValidations(input []ValidationRuleM
}

validationsInput := input[0]
rules.ExpectedHTTPStatusCode = pointer.To(int64(validationsInput.ExpectedStatusCode))
rules.ExpectedHTTPStatusCode = pointer.To(validationsInput.ExpectedStatusCode)

// if URL http, sslCheck cannot be enabled - Catch in CustomiseDiff
rules.SSLCheck = pointer.To(validationsInput.SSLCheck)
// if sslCheck not enabled, SSLCertRemainingLifetimeCheck cannot be enabled
if validationsInput.CertificateRemainingLifetime != 0 && validationsInput.SSLCheck {
rules.SSLCertRemainingLifetimeCheck = pointer.To(int64(validationsInput.CertificateRemainingLifetime))
rules.SSLCertRemainingLifetimeCheck = pointer.To(validationsInput.CertificateRemainingLifetime)
}
rules.ContentValidation = expandApplicationInsightsStandardWebTestContentValidations(validationsInput.Content)

Expand Down
8 changes: 4 additions & 4 deletions internal/services/appservice/service_plan_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ type ServicePlanDataSourceModel struct {
AppServiceEnvironmentId string `tfschema:"app_service_environment_id"`
PerSiteScaling bool `tfschema:"per_site_scaling_enabled"`
Reserved bool `tfschema:"reserved"`
WorkerCount int `tfschema:"worker_count"`
MaximumElasticWorkerCount int `tfschema:"maximum_elastic_worker_count"`
WorkerCount int64 `tfschema:"worker_count"`
MaximumElasticWorkerCount int64 `tfschema:"maximum_elastic_worker_count"`
ZoneBalancing bool `tfschema:"zone_balancing_enabled"`
Tags map[string]string `tfschema:"tags"`
}
Expand Down Expand Up @@ -143,7 +143,7 @@ func (r ServicePlanDataSource) Read() sdk.ResourceFunc {
if sku.Name != nil {
servicePlan.Sku = *sku.Name
if sku.Capacity != nil {
servicePlan.WorkerCount = int(*sku.Capacity)
servicePlan.WorkerCount = *sku.Capacity
}
}
}
Expand All @@ -167,7 +167,7 @@ func (r ServicePlanDataSource) Read() sdk.ResourceFunc {

servicePlan.ZoneBalancing = utils.NormaliseNilableBool(props.ZoneRedundant)

servicePlan.MaximumElasticWorkerCount = int(pointer.From(props.MaximumElasticWorkerCount))
servicePlan.MaximumElasticWorkerCount = pointer.From(props.MaximumElasticWorkerCount)
}
servicePlan.Tags = pointer.From(model.Tags)
}
Expand Down
16 changes: 8 additions & 8 deletions internal/services/appservice/service_plan_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ type ServicePlanModel struct {
AppServiceEnvironmentId string `tfschema:"app_service_environment_id"`
PerSiteScaling bool `tfschema:"per_site_scaling_enabled"`
Reserved bool `tfschema:"reserved"`
WorkerCount int `tfschema:"worker_count"`
MaximumElasticWorkerCount int `tfschema:"maximum_elastic_worker_count"`
WorkerCount int64 `tfschema:"worker_count"`
MaximumElasticWorkerCount int64 `tfschema:"maximum_elastic_worker_count"`
ZoneBalancing bool `tfschema:"zone_balancing_enabled"`
Tags map[string]string `tfschema:"tags"`
}
Expand Down Expand Up @@ -195,11 +195,11 @@ func (r ServicePlanResource) Create() sdk.ResourceFunc {
if !isServicePlanSupportScaleOut(servicePlan.Sku) {
return fmt.Errorf("`maximum_elastic_worker_count` can only be specified with Elastic Premium Skus")
}
appServicePlan.Properties.MaximumElasticWorkerCount = pointer.To(int64(servicePlan.MaximumElasticWorkerCount))
appServicePlan.Properties.MaximumElasticWorkerCount = pointer.To(servicePlan.MaximumElasticWorkerCount)
}

if servicePlan.WorkerCount != 0 {
appServicePlan.Sku.Capacity = pointer.To(int64(servicePlan.WorkerCount))
appServicePlan.Sku.Capacity = pointer.To(servicePlan.WorkerCount)
}

if err := client.CreateOrUpdateThenPoll(ctx, id, appServicePlan); err != nil {
Expand Down Expand Up @@ -245,7 +245,7 @@ func (r ServicePlanResource) Read() sdk.ResourceFunc {
if sku.Name != nil {
state.Sku = *sku.Name
if sku.Capacity != nil {
state.WorkerCount = int(*sku.Capacity)
state.WorkerCount = *sku.Capacity
}
}
}
Expand All @@ -270,7 +270,7 @@ func (r ServicePlanResource) Read() sdk.ResourceFunc {

state.ZoneBalancing = utils.NormaliseNilableBool(props.ZoneRedundant)

state.MaximumElasticWorkerCount = int(pointer.From(props.MaximumElasticWorkerCount))
state.MaximumElasticWorkerCount = pointer.From(props.MaximumElasticWorkerCount)
}
state.Tags = pointer.From(model.Tags)
}
Expand Down Expand Up @@ -341,14 +341,14 @@ func (r ServicePlanResource) Update() sdk.ResourceFunc {
}

if metadata.ResourceData.HasChange("worker_count") {
model.Sku.Capacity = pointer.To(int64(state.WorkerCount))
model.Sku.Capacity = pointer.To(state.WorkerCount)
}

if metadata.ResourceData.HasChange("maximum_elastic_worker_count") {
if metadata.ResourceData.HasChange("maximum_elastic_worker_count") && !isServicePlanSupportScaleOut(state.Sku) {
return fmt.Errorf("`maximum_elastic_worker_count` can only be specified with Elastic Premium Skus")
}
model.Properties.MaximumElasticWorkerCount = pointer.To(int64(state.MaximumElasticWorkerCount))
model.Properties.MaximumElasticWorkerCount = pointer.To(state.MaximumElasticWorkerCount)
}

if err = client.CreateOrUpdateThenPoll(ctx, *id, model); err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ type PimActiveRoleAssignmentScheduleInfo struct {
}

type PimActiveRoleAssignmentScheduleInfoExpiration struct {
DurationDays int `tfschema:"duration_days"`
DurationHours int `tfschema:"duration_hours"`
DurationDays int64 `tfschema:"duration_days"`
DurationHours int64 `tfschema:"duration_hours"`
EndDateTime string `tfschema:"end_date_time"`
}

Expand Down Expand Up @@ -437,7 +437,7 @@ func (r PimActiveRoleAssignmentResource) Read() sdk.ResourceFunc {
reHours := regexp.MustCompile(`PT(\d+)H`)
matches := reHours.FindStringSubmatch(durationRaw)
if len(matches) == 2 {
hours, err := strconv.Atoi(matches[1])
hours, err := strconv.ParseInt(matches[1], 10, 0)
if err != nil {
return fmt.Errorf("parsing duration: %+v", err)
}
Expand All @@ -447,7 +447,7 @@ func (r PimActiveRoleAssignmentResource) Read() sdk.ResourceFunc {
reDays := regexp.MustCompile(`P(\d+)D`)
matches = reDays.FindStringSubmatch(durationRaw)
if len(matches) == 2 {
days, err := strconv.Atoi(matches[1])
days, err := strconv.ParseInt(matches[1], 10, 0)
if err != nil {
return fmt.Errorf("parsing duration: %+v", err)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ type PimEligibleRoleAssignmentScheduleInfo struct {
}

type PimEligibleRoleAssignmentScheduleInfoExpiration struct {
DurationDays int `tfschema:"duration_days"`
DurationHours int `tfschema:"duration_hours"`
DurationDays int64 `tfschema:"duration_days"`
DurationHours int64 `tfschema:"duration_hours"`
EndDateTime string `tfschema:"end_date_time"`
}

Expand Down Expand Up @@ -437,7 +437,7 @@ func (r PimEligibleRoleAssignmentResource) Read() sdk.ResourceFunc {
reHours := regexp.MustCompile(`PT(\d+)H`)
matches := reHours.FindStringSubmatch(durationRaw)
if len(matches) == 2 {
hours, err := strconv.Atoi(matches[1])
hours, err := strconv.ParseInt(matches[1], 10, 0)
if err != nil {
return fmt.Errorf("parsing duration: %+v", err)
}
Expand All @@ -447,7 +447,7 @@ func (r PimEligibleRoleAssignmentResource) Read() sdk.ResourceFunc {
reDays := regexp.MustCompile(`P(\d+)D`)
matches = reDays.FindStringSubmatch(durationRaw)
if len(matches) == 2 {
days, err := strconv.Atoi(matches[1])
days, err := strconv.ParseInt(matches[1], 10, 0)
if err != nil {
return fmt.Errorf("parsing duration: %+v", err)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ type AntimalwareConfiguration struct {
RealTimeProtectionEnabled bool `tfschema:"real_time_protection_enabled"`
ScheduledScanEnabled bool `tfschema:"scheduled_scan_enabled"`
ScanType string `tfschema:"scheduled_scan_type"`
ScanDay int `tfschema:"scheduled_scan_day"`
ScanTimeInMinutes int `tfschema:"scheduled_scan_time_in_minutes"`
ScanDay int64 `tfschema:"scheduled_scan_day"`
ScanTimeInMinutes int64 `tfschema:"scheduled_scan_time_in_minutes"`
}

type AntimalwareExclusions struct {
Expand All @@ -42,7 +42,7 @@ type AntimalwareExclusions struct {
type BackupConfiguration struct {
PolicyName string `tfschema:"policy_name"`
TimeZone string `tfschema:"time_zone"`
InstantRpRetentionRangeInDays int `tfschema:"instant_rp_retention_range_in_days"`
InstantRpRetentionRangeInDays int64 `tfschema:"instant_rp_retention_range_in_days"`
SchedulePolicy []SchedulePolicyConfiguration `tfschema:"schedule_policy"`
RetentionPolicy []RetentionPolicyConfiguration `tfschema:"retention_policy"`
}
Expand Down Expand Up @@ -77,7 +77,7 @@ type RetentionPolicyConfiguration struct {
}

type RetentionDurationConfiguration struct {
Count int `tfschema:"count"`
Count int64 `tfschema:"count"`
DurationType string `tfschema:"duration_type"`
}

Expand Down Expand Up @@ -752,11 +752,11 @@ func flattenAntiMalwareConfig(configMap map[string]interface{}) []AntimalwareCon
}

if val, ok := configMap["Antimalware/ScanDay"]; ok {
antimalware[0].ScanDay = int(val.(float64))
antimalware[0].ScanDay = int64(val.(float64))
}

if val, ok := configMap["Antimalware/ScanTimeInMinutes"]; ok {
antimalware[0].ScanTimeInMinutes = int(val.(float64))
antimalware[0].ScanTimeInMinutes = int64(val.(float64))
}

exclusions := AntimalwareExclusions{}
Expand Down Expand Up @@ -816,7 +816,7 @@ func flattenBackupConfig(configMap map[string]interface{}) []BackupConfiguration
}

if val, ok := configMap["Backup/InstantRpRetentionRangeInDays"]; ok {
backup[0].InstantRpRetentionRangeInDays = int(val.(float64))
backup[0].InstantRpRetentionRangeInDays = int64(val.(float64))
}

schedulePolicy := SchedulePolicyConfiguration{}
Expand Down Expand Up @@ -863,7 +863,7 @@ func flattenBackupConfig(configMap map[string]interface{}) []BackupConfiguration
retentionDuration := RetentionDurationConfiguration{}
retentionDurationChanged := false
if val, ok := configMap["Backup/RetentionPolicy/DailySchedule/RetentionDuration/Count"]; ok {
retentionDuration.Count = int(val.(float64))
retentionDuration.Count = int64(val.(float64))
retentionDurationChanged = true
}

Expand Down Expand Up @@ -892,7 +892,7 @@ func flattenBackupConfig(configMap map[string]interface{}) []BackupConfiguration
weeklyRetentionDuration := RetentionDurationConfiguration{}
weeklyRetentionDurationChanged := false
if val, ok := configMap["Backup/RetentionPolicy/WeeklySchedule/RetentionDuration/Count"]; ok {
weeklyRetentionDuration.Count = int(val.(float64))
weeklyRetentionDuration.Count = int64(val.(float64))
weeklyRetentionDurationChanged = true
}

Expand Down