I got fed up of assert errors in tests that looked like:
```
Expected nil, but got: &result.simpleResult{err:(*errors.fundamental)(0xc0002fa5d0)}
```
It was very hard to work out at a glance what had gone wrong and I kept
having to hook a debugger just to look at what the error was.
With GoString these now print something like:
```
Expected nil, but got: &simpleResult{err: Unexpected diag message: <{%reset%}>resource violates plan: properties changed: -zed, -baz, -foo<{%reset%}>
}
```
Which is much more useful.
* Add test case
* Fix tests
* Add test dependencies correctly
* Feed through error handling
* Include test output
* Get types to line up
* Add remaining test files
* Update changelog
* Correctly find type paths
* Handle transitive objects
* Handle required fields
* Add feature flag for go
* Add required+default test case
* Don't `<any>` cast known types.
* Add more flags.
I realize this should really wait for PR#8400 to merge.
* Add plain object to env-helper test
This test fails right now. My next problem is fixing it.
* Handle plain types
* Handle function inputs
* Fix the indentation
* Handle output types correctly
* Remove unnecessary `!`
* Add test case
* Fix tests
* Add test dependencies correctly
* Feed through error handling
* Include test output
* Get types to line up
* Add remaining test files
* Update changelog
* Correctly find type paths
* Handle transitive objects
* Handle required fields
* Add required+default test case
* Don't `<any>` cast known types.
* Add plain object to env-helper test
This test fails right now. My next problem is fixing it.
* Handle plain types
* Handle function inputs
* Fix the indentation
* Handle output types correctly
* Remove unnecessary `!`
* Start on `genPlainObjectDefaultFunc`
* Add missing change to fix test
* Run tests with merge
* Refactor out assign
* Merge in next _index.md diff
* Change method name to `Defaults`
* Handle enums correctly
* Another attempt at _index.md
* Make module generation deterministic
* Add checks for old values
* Insert defaults in resources
* Fix docs generation
Credit to @praneetloke
* Progress on adding defaults to Resource arguments
* Handle resource argument defaults
* Don't create defaults if disableObjectDefaults
* Rename test folder
* Add test for disable flag
* Fix disable test
* Update docs
* Abstract out nil comparisons
* Use reflection to test for empty values
* Simplify Ptr and pulumi.Any type handling
* Remove unused function
* Apply defaults to functions
* Update new test with master codegen
* Tests + nil check
These changes remove the `Ptr` variants of input/ouptut types for
resources. A `TPtr` input or output is normally generated for `T` if `T`
is present in an `optional(input(T))` or `optional(output(T))` and if
the Go representation for `T` is not nilable. The generation of `Ptr`
variants for resource types breaks the latter rule: the canonical
representation of a resource type named `Foo` is a pointer to a struct
type named `Foo` (i.e. `*Foo`). `Foo` itself is not a resource, as it
does not implement the Go `Resource` interface. Because this
representation already accommodates `nil` to indicate the lack of a
value, we need not generate `FooPtr{Input,Output}` types.
Besides being unnecessary, the implementation of `Ptr` types for
resources was incorrect. Rather than using `**Foo` as their element
type, these types use `*Foo`--identical to the element type used for
the normal input/output types. Furthermore, the generated code for
at least `FooOutput.ToFooPtrOutputWithContext` and `FooPtrOutput.Elem`
was incorrect, making these types virtually unusable in practice.
Finally, these `Ptr` types should never appear on input/output
properties in practice, as the logic we use to generate input and output
type references never generates them for `optional({input,output}(T)).
Instead, it generates references to the standard input/output types.
Though this is _technically_ a breaking change--it changes the set of
exported types for any package that defines resources--I believe that in
practice it will be invisible to users for the reasons stated above.
These types are not usable, and were never referenced.
This is preparatory work for #7943.
* Allow specifying a branch with url#branch
* Probe for master and main
* Update CHANGELOG
* Fix linter errors
* Remove unnecessary feature
* Fix lint
* Update changelog to reflect new limited scope.
We only talk about the master -> main probing, because that is all the
PR does. It used to duplicate another feature.
* Modify Go codegen for fn.Output overloads
* Fix go tests
* Fixed CHANGELOG conflict
* ACCEPT changes reverting Fargate example to master, file issue
* Link an issue
* Add test case
* Fix tests
* Add test dependencies correctly
* Feed through error handling
* Include test output
* Get types to line up
* Add remaining test files
* Update changelog
* Correctly find type paths
* Handle transitive objects
* Handle required fields
* Add required+default test case
* Don't `<any>` cast known types.
* Add plain object to env-helper test
This test fails right now. My next problem is fixing it.
* Handle plain types
* Handle function inputs
* Fix the indentation
* Handle output types correctly
* Remove unnecessary `!`
* Add missing change to fix test
* Run tests with merge
* Merge in next _index.md diff
* Another attempt at _index.md
* Make module generation deterministic
* Fix docs generation
Credit to @praneetloke
* Teach PCL about fnOutput forms
* Teach PCL about fnOutput forms
* Teach Node program gen to emit fnOutput forms
* TypeCheck fix
* AWS package bump
* Add tests
* CHANGELOG
* Temporarily skip non-Node affected tests
* Address PR feedback: restrict new form to Output args only
* Update command respects `--target-dependents`
* Update CHANGELOG_PENDING.md
* Depend on parent and provider
* Add tests for new feature
* Separate predicate and mutation in code
* Remove `targetDependentsForUpdate`
* Refactor `isTargetedForUpdate`
* Add very important nil check
And update the metaschema to accommodate the `isOverlay` properties
added in #8338. Overlay enums, like other overlay members, are
implemented out-of-band by the declaring package. Code generators should
not generate declarations for overlay enums.
We have seen cases where a lot of errors like this are reported:
```
UnboundLocalError: local variable 'resources' referenced before assignment
```
This change prevents this failure mode, which might be a symptom of some
other issue, but currently obscures it in the error path.
- [sdk/nodejs] - Allow returning failures from Call in the provider without setting result outputs.
- [sdk/go] - Allow specifying Call failures from the provider.
- Add tests that return failures from Call.
* Implement the --exclude-protected feature
This piggybacks on the same machinery used by the --target flag. By
examining the stack, we find a list of all resources managed by
Pulumi (in that stack). We then form them into a DAG, and mark all
resources as either protected or unprotected.
A resource is protected it has the `Protect` flag set or is has a child
with the `protect` flag set. It is unprotected otherwise.
We then pass the urns of unprotected resources to the update options
passed to the destroy operation in the same way that `--target` does.
* Update changelog
* Handle providers correctly
* Add integration test
* Protect dependencies of protected resources
* Handle --exclude-protected in separate function
* Simplify implementation via DependencyGraph
* Add TransitiveDependenciesOf
* Cleanup unused functions
* Gate printed message behind !jsonDisplay
* Ensure provider is not `""`
* Clean up documentation (and some code)
* Added a buildkite detector for detecting the correct env vars in CI
* adding pending changelog entry
* fixed PR logic to actually match the Buildkite Docs and simplified if statement, Fixed a few typos in comments and added PR to CHANGELOG_PENDING.md
* made PR number fetch easier to read
* fixing typo in comment
* Fix issue with --target deletion dependant calculation
The code that computed --target deletion dependants was not correct.
It used parent/child component relationships, but did not respect actual
DAG dependencies. As a result, it could erroneously leave hanging
references to resources that no longer exist after performing a
`pulumi destroy --target X` operation. This manifested in bugs like
https://github.com/pulumi/pulumi/issues/6283, which is fixed by this
change. The solution is to compute the (transitive!) dependency graph
correctly, factoring in both parent/child, as well as explicit and
implicit, dependencies. The existing logic does the correct thing once
we do this. I've also added tests for this area, including regression
tests that cover transitive dependency relationships, as well as ones
that would cause an infinite loop given a naive implementation.
* Add a changelog entry
* Fix failing test to include all destroyed targets
Unless I'm missing something, the entire tree should be deleted
in this test case because A is the ancestor for the entire tree.
* Use DependencyGraph to compute dependents
Per code review feedback from @pgavlin.
Co-authored-by: Anton Tayanovskyy <anton@pulumi.com>
Add a new `IsOverlay` option to schema types and functions that allows providers to document overlays in the schema. This makes it easier to generate API docs consistently, even for code that is generated outside of the typical codegen process.
* Improve corrupt workspace settings experience
This improvement comes in two parts.
1. The error message for a corrupt workspace settings file now clearly
indicates both the file and the parsing error.
2. Writing the workspace settings is now atomic. This prevents
corruption from multiple concurrent calls.
* Use builtin atomic write
* Use builtin ioutil.TempFile
* Change tmp file dir
* Run make ensure on devcontainer creation
Added an ensure target to the dotnet makefile to run `dotnet restore`.
* Add dotnet test explorer and set default vscode settings for it
* Ensure PULUMI_LOCAL_NUGET exists
* Add missing mkdirs
* Use the display name from the schema, if available
* Update comment on the titleLookup map
* Add examples of reserved labels that can be used with the Keywords array in the schema