Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

importer-msgraph-metadata: workaround to remove nonexistent administrativeunit resources in the beta API, since these actually exist in their own service #4450

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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