Skip to content

Commit

Permalink
tools/importer-rest-api-specs: adding a workaround for the missing re…
Browse files Browse the repository at this point in the history
…dis field

Works around Azure/azure-rest-api-specs#22407
  • Loading branch information
tombuildsstuff committed Feb 1, 2023
1 parent e43dde9 commit 13e1776
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package dataworkarounds

import (
"github.com/hashicorp/pandora/tools/importer-rest-api-specs/models"
)

type workaroundRedis22407 struct {
}

func (w workaroundRedis22407) IsApplicable(apiDefinition *models.AzureApiDefinition) bool {
serviceMatches := apiDefinition.ServiceName == "Redis"
apiVersionMatches := apiDefinition.ApiVersion == "2021-06-01" || apiDefinition.ApiVersion == "2022-05-01" || apiDefinition.ApiVersion == "2022-06-01"
return serviceMatches && apiVersionMatches
}

func (w workaroundRedis22407) Name() string {
return "Redis / 22407"
}

func (w workaroundRedis22407) Process(apiDefinition models.AzureApiDefinition) (*models.AzureApiDefinition, error) {
if resource, ok := apiDefinition.Resources["Redis"]; ok {
if model, ok := resource.Models["RedisCommonPropertiesRedisConfiguration"]; ok {

if _, ok := model.Fields["NotifyKeyspaceEvents"]; !ok {
model.Fields["NotifyKeyspaceEvents"] = models.FieldDetails{
Required: false,
ReadOnly: false,
Sensitive: false,
JsonName: "notify-keyspace-events",
Description: "The KeySpace Events which should be monitored.",
ObjectDefinition: &models.ObjectDefinition{
Type: models.ObjectDefinitionString,
},
}
}
resource.Models["RedisCommonPropertiesRedisConfiguration"] = model
}
apiDefinition.Resources["Redis"] = resource
}
return &apiDefinition, nil
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ var workarounds = []workaround{
workaroundContainerService21394{},
workaroundLoadTest20961{},
workaroundMedia21581{},
workaroundRedis22407{},

// @tombuildsstuff: this is an odd place for this however this allows working around inconsistencies in the Swagger
// we should look at moving this into the `resourceids` package when time allows.
Expand Down

0 comments on commit 13e1776

Please sign in to comment.