pulumi/tests/integration
bors[bot] 7a173bedac
Merge #11456
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>
2022-12-13 20:37:38 +00:00
..
about ci: Simplify test listing, update go dependencies to 1.18 compat 2022-09-21 09:51:59 -07:00
aliases Improve ProgramTest errors and path handling for Go programs 2022-12-13 06:53:09 -08:00
cloud_secrets_provider Enable full strict mode. (#3218) 2019-09-11 16:21:35 -07:00
component_provider_schema ci: Simplify test listing, update go dependencies to 1.18 compat 2022-09-21 09:51:59 -07:00
config_basic ci: Simplify test listing, update go dependencies to 1.18 compat 2022-09-21 09:51:59 -07:00
config_capture_e2e/nodejs Changing build.proj to run all languages and tests on windows 2020-01-27 21:16:37 +02:00
config_secrets_warn ci: Simplify test listing, update go dependencies to 1.18 compat 2022-09-21 09:51:59 -07:00
construct_component Phase 3 of the convert mapper 2022-12-01 23:43:43 +00:00
construct_component_error_apply Fix a hang in nodejs remote components when an error is thrown within an apply (#7365) 2021-06-25 18:41:54 -07:00
construct_component_methods Engine and Golang support for shimless providers 2022-11-14 11:25:41 +00:00
construct_component_methods_errors Engine and Golang support for shimless providers 2022-11-14 11:25:41 +00:00
construct_component_methods_resources Engine and Golang support for shimless providers 2022-11-14 11:25:41 +00:00
construct_component_methods_unknown Engine and Golang support for shimless providers 2022-11-14 11:25:41 +00:00
construct_component_output_values Engine and Golang support for shimless providers 2022-11-14 11:25:41 +00:00
construct_component_plain Phase 3 of the convert mapper 2022-12-01 23:43:43 +00:00
construct_component_provider Engine and Golang support for shimless providers 2022-11-14 11:25:41 +00:00
construct_component_slow ci: Simplify test listing, update go dependencies to 1.18 compat 2022-09-21 09:51:59 -07:00
construct_component_unknown Phase 3 of the convert mapper 2022-12-01 23:43:43 +00:00
construct_nested_component/go chore: Update dependencies 2022-12-10 14:26:14 -08:00
custom_timeouts ci: Use reduced smoke testing on Windows & macOS targets 2022-09-21 09:55:06 -07:00
delete_before_create ci: Use reduced smoke testing on Windows & macOS targets 2022-09-21 09:55:06 -07:00
dependency_steps ci: Use reduced smoke testing on Windows & macOS targets 2022-09-21 09:55:06 -07:00
double_pending_delete Do not execute pending deletes at the start of deployment 2022-10-14 15:52:13 +01:00
duplicate_urns ci: Use reduced smoke testing on Windows & macOS targets 2022-09-21 09:55:06 -07:00
dynamic Lower the BrokenDynamicProvider regression test from integration to mock (#7951) 2021-09-10 17:25:48 -04:00
ee_perf Use prefered `new pulumi.Config()` form 2019-01-31 16:11:57 -08:00
empty ci: Simplify test listing, update go dependencies to 1.18 compat 2022-09-21 09:51:59 -07:00
enums Fix non-determinism in Python dynamic provider serialization (#9656) 2022-05-22 20:15:29 -07:00
exclude_protected Implement the --exclude-protected feature (#8359) 2021-11-15 11:45:14 -08:00
explicit_provider Enable full strict mode. (#3218) 2019-09-11 16:21:35 -07:00
gather_plugin ci: Move several tests out of smoke test jobs 2022-11-03 18:23:02 -07:00
get_created Enable full strict mode. (#3218) 2019-09-11 16:21:35 -07:00
get_resource ci: Simplify test listing, update go dependencies to 1.18 compat 2022-09-21 09:51:59 -07:00
go [yaml] Update Pulumi YAML to v0.5.8 2022-09-26 17:19:57 -07:00
invalid_package_json Enable full strict mode. (#3218) 2019-09-11 16:21:35 -07:00
large_resource ci: Simplify test listing, update go dependencies to 1.18 compat 2022-09-21 09:51:59 -07:00
nodejs chore: add new test case for esm-loading with a srcdir 2022-12-13 02:28:42 +00:00
partial_state ci: Use reduced smoke testing on Windows & macOS targets 2022-09-21 09:55:06 -07:00
partial_values Propagate inputs to outputs during preview. (#3327) 2019-11-11 12:09:34 -08:00
policy ci: gofmt 1.18+ clean 2022-09-21 09:48:39 -07:00
printf ci: Simplify test listing, update go dependencies to 1.18 compat 2022-09-21 09:51:59 -07:00
project_main Add a 'main' test for golang 2022-09-22 14:46:48 +01:00
project_main_abs Enable absolute and relative parent paths for pulumi main (#6734) 2021-04-08 21:39:52 -07:00
project_main_parent/foo Enable absolute and relative parent paths for pulumi main (#6734) 2021-04-08 21:39:52 -07:00
protect_resources ci: Use reduced smoke testing on Windows & macOS targets 2022-09-21 09:55:06 -07:00
provider_secret_config Enable full strict mode. (#3218) 2019-09-11 16:21:35 -07:00
python fix: handle exception for main not found in python (#10617) 2022-09-07 08:42:38 -07:00
python_await [sdk/python] - Await all async tasks (#6606) 2021-03-30 10:56:17 -07:00
query ci: Use reduced smoke testing on Windows & macOS targets 2022-09-21 09:55:06 -07:00
read ci: Use reduced smoke testing on Windows & macOS targets 2022-09-21 09:55:06 -07:00
recreate_resource_check ci: Use reduced smoke testing on Windows & macOS targets 2022-09-21 09:55:06 -07:00
refresh/go Fix regression validating project files with `refresh: always` set 2022-09-22 11:51:54 -07:00
rotate_passphrase ci: Simplify test listing, update go dependencies to 1.18 compat 2022-09-21 09:51:59 -07:00
secret_outputs [sdk/python] Fix secret regression (#5496) 2020-10-01 14:57:51 -07:00
single_resource Suppress JSON outputs in preview correctly (#2771) 2019-05-25 12:10:38 +02:00
stack_bad_parenting Consistent dependencies (#2517) 2019-03-05 20:34:51 -08:00
stack_component dotnet program-gen now targets .NET 6 (#10143) 2022-07-21 21:04:02 +02:00
stack_dependencies Remove existing lock files 2018-11-12 15:33:58 -08:00
stack_outputs dotnet program-gen now targets .NET 6 (#10143) 2022-07-21 21:04:02 +02:00
stack_parenting Consistent dependencies (#2517) 2019-03-05 20:34:51 -08:00
stack_project_name Actually fix the naming test (#10554) 2022-08-31 20:52:23 +01:00
stack_reference [yaml] Update Pulumi YAML to v0.5.8 2022-09-26 17:19:57 -07:00
stack_reference_multi/python Regression tests for StackReference in the Python SDK (#3913) 2020-02-17 10:40:46 -08:00
stack_reference_secrets Make getOrganization total, default to 'organization' 2022-09-22 11:06:51 -07:00
steps ci: Use reduced smoke testing on Windows & macOS targets 2022-09-21 09:55:06 -07:00
targets ci: Use reduced smoke testing on Windows & macOS targets 2022-09-21 09:55:06 -07:00
transformations ci: Use reduced smoke testing on Windows & macOS targets 2022-09-21 09:55:06 -07:00
tsconfig Add tsconfig option to specify tsconfig path (#8452) 2021-11-22 11:42:39 -08:00
types ci: Use reduced smoke testing on Windows & macOS targets 2022-09-21 09:55:06 -07:00
unsafe_snapshot_tests/bad_resource Update tests/integration/unsafe_snapshot_tests/bad_resource/resource.ts 2022-09-15 08:00:36 -07:00
.gitignore ci: Enable async component builds 2022-09-14 10:06:05 -07:00
appdash_test.go Add trace proxying to fix sub-process trace collection into files (#7248) 2021-06-10 22:57:18 -04:00
component_setup.sh Engine and Golang support for shimless providers 2022-11-14 11:25:41 +00:00
integration_dotnet_smoke_test.go ci: Move several tests out of smoke test jobs 2022-11-03 18:23:02 -07:00
integration_dotnet_test.go ci: Move several tests out of smoke test jobs 2022-11-03 18:23:02 -07:00
integration_go_smoke_test.go ci: Move several tests out of smoke test jobs 2022-11-03 18:23:02 -07:00
integration_go_test.go test: use T.TempDir to create temporary test directory 2022-12-03 15:17:08 +08:00
integration_nodejs_smoke_test.go ci: Move several tests out of smoke test jobs 2022-11-03 18:23:02 -07:00
integration_nodejs_test.go created initial test 2022-12-12 11:33:57 -08:00
integration_python_smoke_test.go fix(testing): Adds cached python venvs for integration tests 2022-12-06 13:57:07 -05:00
integration_python_test.go ci: Move several tests out of smoke test jobs 2022-11-03 18:23:02 -07:00
integration_smoke_test.go ci: Move several tests out of smoke test jobs 2022-11-03 18:23:02 -07:00
integration_test.go ci: Move several tests out of smoke test jobs 2022-11-03 18:23:02 -07:00
integration_util_test.go ci: Move several tests out of smoke test jobs 2022-11-03 18:23:02 -07:00