-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
support migrating resources from azurerm to azapi provider
- Loading branch information
Showing
20 changed files
with
1,698 additions
and
1,156 deletions.
There are no files selected for viewing
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
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
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,44 @@ | ||
package cmd_test | ||
|
||
import tfjson "github.com/hashicorp/terraform-json" | ||
|
||
type Action string | ||
|
||
const ( | ||
ActionCreate Action = "create" | ||
ActionReplace Action = "replace" | ||
ActionUpdate Action = "update" | ||
ActionDelete Action = "delete" | ||
) | ||
|
||
// Actions denotes a valid change type. | ||
type Actions []Action | ||
|
||
func GetChanges(plan *tfjson.Plan) []Action { | ||
if plan == nil { | ||
return []Action{} | ||
} | ||
actions := make([]Action, 0) | ||
for _, change := range plan.ResourceChanges { | ||
if change.Change != nil { | ||
if len(change.Change.Actions) == 0 { | ||
continue | ||
} | ||
if len(change.Change.Actions) == 1 { | ||
switch change.Change.Actions[0] { | ||
case tfjson.ActionCreate: | ||
actions = append(actions, ActionCreate) | ||
case tfjson.ActionDelete: | ||
actions = append(actions, ActionDelete) | ||
case tfjson.ActionUpdate: | ||
actions = append(actions, ActionUpdate) | ||
case tfjson.ActionNoop: | ||
case tfjson.ActionRead: | ||
} | ||
} else { | ||
actions = append(actions, ActionReplace) | ||
} | ||
} | ||
} | ||
return actions | ||
} |
Oops, something went wrong.