Skip to content

Commit 6f6463d

Browse files
authored
workaround - ManagedDevopsPools identity field (#5242)
* Add workaround for managed devops pools identity * fmt * Fix issue number * Include the latest api version
1 parent b356fd4 commit 6f6463d

2 files changed

Lines changed: 57 additions & 0 deletions

File tree

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
package dataworkarounds
2+
3+
import (
4+
"errors"
5+
"fmt"
6+
7+
sdkModels "github.com/hashicorp/pandora/tools/data-api-sdk/v1/models"
8+
)
9+
10+
var _ workaround = workaroundManagedDevopsPools40905{}
11+
12+
// workaroundManagedDevopsPools40905 works around the wrong identity type.
13+
// Swagger PR: https://github.com/Azure/azure-rest-api-specs/pull/40905
14+
type workaroundManagedDevopsPools40905 struct{}
15+
16+
func (workaroundManagedDevopsPools40905) IsApplicable(serviceName string, apiVersion sdkModels.APIVersion) bool {
17+
return serviceName == "DevOpsInfrastructure" && (apiVersion.APIVersion == "2025-01-21" || apiVersion.APIVersion == "2025-09-20")
18+
}
19+
20+
func (workaroundManagedDevopsPools40905) Name() string {
21+
return "ManagedDevopsPools / 40905"
22+
}
23+
24+
func (workaroundManagedDevopsPools40905) Process(input sdkModels.APIVersion) (*sdkModels.APIVersion, error) {
25+
resource, ok := input.Resources["Pools"]
26+
if !ok {
27+
return nil, errors.New("expected a resource named `Pools` but didn't get one")
28+
}
29+
30+
models := []string{
31+
"Pool",
32+
"PoolUpdate",
33+
}
34+
35+
for _, modelName := range models {
36+
model, ok := resource.Models[modelName]
37+
if !ok {
38+
return nil, fmt.Errorf("couldn't find model `%s`", modelName)
39+
}
40+
41+
identityField, ok := model.Fields["Identity"]
42+
if !ok {
43+
return nil, fmt.Errorf("couldn't find the field `Identity` within model `%s`", modelName)
44+
}
45+
46+
identityField.ObjectDefinition.Type = sdkModels.UserAssignedIdentityMapSDKObjectDefinitionType
47+
identityField.ObjectDefinition.ReferenceName = nil
48+
49+
model.Fields["Identity"] = identityField
50+
resource.Models[modelName] = model
51+
}
52+
53+
input.Resources["Pools"] = resource
54+
55+
return &input, nil
56+
}

tools/importer-rest-api-specs/internal/components/apidefinitions/parser/dataworkarounds/workarounds.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ var workarounds = []workaround{
3232
workaroundLoadTest20961{},
3333
workaroundMachineLearning25142{},
3434
workaroundMachineLearning40149{},
35+
workaroundManagedDevopsPools40905{},
3536
workaroundMongoCluster38810{},
3637
workaroundNetwork29303{},
3738
workaroundNetwork38407{},

0 commit comments

Comments
 (0)