-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tools/importer-rest-api-specs: adding a workaround for the missing re…
…dis field Works around Azure/azure-rest-api-specs#22407
- Loading branch information
1 parent
e43dde9
commit 13e1776
Showing
2 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
tools/importer-rest-api-specs/components/parser/dataworkarounds/workaround_redis_22407.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters