-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
importer-msgraph-metadata: workaround for group/UpdateGroup method wh…
…ich also returns 200
- Loading branch information
1 parent
54bc54d
commit dfdc63a
Showing
2 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
tools/importer-msgraph-metadata/components/workarounds/workaround_service_groups.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,51 @@ | ||
// Copyright (c) HashiCorp, Inc. | ||
// SPDX-License-Identifier: MPL-2.0 | ||
|
||
package workarounds | ||
|
||
import ( | ||
"fmt" | ||
"slices" | ||
|
||
"github.com/hashicorp/go-azure-helpers/lang/pointer" | ||
"github.com/hashicorp/pandora/tools/importer-msgraph-metadata/components/parser" | ||
) | ||
|
||
var _ serviceWorkaround = workaroundGroups{} | ||
|
||
// workaroundGroups adds a missing GET method for synchronization secrets, which is absent from upstream specs. | ||
type workaroundGroups struct{} | ||
|
||
func (workaroundGroups) Name() string { | ||
return "Groups / set correct response status codes" | ||
} | ||
|
||
func (workaroundGroups) Process(apiVersion, serviceName string, resources parser.Resources, resourceIds parser.ResourceIds) error { | ||
if serviceName != "groups" { | ||
return nil | ||
} | ||
|
||
resource, ok := resources["Group"] | ||
if !ok { | ||
return fmt.Errorf("`Group` resource was not found for the `groups` service") | ||
} | ||
|
||
for i := range resource.Operations { | ||
if resource.Operations[i].Name == "UpdateGroup" { | ||
statusesFromSpec := make([]int, 0, len(resource.Operations[i].Responses)) | ||
for j := range resource.Operations[i].Responses { | ||
statusesFromSpec = append(statusesFromSpec, resource.Operations[i].Responses[j].Status) | ||
} | ||
|
||
if !slices.Contains(statusesFromSpec, 200) { | ||
resource.Operations[i].Responses = append(resource.Operations[i].Responses, parser.Response{ | ||
Status: 200, | ||
ContentType: pointer.To("application/json"), | ||
}) | ||
} | ||
break | ||
} | ||
} | ||
|
||
return 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