Skip to content

Commit

Permalink
Merge pull request #2876 from hashicorp/f/automation-workaround-25108
Browse files Browse the repository at this point in the history
`tools/importer-rest-api-specs`: adding a workaround for automation until the upstream PR is merged
  • Loading branch information
tombuildsstuff authored Aug 2, 2023
2 parents 0e90796 + 57d0912 commit d0b4d9f
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package dataworkarounds

import (
"fmt"

"github.com/hashicorp/pandora/tools/importer-rest-api-specs/models"
)

var _ workaround = workaroundAutomation25108{}

type workaroundAutomation25108 struct {
}

func (workaroundAutomation25108) IsApplicable(apiDefinition *models.AzureApiDefinition) bool {
return apiDefinition.ServiceName == "Automation" && apiDefinition.ApiVersion == "2022-08-08"
}

func (workaroundAutomation25108) Name() string {
return "Automation / 25108"
}

func (workaroundAutomation25108) Process(apiDefinition models.AzureApiDefinition) (*models.AzureApiDefinition, error) {
resource, ok := apiDefinition.Resources["ListAllHybridRunbookWorkerGroupInAutomationAccount"]
if !ok {
return nil, fmt.Errorf("expected a Resource named `ListAllHybridRunbookWorkerGroupInAutomationAccount`")
}
operation, ok := resource.Operations["HybridRunbookWorkerGroupDelete"]
if !ok {
return nil, fmt.Errorf("expected an Operation named `HybridRunbookWorkerGroupDelete`")
}

otherResource, ok := apiDefinition.Resources["HybridRunbookWorkerGroup"]
if !ok {
return nil, fmt.Errorf("expected a Resource named `HybridRunbookWorkerGroup`")
}
if _, hasExisting := otherResource.Operations["Delete"]; hasExisting {
return nil, fmt.Errorf("an existing `Delete` operation exists for `HybridRunbookWorkerGroup`")
}
otherResource.Operations["Delete"] = operation

apiDefinition.Resources["HybridRunbookWorkerGroup"] = otherResource
delete(apiDefinition.Resources, "ListAllHybridRunbookWorkerGroupInAutomationAccount")

return &apiDefinition, nil
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

var workarounds = []workaround{
workaroundAuthorization25080{},
workaroundAutomation25108{},
workaroundBatch21291{},
workaroundContainerService21394{},
workaroundDataFactory23013{},
Expand Down

0 comments on commit d0b4d9f

Please sign in to comment.