Skip to content

Commit

Permalink
Merge pull request #3576 from hashicorp/f/common-id-for-bot-service
Browse files Browse the repository at this point in the history
`tools/importer-rest-api-specs`: detecting the Common IDs for Bot Service
  • Loading branch information
tombuildsstuff authored Jan 10, 2024
2 parents a175e74 + 6cc58c6 commit 1f3faf6
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package resourceids

import (
"github.com/hashicorp/pandora/tools/importer-rest-api-specs/models"
"github.com/hashicorp/pandora/tools/sdk/resourcemanager"
)

var _ commonIdMatcher = commonIdBotService{}

type commonIdBotService struct{}

func (commonIdBotService) id() models.ParsedResourceId {
name := "BotService"
return models.ParsedResourceId{
CommonAlias: &name,
Constants: map[string]resourcemanager.ConstantDetails{},
Segments: []resourcemanager.ResourceIdSegment{
models.StaticResourceIDSegment("staticSubscriptions", "subscriptions"),
models.SubscriptionIDResourceIDSegment("subscriptionId"),
models.StaticResourceIDSegment("staticResourceGroups", "resourceGroups"),
models.ResourceGroupResourceIDSegment("resourceGroupName"),
models.StaticResourceIDSegment("staticProviders", "providers"),
models.ResourceProviderResourceIDSegment("staticMicrosoftBotService", "Microsoft.BotService"),
models.StaticResourceIDSegment("staticBotServices", "botServices"),
models.UserSpecifiedResourceIDSegment("botServiceName"),
},
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package resourceids

import (
"github.com/hashicorp/pandora/tools/importer-rest-api-specs/models"
"github.com/hashicorp/pandora/tools/sdk/resourcemanager"
)

var _ commonIdMatcher = commonIdBotServiceChannel{}

type commonIdBotServiceChannel struct{}

func (commonIdBotServiceChannel) id() models.ParsedResourceId {
name := "BotServiceChannel"
return models.ParsedResourceId{
CommonAlias: &name,
Constants: map[string]resourcemanager.ConstantDetails{},
Segments: []resourcemanager.ResourceIdSegment{
models.StaticResourceIDSegment("staticSubscriptions", "subscriptions"),
models.SubscriptionIDResourceIDSegment("subscriptionId"),
models.StaticResourceIDSegment("staticResourceGroups", "resourceGroups"),
models.ResourceGroupResourceIDSegment("resourceGroupName"),
models.StaticResourceIDSegment("staticProviders", "providers"),
models.ResourceProviderResourceIDSegment("staticMicrosoftBotService", "Microsoft.BotService"),
models.StaticResourceIDSegment("staticBotServices", "botServices"),
models.UserSpecifiedResourceIDSegment("botServiceName"),
models.StaticResourceIDSegment("staticChannels", "channels"),
models.ConstantResourceIDSegment("channelType", "BotServiceChannelType"),
},
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,18 @@ var commonIdTypes = []commonIdMatcher{
commonIdAutomationCompilationJob{}, // (@stephybun) CompilationJobId segment is defined in three different ways `jobId`, `compilationJobId` and `compilationJobName`
commonIdProvisioningService{}, // (@jackofallops): Inconsistent user specified fields in the swagger - `provisioningServices/{resourceName}` vs `provisioningServices/{provisioningServiceName}`

// Bot Service
commonIdBotService{},
commonIdBotServiceChannel{},

// Compute
commonIdAvailabilitySet{},
commonIdDedicatedHost{},
commonIdDedicatedHostGroup{},
commonIdDiskEncryptionSet{},
commonIdManagedDisk{},

// HDInsight
// HDInsight
commonIdHDInsightCluster{},


Expand All @@ -73,7 +77,7 @@ var commonIdTypes = []commonIdMatcher{
commonIdSqlManagedInstanceDatabase{},
commonIdSqlServer{},

// Spring Cloud
// Spring Cloud
commonIdSpringCloudService{},

// Storage
Expand Down
7 changes: 4 additions & 3 deletions tools/importer-rest-api-specs/models/resource_ids.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,10 @@ func (pri ParsedResourceId) Matches(other ParsedResourceId) bool {
if first.ConstantReference == nil && second.ConstantReference != nil {
return false
}
if first.ConstantReference != nil && second.ConstantReference != nil && *first.ConstantReference != *second.ConstantReference {
return false
}

// We're intentionally not checking the constants involved, since both the name and values could differ
// between different operations due to data issues - however when either happens we'd end up using a
// Common ID to resolve this - therefore presuming the rest of the Resource ID matches we should be good.

continue
}
Expand Down

0 comments on commit 1f3faf6

Please sign in to comment.