Skip to content

dataworkaround: add workaround for resources 29885 #4691

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package dataworkarounds

import (
"fmt"

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

var _ workaround = workaroundResources29885{}

// workaroundResources29885 converts the `PrivateEndpointConnections` property from a string to an interface - this can be removed once
// https://github.com/Azure/azure-rest-api-specs/issues/29885 has been fixed
type workaroundResources29885 struct{}

func (workaroundResources29885) IsApplicable(serviceName string, apiVersion sdkModels.APIVersion) bool {
return serviceName == "Resources" && apiVersion.APIVersion == "2020-05-01"
}

func (workaroundResources29885) Name() string {
return "Resources / 29885"
}

func (workaroundResources29885) Process(input sdkModels.APIVersion) (*sdkModels.APIVersion, error) {
resource, ok := input.Resources["ResourceManagementPrivateLink"]
if !ok {
return nil, fmt.Errorf("expected a Resource named `ResourceManagementPrivateLink` but didn't get one")
}

model, ok := resource.Models["ResourceManagementPrivateLinkEndpointConnections"]
if !ok {
return nil, fmt.Errorf("couldn't find Model `ResourceManagementPrivateLinkEndpointConnections`")
}

field, ok := model.Fields["PrivateEndpointConnections"]
if !ok {
return nil, fmt.Errorf("couldn't find the field `PrivateEndpointConnections` in model `ResourceManagementPrivateLinkEndpointConnections`")
}
if field.ObjectDefinition.NestedItem != nil {
field.ObjectDefinition.NestedItem.Type = sdkModels.RawObjectSDKObjectDefinitionType
}

model.Fields["PrivateEndpointConnections"] = field
resource.Models["ResourceManagementPrivateLinkEndpointConnections"] = model
input.Resources["ResourceManagementPrivateLink"] = resource

return &input, nil
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ var workarounds = []workaround{
workaroundOperationalinsights27524{},
workaroundRecoveryServicesSiteRecovery26680{},
workaroundRedis22407{},
workaroundResources29885{},
workaroundStorageCache32537{},
workaroundStreamAnalytics27577{},
workaroundSubscriptions20254{},
Expand Down
Loading