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

fix: Fix provider overwriting parts of the resource that is not managed by it #145

Merged
merged 4 commits into from
Sep 6, 2024

Conversation

kklimonda-cl
Copy link
Contributor

Description

During Update() calls make sure fields from the updated entry that are not managed by
terraform are copied from the existing entry, as returned by the server.

Closes: #141

Motivation and Context

Some resource attributes can be marked as private, meaning they are not going to be exposed to users directly. For example, when creating panorama templates, entire import attribute tree is not exposed, as imports are done implicitly based on the location of the import object. This fixes a problem where subsequent terraform apply runs remove entries from the import list.

This however mean, that some of the resource data (private attributes, but also Misc generic XML) have to be somehow restored during Update() calls. This PR creates a very basic implementation that calls Read() during Update() to make sure that we have this data available.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

@kklimonda-cl kklimonda-cl changed the title bug: Fix provider overwriting parts of the resource that it's not managing fix: Fix provider overwriting parts of the resource that it's not managing Aug 29, 2024
@kklimonda-cl kklimonda-cl changed the title fix: Fix provider overwriting parts of the resource that it's not managing fix: Fix provider overwriting parts of the resource that is not managed by it Aug 29, 2024
@kklimonda-cl kklimonda-cl changed the base branch from main to feat-sdk-manager August 29, 2024 14:11
@kklimonda-cl kklimonda-cl force-pushed the feat-sdk-manager branch 2 times, most recently from ef903da to 3559991 Compare September 2, 2024 10:06
@kklimonda-cl kklimonda-cl force-pushed the feat-sdk-manager branch 2 times, most recently from cc0557a to 16d11ac Compare September 3, 2024 07:51
@kklimonda-cl kklimonda-cl force-pushed the feat-sdk-manager branch 3 times, most recently from 79dedac to 17dddfe Compare September 6, 2024 10:46
Base automatically changed from feat-sdk-manager to main September 6, 2024 11:19
Private parameters are not part of the schema, but are still managed by terraform.
Some parameters can have codegen override set to skip parameter in terraform
provider - this can be used for example when rendering panorama templates to
skip attributes related to importing - import is done implicitly when creating
other resources.

Due to that care has to be taken to make sure those private fields are still
copied to pango structures for the update, otherwise Update() call will end
up removing them.

This implementation follows the old provider, by reading existing entries from
the server during Update() call in the provider, and only copying data that
is known to the provider, leaving everything else intact.
@kklimonda-cl kklimonda-cl merged commit 30148fc into main Sep 6, 2024
3 checks passed
@kklimonda-cl kklimonda-cl deleted the bug-panos-template-imports branch September 6, 2024 11:35
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.

panos_panorama_template removes interface import entries during update
2 participants