Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ var serviceWorkarounds = []serviceWorkaround{
workaroundBlacklist{},

// Service-specific workarounds
workaroundAdministrativeUnits{},
workaroundApplicationTemplates{},
workaroundEntitlementManagementAccessPackageAccessPackageResourceRoleScope{},
workaroundEntitlementManagementRoleAssignment{},
Expand Down
Loading