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

Created ACI converter tool #1263

Closed
wants to merge 8 commits into from
Closed

Conversation

harismalk
Copy link
Collaborator

@harismalk harismalk commented Jul 30, 2024

No description provided.

@harismalk harismalk requested a review from akinross July 30, 2024 03:24
@harismalk harismalk changed the title Updated Terraform Plan to ACI Payload converter Added functionality for nested objects of resources. Jul 30, 2024
@@ -488,7 +488,7 @@ func setFvEpIpTagId(ctx context.Context, data *FvEpIpTagResourceModel) {
data.Id = types.StringValue(fmt.Sprintf("%s/%s", data.ParentDn.ValueString(), rn))
}

func getFvEpIpTagTagAnnotationChildPayloads(ctx context.Context, diags *diag.Diagnostics, data *FvEpIpTagResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationFvEpIpTagResourceModel) []map[string]interface{} {
func GetFvEpIpTagTagAnnotationChildPayloads(ctx context.Context, diags *diag.Diagnostics, data *FvEpIpTagResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationFvEpIpTagResourceModel) []map[string]interface{} {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If these need to be exposed as global functions we should change the generator logic. I see a few options.

  1. We could make them public by capitalising the functions.
  2. We can create a separate package for public functions which we expose and then import in the current codebase and any support tools.

main.go Outdated Show resolved Hide resolved
current_draft.go Outdated Show resolved Hide resolved
current_draft.go Outdated
Comment on lines 863 to 866
jsonFile, err := runTerraformCommands()
if err != nil {
log.Fatalf("Error running Terraform commands: %v", err)
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this done always? I thought this would be an offline tool first which does translation only of generated plan file / state? Should we have a file input into this tool?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is done to automate processes for testing on my end, which I use Terraform commands for. I will change this once testing is complete.

log.Fatalf("Error parsing input file: %v", err)
}

itemList := processResources(terraformPlan)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would probably rename the variable and the function to clarify a bit better what the function is doing and returning

Type string `json:"type"`
Change struct {
Actions []string `json:"actions"`
Before map[string]interface{} `json:"before"`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we interested in the before to generate a plan?

Address string `json:"address"`
Type string `json:"type"`
Change struct {
Actions []string `json:"actions"`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we interested in the actions or just if something is deleted?

}

type ResourceChange struct {
Address string `json:"address"`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what do we use the address for?


type Resource struct {
Type string `json:"type"`
Name string `json:"name"`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do we use the Name for in the resource?

return item
}

func createChildrenFromAttributes(attributes map[string]interface{}) []map[string]Item {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are these children hardcoded?

@harismalk harismalk changed the title Added functionality for nested objects of resources. Created ACI converter tool Aug 8, 2024
@harismalk harismalk closed this Aug 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants