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

feat: Render config.go (first stage) and improvements in rendering entry.go #35

Merged
merged 71 commits into from
Apr 2, 2024

Conversation

sebastianczech
Copy link
Contributor

@sebastianczech sebastianczech commented Mar 15, 2024

Description

PR delivers generation of config.go (first stage) for objects, which are not entries (like NTP settings).

Moreover it introduces improvements in rendering entry.go:

  • improve rendering of nested structs
  • introduce versioning of structs and params (dependent from profiles)

Motivation and Context

How Has This Been Tested?

Automated tests are part of PR.

Moreover entry.go generated for address and service was checked directly with the firewall in the cloud.

Types of changes

  • New feature (non-breaking change which adds functionality)

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.

… the issues from `golangci-lint run --enable-all`
# Conflicts:
#	pkg/translate/funcs.go
@sebastianczech
Copy link
Contributor Author

sebastianczech commented Mar 25, 2024

During review, please take a look especially on:

Note - currently that function is also generating functions to compare int- can I take file https://github.com/PaloAltoNetworks/pango/blob/develop/util/comparison.go , put it as static assets and do not create specific function for that, use new function from util ? Copying static files is working and it was delivered in #29.

@sebastianczech sebastianczech marked this pull request as ready for review March 25, 2024 20:00
@pimielowski pimielowski self-requested a review April 2, 2024 10:09
Copy link
Contributor

@pimielowski pimielowski left a comment

Choose a reason for hiding this comment

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

After internal testing I found some issue which was resolved by @sebastianczech here:
0235c2a
52d26ef

Overall very great approach!
We agreed to push forward with known issues:

  • tags color (to be defined based on the separated struct, in tag.yaml it is implemented already)
  • function in entry.tmpl MarshalXML currently if we specified version to the ie fqdn_refresh_time parameter in struct/dns.yaml it will generate with attribute related to the versioned struct, which in summary create missing parameter (because MarshalXML is c configXML where this variable don't exists)

Also, there was an topic related to the duplication in generated code, and to handle this case after some testing I found 2 solution we can try:

  • use Reflect library to create complex dynamic structure
  • use a lot of custom logic with struct merges

either of this approaches could take a long time to figure it out the best approach, so we agreed that we will move forward with that approach that we have right now, and we tackle this issue later.

@sebastianczech sebastianczech merged commit 49457a5 into main Apr 2, 2024
2 checks passed
@sebastianczech sebastianczech deleted the render-config branch April 2, 2024 16:18
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