2021-09-13 16:05:31 +00:00
|
|
|
// Copyright 2016-2021, Pulumi Corporation.
|
2018-05-22 19:43:36 +00:00
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
2017-02-20 19:18:47 +00:00
|
|
|
|
|
|
|
package resource
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"reflect"
|
Make more progress on the new deployment model
This change restructures a lot more pertaining to deployments, snapshots,
environments, and the like.
The most notable change is that the notion of a deploy.Source is introduced,
which splits the responsibility between the deploy.Plan -- which simply
understands how to compute and carry out deployment plans -- and the idea
of something that can produce new objects on-demand during deployment.
The primary such implementation is evalSource, which encapsulates an
interpreter and takes a package, args, and config map, and proceeds to run
the interpreter in a distinct goroutine. It synchronizes as needed to
poke and prod the interpreter along its path to create new resource objects.
There are two other sources, however. First, a nullSource, which simply
refuses to create new objects. This can be handy when writing isolated
tests but is also used to simulate the "empty" environment as necessary to
do a complete teardown of the target environment. Second, a fixedSource,
which takes a pre-computed array of objects, and hands those, in order, to
the planning engine; this is mostly useful as a testing technique.
Boatloads of code is now changed and updated in the various CLI commands.
This further chugs along towards pulumi/lumi#90. The end is in sight.
2017-06-10 18:50:47 +00:00
|
|
|
"sort"
|
2020-03-18 18:39:13 +00:00
|
|
|
"strings"
|
2017-02-20 19:18:47 +00:00
|
|
|
|
Move assets and archives to their own package (#15157)
<!---
Thanks so much for your contribution! If this is your first time
contributing, please ensure that you have read the
[CONTRIBUTING](https://github.com/pulumi/pulumi/blob/master/CONTRIBUTING.md)
documentation.
-->
# Description
This PR is motivated by https://github.com/pulumi/pulumi/pull/15145.
`resource.*` should be built on top of `property.Value`,[^1] which means
that `resource`
needs to be able to import `property.Value`, and so `property` cannot
import
`resource`. Since Assets and Archives are both types of properties, they
must be moved out
of `resource`.
[^1]: For example:
https://github.com/pulumi/pulumi/blob/a1d686227cd7e3c70c51bd772450cb0cd57c1479/sdk/go/common/resource/resource_state.go#L35-L36
## Open Question
This PR moves them to their own sub-folders in `resource`. Should
`asset` and `archive`
live somewhere more high level, like `sdk/go/property/{asset,archive}`?
<!--- Please include a summary of the change and which issue is fixed.
Please also include relevant motivation and context. -->
## Checklist
- [ ] I have run `make tidy` to update any new dependencies
- [ ] I have run `make lint` to verify my code passes the lint check
- [ ] I have formatted my code using `gofumpt`
<!--- Please provide details if the checkbox below is to be left
unchecked. -->
- [ ] I have added tests that prove my fix is effective or that my
feature works
<!---
User-facing changes require a CHANGELOG entry.
-->
- [ ] I have run `make changelog` and committed the
`changelog/pending/<file>` documenting my change
<!--
If the change(s) in this PR is a modification of an existing call to the
Pulumi Cloud,
then the service should honor older versions of the CLI where this
change would not exist.
You must then bump the API version in
/pkg/backend/httpstate/client/api.go, as well as add
it to the service.
-->
- [ ] Yes, there are changes in this PR that warrants bumping the Pulumi
Cloud API version
<!-- @Pulumi employees: If yes, you must submit corresponding changes in
the service repo. -->
2024-01-25 20:39:31 +00:00
|
|
|
"github.com/pulumi/pulumi/sdk/v3/go/common/resource/archive"
|
|
|
|
"github.com/pulumi/pulumi/sdk/v3/go/common/resource/asset"
|
|
|
|
"github.com/pulumi/pulumi/sdk/v3/go/common/resource/sig"
|
2023-06-28 16:02:04 +00:00
|
|
|
"github.com/pulumi/pulumi/sdk/v3/go/common/slice"
|
2021-03-17 13:20:05 +00:00
|
|
|
"github.com/pulumi/pulumi/sdk/v3/go/common/tokens"
|
|
|
|
"github.com/pulumi/pulumi/sdk/v3/go/common/util/contract"
|
|
|
|
"github.com/pulumi/pulumi/sdk/v3/go/common/util/mapper"
|
2017-02-20 19:18:47 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// PropertyKey is the name of a property.
|
|
|
|
type PropertyKey tokens.Name
|
|
|
|
|
|
|
|
// PropertyMap is a simple map keyed by property name with "JSON-like" values.
|
|
|
|
type PropertyMap map[PropertyKey]PropertyValue
|
|
|
|
|
2017-04-21 22:27:32 +00:00
|
|
|
// NewPropertyMap turns a struct into a property map, using any JSON tags inside to determine naming.
|
|
|
|
func NewPropertyMap(s interface{}) PropertyMap {
|
2017-07-11 00:40:28 +00:00
|
|
|
return NewPropertyMapRepl(s, nil, nil)
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewPropertyMapRepl turns a struct into a property map, using any JSON tags inside to determine naming. If non-nil
|
|
|
|
// replk or replv function(s) are provided, key and/or value transformations are performed during the mapping.
|
|
|
|
func NewPropertyMapRepl(s interface{},
|
2023-03-03 16:36:39 +00:00
|
|
|
replk func(string) (PropertyKey, bool), replv func(interface{}) (PropertyValue, bool),
|
|
|
|
) PropertyMap {
|
Implement mapper.Encode "for real"
This change implements `mapper.Encode` "for real" (that is, in a way
that isn't a complete embarrassment). It uses the obvious reflection
trickery to encode a tagged struct and its values as a JSON-like
in-memory map and collection of keyed values.
During this, I took the opportunity to also clean up a few other things
that had been bugging me. Namely, the presence of `mapper.Object` was
always error prone, since it isn't a true "typedef" in the sence that
it carries extra RTTI. Instead of doing that, let's just use the real
`map[string]interface{}` "JSON-map-like" object type. Even better, we
no longer require resource providers to deal with the mapper
infrastructure. Instead, the `Check` function can simply return an
array of errors. It's still best practice to return field-specific errors
to facilitate better diagnostics, but it's no longer required; and I've
added `resource.NewFieldError` to eliminate the need to import mapper.
As of this change, we can also consistently emit RPC structs with `lumi`
tags, rather than `lumi` tags on the way in and `json` on the way out.
This completes pulumi/lumi#183.
2017-06-06 00:43:52 +00:00
|
|
|
m, err := mapper.Unmap(s)
|
|
|
|
contract.Assertf(err == nil, "Struct of properties failed to map correctly: %v", err)
|
2017-07-11 00:40:28 +00:00
|
|
|
return NewPropertyMapFromMapRepl(m, replk, replv)
|
2017-05-30 17:55:53 +00:00
|
|
|
}
|
|
|
|
|
2017-07-11 00:40:28 +00:00
|
|
|
// NewPropertyMapFromMap creates a resource map from a regular weakly typed JSON-like map.
|
2017-05-30 17:55:53 +00:00
|
|
|
func NewPropertyMapFromMap(m map[string]interface{}) PropertyMap {
|
2017-07-11 00:40:28 +00:00
|
|
|
return NewPropertyMapFromMapRepl(m, nil, nil)
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewPropertyMapFromMapRepl optionally replaces keys/values in an existing map while creating a new resource map.
|
|
|
|
func NewPropertyMapFromMapRepl(m map[string]interface{},
|
2023-03-03 16:36:39 +00:00
|
|
|
replk func(string) (PropertyKey, bool), replv func(interface{}) (PropertyValue, bool),
|
|
|
|
) PropertyMap {
|
2017-04-21 22:27:32 +00:00
|
|
|
result := make(PropertyMap)
|
|
|
|
for k, v := range m {
|
2017-07-11 00:40:28 +00:00
|
|
|
key := PropertyKey(k)
|
|
|
|
if replk != nil {
|
|
|
|
if rk, repl := replk(k); repl {
|
|
|
|
key = rk
|
|
|
|
}
|
|
|
|
}
|
|
|
|
result[key] = NewPropertyValueRepl(v, replk, replv)
|
2017-04-21 22:27:32 +00:00
|
|
|
}
|
|
|
|
return result
|
|
|
|
}
|
|
|
|
|
2017-02-20 19:18:47 +00:00
|
|
|
// PropertyValue is the value of a property, limited to a select few types (see below).
|
|
|
|
type PropertyValue struct {
|
|
|
|
V interface{}
|
|
|
|
}
|
|
|
|
|
2017-05-25 20:19:20 +00:00
|
|
|
// Computed represents the absence of a property value, because it will be computed at some point in the future. It
|
|
|
|
// contains a property value which represents the underlying expected type of the eventual property value.
|
2017-06-08 13:44:21 +00:00
|
|
|
type Computed struct {
|
2017-06-08 13:48:23 +00:00
|
|
|
Element PropertyValue // the eventual value (type) of the computed property.
|
2017-05-25 20:19:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Output is a property value that will eventually be computed by the resource provider. If an output property is
|
|
|
|
// encountered, it means the resource has not yet been created, and so the output value is unavailable. Note that an
|
|
|
|
// output property is a special case of computed, but carries additional semantic meaning.
|
2017-06-08 13:44:21 +00:00
|
|
|
type Output struct {
|
2021-09-13 16:05:31 +00:00
|
|
|
Element PropertyValue // the value of this output if it is resolved.
|
|
|
|
Known bool `json:"-"` // true if this output's value is known.
|
|
|
|
Secret bool `json:"-"` // true if this output's value is secret.
|
|
|
|
Dependencies []URN `json:"-"` // the dependencies associated with this output.
|
Initial support for output properties (1 of 3)
This change includes approximately 1/3rd of the change necessary
to support output properties, as per pulumi/lumi#90.
In short, the runtime now has a new hidden type, Latent<T>, which
represents a "speculative" value, whose eventual type will be T,
that we can use during evaluation in various ways. Namely,
operations against Latent<T>s generally produce new Latent<U>s.
During planning, any Latent<T>s that end up in resource properties
are transformed into "unknown" property values. An unknown property
value is legal only during planning-time activities, such as Check,
Name, and InspectChange. As a result, those RPC interfaces have
been updated to include lookaside maps indicating which properties
have unknown values. My intent is to add some helper functions to
make dealing with this circumstance more correct-by-construction.
For now, using an unresolved Latent<T> in a conditional will lead
to an error. See pulumi/lumi#67. Speculating beyond these -- by
supporting iterative planning and application -- is something we
want to support eventually, but it makes sense to do that as an
additive change beyond this initial support. That is a missing 1/3.
Finally, the other missing 1/3rd which will happen much sooner
than the rest is restructuing plan application so that it will
correctly observe resolution of Latent<T> values. Right now, the
evaluation happens in one single pass, prior to the application, and
so Latent<T>s never actually get witnessed in a resolved state.
2017-05-24 00:32:59 +00:00
|
|
|
}
|
|
|
|
|
2019-04-12 21:29:08 +00:00
|
|
|
// Secret indicates that the underlying value should be persisted securely.
|
2019-09-18 22:52:31 +00:00
|
|
|
//
|
|
|
|
// In order to facilitate the ability to distinguish secrets with identical plaintext in downstream code that may
|
|
|
|
// want to cache a secret's ciphertext, secret PropertyValues hold the address of the Secret. If a secret must be
|
|
|
|
// copied, its value--not its address--should be copied.
|
2019-04-12 21:29:08 +00:00
|
|
|
type Secret struct {
|
|
|
|
Element PropertyValue
|
|
|
|
}
|
|
|
|
|
2020-10-27 17:12:12 +00:00
|
|
|
// ResourceReference is a property value that represents a reference to a Resource. The reference captures the
|
2021-01-21 23:40:27 +00:00
|
|
|
// resource's URN, ID, and the version of its containing package. Note that there are several cases to consider with
|
|
|
|
// respect to the ID:
|
|
|
|
//
|
2022-09-14 02:12:02 +00:00
|
|
|
// - The reference may not contain an ID if the referenced resource is a component resource. In this case, the ID will
|
|
|
|
// be null.
|
|
|
|
// - The ID may be unknown (in which case it will be the unknown property value)
|
|
|
|
// - Otherwise, the ID must be a string.
|
2020-10-27 17:12:12 +00:00
|
|
|
//
|
2023-01-06 00:07:45 +00:00
|
|
|
//nolint:revive
|
2020-10-27 17:12:12 +00:00
|
|
|
type ResourceReference struct {
|
|
|
|
URN URN
|
2021-01-21 23:40:27 +00:00
|
|
|
ID PropertyValue
|
2020-10-27 17:12:12 +00:00
|
|
|
PackageVersion string
|
|
|
|
}
|
|
|
|
|
2021-01-21 23:40:27 +00:00
|
|
|
func (ref ResourceReference) IDString() (value string, hasID bool) {
|
|
|
|
switch {
|
|
|
|
case ref.ID.IsComputed():
|
|
|
|
return "", true
|
|
|
|
case ref.ID.IsString():
|
|
|
|
return ref.ID.StringValue(), true
|
|
|
|
default:
|
|
|
|
return "", false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
A property.Value implementation to replace resource.PropertyValue (#15145)
<!---
Thanks so much for your contribution! If this is your first time
contributing, please ensure that you have read the
[CONTRIBUTING](https://github.com/pulumi/pulumi/blob/master/CONTRIBUTING.md)
documentation.
-->
# Description
<!--- Please include a summary of the change and which issue is fixed.
Please also include relevant motivation and context. -->
The plan is to gradually replace resource.PropertyValue both internally
(in `pulumi/pulumi`) and in providers with this implementation.
This representation eliminates certain classes of bugs inherent with the
old representation:
- Modifiers (computed, secret, dependencies) live in a separate space
from values, so there is no longer a problem with different nestings.
- Equality is well defined and encapsulated.
- The distinction between `Output`, `Secret` and `Computed`.
- Names have been normalized (Input/Computed, Map/Object).
This is our chance to have a property value representation that we like,
so please leave comments if you think we can improve the API here.
## Checklist
- [X] I have run `make tidy` to update any new dependencies
- [X] I have run `make lint` to verify my code passes the lint check
- [ ] I have formatted my code using `gofumpt`
<!--- Please provide details if the checkbox below is to be left
unchecked. -->
- [ ] I have added tests that prove my fix is effective or that my
feature works
<!---
User-facing changes require a CHANGELOG entry.
-->
- [ ] I have run `make changelog` and committed the
`changelog/pending/<file>` documenting my change
<!--
If the change(s) in this PR is a modification of an existing call to the
Pulumi Cloud,
then the service should honor older versions of the CLI where this
change would not exist.
You must then bump the API version in
/pkg/backend/httpstate/client/api.go, as well as add
it to the service.
-->
- [ ] Yes, there are changes in this PR that warrants bumping the Pulumi
Cloud API version
<!-- @Pulumi employees: If yes, you must submit corresponding changes in
the service repo. -->
2024-03-14 19:58:59 +00:00
|
|
|
func (ref ResourceReference) Equal(other ResourceReference) bool {
|
|
|
|
if ref.URN != other.URN {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
vid, oid := ref.ID, other.ID
|
|
|
|
if vid.IsComputed() && oid.IsComputed() {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
return vid.DeepEquals(oid)
|
|
|
|
}
|
|
|
|
|
2017-02-20 19:18:47 +00:00
|
|
|
type ReqError struct {
|
|
|
|
K PropertyKey
|
|
|
|
}
|
|
|
|
|
|
|
|
func IsReqError(err error) bool {
|
|
|
|
_, isreq := err.(*ReqError)
|
|
|
|
return isreq
|
|
|
|
}
|
|
|
|
|
|
|
|
func (err *ReqError) Error() string {
|
|
|
|
return fmt.Sprintf("required property '%v' is missing", err.K)
|
|
|
|
}
|
|
|
|
|
2017-06-05 02:24:48 +00:00
|
|
|
// HasValue returns true if the slot associated with the given property key contains a real value. It returns false
|
|
|
|
// if a value is null or an output property that is awaiting a value to be assigned. That is to say, HasValue indicates
|
|
|
|
// a semantically meaningful value is present (even if it's a computed one whose concrete value isn't yet evaluated).
|
2022-10-09 14:58:33 +00:00
|
|
|
func (props PropertyMap) HasValue(k PropertyKey) bool {
|
|
|
|
v, has := props[k]
|
2017-06-05 02:24:48 +00:00
|
|
|
return has && v.HasValue()
|
2017-06-01 17:09:52 +00:00
|
|
|
}
|
|
|
|
|
2017-09-14 23:40:44 +00:00
|
|
|
// ContainsUnknowns returns true if the property map contains at least one unknown value.
|
2022-10-09 14:58:33 +00:00
|
|
|
func (props PropertyMap) ContainsUnknowns() bool {
|
|
|
|
for _, v := range props {
|
2017-09-14 23:40:44 +00:00
|
|
|
if v.ContainsUnknowns() {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2019-05-15 05:17:28 +00:00
|
|
|
// ContainsSecrets returns true if the property map contains at least one secret value.
|
2022-10-09 14:58:33 +00:00
|
|
|
func (props PropertyMap) ContainsSecrets() bool {
|
|
|
|
for _, v := range props {
|
2019-05-15 05:17:28 +00:00
|
|
|
if v.ContainsSecrets() {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2017-03-12 21:13:44 +00:00
|
|
|
// Mappable returns a mapper-compatible object map, suitable for deserialization into structures.
|
2022-10-09 14:58:33 +00:00
|
|
|
func (props PropertyMap) Mappable() map[string]interface{} {
|
|
|
|
return props.MapRepl(nil, nil)
|
2017-07-01 19:08:55 +00:00
|
|
|
}
|
|
|
|
|
2017-07-11 00:40:28 +00:00
|
|
|
// MapRepl returns a mapper-compatible object map, suitable for deserialization into structures. A key and/or value
|
|
|
|
// replace function, replk/replv, may be passed that will replace elements using custom logic if appropriate.
|
2022-10-09 14:58:33 +00:00
|
|
|
func (props PropertyMap) MapRepl(replk func(string) (string, bool),
|
2023-03-03 16:36:39 +00:00
|
|
|
replv func(PropertyValue) (interface{}, bool),
|
|
|
|
) map[string]interface{} {
|
Implement mapper.Encode "for real"
This change implements `mapper.Encode` "for real" (that is, in a way
that isn't a complete embarrassment). It uses the obvious reflection
trickery to encode a tagged struct and its values as a JSON-like
in-memory map and collection of keyed values.
During this, I took the opportunity to also clean up a few other things
that had been bugging me. Namely, the presence of `mapper.Object` was
always error prone, since it isn't a true "typedef" in the sence that
it carries extra RTTI. Instead of doing that, let's just use the real
`map[string]interface{}` "JSON-map-like" object type. Even better, we
no longer require resource providers to deal with the mapper
infrastructure. Instead, the `Check` function can simply return an
array of errors. It's still best practice to return field-specific errors
to facilitate better diagnostics, but it's no longer required; and I've
added `resource.NewFieldError` to eliminate the need to import mapper.
As of this change, we can also consistently emit RPC structs with `lumi`
tags, rather than `lumi` tags on the way in and `json` on the way out.
This completes pulumi/lumi#183.
2017-06-06 00:43:52 +00:00
|
|
|
obj := make(map[string]interface{})
|
2022-10-09 14:58:33 +00:00
|
|
|
for _, k := range props.StableKeys() {
|
2017-07-11 00:40:28 +00:00
|
|
|
key := string(k)
|
|
|
|
if replk != nil {
|
|
|
|
if rk, repk := replk(key); repk {
|
|
|
|
key = rk
|
|
|
|
}
|
|
|
|
}
|
2022-10-09 14:58:33 +00:00
|
|
|
obj[key] = props[k].MapRepl(replk, replv)
|
2017-03-12 21:13:44 +00:00
|
|
|
}
|
|
|
|
return obj
|
|
|
|
}
|
|
|
|
|
2017-07-20 15:07:45 +00:00
|
|
|
// Copy makes a shallow copy of the map.
|
2022-10-09 14:58:33 +00:00
|
|
|
func (props PropertyMap) Copy() PropertyMap {
|
2017-07-19 15:31:45 +00:00
|
|
|
new := make(PropertyMap)
|
2022-10-09 14:58:33 +00:00
|
|
|
for k, v := range props {
|
2017-07-19 15:31:45 +00:00
|
|
|
new[k] = v
|
|
|
|
}
|
2017-07-20 15:07:45 +00:00
|
|
|
return new
|
|
|
|
}
|
|
|
|
|
Make more progress on the new deployment model
This change restructures a lot more pertaining to deployments, snapshots,
environments, and the like.
The most notable change is that the notion of a deploy.Source is introduced,
which splits the responsibility between the deploy.Plan -- which simply
understands how to compute and carry out deployment plans -- and the idea
of something that can produce new objects on-demand during deployment.
The primary such implementation is evalSource, which encapsulates an
interpreter and takes a package, args, and config map, and proceeds to run
the interpreter in a distinct goroutine. It synchronizes as needed to
poke and prod the interpreter along its path to create new resource objects.
There are two other sources, however. First, a nullSource, which simply
refuses to create new objects. This can be handy when writing isolated
tests but is also used to simulate the "empty" environment as necessary to
do a complete teardown of the target environment. Second, a fixedSource,
which takes a pre-computed array of objects, and hands those, in order, to
the planning engine; this is mostly useful as a testing technique.
Boatloads of code is now changed and updated in the various CLI commands.
This further chugs along towards pulumi/lumi#90. The end is in sight.
2017-06-10 18:50:47 +00:00
|
|
|
// StableKeys returns all of the map's keys in a stable order.
|
2022-10-09 14:58:33 +00:00
|
|
|
func (props PropertyMap) StableKeys() []PropertyKey {
|
2023-06-28 16:02:04 +00:00
|
|
|
sorted := slice.Prealloc[PropertyKey](len(props))
|
2022-10-09 14:58:33 +00:00
|
|
|
for k := range props {
|
Make more progress on the new deployment model
This change restructures a lot more pertaining to deployments, snapshots,
environments, and the like.
The most notable change is that the notion of a deploy.Source is introduced,
which splits the responsibility between the deploy.Plan -- which simply
understands how to compute and carry out deployment plans -- and the idea
of something that can produce new objects on-demand during deployment.
The primary such implementation is evalSource, which encapsulates an
interpreter and takes a package, args, and config map, and proceeds to run
the interpreter in a distinct goroutine. It synchronizes as needed to
poke and prod the interpreter along its path to create new resource objects.
There are two other sources, however. First, a nullSource, which simply
refuses to create new objects. This can be handy when writing isolated
tests but is also used to simulate the "empty" environment as necessary to
do a complete teardown of the target environment. Second, a fixedSource,
which takes a pre-computed array of objects, and hands those, in order, to
the planning engine; this is mostly useful as a testing technique.
Boatloads of code is now changed and updated in the various CLI commands.
This further chugs along towards pulumi/lumi#90. The end is in sight.
2017-06-10 18:50:47 +00:00
|
|
|
sorted = append(sorted, k)
|
|
|
|
}
|
|
|
|
sort.Slice(sorted, func(i, j int) bool { return sorted[i] < sorted[j] })
|
|
|
|
return sorted
|
|
|
|
}
|
|
|
|
|
2023-11-11 21:12:17 +00:00
|
|
|
// PropertyValueType enumerates the actual types that may be stored in a PropertyValue.
|
|
|
|
//
|
|
|
|
//nolint:lll
|
|
|
|
type PropertyValueType interface {
|
Move assets and archives to their own package (#15157)
<!---
Thanks so much for your contribution! If this is your first time
contributing, please ensure that you have read the
[CONTRIBUTING](https://github.com/pulumi/pulumi/blob/master/CONTRIBUTING.md)
documentation.
-->
# Description
This PR is motivated by https://github.com/pulumi/pulumi/pull/15145.
`resource.*` should be built on top of `property.Value`,[^1] which means
that `resource`
needs to be able to import `property.Value`, and so `property` cannot
import
`resource`. Since Assets and Archives are both types of properties, they
must be moved out
of `resource`.
[^1]: For example:
https://github.com/pulumi/pulumi/blob/a1d686227cd7e3c70c51bd772450cb0cd57c1479/sdk/go/common/resource/resource_state.go#L35-L36
## Open Question
This PR moves them to their own sub-folders in `resource`. Should
`asset` and `archive`
live somewhere more high level, like `sdk/go/property/{asset,archive}`?
<!--- Please include a summary of the change and which issue is fixed.
Please also include relevant motivation and context. -->
## Checklist
- [ ] I have run `make tidy` to update any new dependencies
- [ ] I have run `make lint` to verify my code passes the lint check
- [ ] I have formatted my code using `gofumpt`
<!--- Please provide details if the checkbox below is to be left
unchecked. -->
- [ ] I have added tests that prove my fix is effective or that my
feature works
<!---
User-facing changes require a CHANGELOG entry.
-->
- [ ] I have run `make changelog` and committed the
`changelog/pending/<file>` documenting my change
<!--
If the change(s) in this PR is a modification of an existing call to the
Pulumi Cloud,
then the service should honor older versions of the CLI where this
change would not exist.
You must then bump the API version in
/pkg/backend/httpstate/client/api.go, as well as add
it to the service.
-->
- [ ] Yes, there are changes in this PR that warrants bumping the Pulumi
Cloud API version
<!-- @Pulumi employees: If yes, you must submit corresponding changes in
the service repo. -->
2024-01-25 20:39:31 +00:00
|
|
|
bool | float64 | string | *asset.Asset | *archive.Archive | Computed | Output | *Secret | ResourceReference | []PropertyValue | PropertyMap
|
2023-11-11 21:12:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// NewProperty creates a new PropertyValue.
|
|
|
|
func NewProperty[T PropertyValueType](v T) PropertyValue {
|
|
|
|
return PropertyValue{v}
|
|
|
|
}
|
|
|
|
|
2020-10-27 17:12:12 +00:00
|
|
|
func NewNullProperty() PropertyValue { return PropertyValue{nil} }
|
|
|
|
func NewBoolProperty(v bool) PropertyValue { return PropertyValue{v} }
|
|
|
|
func NewNumberProperty(v float64) PropertyValue { return PropertyValue{v} }
|
|
|
|
func NewStringProperty(v string) PropertyValue { return PropertyValue{v} }
|
|
|
|
func NewArrayProperty(v []PropertyValue) PropertyValue { return PropertyValue{v} }
|
Move assets and archives to their own package (#15157)
<!---
Thanks so much for your contribution! If this is your first time
contributing, please ensure that you have read the
[CONTRIBUTING](https://github.com/pulumi/pulumi/blob/master/CONTRIBUTING.md)
documentation.
-->
# Description
This PR is motivated by https://github.com/pulumi/pulumi/pull/15145.
`resource.*` should be built on top of `property.Value`,[^1] which means
that `resource`
needs to be able to import `property.Value`, and so `property` cannot
import
`resource`. Since Assets and Archives are both types of properties, they
must be moved out
of `resource`.
[^1]: For example:
https://github.com/pulumi/pulumi/blob/a1d686227cd7e3c70c51bd772450cb0cd57c1479/sdk/go/common/resource/resource_state.go#L35-L36
## Open Question
This PR moves them to their own sub-folders in `resource`. Should
`asset` and `archive`
live somewhere more high level, like `sdk/go/property/{asset,archive}`?
<!--- Please include a summary of the change and which issue is fixed.
Please also include relevant motivation and context. -->
## Checklist
- [ ] I have run `make tidy` to update any new dependencies
- [ ] I have run `make lint` to verify my code passes the lint check
- [ ] I have formatted my code using `gofumpt`
<!--- Please provide details if the checkbox below is to be left
unchecked. -->
- [ ] I have added tests that prove my fix is effective or that my
feature works
<!---
User-facing changes require a CHANGELOG entry.
-->
- [ ] I have run `make changelog` and committed the
`changelog/pending/<file>` documenting my change
<!--
If the change(s) in this PR is a modification of an existing call to the
Pulumi Cloud,
then the service should honor older versions of the CLI where this
change would not exist.
You must then bump the API version in
/pkg/backend/httpstate/client/api.go, as well as add
it to the service.
-->
- [ ] Yes, there are changes in this PR that warrants bumping the Pulumi
Cloud API version
<!-- @Pulumi employees: If yes, you must submit corresponding changes in
the service repo. -->
2024-01-25 20:39:31 +00:00
|
|
|
func NewAssetProperty(v *asset.Asset) PropertyValue { return PropertyValue{v} }
|
|
|
|
func NewArchiveProperty(v *archive.Archive) PropertyValue { return PropertyValue{v} }
|
2020-10-27 17:12:12 +00:00
|
|
|
func NewObjectProperty(v PropertyMap) PropertyValue { return PropertyValue{v} }
|
|
|
|
func NewComputedProperty(v Computed) PropertyValue { return PropertyValue{v} }
|
|
|
|
func NewOutputProperty(v Output) PropertyValue { return PropertyValue{v} }
|
|
|
|
func NewSecretProperty(v *Secret) PropertyValue { return PropertyValue{v} }
|
|
|
|
func NewResourceReferenceProperty(v ResourceReference) PropertyValue { return PropertyValue{v} }
|
2017-05-25 20:19:20 +00:00
|
|
|
|
2017-06-10 01:34:37 +00:00
|
|
|
func MakeComputed(v PropertyValue) PropertyValue {
|
2023-11-11 21:12:17 +00:00
|
|
|
return NewProperty(Computed{Element: v})
|
2017-06-08 13:44:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func MakeOutput(v PropertyValue) PropertyValue {
|
2023-11-11 21:12:17 +00:00
|
|
|
return NewProperty(Output{Element: v})
|
2017-06-08 13:44:21 +00:00
|
|
|
}
|
2017-02-20 19:18:47 +00:00
|
|
|
|
2019-04-12 21:29:08 +00:00
|
|
|
func MakeSecret(v PropertyValue) PropertyValue {
|
2023-11-11 21:12:17 +00:00
|
|
|
return NewProperty(&Secret{Element: v})
|
2019-04-12 21:29:08 +00:00
|
|
|
}
|
|
|
|
|
2021-01-21 23:40:27 +00:00
|
|
|
// MakeComponentResourceReference creates a reference to a component resource.
|
|
|
|
func MakeComponentResourceReference(urn URN, packageVersion string) PropertyValue {
|
2023-11-11 21:12:17 +00:00
|
|
|
return NewProperty(ResourceReference{
|
2021-01-21 23:40:27 +00:00
|
|
|
URN: urn,
|
|
|
|
PackageVersion: packageVersion,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
// MakeCustomResourceReference creates a reference to a custom resource. If the resource's ID is the empty string, it
|
|
|
|
// will be treated as unknown.
|
|
|
|
func MakeCustomResourceReference(urn URN, id ID, packageVersion string) PropertyValue {
|
2023-11-11 21:12:17 +00:00
|
|
|
idProp := NewProperty(string(id))
|
2021-01-21 23:40:27 +00:00
|
|
|
if id == "" {
|
2023-11-11 21:12:17 +00:00
|
|
|
idProp = MakeComputed(NewProperty(""))
|
2021-01-21 23:40:27 +00:00
|
|
|
}
|
|
|
|
|
2023-11-11 21:12:17 +00:00
|
|
|
return NewProperty(ResourceReference{
|
2021-01-21 23:40:27 +00:00
|
|
|
ID: idProp,
|
2020-11-23 19:15:10 +00:00
|
|
|
URN: urn,
|
|
|
|
PackageVersion: packageVersion,
|
|
|
|
})
|
2020-10-27 17:12:12 +00:00
|
|
|
}
|
|
|
|
|
2017-04-21 22:27:32 +00:00
|
|
|
// NewPropertyValue turns a value into a property value, provided it is of a legal "JSON-like" kind.
|
|
|
|
func NewPropertyValue(v interface{}) PropertyValue {
|
2017-07-11 00:40:28 +00:00
|
|
|
return NewPropertyValueRepl(v, nil, nil)
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewPropertyValueRepl turns a value into a property value, provided it is of a legal "JSON-like" kind. The
|
|
|
|
// replacement functions, replk and replv, may be supplied to transform keys and/or values as the mapping takes place.
|
|
|
|
func NewPropertyValueRepl(v interface{},
|
2023-03-03 16:36:39 +00:00
|
|
|
replk func(string) (PropertyKey, bool), replv func(interface{}) (PropertyValue, bool),
|
|
|
|
) PropertyValue {
|
2017-07-11 00:40:28 +00:00
|
|
|
// If a replacement routine is supplied, use that.
|
|
|
|
if replv != nil {
|
|
|
|
if rv, repl := replv(v); repl {
|
|
|
|
return rv
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-21 22:27:32 +00:00
|
|
|
// If nil, easy peasy, just return a null.
|
|
|
|
if v == nil {
|
2017-05-25 20:19:20 +00:00
|
|
|
return NewNullProperty()
|
2017-04-21 22:27:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Else, check for some known primitive types.
|
|
|
|
switch t := v.(type) {
|
|
|
|
case bool:
|
2023-11-11 21:12:17 +00:00
|
|
|
return NewProperty(t)
|
2017-07-20 15:07:45 +00:00
|
|
|
case int:
|
2023-11-11 21:12:17 +00:00
|
|
|
return NewProperty(float64(t))
|
2017-07-20 15:07:45 +00:00
|
|
|
case uint:
|
2023-11-11 21:12:17 +00:00
|
|
|
return NewProperty(float64(t))
|
2017-07-20 15:07:45 +00:00
|
|
|
case int32:
|
2023-11-11 21:12:17 +00:00
|
|
|
return NewProperty(float64(t))
|
2017-07-20 15:07:45 +00:00
|
|
|
case uint32:
|
2023-11-11 21:12:17 +00:00
|
|
|
return NewProperty(float64(t))
|
2017-07-20 15:07:45 +00:00
|
|
|
case int64:
|
2023-11-11 21:12:17 +00:00
|
|
|
return NewProperty(float64(t))
|
2017-07-20 15:07:45 +00:00
|
|
|
case uint64:
|
2023-11-11 21:12:17 +00:00
|
|
|
return NewProperty(float64(t))
|
2017-07-20 15:07:45 +00:00
|
|
|
case float32:
|
2023-11-11 21:12:17 +00:00
|
|
|
return NewProperty(float64(t))
|
2017-04-21 22:27:32 +00:00
|
|
|
case float64:
|
2023-11-11 21:12:17 +00:00
|
|
|
return NewProperty(t)
|
2017-04-21 22:27:32 +00:00
|
|
|
case string:
|
2023-11-11 21:12:17 +00:00
|
|
|
return NewProperty(t)
|
Move assets and archives to their own package (#15157)
<!---
Thanks so much for your contribution! If this is your first time
contributing, please ensure that you have read the
[CONTRIBUTING](https://github.com/pulumi/pulumi/blob/master/CONTRIBUTING.md)
documentation.
-->
# Description
This PR is motivated by https://github.com/pulumi/pulumi/pull/15145.
`resource.*` should be built on top of `property.Value`,[^1] which means
that `resource`
needs to be able to import `property.Value`, and so `property` cannot
import
`resource`. Since Assets and Archives are both types of properties, they
must be moved out
of `resource`.
[^1]: For example:
https://github.com/pulumi/pulumi/blob/a1d686227cd7e3c70c51bd772450cb0cd57c1479/sdk/go/common/resource/resource_state.go#L35-L36
## Open Question
This PR moves them to their own sub-folders in `resource`. Should
`asset` and `archive`
live somewhere more high level, like `sdk/go/property/{asset,archive}`?
<!--- Please include a summary of the change and which issue is fixed.
Please also include relevant motivation and context. -->
## Checklist
- [ ] I have run `make tidy` to update any new dependencies
- [ ] I have run `make lint` to verify my code passes the lint check
- [ ] I have formatted my code using `gofumpt`
<!--- Please provide details if the checkbox below is to be left
unchecked. -->
- [ ] I have added tests that prove my fix is effective or that my
feature works
<!---
User-facing changes require a CHANGELOG entry.
-->
- [ ] I have run `make changelog` and committed the
`changelog/pending/<file>` documenting my change
<!--
If the change(s) in this PR is a modification of an existing call to the
Pulumi Cloud,
then the service should honor older versions of the CLI where this
change would not exist.
You must then bump the API version in
/pkg/backend/httpstate/client/api.go, as well as add
it to the service.
-->
- [ ] Yes, there are changes in this PR that warrants bumping the Pulumi
Cloud API version
<!-- @Pulumi employees: If yes, you must submit corresponding changes in
the service repo. -->
2024-01-25 20:39:31 +00:00
|
|
|
case *asset.Asset:
|
2023-11-11 21:12:17 +00:00
|
|
|
return NewProperty(t)
|
Move assets and archives to their own package (#15157)
<!---
Thanks so much for your contribution! If this is your first time
contributing, please ensure that you have read the
[CONTRIBUTING](https://github.com/pulumi/pulumi/blob/master/CONTRIBUTING.md)
documentation.
-->
# Description
This PR is motivated by https://github.com/pulumi/pulumi/pull/15145.
`resource.*` should be built on top of `property.Value`,[^1] which means
that `resource`
needs to be able to import `property.Value`, and so `property` cannot
import
`resource`. Since Assets and Archives are both types of properties, they
must be moved out
of `resource`.
[^1]: For example:
https://github.com/pulumi/pulumi/blob/a1d686227cd7e3c70c51bd772450cb0cd57c1479/sdk/go/common/resource/resource_state.go#L35-L36
## Open Question
This PR moves them to their own sub-folders in `resource`. Should
`asset` and `archive`
live somewhere more high level, like `sdk/go/property/{asset,archive}`?
<!--- Please include a summary of the change and which issue is fixed.
Please also include relevant motivation and context. -->
## Checklist
- [ ] I have run `make tidy` to update any new dependencies
- [ ] I have run `make lint` to verify my code passes the lint check
- [ ] I have formatted my code using `gofumpt`
<!--- Please provide details if the checkbox below is to be left
unchecked. -->
- [ ] I have added tests that prove my fix is effective or that my
feature works
<!---
User-facing changes require a CHANGELOG entry.
-->
- [ ] I have run `make changelog` and committed the
`changelog/pending/<file>` documenting my change
<!--
If the change(s) in this PR is a modification of an existing call to the
Pulumi Cloud,
then the service should honor older versions of the CLI where this
change would not exist.
You must then bump the API version in
/pkg/backend/httpstate/client/api.go, as well as add
it to the service.
-->
- [ ] Yes, there are changes in this PR that warrants bumping the Pulumi
Cloud API version
<!-- @Pulumi employees: If yes, you must submit corresponding changes in
the service repo. -->
2024-01-25 20:39:31 +00:00
|
|
|
case *archive.Archive:
|
2023-11-11 21:12:17 +00:00
|
|
|
return NewProperty(t)
|
2017-05-25 20:19:20 +00:00
|
|
|
case Computed:
|
2023-11-11 21:12:17 +00:00
|
|
|
return NewProperty(t)
|
2017-08-03 18:01:38 +00:00
|
|
|
case Output:
|
2023-11-11 21:12:17 +00:00
|
|
|
return NewProperty(t)
|
2019-09-18 22:52:31 +00:00
|
|
|
case *Secret:
|
2023-11-11 21:12:17 +00:00
|
|
|
return NewProperty(t)
|
2020-10-27 17:12:12 +00:00
|
|
|
case ResourceReference:
|
2023-11-11 21:12:17 +00:00
|
|
|
return NewProperty(t)
|
2017-04-21 22:27:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Next, see if it's an array, slice, pointer or struct, and handle each accordingly.
|
|
|
|
rv := reflect.ValueOf(v)
|
turn on the golangci-lint exhaustive linter (#15028)
Turn on the golangci-lint exhaustive linter. This is the first step
towards catching more missing cases during development rather than
in tests, or in production.
This might be best reviewed commit-by-commit, as the first commit turns
on the linter with the `default-signifies-exhaustive: true` option set,
which requires a lot less changes in the current codebase.
I think it's probably worth doing the second commit as well, as that
will get us the real benefits, even though we end up with a little bit
more churn. However it means all the `switch` statements are covered,
which isn't the case after the first commit, since we do have a lot of
`default` statements that just call `assert.Fail`.
Fixes #14601
## Checklist
- [x] I have run `make tidy` to update any new dependencies
- [x] I have run `make lint` to verify my code passes the lint check
- [x] I have formatted my code using `gofumpt`
<!--- Please provide details if the checkbox below is to be left
unchecked. -->
- [ ] I have added tests that prove my fix is effective or that my
feature works
<!---
User-facing changes require a CHANGELOG entry.
-->
- [ ] I have run `make changelog` and committed the
`changelog/pending/<file>` documenting my change
<!--
If the change(s) in this PR is a modification of an existing call to the
Pulumi Cloud,
then the service should honor older versions of the CLI where this
change would not exist.
You must then bump the API version in
/pkg/backend/httpstate/client/api.go, as well as add
it to the service.
-->
- [ ] Yes, there are changes in this PR that warrants bumping the Pulumi
Cloud API version
<!-- @Pulumi employees: If yes, you must submit corresponding changes in
the service repo. -->
2024-01-17 16:50:41 +00:00
|
|
|
//nolint:exhaustive // We intentionally only handle some types here.
|
2017-04-21 22:27:32 +00:00
|
|
|
switch rk := rv.Type().Kind(); rk {
|
|
|
|
case reflect.Array, reflect.Slice:
|
|
|
|
// If an array or slice, just create an array out of it.
|
2019-08-07 18:42:40 +00:00
|
|
|
arr := []PropertyValue{}
|
2017-04-21 22:27:32 +00:00
|
|
|
for i := 0; i < rv.Len(); i++ {
|
|
|
|
elem := rv.Index(i)
|
2017-07-11 00:40:28 +00:00
|
|
|
arr = append(arr, NewPropertyValueRepl(elem.Interface(), replk, replv))
|
2017-04-21 22:27:32 +00:00
|
|
|
}
|
2023-11-11 21:12:17 +00:00
|
|
|
return NewProperty(arr)
|
2017-04-21 22:27:32 +00:00
|
|
|
case reflect.Ptr:
|
|
|
|
// If a pointer, recurse and return the underlying value.
|
2017-04-25 21:04:22 +00:00
|
|
|
if rv.IsNil() {
|
2017-05-25 20:19:20 +00:00
|
|
|
return NewNullProperty()
|
2017-04-25 21:04:22 +00:00
|
|
|
}
|
2017-07-11 00:40:28 +00:00
|
|
|
return NewPropertyValueRepl(rv.Elem().Interface(), replk, replv)
|
2017-05-30 17:55:53 +00:00
|
|
|
case reflect.Map:
|
Unmap properties on the receive side
This change makes progress on a few things with respect to properly
receiving properties on the engine side, coming from the provider side,
of the RPC boundary. The issues here are twofold:
1. Properties need to get unmapped using a JSON-tag-sensitive
marshaler, so that they are cased properly, etc. For that, we
have a new mapper.Unmap function (which is ultra lame -- see
pulumi/lumi#138).
2. We have the reverse problem with respect to resource IDs: on
the send side, we must translate from URNs (which the engine
knows about) and provider IDs (which the provider knows about);
similarly, then, on the receive side, we must translate from
provider IDs back into URNs.
As a result of these getting fixed, we can now properly marshal the
resulting properties back into the resource object during the plan
execution, alongside propagating and memoizing its ID.
2017-05-31 18:51:46 +00:00
|
|
|
// If a map, create a new property map, provided the keys and values are okay.
|
|
|
|
obj := PropertyMap{}
|
2022-05-02 19:11:46 +00:00
|
|
|
for iter := rv.MapRange(); iter.Next(); {
|
|
|
|
key := iter.Key()
|
|
|
|
if key.Kind() != reflect.String {
|
|
|
|
contract.Failf("Unrecognized PropertyMap key type %v", key.Type())
|
Unmap properties on the receive side
This change makes progress on a few things with respect to properly
receiving properties on the engine side, coming from the provider side,
of the RPC boundary. The issues here are twofold:
1. Properties need to get unmapped using a JSON-tag-sensitive
marshaler, so that they are cased properly, etc. For that, we
have a new mapper.Unmap function (which is ultra lame -- see
pulumi/lumi#138).
2. We have the reverse problem with respect to resource IDs: on
the send side, we must translate from URNs (which the engine
knows about) and provider IDs (which the provider knows about);
similarly, then, on the receive side, we must translate from
provider IDs back into URNs.
As a result of these getting fixed, we can now properly marshal the
resulting properties back into the resource object during the plan
execution, alongside propagating and memoizing its ID.
2017-05-31 18:51:46 +00:00
|
|
|
}
|
2022-05-02 19:11:46 +00:00
|
|
|
|
|
|
|
pk := PropertyKey(key.String())
|
2017-07-11 00:40:28 +00:00
|
|
|
if replk != nil {
|
|
|
|
if rk, repl := replk(string(pk)); repl {
|
|
|
|
pk = rk
|
|
|
|
}
|
|
|
|
}
|
2022-05-02 19:11:46 +00:00
|
|
|
|
|
|
|
val := iter.Value().Interface()
|
|
|
|
pv := NewPropertyValueRepl(val, replk, replv)
|
Unmap properties on the receive side
This change makes progress on a few things with respect to properly
receiving properties on the engine side, coming from the provider side,
of the RPC boundary. The issues here are twofold:
1. Properties need to get unmapped using a JSON-tag-sensitive
marshaler, so that they are cased properly, etc. For that, we
have a new mapper.Unmap function (which is ultra lame -- see
pulumi/lumi#138).
2. We have the reverse problem with respect to resource IDs: on
the send side, we must translate from URNs (which the engine
knows about) and provider IDs (which the provider knows about);
similarly, then, on the receive side, we must translate from
provider IDs back into URNs.
As a result of these getting fixed, we can now properly marshal the
resulting properties back into the resource object during the plan
execution, alongside propagating and memoizing its ID.
2017-05-31 18:51:46 +00:00
|
|
|
obj[pk] = pv
|
2017-05-30 17:55:53 +00:00
|
|
|
}
|
2023-11-11 21:12:17 +00:00
|
|
|
return NewProperty(obj)
|
Support Pulumi programs written in Go
This adds rudimentary support for Pulumi programs written in Go. It
is not complete yet but the basic resource registration works.
Note that, stylistically speaking, Go is a bit different from our other
languages. This made it a bit easier to build this initial prototype,
since what we want is actually a rather thin veneer atop our existing
RPC interfaces. The lack of generics, however, adds some friction and
is something I'm continuing to hammer on; this will most likely lead to
little specialized types (e.g. StringOutput) once the dust settles.
There are two primary components:
1) A new language host, `pulumi-language-go`, which is responsible for
communicating with the engine through the usual gRPC interfaces.
Because Go programs are pre-compiled, it very simply loads a binary
with the same name as the project.
2) A client SDK library that Pulumi programs bind against. This exports
the core resource types -- including assets -- properties -- including
output properties -- and configuration.
Most remaining TODOs are marked as such in the code, and this will not
be merged until they have been addressed, and some better tests written.
2018-06-03 17:37:26 +00:00
|
|
|
case reflect.String:
|
2023-11-11 21:12:17 +00:00
|
|
|
return NewProperty(rv.String())
|
2017-05-25 20:19:20 +00:00
|
|
|
case reflect.Struct:
|
2017-07-11 00:40:28 +00:00
|
|
|
obj := NewPropertyMapRepl(v, replk, replv)
|
2023-11-11 21:12:17 +00:00
|
|
|
return NewProperty(obj)
|
2017-04-21 22:27:32 +00:00
|
|
|
default:
|
Unmap properties on the receive side
This change makes progress on a few things with respect to properly
receiving properties on the engine side, coming from the provider side,
of the RPC boundary. The issues here are twofold:
1. Properties need to get unmapped using a JSON-tag-sensitive
marshaler, so that they are cased properly, etc. For that, we
have a new mapper.Unmap function (which is ultra lame -- see
pulumi/lumi#138).
2. We have the reverse problem with respect to resource IDs: on
the send side, we must translate from URNs (which the engine
knows about) and provider IDs (which the provider knows about);
similarly, then, on the receive side, we must translate from
provider IDs back into URNs.
As a result of these getting fixed, we can now properly marshal the
resulting properties back into the resource object during the plan
execution, alongside propagating and memoizing its ID.
2017-05-31 18:51:46 +00:00
|
|
|
contract.Failf("Unrecognized value type: type=%v kind=%v", rv.Type(), rk)
|
2023-11-11 21:12:17 +00:00
|
|
|
return NewNullProperty()
|
2017-04-21 22:27:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-14 19:28:43 +00:00
|
|
|
// HasValue returns true if a value is semantically meaningful.
|
|
|
|
func (v PropertyValue) HasValue() bool {
|
2021-09-13 16:05:31 +00:00
|
|
|
if v.IsOutput() {
|
|
|
|
return v.OutputValue().Known
|
|
|
|
}
|
|
|
|
return !v.IsNull()
|
2017-07-14 19:28:43 +00:00
|
|
|
}
|
|
|
|
|
2017-09-14 23:40:44 +00:00
|
|
|
// ContainsUnknowns returns true if the property value contains at least one unknown (deeply).
|
|
|
|
func (v PropertyValue) ContainsUnknowns() bool {
|
2021-09-13 16:05:31 +00:00
|
|
|
if v.IsComputed() || (v.IsOutput() && !v.OutputValue().Known) {
|
2017-09-14 23:40:44 +00:00
|
|
|
return true
|
|
|
|
} else if v.IsArray() {
|
|
|
|
for _, e := range v.ArrayValue() {
|
|
|
|
if e.ContainsUnknowns() {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if v.IsObject() {
|
|
|
|
return v.ObjectValue().ContainsUnknowns()
|
2020-04-13 21:47:08 +00:00
|
|
|
} else if v.IsSecret() {
|
|
|
|
return v.SecretValue().Element.ContainsUnknowns()
|
2017-09-14 23:40:44 +00:00
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2019-05-15 05:17:28 +00:00
|
|
|
// ContainsSecrets returns true if the property value contains at least one secret (deeply).
|
|
|
|
func (v PropertyValue) ContainsSecrets() bool {
|
|
|
|
if v.IsSecret() {
|
|
|
|
return true
|
|
|
|
} else if v.IsComputed() {
|
|
|
|
return v.Input().Element.ContainsSecrets()
|
|
|
|
} else if v.IsOutput() {
|
2021-09-13 16:05:31 +00:00
|
|
|
return v.OutputValue().Secret || v.OutputValue().Element.ContainsSecrets()
|
2019-05-15 05:17:28 +00:00
|
|
|
} else if v.IsArray() {
|
|
|
|
for _, e := range v.ArrayValue() {
|
|
|
|
if e.ContainsSecrets() {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if v.IsObject() {
|
|
|
|
return v.ObjectValue().ContainsSecrets()
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
Unmap properties on the receive side
This change makes progress on a few things with respect to properly
receiving properties on the engine side, coming from the provider side,
of the RPC boundary. The issues here are twofold:
1. Properties need to get unmapped using a JSON-tag-sensitive
marshaler, so that they are cased properly, etc. For that, we
have a new mapper.Unmap function (which is ultra lame -- see
pulumi/lumi#138).
2. We have the reverse problem with respect to resource IDs: on
the send side, we must translate from URNs (which the engine
knows about) and provider IDs (which the provider knows about);
similarly, then, on the receive side, we must translate from
provider IDs back into URNs.
As a result of these getting fixed, we can now properly marshal the
resulting properties back into the resource object during the plan
execution, alongside propagating and memoizing its ID.
2017-05-31 18:51:46 +00:00
|
|
|
// BoolValue fetches the underlying bool value (panicking if it isn't a bool).
|
|
|
|
func (v PropertyValue) BoolValue() bool { return v.V.(bool) }
|
|
|
|
|
|
|
|
// NumberValue fetches the underlying number value (panicking if it isn't a number).
|
|
|
|
func (v PropertyValue) NumberValue() float64 { return v.V.(float64) }
|
|
|
|
|
|
|
|
// StringValue fetches the underlying string value (panicking if it isn't a string).
|
|
|
|
func (v PropertyValue) StringValue() string { return v.V.(string) }
|
|
|
|
|
|
|
|
// ArrayValue fetches the underlying array value (panicking if it isn't a array).
|
2017-02-20 19:18:47 +00:00
|
|
|
func (v PropertyValue) ArrayValue() []PropertyValue { return v.V.([]PropertyValue) }
|
|
|
|
|
2017-07-14 19:28:43 +00:00
|
|
|
// AssetValue fetches the underlying asset value (panicking if it isn't an asset).
|
Move assets and archives to their own package (#15157)
<!---
Thanks so much for your contribution! If this is your first time
contributing, please ensure that you have read the
[CONTRIBUTING](https://github.com/pulumi/pulumi/blob/master/CONTRIBUTING.md)
documentation.
-->
# Description
This PR is motivated by https://github.com/pulumi/pulumi/pull/15145.
`resource.*` should be built on top of `property.Value`,[^1] which means
that `resource`
needs to be able to import `property.Value`, and so `property` cannot
import
`resource`. Since Assets and Archives are both types of properties, they
must be moved out
of `resource`.
[^1]: For example:
https://github.com/pulumi/pulumi/blob/a1d686227cd7e3c70c51bd772450cb0cd57c1479/sdk/go/common/resource/resource_state.go#L35-L36
## Open Question
This PR moves them to their own sub-folders in `resource`. Should
`asset` and `archive`
live somewhere more high level, like `sdk/go/property/{asset,archive}`?
<!--- Please include a summary of the change and which issue is fixed.
Please also include relevant motivation and context. -->
## Checklist
- [ ] I have run `make tidy` to update any new dependencies
- [ ] I have run `make lint` to verify my code passes the lint check
- [ ] I have formatted my code using `gofumpt`
<!--- Please provide details if the checkbox below is to be left
unchecked. -->
- [ ] I have added tests that prove my fix is effective or that my
feature works
<!---
User-facing changes require a CHANGELOG entry.
-->
- [ ] I have run `make changelog` and committed the
`changelog/pending/<file>` documenting my change
<!--
If the change(s) in this PR is a modification of an existing call to the
Pulumi Cloud,
then the service should honor older versions of the CLI where this
change would not exist.
You must then bump the API version in
/pkg/backend/httpstate/client/api.go, as well as add
it to the service.
-->
- [ ] Yes, there are changes in this PR that warrants bumping the Pulumi
Cloud API version
<!-- @Pulumi employees: If yes, you must submit corresponding changes in
the service repo. -->
2024-01-25 20:39:31 +00:00
|
|
|
func (v PropertyValue) AssetValue() *asset.Asset { return v.V.(*asset.Asset) }
|
2017-07-14 19:28:43 +00:00
|
|
|
|
|
|
|
// ArchiveValue fetches the underlying archive value (panicking if it isn't an archive).
|
Move assets and archives to their own package (#15157)
<!---
Thanks so much for your contribution! If this is your first time
contributing, please ensure that you have read the
[CONTRIBUTING](https://github.com/pulumi/pulumi/blob/master/CONTRIBUTING.md)
documentation.
-->
# Description
This PR is motivated by https://github.com/pulumi/pulumi/pull/15145.
`resource.*` should be built on top of `property.Value`,[^1] which means
that `resource`
needs to be able to import `property.Value`, and so `property` cannot
import
`resource`. Since Assets and Archives are both types of properties, they
must be moved out
of `resource`.
[^1]: For example:
https://github.com/pulumi/pulumi/blob/a1d686227cd7e3c70c51bd772450cb0cd57c1479/sdk/go/common/resource/resource_state.go#L35-L36
## Open Question
This PR moves them to their own sub-folders in `resource`. Should
`asset` and `archive`
live somewhere more high level, like `sdk/go/property/{asset,archive}`?
<!--- Please include a summary of the change and which issue is fixed.
Please also include relevant motivation and context. -->
## Checklist
- [ ] I have run `make tidy` to update any new dependencies
- [ ] I have run `make lint` to verify my code passes the lint check
- [ ] I have formatted my code using `gofumpt`
<!--- Please provide details if the checkbox below is to be left
unchecked. -->
- [ ] I have added tests that prove my fix is effective or that my
feature works
<!---
User-facing changes require a CHANGELOG entry.
-->
- [ ] I have run `make changelog` and committed the
`changelog/pending/<file>` documenting my change
<!--
If the change(s) in this PR is a modification of an existing call to the
Pulumi Cloud,
then the service should honor older versions of the CLI where this
change would not exist.
You must then bump the API version in
/pkg/backend/httpstate/client/api.go, as well as add
it to the service.
-->
- [ ] Yes, there are changes in this PR that warrants bumping the Pulumi
Cloud API version
<!-- @Pulumi employees: If yes, you must submit corresponding changes in
the service repo. -->
2024-01-25 20:39:31 +00:00
|
|
|
func (v PropertyValue) ArchiveValue() *archive.Archive { return v.V.(*archive.Archive) }
|
2017-07-14 19:28:43 +00:00
|
|
|
|
Unmap properties on the receive side
This change makes progress on a few things with respect to properly
receiving properties on the engine side, coming from the provider side,
of the RPC boundary. The issues here are twofold:
1. Properties need to get unmapped using a JSON-tag-sensitive
marshaler, so that they are cased properly, etc. For that, we
have a new mapper.Unmap function (which is ultra lame -- see
pulumi/lumi#138).
2. We have the reverse problem with respect to resource IDs: on
the send side, we must translate from URNs (which the engine
knows about) and provider IDs (which the provider knows about);
similarly, then, on the receive side, we must translate from
provider IDs back into URNs.
As a result of these getting fixed, we can now properly marshal the
resulting properties back into the resource object during the plan
execution, alongside propagating and memoizing its ID.
2017-05-31 18:51:46 +00:00
|
|
|
// ObjectValue fetches the underlying object value (panicking if it isn't a object).
|
|
|
|
func (v PropertyValue) ObjectValue() PropertyMap { return v.V.(PropertyMap) }
|
|
|
|
|
2018-02-05 22:44:23 +00:00
|
|
|
// Input fetches the underlying computed value (panicking if it isn't a computed).
|
|
|
|
func (v PropertyValue) Input() Computed { return v.V.(Computed) }
|
Unmap properties on the receive side
This change makes progress on a few things with respect to properly
receiving properties on the engine side, coming from the provider side,
of the RPC boundary. The issues here are twofold:
1. Properties need to get unmapped using a JSON-tag-sensitive
marshaler, so that they are cased properly, etc. For that, we
have a new mapper.Unmap function (which is ultra lame -- see
pulumi/lumi#138).
2. We have the reverse problem with respect to resource IDs: on
the send side, we must translate from URNs (which the engine
knows about) and provider IDs (which the provider knows about);
similarly, then, on the receive side, we must translate from
provider IDs back into URNs.
As a result of these getting fixed, we can now properly marshal the
resulting properties back into the resource object during the plan
execution, alongside propagating and memoizing its ID.
2017-05-31 18:51:46 +00:00
|
|
|
|
|
|
|
// OutputValue fetches the underlying output value (panicking if it isn't a output).
|
|
|
|
func (v PropertyValue) OutputValue() Output { return v.V.(Output) }
|
|
|
|
|
2019-04-12 21:29:08 +00:00
|
|
|
// SecretValue fetches the underlying secret value (panicking if it isn't a secret).
|
2019-09-18 22:52:31 +00:00
|
|
|
func (v PropertyValue) SecretValue() *Secret { return v.V.(*Secret) }
|
2019-04-12 21:29:08 +00:00
|
|
|
|
2020-10-27 17:12:12 +00:00
|
|
|
// ResourceReferenceValue fetches the underlying resource reference value (panicking if it isn't a resource reference).
|
|
|
|
func (v PropertyValue) ResourceReferenceValue() ResourceReference { return v.V.(ResourceReference) }
|
|
|
|
|
Unmap properties on the receive side
This change makes progress on a few things with respect to properly
receiving properties on the engine side, coming from the provider side,
of the RPC boundary. The issues here are twofold:
1. Properties need to get unmapped using a JSON-tag-sensitive
marshaler, so that they are cased properly, etc. For that, we
have a new mapper.Unmap function (which is ultra lame -- see
pulumi/lumi#138).
2. We have the reverse problem with respect to resource IDs: on
the send side, we must translate from URNs (which the engine
knows about) and provider IDs (which the provider knows about);
similarly, then, on the receive side, we must translate from
provider IDs back into URNs.
As a result of these getting fixed, we can now properly marshal the
resulting properties back into the resource object during the plan
execution, alongside propagating and memoizing its ID.
2017-05-31 18:51:46 +00:00
|
|
|
// IsNull returns true if the underlying value is a null.
|
2017-04-08 14:44:02 +00:00
|
|
|
func (v PropertyValue) IsNull() bool {
|
|
|
|
return v.V == nil
|
2017-02-20 19:18:47 +00:00
|
|
|
}
|
Unmap properties on the receive side
This change makes progress on a few things with respect to properly
receiving properties on the engine side, coming from the provider side,
of the RPC boundary. The issues here are twofold:
1. Properties need to get unmapped using a JSON-tag-sensitive
marshaler, so that they are cased properly, etc. For that, we
have a new mapper.Unmap function (which is ultra lame -- see
pulumi/lumi#138).
2. We have the reverse problem with respect to resource IDs: on
the send side, we must translate from URNs (which the engine
knows about) and provider IDs (which the provider knows about);
similarly, then, on the receive side, we must translate from
provider IDs back into URNs.
As a result of these getting fixed, we can now properly marshal the
resulting properties back into the resource object during the plan
execution, alongside propagating and memoizing its ID.
2017-05-31 18:51:46 +00:00
|
|
|
|
|
|
|
// IsBool returns true if the underlying value is a bool.
|
2017-04-08 14:44:02 +00:00
|
|
|
func (v PropertyValue) IsBool() bool {
|
|
|
|
_, is := v.V.(bool)
|
2017-02-20 19:18:47 +00:00
|
|
|
return is
|
|
|
|
}
|
Unmap properties on the receive side
This change makes progress on a few things with respect to properly
receiving properties on the engine side, coming from the provider side,
of the RPC boundary. The issues here are twofold:
1. Properties need to get unmapped using a JSON-tag-sensitive
marshaler, so that they are cased properly, etc. For that, we
have a new mapper.Unmap function (which is ultra lame -- see
pulumi/lumi#138).
2. We have the reverse problem with respect to resource IDs: on
the send side, we must translate from URNs (which the engine
knows about) and provider IDs (which the provider knows about);
similarly, then, on the receive side, we must translate from
provider IDs back into URNs.
As a result of these getting fixed, we can now properly marshal the
resulting properties back into the resource object during the plan
execution, alongside propagating and memoizing its ID.
2017-05-31 18:51:46 +00:00
|
|
|
|
|
|
|
// IsNumber returns true if the underlying value is a number.
|
2017-04-08 14:44:02 +00:00
|
|
|
func (v PropertyValue) IsNumber() bool {
|
|
|
|
_, is := v.V.(float64)
|
2017-02-20 19:18:47 +00:00
|
|
|
return is
|
|
|
|
}
|
Unmap properties on the receive side
This change makes progress on a few things with respect to properly
receiving properties on the engine side, coming from the provider side,
of the RPC boundary. The issues here are twofold:
1. Properties need to get unmapped using a JSON-tag-sensitive
marshaler, so that they are cased properly, etc. For that, we
have a new mapper.Unmap function (which is ultra lame -- see
pulumi/lumi#138).
2. We have the reverse problem with respect to resource IDs: on
the send side, we must translate from URNs (which the engine
knows about) and provider IDs (which the provider knows about);
similarly, then, on the receive side, we must translate from
provider IDs back into URNs.
As a result of these getting fixed, we can now properly marshal the
resulting properties back into the resource object during the plan
execution, alongside propagating and memoizing its ID.
2017-05-31 18:51:46 +00:00
|
|
|
|
|
|
|
// IsString returns true if the underlying value is a string.
|
2017-04-08 14:44:02 +00:00
|
|
|
func (v PropertyValue) IsString() bool {
|
|
|
|
_, is := v.V.(string)
|
2017-02-20 19:18:47 +00:00
|
|
|
return is
|
|
|
|
}
|
Unmap properties on the receive side
This change makes progress on a few things with respect to properly
receiving properties on the engine side, coming from the provider side,
of the RPC boundary. The issues here are twofold:
1. Properties need to get unmapped using a JSON-tag-sensitive
marshaler, so that they are cased properly, etc. For that, we
have a new mapper.Unmap function (which is ultra lame -- see
pulumi/lumi#138).
2. We have the reverse problem with respect to resource IDs: on
the send side, we must translate from URNs (which the engine
knows about) and provider IDs (which the provider knows about);
similarly, then, on the receive side, we must translate from
provider IDs back into URNs.
As a result of these getting fixed, we can now properly marshal the
resulting properties back into the resource object during the plan
execution, alongside propagating and memoizing its ID.
2017-05-31 18:51:46 +00:00
|
|
|
|
|
|
|
// IsArray returns true if the underlying value is an array.
|
2017-04-08 14:44:02 +00:00
|
|
|
func (v PropertyValue) IsArray() bool {
|
|
|
|
_, is := v.V.([]PropertyValue)
|
2017-02-20 19:18:47 +00:00
|
|
|
return is
|
|
|
|
}
|
Unmap properties on the receive side
This change makes progress on a few things with respect to properly
receiving properties on the engine side, coming from the provider side,
of the RPC boundary. The issues here are twofold:
1. Properties need to get unmapped using a JSON-tag-sensitive
marshaler, so that they are cased properly, etc. For that, we
have a new mapper.Unmap function (which is ultra lame -- see
pulumi/lumi#138).
2. We have the reverse problem with respect to resource IDs: on
the send side, we must translate from URNs (which the engine
knows about) and provider IDs (which the provider knows about);
similarly, then, on the receive side, we must translate from
provider IDs back into URNs.
As a result of these getting fixed, we can now properly marshal the
resulting properties back into the resource object during the plan
execution, alongside propagating and memoizing its ID.
2017-05-31 18:51:46 +00:00
|
|
|
|
2017-07-14 19:28:43 +00:00
|
|
|
// IsAsset returns true if the underlying value is an object.
|
|
|
|
func (v PropertyValue) IsAsset() bool {
|
Move assets and archives to their own package (#15157)
<!---
Thanks so much for your contribution! If this is your first time
contributing, please ensure that you have read the
[CONTRIBUTING](https://github.com/pulumi/pulumi/blob/master/CONTRIBUTING.md)
documentation.
-->
# Description
This PR is motivated by https://github.com/pulumi/pulumi/pull/15145.
`resource.*` should be built on top of `property.Value`,[^1] which means
that `resource`
needs to be able to import `property.Value`, and so `property` cannot
import
`resource`. Since Assets and Archives are both types of properties, they
must be moved out
of `resource`.
[^1]: For example:
https://github.com/pulumi/pulumi/blob/a1d686227cd7e3c70c51bd772450cb0cd57c1479/sdk/go/common/resource/resource_state.go#L35-L36
## Open Question
This PR moves them to their own sub-folders in `resource`. Should
`asset` and `archive`
live somewhere more high level, like `sdk/go/property/{asset,archive}`?
<!--- Please include a summary of the change and which issue is fixed.
Please also include relevant motivation and context. -->
## Checklist
- [ ] I have run `make tidy` to update any new dependencies
- [ ] I have run `make lint` to verify my code passes the lint check
- [ ] I have formatted my code using `gofumpt`
<!--- Please provide details if the checkbox below is to be left
unchecked. -->
- [ ] I have added tests that prove my fix is effective or that my
feature works
<!---
User-facing changes require a CHANGELOG entry.
-->
- [ ] I have run `make changelog` and committed the
`changelog/pending/<file>` documenting my change
<!--
If the change(s) in this PR is a modification of an existing call to the
Pulumi Cloud,
then the service should honor older versions of the CLI where this
change would not exist.
You must then bump the API version in
/pkg/backend/httpstate/client/api.go, as well as add
it to the service.
-->
- [ ] Yes, there are changes in this PR that warrants bumping the Pulumi
Cloud API version
<!-- @Pulumi employees: If yes, you must submit corresponding changes in
the service repo. -->
2024-01-25 20:39:31 +00:00
|
|
|
_, is := v.V.(*asset.Asset)
|
2017-07-14 19:28:43 +00:00
|
|
|
return is
|
|
|
|
}
|
|
|
|
|
|
|
|
// IsArchive returns true if the underlying value is an object.
|
|
|
|
func (v PropertyValue) IsArchive() bool {
|
Move assets and archives to their own package (#15157)
<!---
Thanks so much for your contribution! If this is your first time
contributing, please ensure that you have read the
[CONTRIBUTING](https://github.com/pulumi/pulumi/blob/master/CONTRIBUTING.md)
documentation.
-->
# Description
This PR is motivated by https://github.com/pulumi/pulumi/pull/15145.
`resource.*` should be built on top of `property.Value`,[^1] which means
that `resource`
needs to be able to import `property.Value`, and so `property` cannot
import
`resource`. Since Assets and Archives are both types of properties, they
must be moved out
of `resource`.
[^1]: For example:
https://github.com/pulumi/pulumi/blob/a1d686227cd7e3c70c51bd772450cb0cd57c1479/sdk/go/common/resource/resource_state.go#L35-L36
## Open Question
This PR moves them to their own sub-folders in `resource`. Should
`asset` and `archive`
live somewhere more high level, like `sdk/go/property/{asset,archive}`?
<!--- Please include a summary of the change and which issue is fixed.
Please also include relevant motivation and context. -->
## Checklist
- [ ] I have run `make tidy` to update any new dependencies
- [ ] I have run `make lint` to verify my code passes the lint check
- [ ] I have formatted my code using `gofumpt`
<!--- Please provide details if the checkbox below is to be left
unchecked. -->
- [ ] I have added tests that prove my fix is effective or that my
feature works
<!---
User-facing changes require a CHANGELOG entry.
-->
- [ ] I have run `make changelog` and committed the
`changelog/pending/<file>` documenting my change
<!--
If the change(s) in this PR is a modification of an existing call to the
Pulumi Cloud,
then the service should honor older versions of the CLI where this
change would not exist.
You must then bump the API version in
/pkg/backend/httpstate/client/api.go, as well as add
it to the service.
-->
- [ ] Yes, there are changes in this PR that warrants bumping the Pulumi
Cloud API version
<!-- @Pulumi employees: If yes, you must submit corresponding changes in
the service repo. -->
2024-01-25 20:39:31 +00:00
|
|
|
_, is := v.V.(*archive.Archive)
|
2017-07-14 19:28:43 +00:00
|
|
|
return is
|
|
|
|
}
|
|
|
|
|
Unmap properties on the receive side
This change makes progress on a few things with respect to properly
receiving properties on the engine side, coming from the provider side,
of the RPC boundary. The issues here are twofold:
1. Properties need to get unmapped using a JSON-tag-sensitive
marshaler, so that they are cased properly, etc. For that, we
have a new mapper.Unmap function (which is ultra lame -- see
pulumi/lumi#138).
2. We have the reverse problem with respect to resource IDs: on
the send side, we must translate from URNs (which the engine
knows about) and provider IDs (which the provider knows about);
similarly, then, on the receive side, we must translate from
provider IDs back into URNs.
As a result of these getting fixed, we can now properly marshal the
resulting properties back into the resource object during the plan
execution, alongside propagating and memoizing its ID.
2017-05-31 18:51:46 +00:00
|
|
|
// IsObject returns true if the underlying value is an object.
|
2017-04-08 14:44:02 +00:00
|
|
|
func (v PropertyValue) IsObject() bool {
|
|
|
|
_, is := v.V.(PropertyMap)
|
2017-02-20 19:18:47 +00:00
|
|
|
return is
|
|
|
|
}
|
Unmap properties on the receive side
This change makes progress on a few things with respect to properly
receiving properties on the engine side, coming from the provider side,
of the RPC boundary. The issues here are twofold:
1. Properties need to get unmapped using a JSON-tag-sensitive
marshaler, so that they are cased properly, etc. For that, we
have a new mapper.Unmap function (which is ultra lame -- see
pulumi/lumi#138).
2. We have the reverse problem with respect to resource IDs: on
the send side, we must translate from URNs (which the engine
knows about) and provider IDs (which the provider knows about);
similarly, then, on the receive side, we must translate from
provider IDs back into URNs.
As a result of these getting fixed, we can now properly marshal the
resulting properties back into the resource object during the plan
execution, alongside propagating and memoizing its ID.
2017-05-31 18:51:46 +00:00
|
|
|
|
|
|
|
// IsComputed returns true if the underlying value is a computed value.
|
2017-05-25 20:19:20 +00:00
|
|
|
func (v PropertyValue) IsComputed() bool {
|
|
|
|
_, is := v.V.(Computed)
|
|
|
|
return is
|
|
|
|
}
|
Unmap properties on the receive side
This change makes progress on a few things with respect to properly
receiving properties on the engine side, coming from the provider side,
of the RPC boundary. The issues here are twofold:
1. Properties need to get unmapped using a JSON-tag-sensitive
marshaler, so that they are cased properly, etc. For that, we
have a new mapper.Unmap function (which is ultra lame -- see
pulumi/lumi#138).
2. We have the reverse problem with respect to resource IDs: on
the send side, we must translate from URNs (which the engine
knows about) and provider IDs (which the provider knows about);
similarly, then, on the receive side, we must translate from
provider IDs back into URNs.
As a result of these getting fixed, we can now properly marshal the
resulting properties back into the resource object during the plan
execution, alongside propagating and memoizing its ID.
2017-05-31 18:51:46 +00:00
|
|
|
|
|
|
|
// IsOutput returns true if the underlying value is an output value.
|
2017-05-25 20:19:20 +00:00
|
|
|
func (v PropertyValue) IsOutput() bool {
|
|
|
|
_, is := v.V.(Output)
|
Initial support for output properties (1 of 3)
This change includes approximately 1/3rd of the change necessary
to support output properties, as per pulumi/lumi#90.
In short, the runtime now has a new hidden type, Latent<T>, which
represents a "speculative" value, whose eventual type will be T,
that we can use during evaluation in various ways. Namely,
operations against Latent<T>s generally produce new Latent<U>s.
During planning, any Latent<T>s that end up in resource properties
are transformed into "unknown" property values. An unknown property
value is legal only during planning-time activities, such as Check,
Name, and InspectChange. As a result, those RPC interfaces have
been updated to include lookaside maps indicating which properties
have unknown values. My intent is to add some helper functions to
make dealing with this circumstance more correct-by-construction.
For now, using an unresolved Latent<T> in a conditional will lead
to an error. See pulumi/lumi#67. Speculating beyond these -- by
supporting iterative planning and application -- is something we
want to support eventually, but it makes sense to do that as an
additive change beyond this initial support. That is a missing 1/3.
Finally, the other missing 1/3rd which will happen much sooner
than the rest is restructuing plan application so that it will
correctly observe resolution of Latent<T> values. Right now, the
evaluation happens in one single pass, prior to the application, and
so Latent<T>s never actually get witnessed in a resolved state.
2017-05-24 00:32:59 +00:00
|
|
|
return is
|
|
|
|
}
|
|
|
|
|
2019-04-12 21:29:08 +00:00
|
|
|
// IsSecret returns true if the underlying value is a secret value.
|
|
|
|
func (v PropertyValue) IsSecret() bool {
|
2019-09-18 22:52:31 +00:00
|
|
|
_, is := v.V.(*Secret)
|
2019-04-12 21:29:08 +00:00
|
|
|
return is
|
|
|
|
}
|
|
|
|
|
2020-10-27 17:12:12 +00:00
|
|
|
// IsResourceReference returns true if the underlying value is a resource reference value.
|
|
|
|
func (v PropertyValue) IsResourceReference() bool {
|
|
|
|
_, is := v.V.(ResourceReference)
|
|
|
|
return is
|
|
|
|
}
|
|
|
|
|
Unmap properties on the receive side
This change makes progress on a few things with respect to properly
receiving properties on the engine side, coming from the provider side,
of the RPC boundary. The issues here are twofold:
1. Properties need to get unmapped using a JSON-tag-sensitive
marshaler, so that they are cased properly, etc. For that, we
have a new mapper.Unmap function (which is ultra lame -- see
pulumi/lumi#138).
2. We have the reverse problem with respect to resource IDs: on
the send side, we must translate from URNs (which the engine
knows about) and provider IDs (which the provider knows about);
similarly, then, on the receive side, we must translate from
provider IDs back into URNs.
As a result of these getting fixed, we can now properly marshal the
resulting properties back into the resource object during the plan
execution, alongside propagating and memoizing its ID.
2017-05-31 18:51:46 +00:00
|
|
|
// TypeString returns a type representation of the property value's holder type.
|
Initial support for output properties (1 of 3)
This change includes approximately 1/3rd of the change necessary
to support output properties, as per pulumi/lumi#90.
In short, the runtime now has a new hidden type, Latent<T>, which
represents a "speculative" value, whose eventual type will be T,
that we can use during evaluation in various ways. Namely,
operations against Latent<T>s generally produce new Latent<U>s.
During planning, any Latent<T>s that end up in resource properties
are transformed into "unknown" property values. An unknown property
value is legal only during planning-time activities, such as Check,
Name, and InspectChange. As a result, those RPC interfaces have
been updated to include lookaside maps indicating which properties
have unknown values. My intent is to add some helper functions to
make dealing with this circumstance more correct-by-construction.
For now, using an unresolved Latent<T> in a conditional will lead
to an error. See pulumi/lumi#67. Speculating beyond these -- by
supporting iterative planning and application -- is something we
want to support eventually, but it makes sense to do that as an
additive change beyond this initial support. That is a missing 1/3.
Finally, the other missing 1/3rd which will happen much sooner
than the rest is restructuing plan application so that it will
correctly observe resolution of Latent<T> values. Right now, the
evaluation happens in one single pass, prior to the application, and
so Latent<T>s never actually get witnessed in a resolved state.
2017-05-24 00:32:59 +00:00
|
|
|
func (v PropertyValue) TypeString() string {
|
|
|
|
if v.IsNull() {
|
|
|
|
return "null"
|
|
|
|
} else if v.IsBool() {
|
|
|
|
return "bool"
|
|
|
|
} else if v.IsNumber() {
|
|
|
|
return "number"
|
|
|
|
} else if v.IsString() {
|
|
|
|
return "string"
|
|
|
|
} else if v.IsArray() {
|
|
|
|
return "[]"
|
2017-07-14 19:28:43 +00:00
|
|
|
} else if v.IsAsset() {
|
|
|
|
return "asset"
|
|
|
|
} else if v.IsArchive() {
|
|
|
|
return "archive"
|
Initial support for output properties (1 of 3)
This change includes approximately 1/3rd of the change necessary
to support output properties, as per pulumi/lumi#90.
In short, the runtime now has a new hidden type, Latent<T>, which
represents a "speculative" value, whose eventual type will be T,
that we can use during evaluation in various ways. Namely,
operations against Latent<T>s generally produce new Latent<U>s.
During planning, any Latent<T>s that end up in resource properties
are transformed into "unknown" property values. An unknown property
value is legal only during planning-time activities, such as Check,
Name, and InspectChange. As a result, those RPC interfaces have
been updated to include lookaside maps indicating which properties
have unknown values. My intent is to add some helper functions to
make dealing with this circumstance more correct-by-construction.
For now, using an unresolved Latent<T> in a conditional will lead
to an error. See pulumi/lumi#67. Speculating beyond these -- by
supporting iterative planning and application -- is something we
want to support eventually, but it makes sense to do that as an
additive change beyond this initial support. That is a missing 1/3.
Finally, the other missing 1/3rd which will happen much sooner
than the rest is restructuing plan application so that it will
correctly observe resolution of Latent<T> values. Right now, the
evaluation happens in one single pass, prior to the application, and
so Latent<T>s never actually get witnessed in a resolved state.
2017-05-24 00:32:59 +00:00
|
|
|
} else if v.IsObject() {
|
|
|
|
return "object"
|
2017-05-25 20:19:20 +00:00
|
|
|
} else if v.IsComputed() {
|
2018-12-03 03:44:50 +00:00
|
|
|
return "output<" + v.Input().Element.TypeString() + ">"
|
2017-05-25 20:19:20 +00:00
|
|
|
} else if v.IsOutput() {
|
2021-09-13 16:05:31 +00:00
|
|
|
if !v.OutputValue().Known {
|
|
|
|
return MakeComputed(v.OutputValue().Element).TypeString()
|
|
|
|
} else if v.OutputValue().Secret {
|
|
|
|
return MakeSecret(v.OutputValue().Element).TypeString()
|
|
|
|
}
|
|
|
|
return v.OutputValue().Element.TypeString()
|
2019-04-12 21:29:08 +00:00
|
|
|
} else if v.IsSecret() {
|
|
|
|
return "secret<" + v.SecretValue().Element.TypeString() + ">"
|
2020-10-27 17:12:12 +00:00
|
|
|
} else if v.IsResourceReference() {
|
|
|
|
ref := v.ResourceReferenceValue()
|
|
|
|
return fmt.Sprintf("resourceReference(%q, %q, %q)", ref.URN, ref.ID, ref.PackageVersion)
|
Initial support for output properties (1 of 3)
This change includes approximately 1/3rd of the change necessary
to support output properties, as per pulumi/lumi#90.
In short, the runtime now has a new hidden type, Latent<T>, which
represents a "speculative" value, whose eventual type will be T,
that we can use during evaluation in various ways. Namely,
operations against Latent<T>s generally produce new Latent<U>s.
During planning, any Latent<T>s that end up in resource properties
are transformed into "unknown" property values. An unknown property
value is legal only during planning-time activities, such as Check,
Name, and InspectChange. As a result, those RPC interfaces have
been updated to include lookaside maps indicating which properties
have unknown values. My intent is to add some helper functions to
make dealing with this circumstance more correct-by-construction.
For now, using an unresolved Latent<T> in a conditional will lead
to an error. See pulumi/lumi#67. Speculating beyond these -- by
supporting iterative planning and application -- is something we
want to support eventually, but it makes sense to do that as an
additive change beyond this initial support. That is a missing 1/3.
Finally, the other missing 1/3rd which will happen much sooner
than the rest is restructuing plan application so that it will
correctly observe resolution of Latent<T> values. Right now, the
evaluation happens in one single pass, prior to the application, and
so Latent<T>s never actually get witnessed in a resolved state.
2017-05-24 00:32:59 +00:00
|
|
|
}
|
|
|
|
contract.Failf("Unrecognized PropertyValue type")
|
|
|
|
return ""
|
|
|
|
}
|
Implement updates
This change is a first whack at implementing updates.
Creation and deletion plans are pretty straightforward; we just take
a single graph, topologically sort it, and perform the operations in
the right order. For creation, this is in dependency order (things
that are depended upon must be created before dependents); for deletion,
this is in reverse-dependency order (things that depend on others must
be deleted before dependencies). These are just special cases of the more
general idea of performing DAG operations in dependency order.
Updates must work in terms of this more general notion. For example:
* It is an error to delete a resource while another refers to it; thus,
resources are deleted after deleting dependents, or after updating
dependent properties that reference the resource to new values.
* It is an error to depend on a create a resource before it is created;
thus, resources must be created before dependents are created, and/or
before updates to existing resource properties that would cause them
to refer to the new resource.
Of course, all of this is tangled up in a graph of dependencies. As a
result, we must create a DAG of the dependencies between creates, updates,
and deletes, and then topologically sort this DAG, in order to determine
the proper order of update operations.
To do this, we slightly generalize the existing graph infrastructure,
while also specializing two kinds of graphs; the existing one becomes a
heapstate.ObjectGraph, while this new one is resource.planGraph (internal).
2017-02-23 22:56:23 +00:00
|
|
|
|
2017-03-12 21:13:44 +00:00
|
|
|
// Mappable returns a mapper-compatible value, suitable for deserialization into structures.
|
Implement mapper.Encode "for real"
This change implements `mapper.Encode` "for real" (that is, in a way
that isn't a complete embarrassment). It uses the obvious reflection
trickery to encode a tagged struct and its values as a JSON-like
in-memory map and collection of keyed values.
During this, I took the opportunity to also clean up a few other things
that had been bugging me. Namely, the presence of `mapper.Object` was
always error prone, since it isn't a true "typedef" in the sence that
it carries extra RTTI. Instead of doing that, let's just use the real
`map[string]interface{}` "JSON-map-like" object type. Even better, we
no longer require resource providers to deal with the mapper
infrastructure. Instead, the `Check` function can simply return an
array of errors. It's still best practice to return field-specific errors
to facilitate better diagnostics, but it's no longer required; and I've
added `resource.NewFieldError` to eliminate the need to import mapper.
As of this change, we can also consistently emit RPC structs with `lumi`
tags, rather than `lumi` tags on the way in and `json` on the way out.
This completes pulumi/lumi#183.
2017-06-06 00:43:52 +00:00
|
|
|
func (v PropertyValue) Mappable() interface{} {
|
2017-07-11 00:40:28 +00:00
|
|
|
return v.MapRepl(nil, nil)
|
2017-07-01 19:08:55 +00:00
|
|
|
}
|
|
|
|
|
2017-07-11 00:40:28 +00:00
|
|
|
// MapRepl returns a mapper-compatible object map, suitable for deserialization into structures. A key and/or value
|
|
|
|
// replace function, replk/replv, may be passed that will replace elements using custom logic if appropriate.
|
|
|
|
func (v PropertyValue) MapRepl(replk func(string) (string, bool),
|
2023-03-03 16:36:39 +00:00
|
|
|
replv func(PropertyValue) (interface{}, bool),
|
|
|
|
) interface{} {
|
2017-07-11 00:40:28 +00:00
|
|
|
if replv != nil {
|
|
|
|
if rv, repv := replv(v); repv {
|
|
|
|
return rv
|
2017-07-01 19:08:55 +00:00
|
|
|
}
|
|
|
|
}
|
2017-03-12 21:13:44 +00:00
|
|
|
if v.IsNull() {
|
|
|
|
return nil
|
|
|
|
} else if v.IsBool() {
|
|
|
|
return v.BoolValue()
|
|
|
|
} else if v.IsNumber() {
|
|
|
|
return v.NumberValue()
|
|
|
|
} else if v.IsString() {
|
|
|
|
return v.StringValue()
|
|
|
|
} else if v.IsArray() {
|
2019-08-07 18:42:40 +00:00
|
|
|
arr := []interface{}{}
|
2017-03-12 21:13:44 +00:00
|
|
|
for _, e := range v.ArrayValue() {
|
2017-07-11 00:40:28 +00:00
|
|
|
arr = append(arr, e.MapRepl(replk, replv))
|
2017-03-12 21:13:44 +00:00
|
|
|
}
|
|
|
|
return arr
|
2017-07-14 19:28:43 +00:00
|
|
|
} else if v.IsAsset() {
|
|
|
|
return v.AssetValue()
|
|
|
|
} else if v.IsArchive() {
|
|
|
|
return v.ArchiveValue()
|
2017-08-03 18:01:38 +00:00
|
|
|
} else if v.IsComputed() {
|
2018-02-05 22:44:23 +00:00
|
|
|
return v.Input()
|
2017-08-03 18:01:38 +00:00
|
|
|
} else if v.IsOutput() {
|
|
|
|
return v.OutputValue()
|
2019-04-12 21:29:08 +00:00
|
|
|
} else if v.IsSecret() {
|
|
|
|
return v.SecretValue()
|
2020-10-27 17:12:12 +00:00
|
|
|
} else if v.IsResourceReference() {
|
|
|
|
return v.ResourceReferenceValue()
|
2017-03-12 21:13:44 +00:00
|
|
|
}
|
2017-10-24 15:25:39 +00:00
|
|
|
contract.Assertf(v.IsObject(), "v is not Object '%v' instead", v.TypeString())
|
2017-07-11 00:40:28 +00:00
|
|
|
return v.ObjectValue().MapRepl(replk, replv)
|
2017-03-12 21:13:44 +00:00
|
|
|
}
|
|
|
|
|
2017-06-01 15:23:59 +00:00
|
|
|
// String implements the fmt.Stringer interface to add slightly more information to the output.
|
|
|
|
func (v PropertyValue) String() string {
|
2021-09-13 16:05:31 +00:00
|
|
|
if v.IsComputed() {
|
|
|
|
// For computed properties, show the type followed by an empty object string.
|
2017-06-01 15:23:59 +00:00
|
|
|
return fmt.Sprintf("%v{}", v.TypeString())
|
2021-09-13 16:05:31 +00:00
|
|
|
} else if v.IsOutput() {
|
|
|
|
if !v.OutputValue().Known {
|
|
|
|
return MakeComputed(v.OutputValue().Element).String()
|
|
|
|
} else if v.OutputValue().Secret {
|
|
|
|
return MakeSecret(v.OutputValue().Element).String()
|
|
|
|
}
|
|
|
|
return v.OutputValue().Element.String()
|
2017-06-01 15:23:59 +00:00
|
|
|
}
|
|
|
|
// For all others, just display the underlying property value.
|
|
|
|
return fmt.Sprintf("{%v}", v.V)
|
|
|
|
}
|
2017-07-01 20:26:49 +00:00
|
|
|
|
|
|
|
// Property is a pair of key and value.
|
|
|
|
type Property struct {
|
|
|
|
Key PropertyKey
|
|
|
|
Value PropertyValue
|
|
|
|
}
|
2017-07-17 17:38:57 +00:00
|
|
|
|
|
|
|
// SigKey is sometimes used to encode type identity inside of a map. This is required when flattening into ordinary
|
|
|
|
// maps, like we do when performing serialization, to ensure recoverability of type identities later on.
|
Move assets and archives to their own package (#15157)
<!---
Thanks so much for your contribution! If this is your first time
contributing, please ensure that you have read the
[CONTRIBUTING](https://github.com/pulumi/pulumi/blob/master/CONTRIBUTING.md)
documentation.
-->
# Description
This PR is motivated by https://github.com/pulumi/pulumi/pull/15145.
`resource.*` should be built on top of `property.Value`,[^1] which means
that `resource`
needs to be able to import `property.Value`, and so `property` cannot
import
`resource`. Since Assets and Archives are both types of properties, they
must be moved out
of `resource`.
[^1]: For example:
https://github.com/pulumi/pulumi/blob/a1d686227cd7e3c70c51bd772450cb0cd57c1479/sdk/go/common/resource/resource_state.go#L35-L36
## Open Question
This PR moves them to their own sub-folders in `resource`. Should
`asset` and `archive`
live somewhere more high level, like `sdk/go/property/{asset,archive}`?
<!--- Please include a summary of the change and which issue is fixed.
Please also include relevant motivation and context. -->
## Checklist
- [ ] I have run `make tidy` to update any new dependencies
- [ ] I have run `make lint` to verify my code passes the lint check
- [ ] I have formatted my code using `gofumpt`
<!--- Please provide details if the checkbox below is to be left
unchecked. -->
- [ ] I have added tests that prove my fix is effective or that my
feature works
<!---
User-facing changes require a CHANGELOG entry.
-->
- [ ] I have run `make changelog` and committed the
`changelog/pending/<file>` documenting my change
<!--
If the change(s) in this PR is a modification of an existing call to the
Pulumi Cloud,
then the service should honor older versions of the CLI where this
change would not exist.
You must then bump the API version in
/pkg/backend/httpstate/client/api.go, as well as add
it to the service.
-->
- [ ] Yes, there are changes in this PR that warrants bumping the Pulumi
Cloud API version
<!-- @Pulumi employees: If yes, you must submit corresponding changes in
the service repo. -->
2024-01-25 20:39:31 +00:00
|
|
|
const SigKey = sig.Key
|
2017-07-17 17:38:57 +00:00
|
|
|
|
|
|
|
// HasSig checks to see if the given property map contains the specific signature match.
|
|
|
|
func HasSig(obj PropertyMap, match string) bool {
|
|
|
|
if sig, hassig := obj[SigKey]; hassig {
|
|
|
|
return sig.IsString() && sig.StringValue() == match
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
2019-01-23 21:33:25 +00:00
|
|
|
|
|
|
|
// SecretSig is the unique secret signature.
|
Move assets and archives to their own package (#15157)
<!---
Thanks so much for your contribution! If this is your first time
contributing, please ensure that you have read the
[CONTRIBUTING](https://github.com/pulumi/pulumi/blob/master/CONTRIBUTING.md)
documentation.
-->
# Description
This PR is motivated by https://github.com/pulumi/pulumi/pull/15145.
`resource.*` should be built on top of `property.Value`,[^1] which means
that `resource`
needs to be able to import `property.Value`, and so `property` cannot
import
`resource`. Since Assets and Archives are both types of properties, they
must be moved out
of `resource`.
[^1]: For example:
https://github.com/pulumi/pulumi/blob/a1d686227cd7e3c70c51bd772450cb0cd57c1479/sdk/go/common/resource/resource_state.go#L35-L36
## Open Question
This PR moves them to their own sub-folders in `resource`. Should
`asset` and `archive`
live somewhere more high level, like `sdk/go/property/{asset,archive}`?
<!--- Please include a summary of the change and which issue is fixed.
Please also include relevant motivation and context. -->
## Checklist
- [ ] I have run `make tidy` to update any new dependencies
- [ ] I have run `make lint` to verify my code passes the lint check
- [ ] I have formatted my code using `gofumpt`
<!--- Please provide details if the checkbox below is to be left
unchecked. -->
- [ ] I have added tests that prove my fix is effective or that my
feature works
<!---
User-facing changes require a CHANGELOG entry.
-->
- [ ] I have run `make changelog` and committed the
`changelog/pending/<file>` documenting my change
<!--
If the change(s) in this PR is a modification of an existing call to the
Pulumi Cloud,
then the service should honor older versions of the CLI where this
change would not exist.
You must then bump the API version in
/pkg/backend/httpstate/client/api.go, as well as add
it to the service.
-->
- [ ] Yes, there are changes in this PR that warrants bumping the Pulumi
Cloud API version
<!-- @Pulumi employees: If yes, you must submit corresponding changes in
the service repo. -->
2024-01-25 20:39:31 +00:00
|
|
|
const SecretSig = sig.Secret
|
2020-03-18 18:39:13 +00:00
|
|
|
|
2020-10-27 17:12:12 +00:00
|
|
|
// ResourceReferenceSig is the unique resource reference signature.
|
Move assets and archives to their own package (#15157)
<!---
Thanks so much for your contribution! If this is your first time
contributing, please ensure that you have read the
[CONTRIBUTING](https://github.com/pulumi/pulumi/blob/master/CONTRIBUTING.md)
documentation.
-->
# Description
This PR is motivated by https://github.com/pulumi/pulumi/pull/15145.
`resource.*` should be built on top of `property.Value`,[^1] which means
that `resource`
needs to be able to import `property.Value`, and so `property` cannot
import
`resource`. Since Assets and Archives are both types of properties, they
must be moved out
of `resource`.
[^1]: For example:
https://github.com/pulumi/pulumi/blob/a1d686227cd7e3c70c51bd772450cb0cd57c1479/sdk/go/common/resource/resource_state.go#L35-L36
## Open Question
This PR moves them to their own sub-folders in `resource`. Should
`asset` and `archive`
live somewhere more high level, like `sdk/go/property/{asset,archive}`?
<!--- Please include a summary of the change and which issue is fixed.
Please also include relevant motivation and context. -->
## Checklist
- [ ] I have run `make tidy` to update any new dependencies
- [ ] I have run `make lint` to verify my code passes the lint check
- [ ] I have formatted my code using `gofumpt`
<!--- Please provide details if the checkbox below is to be left
unchecked. -->
- [ ] I have added tests that prove my fix is effective or that my
feature works
<!---
User-facing changes require a CHANGELOG entry.
-->
- [ ] I have run `make changelog` and committed the
`changelog/pending/<file>` documenting my change
<!--
If the change(s) in this PR is a modification of an existing call to the
Pulumi Cloud,
then the service should honor older versions of the CLI where this
change would not exist.
You must then bump the API version in
/pkg/backend/httpstate/client/api.go, as well as add
it to the service.
-->
- [ ] Yes, there are changes in this PR that warrants bumping the Pulumi
Cloud API version
<!-- @Pulumi employees: If yes, you must submit corresponding changes in
the service repo. -->
2024-01-25 20:39:31 +00:00
|
|
|
const ResourceReferenceSig = sig.ResourceReference
|
2020-10-27 17:12:12 +00:00
|
|
|
|
2021-09-13 16:05:31 +00:00
|
|
|
// OutputValueSig is the unique output value signature.
|
Move assets and archives to their own package (#15157)
<!---
Thanks so much for your contribution! If this is your first time
contributing, please ensure that you have read the
[CONTRIBUTING](https://github.com/pulumi/pulumi/blob/master/CONTRIBUTING.md)
documentation.
-->
# Description
This PR is motivated by https://github.com/pulumi/pulumi/pull/15145.
`resource.*` should be built on top of `property.Value`,[^1] which means
that `resource`
needs to be able to import `property.Value`, and so `property` cannot
import
`resource`. Since Assets and Archives are both types of properties, they
must be moved out
of `resource`.
[^1]: For example:
https://github.com/pulumi/pulumi/blob/a1d686227cd7e3c70c51bd772450cb0cd57c1479/sdk/go/common/resource/resource_state.go#L35-L36
## Open Question
This PR moves them to their own sub-folders in `resource`. Should
`asset` and `archive`
live somewhere more high level, like `sdk/go/property/{asset,archive}`?
<!--- Please include a summary of the change and which issue is fixed.
Please also include relevant motivation and context. -->
## Checklist
- [ ] I have run `make tidy` to update any new dependencies
- [ ] I have run `make lint` to verify my code passes the lint check
- [ ] I have formatted my code using `gofumpt`
<!--- Please provide details if the checkbox below is to be left
unchecked. -->
- [ ] I have added tests that prove my fix is effective or that my
feature works
<!---
User-facing changes require a CHANGELOG entry.
-->
- [ ] I have run `make changelog` and committed the
`changelog/pending/<file>` documenting my change
<!--
If the change(s) in this PR is a modification of an existing call to the
Pulumi Cloud,
then the service should honor older versions of the CLI where this
change would not exist.
You must then bump the API version in
/pkg/backend/httpstate/client/api.go, as well as add
it to the service.
-->
- [ ] Yes, there are changes in this PR that warrants bumping the Pulumi
Cloud API version
<!-- @Pulumi employees: If yes, you must submit corresponding changes in
the service repo. -->
2024-01-25 20:39:31 +00:00
|
|
|
const OutputValueSig = sig.OutputValue
|
2021-09-13 16:05:31 +00:00
|
|
|
|
2020-03-18 18:39:13 +00:00
|
|
|
// IsInternalPropertyKey returns true if the given property key is an internal key that should not be displayed to
|
|
|
|
// users.
|
|
|
|
func IsInternalPropertyKey(key PropertyKey) bool {
|
|
|
|
return strings.HasPrefix(string(key), "__")
|
|
|
|
}
|