Skip to content

feat: Add full rendering for terraform resources and data sources #106

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

Merged
merged 56 commits into from
Aug 8, 2024

Conversation

pimielowski
Copy link
Contributor

Description

Motivation and Context

How Has This Been Tested?

Screenshots (if appropriate)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes if appropriate.
  • All new and existing tests passed.

@pimielowski pimielowski marked this pull request as ready for review June 21, 2024 08:42
@pimielowski pimielowski changed the title Feat render resource second part feat: render resource second part Jun 21, 2024
@michalbil michalbil force-pushed the feat-render-resource-second-part branch from 74b4505 to b4c5f63 Compare June 26, 2024 12:24
@kklimonda-cl kklimonda-cl self-assigned this Jul 3, 2024
pimielowski and others added 25 commits July 17, 2024 16:04
The codegen config.yaml has been updated to include file sections for SDK and Terraform Provider. Additional SDK imports have been added to handle resources with hashicorp/terraform-plugin-framework. Also, commenting out the code block invoking `GenerateTerraformDataSource` is part of this commit. Moreover, a new `tools.go` file has been created under the assets/provider directory.
Updated code generation for both Terraform resources and data sources. Added configuration details for the Terraform provider. Also, other minor modifications which include adding new files, file renaming, and updating imports in several files have been made as well.
Various changes were committed across multiple files to improve the code base's cleanliness and readability. Main changes included refactoring naming conventions in the 'funcs.go' file, providing clearer and more descriptive names. Moreover, an unused import in 'tfid.go' was cleaned up, and other minor reformatting actions were performed to enhance code alignment and consistency.
A TfidStruct function was added to generate tfid structures through a function in terraform_provider/template.go. This function includes both Name and Location fields in the tfid struct. Also, EncodeLocation and DecodeLocation functions were introduced in provider_internal/tools.go to handle encoding and decoding of Locationer objects. These changes pave the way for better structure generation and data handling.
The updated code improves the generation of nested struct templates and condenses redundant code in the GenerateTerraformResource function. It introduces a helper function to create nested structures for handling parameter specifications. The revised process improves code efficiency and readability.
…terraform_provider

This commit adds several debugging messages to improve visibility during the nested structure handling in terraform_provider. It also refactors the handling of 'Params' and 'OneOf' attributes of the SpecParam object to reduce duplicated code and optimize operations.
This commit includes significant refactoring of the terraform provider related code for better readability and maintainability. This includes changes in the template structure, addition of utility functions and adjusting the existing functions accordingly. It also includes the introduction of unit tests for these functionalities.
Code changes extend the current functionality of the Terraform provider translation used for generating commit messages. New parameters were added mainly to handle attributes related to resource location, including device group, vsys, and shared. These changes facilitate better management of provider resources. Additional import statements were also added as required to support the new implementation. The ParamToModel function was renamed to ParamToModelBasic for clarity and consistency. A new helper function was introduced to combine two existing maps. Code was adjusted where necessary to accommodate these changes, to maintain logical consistency and coherence.
This commit improves code readability by implementing automated code formatting in the generation process. It also enhances schema descriptions by enclosing variables in backticks for clarity. Additionally, support for item length in provider parameters has been added. Several import statements were also included for newly introduced packages.
Code related to generating templates and writing to files has been refactored to improve readability and efficiency. Redundant code has been consolidated into new helper functions processTemplate and writeFormattedContentToFile, reducing complexity and improving maintainability. Comment descriptions have also been corrected for clarity and consistency.
The update involves changes in the generator code and the terraform provider to support dynamic creation of location structs for varying types. The generated struct will depend on the fields of the type passed to the generator. The code also modifies client type from `*pango.XmlApiClient` to `*pango.Client` across multiple files. This update enhances flexibility and coherence of the code.
The commit involved the removal of unused dependencies from our go.mod and go.sum files. This cleanup makes the project lighter and reduces the potential attack surface given by unused packages. It also potentially improves build times and makes dependency management simpler.
…neration

This commit optimizes the code generation component for Terraform providers. Changes include injecting additional functions to handle resource creation, reading, updating, and deletion. The handling of Go types to Terraform types has been moved to a separate helper function. Code formatting has been temporarily commented out, and will be reinstated after tests.
This update refactors the execution of various code templates for readability and maintainability. It also enriches the Terraform provider file generation mechanism to better handle different resource types and specifications. Furthermore, the update ensures that the generated Go code is formatted correctly, and it fine-tunes the logic for copying assets based on the command type.
Multiple struct types are renamed and added to translate structs in the `terraform_provider` package. The changes affect the `struct.go`, `terraform_provider_file.go` and `template.go` files. Also added instructions in `README.md` file for using the provider locally. Changes also include debugging information in `terraform_provider_file.go` and function renaming/updates in several places in the code.
We are already including location via ResourceSchemaLocationAttribute
function so there is no need to list it separately.
Partially done by disabling unsupported features
@kklimonda-cl kklimonda-cl mentioned this pull request Jul 29, 2024
@kklimonda-cl kklimonda-cl changed the title feat: render resource second part feat: Add full rendering for terraform resources and data sources Aug 6, 2024
@kklimonda-cl kklimonda-cl force-pushed the feat-render-resource-second-part branch from 97fa0e9 to aea8772 Compare August 6, 2024 09:06
@migara migara force-pushed the feat-render-resource-second-part branch from e84eeeb to aea8772 Compare August 8, 2024 12:53
@migara migara merged commit 70807b2 into main Aug 8, 2024
6 checks passed
@migara migara deleted the feat-render-resource-second-part branch August 8, 2024 12:53
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.

5 participants