Skip to content

Commit

Permalink
dataworkaround: add a workaround for storagecache 32537 (#4661)
Browse files Browse the repository at this point in the history
* add a data workaround for storage cache 32537

* was here, now gone

* use correct PR number in comment

Co-authored-by: catriona-m <[email protected]>

---------

Co-authored-by: catriona-m <[email protected]>
  • Loading branch information
stephybun and catriona-m authored Feb 10, 2025
1 parent d73e911 commit 0f8684e
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 6 deletions.
4 changes: 0 additions & 4 deletions config/resource-manager.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -412,10 +412,6 @@ service "network" {
name = "Network"
available = ["2023-09-01", "2023-11-01", "2024-01-01", "2024-03-01", "2024-05-01"]
}
service "networkanalytics" {
name = "NetworkAnalytics"
available = ["2023-11-15"]
}
service "networkcloud" {
name = "NetworkCloud"
available = ["2023-07-01", "2024-07-01"]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package dataworkarounds

import (
"fmt"

sdkModels "github.com/hashicorp/pandora/tools/data-api-sdk/v1/models"
)

// workaroundStorageCache32537 is a workaround to convert the `percentComplete` field to a float
// which is what the API returns and results in an unmarshaling error in the SDK when trying to
// read the response body - this can be removed when PR https://github.com/Azure/azure-rest-api-specs/pull/32537
// has been merged
type workaroundStorageCache32537 struct {
}

func (w workaroundStorageCache32537) IsApplicable(serviceName string, apiVersion sdkModels.APIVersion) bool {
return serviceName == "StorageCache" && apiVersion.APIVersion == "2023-05-01"
}

func (w workaroundStorageCache32537) Name() string {
return "StorageCache / 32537"
}

func (w workaroundStorageCache32537) Process(input sdkModels.APIVersion) (*sdkModels.APIVersion, error) {
resource, ok := input.Resources["AmlFilesystems"]
if !ok {
return nil, fmt.Errorf(`expected to find the API Resource "AmlFilesystems" but didn't`)
}

model, ok := resource.Models["AmlFilesystemArchiveStatus"]
if !ok {
return nil, fmt.Errorf(`expected the API resource "AmlFilesystems" to contain Model "AmlFilesystemArchiveStatus" but it didn't`)
}

field, ok := model.Fields["PercentComplete"]
if !ok {
return nil, fmt.Errorf(`expected the Model "AmlFilesystemArchiveStatus" to contain the field "PercentComplete" but it didn't'`)
}

field.ObjectDefinition = sdkModels.SDKObjectDefinition{
Type: sdkModels.FloatSDKObjectDefinitionType,
}

model.Fields["PercentComplete"] = field
resource.Models["AmlFilesystemArchiveStatus"] = model
input.Resources["AmlFilesystems"] = resource

return &input, nil
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@ var workarounds = []workaround{
workaroundDigitalTwins25120{},
workaroundHDInsight26838{},
workaroundLoadTest20961{},
workaroundRedis22407{},
workaroundMachineLearning25142{},
workaroundNetwork29303{},
workaroundNewRelic29256{},
workaroundOperationalinsights27524{},
workaroundRecoveryServicesSiteRecovery26680{},
workaroundRedis22407{},
workaroundStorageCache32537{},
workaroundStreamAnalytics27577{},
workaroundSubscriptions20254{},
workaroundNetwork29303{},
workaroundWeb31682{},

// These workarounds relate to Terraform specific overrides we want to apply (for example for Resource Generation)
Expand Down

0 comments on commit 0f8684e

Please sign in to comment.