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
Pulumi Should retain comments in Stack Config #5235
Comments
@JasonWhall Can you confirm which version of the |
@lukehoban - Apologies I've just re-tested this and the issue only occurs when using the stack has a I'm using latest Pulumi CLI I've also updated the steps to reproduce to reflect this. |
@stack72 is this something we can return back to pre- |
Any update on this one? I've used comments in the stack files to annotate the Azure subscription IDs with their names, and was disappointed to find that all lost as soon as I ran a |
Hmm, we use the Pulumi |
Still an issue with 3.4.0. Pulumi also likes to reformat the file even when there are no changes, which is annoying if you have a prettier pre-commit hook. |
Any chance this can be picked up soon? It is extremely annoying if you actually use stack configs :( |
Was suggested today to see about bringing #6489 up to date and giving that another try which would fix this issue. |
11456: Implement YAML roundtripping, comment preserving edits r=AaronFriel a=AaronFriel By caching a copy of the raw bytes of the original loaded document - project, policy project, or stack - on save we: * Unmarshal the original bytes to a YAML AST * Recursively edit nodes of the document to match the values of the value we're saving, preserving trivia * Marshal the modified AST to []byte Closes #423, as we don't support comments in JSON presently (not using "JSON5") Closes #5235 Simplifies work done in #10797 and #10437 which used the previous `yamlutil` package to edit AST nodes directly. # Automation API Integration with automation API requires that operations either perform a "read-modify-write" in a single operation, or use a side channel to allow subsequent "read" (select stack?) and "write" operations to keep state of the original file. However I don't expect this to be needed. We don't have a reason to believe automation API users maintain comments in particular stack files, and doing so is already unsupported in automation scenarios. The Pulumi Service does not persist raw config files, thus `pulumi config refresh` and `CreateOrSelectStack` create config files without comments. n.b.: If you test this, due to the new behavior of this PR, `pulumi config refresh` will persist comments if there is an existing config file. I would expect automation API using local file workspaces to behave similarly. When using these tools to create a config file from the last deployment's definition, the file is created restored without comments. # Tradeoffs I believe that this closes #423 in spirit, but doesn't strictly implement round-tripping. There are a couple reasons for this. ## Marshaller interface and round-tripping simplification decisions We support unmarshaling "simplified" YAML, including allowing: ```yaml runtime: yaml # this unmarshals to a struct, not a scalar value config: someKey: "someScalar" # likewise ``` These simplifications make it much more difficult, the `Marshal` operation would _also_ need context of decisions made when unmarshaling to ensure a bijection. Otherwise we may save one of these as the other: ```yaml runtime: name: yaml ``` ```yaml runtime: yaml ``` This could be considered a feature, as it enforces a style guide - the decisions implemented in our custom `Marshaller` implementations become the style enforced on save. That said, I believe the new `Edit` API while not round-trippable, does reach a fixed point after one save through the new API. Once saved with this API, subsequent loads & saves without changes are idempotent. ## Indentation The YAML library uses a global indentation when marshaling values to YAML, as opposed to indentation being a property of AST nodes. This means we may lose other indentation. Co-authored-by: Aaron Friel <mayreply@aaronfriel.com>
When running Pulumi commands like
pulumi up
orpulumi preview
when using Azure KeyVault as it's Secrets Provider for the selected stac, comments in the relevant config file are removed. It would be useful to retain these comments as config files could be edited by hand and checked into source control with these comments to provide information to other users about the reasoning for the config value. When not using the--secrets-provider
flag. Runningpulumi
commands retain comments in the config as expected.Example stack config file
pulumi.<stack>.yaml
:Expected Behavior
Comments should be retained in the config file as these could contain useful information that refers to config values
Current Behavior
All comments are removed from config
Steps to Reproduce
pulumi new csharp
pulumi.dev.yaml
file and add a commentpulumi up
and comments will be removedThe text was updated successfully, but these errors were encountered: