-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2876 from hashicorp/f/automation-workaround-25108
`tools/importer-rest-api-specs`: adding a workaround for automation until the upstream PR is merged
- Loading branch information
Showing
2 changed files
with
46 additions
and
0 deletions.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
.../importer-rest-api-specs/components/parser/dataworkarounds/workaround_automation_25108.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,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 | ||
} |
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