-
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 to remove nonexistent `administ…
…rativeunit` resources in the beta API, since these actually exist in their own service
- Loading branch information
1 parent
f93bb90
commit ffd3a71
Showing
2 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
tools/importer-msgraph-metadata/components/workarounds/workaround_administrativeunits.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,44 @@ | ||
// Copyright (c) HashiCorp, Inc. | ||
// SPDX-License-Identifier: MPL-2.0 | ||
|
||
package workarounds | ||
|
||
import ( | ||
"strings" | ||
|
||
"github.com/hashicorp/pandora/tools/importer-msgraph-metadata/components/parser" | ||
"github.com/hashicorp/pandora/tools/importer-msgraph-metadata/components/versions" | ||
) | ||
|
||
var _ serviceWorkaround = workaroundAdministrativeUnits{} | ||
|
||
// workaroundAdministrativeUnits removes nonexistent `AdministrativeUnit` resources from the `Directory` service in | ||
// the beta API, as these resources exist in the `administrativeUnits` service for this API version. | ||
type workaroundAdministrativeUnits struct{} | ||
|
||
func (workaroundAdministrativeUnits) Name() string { | ||
return "Administrative Units / remove nonexistent resources" | ||
} | ||
|
||
func (workaroundAdministrativeUnits) Process(apiVersion, serviceName string, resources parser.Resources, resourceIds parser.ResourceIds) error { | ||
if apiVersion != versions.ApiVersionBeta { | ||
return nil | ||
} | ||
|
||
if serviceName != "directory" { | ||
return nil | ||
} | ||
|
||
resourcesToDelete := make([]string, 0) | ||
for resourceName := range resources { | ||
if strings.HasPrefix(resourceName, "DirectoryAdministrativeUnit") { | ||
resourcesToDelete = append(resourcesToDelete, resourceName) | ||
} | ||
} | ||
|
||
for _, resourceName := range resourcesToDelete { | ||
delete(resources, resourceName) | ||
} | ||
|
||
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