2022-08-25 16:43:10 +00:00
|
|
|
// Copyright 2016-2022, 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-10-05 21:08:46 +00:00
|
|
|
|
|
|
|
package engine
|
|
|
|
|
|
|
|
import (
|
2019-06-10 22:20:44 +00:00
|
|
|
"bytes"
|
2018-02-02 05:15:09 +00:00
|
|
|
"time"
|
2017-10-05 21:08:46 +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
|
|
|
codeasset "github.com/pulumi/pulumi/pkg/v3/asset"
|
2023-09-18 11:01:28 +00:00
|
|
|
"github.com/pulumi/pulumi/pkg/v3/display"
|
2021-03-17 13:20:05 +00:00
|
|
|
"github.com/pulumi/pulumi/pkg/v3/resource/deploy"
|
|
|
|
"github.com/pulumi/pulumi/sdk/v3/go/common/apitype"
|
|
|
|
"github.com/pulumi/pulumi/sdk/v3/go/common/diag"
|
|
|
|
"github.com/pulumi/pulumi/sdk/v3/go/common/diag/colors"
|
|
|
|
"github.com/pulumi/pulumi/sdk/v3/go/common/resource"
|
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"
|
2021-03-17 13:20:05 +00:00
|
|
|
"github.com/pulumi/pulumi/sdk/v3/go/common/resource/config"
|
|
|
|
"github.com/pulumi/pulumi/sdk/v3/go/common/resource/plugin"
|
|
|
|
"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/deepcopy"
|
|
|
|
"github.com/pulumi/pulumi/sdk/v3/go/common/util/logging"
|
2017-10-05 21:08:46 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// Event represents an event generated by the engine during an operation. The underlying
|
|
|
|
// type for the `Payload` field will differ depending on the value of the `Type` field
|
|
|
|
type Event struct {
|
2017-10-21 00:28:35 +00:00
|
|
|
Type EventType
|
2020-07-17 06:52:31 +00:00
|
|
|
payload interface{}
|
|
|
|
}
|
|
|
|
|
2023-11-16 16:54:03 +00:00
|
|
|
type EventPayload interface {
|
|
|
|
StdoutEventPayload | DiagEventPayload | PreludeEventPayload | SummaryEventPayload |
|
|
|
|
ResourcePreEventPayload | ResourceOutputsEventPayload | ResourceOperationFailedPayload |
|
|
|
|
PolicyViolationEventPayload | PolicyRemediationEventPayload | PolicyLoadEventPayload
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewCancelEvent() Event {
|
|
|
|
return Event{Type: CancelEvent}
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewEvent[T EventPayload](payload T) Event {
|
|
|
|
var typ EventType
|
|
|
|
switch any(payload).(type) {
|
|
|
|
case StdoutEventPayload:
|
|
|
|
typ = StdoutColorEvent
|
|
|
|
case DiagEventPayload:
|
|
|
|
typ = DiagEvent
|
|
|
|
case PreludeEventPayload:
|
|
|
|
typ = PreludeEvent
|
|
|
|
case SummaryEventPayload:
|
|
|
|
typ = SummaryEvent
|
|
|
|
case ResourcePreEventPayload:
|
|
|
|
typ = ResourcePreEvent
|
|
|
|
case ResourceOutputsEventPayload:
|
|
|
|
typ = ResourceOutputsEvent
|
|
|
|
case ResourceOperationFailedPayload:
|
|
|
|
typ = ResourceOperationFailed
|
|
|
|
case PolicyViolationEventPayload:
|
|
|
|
typ = PolicyViolationEvent
|
|
|
|
case PolicyRemediationEventPayload:
|
|
|
|
typ = PolicyRemediationEvent
|
|
|
|
case PolicyLoadEventPayload:
|
|
|
|
typ = PolicyLoadEvent
|
2020-07-17 06:52:31 +00:00
|
|
|
default:
|
|
|
|
contract.Failf("unknown event type %v", typ)
|
|
|
|
}
|
|
|
|
return Event{
|
|
|
|
Type: typ,
|
Deepcopy event payloads on construction _not_ on access (#14049)
<!---
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. -->
Fixes https://github.com/pulumi/pulumi/issues/14036.
Not sure this is perfect (it's pretty hard to reason about mutation of
the whole system given what Go gives us to work with), but it seems
better.
We copy event payloads on construction, which should be synchronous with
step execution, rather than on access which could be in parallel with
the step executor or deployment executor mutating resource state.
Just copying on construction flagged up that the deployment executor and
step executor both race to modify resource state when the deployment
executor starts scheduling deletes. We add a synchronisation point
between the two parts in this change so that the deployment executor
waits for the step executor to go quite, and keeps it quite while it
computes the deletes, once it starts scheduling them the step executor
can run again.
## 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.
-->
- [x] 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. -->
2023-10-02 14:15:10 +00:00
|
|
|
payload: deepcopy.Copy(payload),
|
2020-07-17 06:52:31 +00:00
|
|
|
}
|
2017-10-05 21:08:46 +00:00
|
|
|
}
|
|
|
|
|
2017-10-21 00:28:35 +00:00
|
|
|
// EventType is the kind of event being emitted.
|
|
|
|
type EventType string
|
|
|
|
|
|
|
|
const (
|
2018-02-04 09:18:06 +00:00
|
|
|
CancelEvent EventType = "cancel"
|
|
|
|
StdoutColorEvent EventType = "stdoutcolor"
|
|
|
|
DiagEvent EventType = "diag"
|
|
|
|
PreludeEvent EventType = "prelude"
|
|
|
|
SummaryEvent EventType = "summary"
|
2018-03-09 17:59:57 +00:00
|
|
|
ResourcePreEvent EventType = "resource-pre"
|
|
|
|
ResourceOutputsEvent EventType = "resource-outputs"
|
|
|
|
ResourceOperationFailed EventType = "resource-operationfailed"
|
2019-06-10 22:20:44 +00:00
|
|
|
PolicyViolationEvent EventType = "policy-violation"
|
2023-10-09 18:31:17 +00:00
|
|
|
PolicyRemediationEvent EventType = "policy-remediation"
|
2023-11-15 11:19:31 +00:00
|
|
|
PolicyLoadEvent EventType = "policy-load"
|
2017-10-21 00:28:35 +00:00
|
|
|
)
|
|
|
|
|
2020-07-17 06:52:31 +00:00
|
|
|
func (e Event) Payload() interface{} {
|
Deepcopy event payloads on construction _not_ on access (#14049)
<!---
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. -->
Fixes https://github.com/pulumi/pulumi/issues/14036.
Not sure this is perfect (it's pretty hard to reason about mutation of
the whole system given what Go gives us to work with), but it seems
better.
We copy event payloads on construction, which should be synchronous with
step execution, rather than on access which could be in parallel with
the step executor or deployment executor mutating resource state.
Just copying on construction flagged up that the deployment executor and
step executor both race to modify resource state when the deployment
executor starts scheduling deletes. We add a synchronisation point
between the two parts in this change so that the deployment executor
waits for the step executor to go quite, and keeps it quite while it
computes the deletes, once it starts scheduling them the step executor
can run again.
## 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.
-->
- [x] 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. -->
2023-10-02 14:15:10 +00:00
|
|
|
return e.payload
|
2020-07-17 06:52:31 +00:00
|
|
|
}
|
|
|
|
|
2023-11-20 21:55:59 +00:00
|
|
|
// Returns true if this is a ResourcePreEvent or ResourceOutputsEvent with the internal flag set.
|
|
|
|
func (e Event) Internal() bool {
|
|
|
|
switch payload := e.payload.(type) {
|
|
|
|
case ResourcePreEventPayload:
|
|
|
|
return payload.Internal
|
|
|
|
case ResourceOutputsEventPayload:
|
|
|
|
return payload.Internal
|
|
|
|
default:
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-05 21:08:46 +00:00
|
|
|
// DiagEventPayload is the payload for an event with type `diag`
|
|
|
|
type DiagEventPayload struct {
|
Implement status sinks
This commit reverts most of #1853 and replaces it with functionally
identical logic, using the notion of status message-specific sinks.
In other words, where the original commit implemented ephemeral status
messages by adding an `isStatus` parameter to most of the logging
methdos in pulumi/pulumi, this implements ephemeral status messages as a
parallel logging sink, which emits _only_ ephemeral status messages.
The original commit message in that PR was:
> Allow log events to be marked "status" events
>
> This commit will introduce a field, IsStatus to LogRequest. A "status"
> logging event will be displayed in the Info column of the main
> display, but will not be printed out at the end, when resource
> operations complete.
>
> For example, for complex resource initialization, we'd like to display
> a series of intermediate results: [1/4] Service object created, for
> example. We'd like these to appear in the Info column, but not at the
> end, where they are not helpful to the user.
2018-08-31 20:12:40 +00:00
|
|
|
URN resource.URN
|
|
|
|
Prefix string
|
|
|
|
Message string
|
|
|
|
Color colors.Colorization
|
|
|
|
Severity diag.Severity
|
|
|
|
StreamID int32
|
|
|
|
Ephemeral bool
|
2017-10-05 21:08:46 +00:00
|
|
|
}
|
|
|
|
|
2019-06-10 22:20:44 +00:00
|
|
|
// PolicyViolationEventPayload is the payload for an event with type `policy-violation`.
|
|
|
|
type PolicyViolationEventPayload struct {
|
2019-06-13 23:14:48 +00:00
|
|
|
ResourceURN resource.URN
|
|
|
|
Message string
|
|
|
|
Color colors.Colorization
|
|
|
|
PolicyName string
|
|
|
|
PolicyPackName string
|
|
|
|
PolicyPackVersion string
|
|
|
|
EnforcementLevel apitype.EnforcementLevel
|
|
|
|
Prefix string
|
2019-06-10 22:20:44 +00:00
|
|
|
}
|
|
|
|
|
2023-10-09 18:31:17 +00:00
|
|
|
// PolicyRemediationEventPayload is the payload for an event with type `policy-remediation`.
|
|
|
|
type PolicyRemediationEventPayload struct {
|
|
|
|
ResourceURN resource.URN
|
|
|
|
Color colors.Colorization
|
|
|
|
PolicyName string
|
|
|
|
PolicyPackName string
|
|
|
|
PolicyPackVersion string
|
|
|
|
Before resource.PropertyMap
|
|
|
|
After resource.PropertyMap
|
|
|
|
}
|
|
|
|
|
2023-11-15 11:19:31 +00:00
|
|
|
// PolicyLoadEventPayload is the payload for an event with type `policy-load`.
|
|
|
|
type PolicyLoadEventPayload struct{}
|
|
|
|
|
2017-12-14 19:53:02 +00:00
|
|
|
type StdoutEventPayload struct {
|
|
|
|
Message string
|
2017-12-18 19:42:32 +00:00
|
|
|
Color colors.Colorization
|
2017-10-05 21:08:46 +00:00
|
|
|
}
|
|
|
|
|
2018-01-31 21:07:40 +00:00
|
|
|
type PreludeEventPayload struct {
|
|
|
|
IsPreview bool // true if this prelude is for a plan operation
|
|
|
|
Config map[string]string // the keys and values for config. For encrypted config, the values may be blinded
|
|
|
|
}
|
|
|
|
|
2018-02-02 05:15:09 +00:00
|
|
|
type SummaryEventPayload struct {
|
2022-06-27 14:08:06 +00:00
|
|
|
IsPreview bool // true if this summary is for a plan operation
|
|
|
|
MaybeCorrupt bool // true if one or more resources may be corrupt
|
|
|
|
Duration time.Duration // the duration of the entire update operation (zero values for previews)
|
|
|
|
ResourceChanges display.ResourceChanges // count of changed resources, useful for reporting
|
|
|
|
PolicyPacks map[string]string // {policy-pack: version} for each policy pack applied
|
2018-02-02 05:15:09 +00:00
|
|
|
}
|
|
|
|
|
2018-02-04 09:18:06 +00:00
|
|
|
type ResourceOperationFailedPayload struct {
|
2018-03-31 19:08:48 +00:00
|
|
|
Metadata StepEventMetadata
|
2018-02-04 09:18:06 +00:00
|
|
|
Status resource.Status
|
|
|
|
Steps int
|
|
|
|
}
|
|
|
|
|
|
|
|
type ResourceOutputsEventPayload struct {
|
2018-03-31 19:08:48 +00:00
|
|
|
Metadata StepEventMetadata
|
|
|
|
Planning bool
|
|
|
|
Debug bool
|
2023-11-20 21:55:59 +00:00
|
|
|
// Internal is set for events that should not be shown to a user but are expected to be used in other parts of the
|
|
|
|
// Pulumi system.
|
|
|
|
Internal bool
|
2018-02-04 09:18:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type ResourcePreEventPayload struct {
|
2018-03-31 19:08:48 +00:00
|
|
|
Metadata StepEventMetadata
|
|
|
|
Planning bool
|
|
|
|
Debug bool
|
2023-11-20 21:55:59 +00:00
|
|
|
// Internal is set for events that should not be shown to a user but are expected to be used in other parts of the
|
|
|
|
// Pulumi system.
|
|
|
|
Internal bool
|
2018-02-04 09:18:06 +00:00
|
|
|
}
|
|
|
|
|
2019-04-20 20:34:58 +00:00
|
|
|
// StepEventMetadata contains the metadata associated with a step the engine is performing.
|
2018-03-31 19:08:48 +00:00
|
|
|
type StepEventMetadata struct {
|
2022-06-27 14:08:06 +00:00
|
|
|
Op display.StepOp // the operation performed by this step.
|
2020-07-09 14:19:12 +00:00
|
|
|
URN resource.URN // the resource URN (for before and after).
|
|
|
|
Type tokens.Type // the type affected by this step.
|
2019-07-01 19:34:19 +00:00
|
|
|
Old *StepEventStateMetadata // the state of the resource before performing this step.
|
|
|
|
New *StepEventStateMetadata // the state of the resource after performing this step.
|
|
|
|
Res *StepEventStateMetadata // the latest state for the resource that is known (worst case, old).
|
|
|
|
Keys []resource.PropertyKey // the keys causing replacement (only for CreateStep and ReplaceStep).
|
|
|
|
Diffs []resource.PropertyKey // the keys causing diffs
|
|
|
|
DetailedDiff map[string]plugin.PropertyDiff // the rich, structured diff
|
|
|
|
Logical bool // true if this step represents a logical operation in the program.
|
|
|
|
Provider string // the provider that performed this step.
|
2018-02-04 09:18:06 +00:00
|
|
|
}
|
|
|
|
|
2019-04-20 20:34:58 +00:00
|
|
|
// StepEventStateMetadata contains detailed metadata about a resource's state pertaining to a given step.
|
2018-02-04 09:18:06 +00:00
|
|
|
type StepEventStateMetadata struct {
|
2019-04-20 20:34:58 +00:00
|
|
|
// State contains the raw, complete state, for this resource.
|
|
|
|
State *resource.State
|
2018-03-31 19:08:48 +00:00
|
|
|
// the resource's type.
|
|
|
|
Type tokens.Type
|
|
|
|
// the resource's object urn, a human-friendly, unique name for the resource.
|
|
|
|
URN resource.URN
|
|
|
|
// true if the resource is custom, managed by a plugin.
|
|
|
|
Custom bool
|
|
|
|
// true if this resource is pending deletion due to a replacement.
|
|
|
|
Delete bool
|
|
|
|
// the resource's unique ID, assigned by the resource provider (or blank if none/uncreated).
|
|
|
|
ID resource.ID
|
|
|
|
// an optional parent URN that this resource belongs to.
|
|
|
|
Parent resource.URN
|
|
|
|
// true to "protect" this resource (protected resources cannot be deleted).
|
|
|
|
Protect bool
|
2023-06-26 18:56:08 +00:00
|
|
|
// RetainOnDelete is true if the resource is not physically deleted when it is logically deleted.
|
|
|
|
RetainOnDelete bool `json:"retainOnDelete"`
|
2018-03-31 19:08:48 +00:00
|
|
|
// the resource's input properties (as specified by the program). Note: because this will cross
|
|
|
|
// over rpc boundaries it will be slightly different than the Inputs found in resource_state.
|
|
|
|
// Specifically, secrets will have been filtered out, and large values (like assets) will be
|
|
|
|
// have a simple hash-based representation. This allows clients to display this information
|
|
|
|
// properly, without worrying about leaking sensitive data, and without having to transmit huge
|
|
|
|
// amounts of data.
|
|
|
|
Inputs resource.PropertyMap
|
|
|
|
// the resource's complete output state (as returned by the resource provider). See "Inputs"
|
|
|
|
// for additional details about how data will be transformed before going into this map.
|
|
|
|
Outputs resource.PropertyMap
|
Implement first-class providers. (#1695)
### First-Class Providers
These changes implement support for first-class providers. First-class
providers are provider plugins that are exposed as resources via the
Pulumi programming model so that they may be explicitly and multiply
instantiated. Each instance of a provider resource may be configured
differently, and configuration parameters may be source from the
outputs of other resources.
### Provider Plugin Changes
In order to accommodate the need to verify and diff provider
configuration and configure providers without complete configuration
information, these changes adjust the high-level provider plugin
interface. Two new methods for validating a provider's configuration
and diffing changes to the same have been added (`CheckConfig` and
`DiffConfig`, respectively), and the type of the configuration bag
accepted by `Configure` has been changed to a `PropertyMap`.
These changes have not yet been reflected in the provider plugin gRPC
interface. We will do this in a set of follow-up changes. Until then,
these methods are implemented by adapters:
- `CheckConfig` validates that all configuration parameters are string
or unknown properties. This is necessary because existing plugins
only accept string-typed configuration values.
- `DiffConfig` either returns "never replace" if all configuration
values are known or "must replace" if any configuration value is
unknown. The justification for this behavior is given
[here](https://github.com/pulumi/pulumi/pull/1695/files#diff-a6cd5c7f337665f5bb22e92ca5f07537R106)
- `Configure` converts the config bag to a legacy config map and
configures the provider plugin if all config values are known. If any
config value is unknown, the underlying plugin is not configured and
the provider may only perform `Check`, `Read`, and `Invoke`, all of
which return empty results. We justify this behavior becuase it is
only possible during a preview and provides the best experience we
can manage with the existing gRPC interface.
### Resource Model Changes
Providers are now exposed as resources that participate in a stack's
dependency graph. Like other resources, they are explicitly created,
may have multiple instances, and may have dependencies on other
resources. Providers are referred to using provider references, which
are a combination of the provider's URN and its ID. This design
addresses the need during a preview to refer to providers that have not
yet been physically created and therefore have no ID.
All custom resources that are not themselves providers must specify a
single provider via a provider reference. The named provider will be
used to manage that resource's CRUD operations. If a resource's
provider reference changes, the resource must be replaced. Though its
URN is not present in the resource's dependency list, the provider
should be treated as a dependency of the resource when topologically
sorting the dependency graph.
Finally, `Invoke` operations must now specify a provider to use for the
invocation via a provider reference.
### Engine Changes
First-class providers support requires a few changes to the engine:
- The engine must have some way to map from provider references to
provider plugins. It must be possible to add providers from a stack's
checkpoint to this map and to register new/updated providers during
the execution of a plan in response to CRUD operations on provider
resources.
- In order to support updating existing stacks using existing Pulumi
programs that may not explicitly instantiate providers, the engine
must be able to manage the "default" providers for each package
referenced by a checkpoint or Pulumi program. The configuration for
a "default" provider is taken from the stack's configuration data.
The former need is addressed by adding a provider registry type that is
responsible for managing all of the plugins required by a plan. In
addition to loading plugins froma checkpoint and providing the ability
to map from a provider reference to a provider plugin, this type serves
as the provider plugin for providers themselves (i.e. it is the
"provider provider").
The latter need is solved via two relatively self-contained changes to
plan setup and the eval source.
During plan setup, the old checkpoint is scanned for custom resources
that do not have a provider reference in order to compute the set of
packages that require a default provider. Once this set has been
computed, the required default provider definitions are conjured and
prepended to the checkpoint's resource list. Each resource that
requires a default provider is then updated to refer to the default
provider for its package.
While an eval source is running, each custom resource registration,
resource read, and invoke that does not name a provider is trapped
before being returned by the source iterator. If no default provider
for the appropriate package has been registered, the eval source
synthesizes an appropriate registration, waits for it to complete, and
records the registered provider's reference. This reference is injected
into the original request, which is then processed as usual. If a
default provider was already registered, the recorded reference is
used and no new registration occurs.
### SDK Changes
These changes only expose first-class providers from the Node.JS SDK.
- A new abstract class, `ProviderResource`, can be subclassed and used
to instantiate first-class providers.
- A new field in `ResourceOptions`, `provider`, can be used to supply
a particular provider instance to manage a `CustomResource`'s CRUD
operations.
- A new type, `InvokeOptions`, can be used to specify options that
control the behavior of a call to `pulumi.runtime.invoke`. This type
includes a `provider` field that is analogous to
`ResourceOptions.provider`.
2018-08-07 00:50:29 +00:00
|
|
|
// the resource's provider reference
|
|
|
|
Provider string
|
Generate empty update steps for partial failures
This commit will greatly improve the experience of dealing with partial
failures by simply re-trying to initialize the relevant resources on
every subsequent `pulumi up`, instead of printing a list of reasons the
resource had previously failed to initialize.
As motivation, consider our behavior in the following common, painful
scenario:
* The user creates a `Service` and a `Deployment`.
* The `Pod`s in the `Deployment` fail to become live. This causes the
`Service` to fail, since it does not target any live `Pod`s.
* The user fixes the `Deployment`. A run of `pulumi up` sees the
`Pod`s successfully initialize.
* Users will expect that the `Service` is now in a state of success,
as the `Pod`s it targets are alive. But, because we don't update the
`Service` by default, it perpetually exists in a state of error.
* The user is now required to change some trivial feature of the
`Service` just to trigger an update, so that we can see it succeed.
There are many situations like this. Another very common one is waiting
for test `Pod`s that are meant to successfully complete when some object
becomes live.
By triggering an empty update step for all resources that have any
initialization errors, we avoid all problems like this.
This commit will implement this empty-update semantics for partial
failures, as well as fix the display UX to correctly render the diff in
these cases.
2018-08-28 21:23:31 +00:00
|
|
|
// InitErrors is the set of errors encountered in the process of initializing resource (i.e.,
|
|
|
|
// during create or update).
|
|
|
|
InitErrors []string
|
2018-02-04 09:18:06 +00:00
|
|
|
}
|
|
|
|
|
2018-08-22 22:32:54 +00:00
|
|
|
func makeEventEmitter(events chan<- Event, update UpdateInfo) (eventEmitter, error) {
|
2018-03-05 19:39:50 +00:00
|
|
|
target := update.GetTarget()
|
2018-05-15 22:28:00 +00:00
|
|
|
var secrets []string
|
2019-08-12 07:22:42 +00:00
|
|
|
if target != nil && target.Config.HasSecureValue() {
|
2018-08-22 22:32:54 +00:00
|
|
|
for k, v := range target.Config {
|
2018-03-05 19:39:50 +00:00
|
|
|
if !v.Secure() {
|
|
|
|
continue
|
|
|
|
}
|
2018-03-10 03:33:00 +00:00
|
|
|
|
Support lists and maps in config (#3342)
This change adds support for lists and maps in config. We now allow
lists/maps (and nested structures) in `Pulumi.<stack>.yaml` (or
`Pulumi.<stack>.json`; yes, we currently support that).
For example:
```yaml
config:
proj:blah:
- a
- b
- c
proj:hello: world
proj:outer:
inner: value
proj:servers:
- port: 80
```
While such structures could be specified in the `.yaml` file manually,
we support setting values in maps/lists from the command line.
As always, you can specify single values with:
```shell
$ pulumi config set hello world
```
Which results in the following YAML:
```yaml
proj:hello world
```
And single value secrets via:
```shell
$ pulumi config set --secret token shhh
```
Which results in the following YAML:
```yaml
proj:token:
secure: v1:VZAhuroR69FkEPTk:isKafsoZVMWA9pQayGzbWNynww==
```
Values in a list can be set from the command line using the new
`--path` flag, which indicates the config key contains a path to a
property in a map or list:
```shell
$ pulumi config set --path names[0] a
$ pulumi config set --path names[1] b
$ pulumi config set --path names[2] c
```
Which results in:
```yaml
proj:names
- a
- b
- c
```
Values can be obtained similarly:
```shell
$ pulumi config get --path names[1]
b
```
Or setting values in a map:
```shell
$ pulumi config set --path outer.inner value
```
Which results in:
```yaml
proj:outer:
inner: value
```
Of course, setting values in nested structures is supported:
```shell
$ pulumi config set --path servers[0].port 80
```
Which results in:
```yaml
proj:servers:
- port: 80
```
If you want to include a period in the name of a property, it can be
specified as:
```
$ pulumi config set --path 'nested["foo.bar"]' baz
```
Which results in:
```yaml
proj:nested:
foo.bar: baz
```
Examples of valid paths:
- root
- root.nested
- 'root["nested"]'
- root.double.nest
- 'root["double"].nest'
- 'root["double"]["nest"]'
- root.array[0]
- root.array[100]
- root.array[0].nested
- root.array[0][1].nested
- root.nested.array[0].double[1]
- 'root["key with \"escaped\" quotes"]'
- 'root["key with a ."]'
- '["root key with \"escaped\" quotes"].nested'
- '["root key with a ."][100]'
Note: paths that contain quotes can be surrounded by single quotes.
When setting values with `--path`, if the value is `"false"` or
`"true"`, it will be saved as the boolean value, and if it is
convertible to an integer, it will be saved as an integer.
Secure values are supported in lists/maps as well:
```shell
$ pulumi config set --path --secret tokens[0] shh
```
Will result in:
```yaml
proj:tokens:
- secure: v1:wpZRCe36sFg1RxwG:WzPeQrCn4n+m4Ks8ps15MxvFXg==
```
Note: maps of length 1 with a key of “secure” and string value are
reserved for storing secret values. Attempting to create such a value
manually will result in an error:
```shell
$ pulumi config set --path parent.secure foo
error: "secure" key in maps of length 1 are reserved
```
**Accessing config values from the command line with JSON**
```shell
$ pulumi config --json
```
Will output:
```json
{
"proj:hello": {
"value": "world",
"secret": false,
"object": false
},
"proj:names": {
"value": "[\"a\",\"b\",\"c\"]",
"secret": false,
"object": true,
"objectValue": [
"a",
"b",
"c"
]
},
"proj:nested": {
"value": "{\"foo.bar\":\"baz\"}",
"secret": false,
"object": true,
"objectValue": {
"foo.bar": "baz"
}
},
"proj:outer": {
"value": "{\"inner\":\"value\"}",
"secret": false,
"object": true,
"objectValue": {
"inner": "value"
}
},
"proj:servers": {
"value": "[{\"port\":80}]",
"secret": false,
"object": true,
"objectValue": [
{
"port": 80
}
]
},
"proj:token": {
"secret": true,
"object": false
},
"proj:tokens": {
"secret": true,
"object": true
}
}
```
If the value is a map or list, `"object"` will be `true`. `"value"` will
contain the object as serialized JSON and a new `"objectValue"` property
will be available containing the value of the object.
If the object contains any secret values, `"secret"` will be `true`, and
just like with scalar values, the value will not be outputted unless
`--show-secrets` is specified.
**Accessing config values from Pulumi programs**
Map/list values are available to Pulumi programs as serialized JSON, so
the existing
`getObject`/`requireObject`/`getSecretObject`/`requireSecretObject`
functions can be used to retrieve such values, e.g.:
```typescript
import * as pulumi from "@pulumi/pulumi";
interface Server {
port: number;
}
const config = new pulumi.Config();
const names = config.requireObject<string[]>("names");
for (const n of names) {
console.log(n);
}
const servers = config.requireObject<Server[]>("servers");
for (const s of servers) {
console.log(s.port);
}
```
2019-11-01 20:41:27 +00:00
|
|
|
secureValues, err := v.SecureValues(target.Decrypter)
|
2018-08-22 22:32:54 +00:00
|
|
|
if err != nil {
|
|
|
|
return eventEmitter{}, DecryptError{
|
|
|
|
Key: k,
|
|
|
|
Err: err,
|
|
|
|
}
|
|
|
|
}
|
Support lists and maps in config (#3342)
This change adds support for lists and maps in config. We now allow
lists/maps (and nested structures) in `Pulumi.<stack>.yaml` (or
`Pulumi.<stack>.json`; yes, we currently support that).
For example:
```yaml
config:
proj:blah:
- a
- b
- c
proj:hello: world
proj:outer:
inner: value
proj:servers:
- port: 80
```
While such structures could be specified in the `.yaml` file manually,
we support setting values in maps/lists from the command line.
As always, you can specify single values with:
```shell
$ pulumi config set hello world
```
Which results in the following YAML:
```yaml
proj:hello world
```
And single value secrets via:
```shell
$ pulumi config set --secret token shhh
```
Which results in the following YAML:
```yaml
proj:token:
secure: v1:VZAhuroR69FkEPTk:isKafsoZVMWA9pQayGzbWNynww==
```
Values in a list can be set from the command line using the new
`--path` flag, which indicates the config key contains a path to a
property in a map or list:
```shell
$ pulumi config set --path names[0] a
$ pulumi config set --path names[1] b
$ pulumi config set --path names[2] c
```
Which results in:
```yaml
proj:names
- a
- b
- c
```
Values can be obtained similarly:
```shell
$ pulumi config get --path names[1]
b
```
Or setting values in a map:
```shell
$ pulumi config set --path outer.inner value
```
Which results in:
```yaml
proj:outer:
inner: value
```
Of course, setting values in nested structures is supported:
```shell
$ pulumi config set --path servers[0].port 80
```
Which results in:
```yaml
proj:servers:
- port: 80
```
If you want to include a period in the name of a property, it can be
specified as:
```
$ pulumi config set --path 'nested["foo.bar"]' baz
```
Which results in:
```yaml
proj:nested:
foo.bar: baz
```
Examples of valid paths:
- root
- root.nested
- 'root["nested"]'
- root.double.nest
- 'root["double"].nest'
- 'root["double"]["nest"]'
- root.array[0]
- root.array[100]
- root.array[0].nested
- root.array[0][1].nested
- root.nested.array[0].double[1]
- 'root["key with \"escaped\" quotes"]'
- 'root["key with a ."]'
- '["root key with \"escaped\" quotes"].nested'
- '["root key with a ."][100]'
Note: paths that contain quotes can be surrounded by single quotes.
When setting values with `--path`, if the value is `"false"` or
`"true"`, it will be saved as the boolean value, and if it is
convertible to an integer, it will be saved as an integer.
Secure values are supported in lists/maps as well:
```shell
$ pulumi config set --path --secret tokens[0] shh
```
Will result in:
```yaml
proj:tokens:
- secure: v1:wpZRCe36sFg1RxwG:WzPeQrCn4n+m4Ks8ps15MxvFXg==
```
Note: maps of length 1 with a key of “secure” and string value are
reserved for storing secret values. Attempting to create such a value
manually will result in an error:
```shell
$ pulumi config set --path parent.secure foo
error: "secure" key in maps of length 1 are reserved
```
**Accessing config values from the command line with JSON**
```shell
$ pulumi config --json
```
Will output:
```json
{
"proj:hello": {
"value": "world",
"secret": false,
"object": false
},
"proj:names": {
"value": "[\"a\",\"b\",\"c\"]",
"secret": false,
"object": true,
"objectValue": [
"a",
"b",
"c"
]
},
"proj:nested": {
"value": "{\"foo.bar\":\"baz\"}",
"secret": false,
"object": true,
"objectValue": {
"foo.bar": "baz"
}
},
"proj:outer": {
"value": "{\"inner\":\"value\"}",
"secret": false,
"object": true,
"objectValue": {
"inner": "value"
}
},
"proj:servers": {
"value": "[{\"port\":80}]",
"secret": false,
"object": true,
"objectValue": [
{
"port": 80
}
]
},
"proj:token": {
"secret": true,
"object": false
},
"proj:tokens": {
"secret": true,
"object": true
}
}
```
If the value is a map or list, `"object"` will be `true`. `"value"` will
contain the object as serialized JSON and a new `"objectValue"` property
will be available containing the value of the object.
If the object contains any secret values, `"secret"` will be `true`, and
just like with scalar values, the value will not be outputted unless
`--show-secrets` is specified.
**Accessing config values from Pulumi programs**
Map/list values are available to Pulumi programs as serialized JSON, so
the existing
`getObject`/`requireObject`/`getSecretObject`/`requireSecretObject`
functions can be used to retrieve such values, e.g.:
```typescript
import * as pulumi from "@pulumi/pulumi";
interface Server {
port: number;
}
const config = new pulumi.Config();
const names = config.requireObject<string[]>("names");
for (const n of names) {
console.log(n);
}
const servers = config.requireObject<Server[]>("servers");
for (const s of servers) {
console.log(s.port);
}
```
2019-11-01 20:41:27 +00:00
|
|
|
secrets = append(secrets, secureValues...)
|
2018-03-10 03:33:00 +00:00
|
|
|
}
|
2018-03-05 19:39:50 +00:00
|
|
|
}
|
|
|
|
|
2018-05-15 23:09:15 +00:00
|
|
|
logging.AddGlobalFilter(logging.CreateFilter(secrets, "[secret]"))
|
2018-05-15 22:28:00 +00:00
|
|
|
|
2019-10-15 22:47:40 +00:00
|
|
|
buffer, done := make(chan Event), make(chan bool)
|
2019-10-22 19:04:22 +00:00
|
|
|
go queueEvents(events, buffer, done)
|
2019-10-15 22:47:40 +00:00
|
|
|
|
2018-03-05 19:39:50 +00:00
|
|
|
return eventEmitter{
|
2019-10-15 22:47:40 +00:00
|
|
|
done: done,
|
|
|
|
ch: buffer,
|
2018-08-22 22:32:54 +00:00
|
|
|
}, nil
|
2018-03-05 19:39:50 +00:00
|
|
|
}
|
|
|
|
|
2019-08-12 07:22:42 +00:00
|
|
|
func makeQueryEventEmitter(events chan<- Event) (eventEmitter, error) {
|
2019-10-22 19:04:22 +00:00
|
|
|
buffer, done := make(chan Event), make(chan bool)
|
|
|
|
|
|
|
|
go queueEvents(events, buffer, done)
|
|
|
|
|
2019-08-12 07:22:42 +00:00
|
|
|
return eventEmitter{
|
2019-10-22 19:04:22 +00:00
|
|
|
done: done,
|
|
|
|
ch: buffer,
|
2019-08-12 07:22:42 +00:00
|
|
|
}, nil
|
|
|
|
}
|
|
|
|
|
2018-03-05 19:39:50 +00:00
|
|
|
type eventEmitter struct {
|
2019-10-15 22:47:40 +00:00
|
|
|
done <-chan bool
|
|
|
|
ch chan<- Event
|
2018-03-05 19:39:50 +00:00
|
|
|
}
|
|
|
|
|
2019-10-22 19:04:22 +00:00
|
|
|
func queueEvents(events chan<- Event, buffer chan Event, done chan bool) {
|
|
|
|
// Instead of sending to the source channel directly, buffer events to account for slow receivers.
|
|
|
|
//
|
|
|
|
// Buffering is done by a goroutine that concurrently receives from the senders and attempts to send events to the
|
|
|
|
// receiver. Events that are received while waiting for the receiver to catch up are buffered in a slice.
|
|
|
|
//
|
|
|
|
// We do not use a buffered channel because it is empirically less likely that the goroutine reading from a
|
|
|
|
// buffered channel will be scheduled when new data is placed in the channel.
|
|
|
|
|
|
|
|
defer close(done)
|
2023-02-15 01:28:14 +00:00
|
|
|
contract.Assertf(buffer != nil, "buffer channel must not be nil")
|
2019-10-22 19:04:22 +00:00
|
|
|
|
|
|
|
var queue []Event
|
|
|
|
for {
|
|
|
|
e, ok := <-buffer
|
|
|
|
if !ok {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
queue = append(queue, e)
|
|
|
|
|
|
|
|
// While there are events in the queue, attempt to send them to the waiting receiver. If the receiver is
|
|
|
|
// blocked and an event is received from the event senders, stick that event in the queue.
|
|
|
|
for len(queue) > 0 {
|
|
|
|
select {
|
|
|
|
case e, ok := <-buffer:
|
|
|
|
if !ok {
|
|
|
|
// If the event source has been closed, flush the queue.
|
|
|
|
for _, e := range queue {
|
2022-08-25 16:43:10 +00:00
|
|
|
trySendEvent(events, e)
|
2019-10-22 19:04:22 +00:00
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
queue = append(queue, e)
|
|
|
|
case events <- queue[0]:
|
|
|
|
queue = queue[1:]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-06-27 14:08:06 +00:00
|
|
|
func makeStepEventMetadata(op display.StepOp, step deploy.Step, debug bool) StepEventMetadata {
|
2023-02-15 01:28:14 +00:00
|
|
|
contract.Assertf(op == step.Op() || step.Op() == deploy.OpRefresh,
|
|
|
|
"step must be %v or %v, got %v", op, deploy.OpRefresh, step.Op())
|
2018-03-31 19:08:48 +00:00
|
|
|
|
2019-03-07 00:41:19 +00:00
|
|
|
var keys, diffs []resource.PropertyKey
|
|
|
|
if keyer, hasKeys := step.(interface{ Keys() []resource.PropertyKey }); hasKeys {
|
|
|
|
keys = keyer.Keys()
|
|
|
|
}
|
|
|
|
if differ, hasDiffs := step.(interface{ Diffs() []resource.PropertyKey }); hasDiffs {
|
|
|
|
diffs = differ.Diffs()
|
2018-03-31 19:08:48 +00:00
|
|
|
}
|
|
|
|
|
2019-07-01 19:34:19 +00:00
|
|
|
var detailedDiff map[string]plugin.PropertyDiff
|
|
|
|
if detailedDiffer, hasDetailedDiff := step.(interface {
|
|
|
|
DetailedDiff() map[string]plugin.PropertyDiff
|
|
|
|
}); hasDetailedDiff {
|
|
|
|
detailedDiff = detailedDiffer.DetailedDiff()
|
|
|
|
}
|
|
|
|
|
2018-03-31 19:08:48 +00:00
|
|
|
return StepEventMetadata{
|
2019-07-01 19:34:19 +00:00
|
|
|
Op: op,
|
2020-07-09 14:19:12 +00:00
|
|
|
URN: step.URN(),
|
|
|
|
Type: step.Type(),
|
2019-07-01 19:34:19 +00:00
|
|
|
Keys: keys,
|
|
|
|
Diffs: diffs,
|
|
|
|
DetailedDiff: detailedDiff,
|
|
|
|
Old: makeStepEventStateMetadata(step.Old(), debug),
|
|
|
|
New: makeStepEventStateMetadata(step.New(), debug),
|
|
|
|
Res: makeStepEventStateMetadata(step.Res(), debug),
|
|
|
|
Logical: step.Logical(),
|
|
|
|
Provider: step.Provider(),
|
2018-02-04 09:18:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-05-15 23:09:15 +00:00
|
|
|
func makeStepEventStateMetadata(state *resource.State, debug bool) *StepEventStateMetadata {
|
2018-02-04 09:18:06 +00:00
|
|
|
if state == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
return &StepEventStateMetadata{
|
2023-06-26 18:56:08 +00:00
|
|
|
State: state,
|
|
|
|
Type: state.Type,
|
|
|
|
URN: state.URN,
|
|
|
|
Custom: state.Custom,
|
|
|
|
Delete: state.Delete,
|
|
|
|
ID: state.ID,
|
|
|
|
Parent: state.Parent,
|
|
|
|
Protect: state.Protect,
|
|
|
|
RetainOnDelete: state.RetainOnDelete,
|
|
|
|
Inputs: filterResourceProperties(state.Inputs, debug),
|
|
|
|
Outputs: filterResourceProperties(state.Outputs, debug),
|
|
|
|
Provider: state.Provider,
|
|
|
|
InitErrors: state.InitErrors,
|
2018-02-04 09:18:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-15 22:47:40 +00:00
|
|
|
func (e *eventEmitter) Close() {
|
2022-08-25 16:43:10 +00:00
|
|
|
tryCloseEventChan(e.ch)
|
2019-10-15 22:47:40 +00:00
|
|
|
<-e.done
|
|
|
|
}
|
|
|
|
|
2022-08-25 16:43:10 +00:00
|
|
|
func (e *eventEmitter) sendEvent(event Event) {
|
|
|
|
trySendEvent(e.ch, event)
|
|
|
|
}
|
|
|
|
|
2018-03-31 19:08:48 +00:00
|
|
|
func (e *eventEmitter) resourceOperationFailedEvent(
|
2023-03-03 16:36:39 +00:00
|
|
|
step deploy.Step, status resource.Status, steps int, debug bool,
|
|
|
|
) {
|
2018-03-05 19:39:50 +00:00
|
|
|
contract.Requiref(e != nil, "e", "!= nil")
|
|
|
|
|
2023-11-16 16:54:03 +00:00
|
|
|
e.sendEvent(NewEvent(ResourceOperationFailedPayload{
|
2020-07-17 06:52:31 +00:00
|
|
|
Metadata: makeStepEventMetadata(step.Op(), step, debug),
|
|
|
|
Status: status,
|
|
|
|
Steps: steps,
|
2022-08-25 16:43:10 +00:00
|
|
|
}))
|
2018-02-04 09:18:06 +00:00
|
|
|
}
|
|
|
|
|
2023-11-20 21:55:59 +00:00
|
|
|
func (e *eventEmitter) resourceOutputsEvent(
|
|
|
|
op display.StepOp, step deploy.Step, planning, debug, internal bool,
|
|
|
|
) {
|
2018-03-05 19:39:50 +00:00
|
|
|
contract.Requiref(e != nil, "e", "!= nil")
|
|
|
|
|
2023-11-16 16:54:03 +00:00
|
|
|
e.sendEvent(NewEvent(ResourceOutputsEventPayload{
|
2020-07-17 06:52:31 +00:00
|
|
|
Metadata: makeStepEventMetadata(op, step, debug),
|
|
|
|
Planning: planning,
|
|
|
|
Debug: debug,
|
2023-11-20 21:55:59 +00:00
|
|
|
Internal: internal,
|
2022-08-25 16:43:10 +00:00
|
|
|
}))
|
2018-02-04 09:18:06 +00:00
|
|
|
}
|
|
|
|
|
2018-03-31 19:08:48 +00:00
|
|
|
func (e *eventEmitter) resourcePreEvent(
|
2023-11-20 21:55:59 +00:00
|
|
|
step deploy.Step, planning, debug, internal bool,
|
2023-03-03 16:36:39 +00:00
|
|
|
) {
|
2018-03-05 19:39:50 +00:00
|
|
|
contract.Requiref(e != nil, "e", "!= nil")
|
|
|
|
|
2023-11-16 16:54:03 +00:00
|
|
|
e.sendEvent(NewEvent(ResourcePreEventPayload{
|
2020-07-17 06:52:31 +00:00
|
|
|
Metadata: makeStepEventMetadata(step.Op(), step, debug),
|
|
|
|
Planning: planning,
|
|
|
|
Debug: debug,
|
2023-11-20 21:55:59 +00:00
|
|
|
Internal: internal,
|
2022-08-25 16:43:10 +00:00
|
|
|
}))
|
2018-02-04 09:18:06 +00:00
|
|
|
}
|
|
|
|
|
2018-03-05 19:39:50 +00:00
|
|
|
func (e *eventEmitter) preludeEvent(isPreview bool, cfg config.Map) {
|
|
|
|
contract.Requiref(e != nil, "e", "!= nil")
|
|
|
|
|
2018-01-31 21:07:40 +00:00
|
|
|
configStringMap := make(map[string]string, len(cfg))
|
|
|
|
for k, v := range cfg {
|
|
|
|
keyString := k.String()
|
|
|
|
valueString, err := v.Value(config.NewBlindingDecrypter())
|
2023-02-15 01:28:14 +00:00
|
|
|
contract.AssertNoErrorf(err, "error getting configuration value for entry %q", keyString)
|
2018-01-31 21:07:40 +00:00
|
|
|
configStringMap[keyString] = valueString
|
|
|
|
}
|
|
|
|
|
2023-11-16 16:54:03 +00:00
|
|
|
e.sendEvent(NewEvent(PreludeEventPayload{
|
2020-07-17 06:52:31 +00:00
|
|
|
IsPreview: isPreview,
|
|
|
|
Config: configStringMap,
|
2022-08-25 16:43:10 +00:00
|
|
|
}))
|
2018-01-31 21:07:40 +00:00
|
|
|
}
|
|
|
|
|
2022-06-27 14:08:06 +00:00
|
|
|
func (e *eventEmitter) summaryEvent(preview, maybeCorrupt bool, duration time.Duration,
|
2023-03-03 16:36:39 +00:00
|
|
|
resourceChanges display.ResourceChanges, policyPacks map[string]string,
|
|
|
|
) {
|
2018-03-05 19:39:50 +00:00
|
|
|
contract.Requiref(e != nil, "e", "!= nil")
|
|
|
|
|
2023-11-16 16:54:03 +00:00
|
|
|
e.sendEvent(NewEvent(SummaryEventPayload{
|
2020-11-18 19:16:30 +00:00
|
|
|
IsPreview: preview,
|
2020-07-17 06:52:31 +00:00
|
|
|
MaybeCorrupt: maybeCorrupt,
|
|
|
|
Duration: duration,
|
|
|
|
ResourceChanges: resourceChanges,
|
|
|
|
PolicyPacks: policyPacks,
|
2022-08-25 16:43:10 +00:00
|
|
|
}))
|
2018-02-02 05:15:09 +00:00
|
|
|
}
|
|
|
|
|
2019-06-10 22:20:44 +00:00
|
|
|
func (e *eventEmitter) policyViolationEvent(urn resource.URN, d plugin.AnalyzeDiagnostic) {
|
|
|
|
contract.Requiref(e != nil, "e", "!= nil")
|
|
|
|
|
|
|
|
// Write prefix.
|
|
|
|
var prefix bytes.Buffer
|
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 only expect mandatory or advisory events here.
|
2019-06-10 22:20:44 +00:00
|
|
|
switch d.EnforcementLevel {
|
|
|
|
case apitype.Mandatory:
|
|
|
|
prefix.WriteString(colors.SpecError)
|
2019-06-24 02:02:37 +00:00
|
|
|
case apitype.Advisory:
|
2019-06-10 22:20:44 +00:00
|
|
|
prefix.WriteString(colors.SpecWarning)
|
|
|
|
default:
|
|
|
|
contract.Failf("Unrecognized diagnostic severity: %v", d)
|
|
|
|
}
|
|
|
|
|
|
|
|
prefix.WriteString(string(d.EnforcementLevel))
|
|
|
|
prefix.WriteString(": ")
|
|
|
|
prefix.WriteString(colors.Reset)
|
|
|
|
|
|
|
|
// Write the message itself.
|
|
|
|
var buffer bytes.Buffer
|
|
|
|
buffer.WriteString(colors.SpecNote)
|
|
|
|
|
|
|
|
buffer.WriteString(d.Message)
|
|
|
|
|
|
|
|
buffer.WriteString(colors.Reset)
|
|
|
|
buffer.WriteRune('\n')
|
|
|
|
|
2023-11-16 16:54:03 +00:00
|
|
|
e.sendEvent(NewEvent(PolicyViolationEventPayload{
|
2020-07-17 06:52:31 +00:00
|
|
|
ResourceURN: urn,
|
|
|
|
Message: logging.FilterString(buffer.String()),
|
|
|
|
Color: colors.Raw,
|
|
|
|
PolicyName: d.PolicyName,
|
|
|
|
PolicyPackName: d.PolicyPackName,
|
|
|
|
PolicyPackVersion: d.PolicyPackVersion,
|
|
|
|
EnforcementLevel: d.EnforcementLevel,
|
|
|
|
Prefix: logging.FilterString(prefix.String()),
|
2022-08-25 16:43:10 +00:00
|
|
|
}))
|
2019-06-10 22:20:44 +00:00
|
|
|
}
|
|
|
|
|
2023-10-09 18:31:17 +00:00
|
|
|
func (e *eventEmitter) policyRemediationEvent(urn resource.URN, t plugin.Remediation,
|
|
|
|
before resource.PropertyMap, after resource.PropertyMap,
|
|
|
|
) {
|
|
|
|
contract.Requiref(e != nil, "e", "!= nil")
|
|
|
|
|
2023-11-16 16:54:03 +00:00
|
|
|
e.sendEvent(NewEvent(PolicyRemediationEventPayload{
|
2023-10-09 18:31:17 +00:00
|
|
|
ResourceURN: urn,
|
|
|
|
Color: colors.Raw,
|
|
|
|
PolicyName: t.PolicyName,
|
|
|
|
PolicyPackName: t.PolicyPackName,
|
|
|
|
PolicyPackVersion: t.PolicyPackVersion,
|
|
|
|
Before: before,
|
|
|
|
After: after,
|
|
|
|
}))
|
|
|
|
}
|
|
|
|
|
2023-11-15 11:19:31 +00:00
|
|
|
func (e *eventEmitter) PolicyLoadEvent() {
|
|
|
|
contract.Requiref(e != nil, "e", "!= nil")
|
|
|
|
|
2023-11-16 16:54:03 +00:00
|
|
|
e.sendEvent(NewEvent(PolicyLoadEventPayload{}))
|
2023-11-15 11:19:31 +00:00
|
|
|
}
|
|
|
|
|
Implement status sinks
This commit reverts most of #1853 and replaces it with functionally
identical logic, using the notion of status message-specific sinks.
In other words, where the original commit implemented ephemeral status
messages by adding an `isStatus` parameter to most of the logging
methdos in pulumi/pulumi, this implements ephemeral status messages as a
parallel logging sink, which emits _only_ ephemeral status messages.
The original commit message in that PR was:
> Allow log events to be marked "status" events
>
> This commit will introduce a field, IsStatus to LogRequest. A "status"
> logging event will be displayed in the Info column of the main
> display, but will not be printed out at the end, when resource
> operations complete.
>
> For example, for complex resource initialization, we'd like to display
> a series of intermediate results: [1/4] Service object created, for
> example. We'd like these to appear in the Info column, but not at the
> end, where they are not helpful to the user.
2018-08-31 20:12:40 +00:00
|
|
|
func diagEvent(e *eventEmitter, d *diag.Diag, prefix, msg string, sev diag.Severity,
|
2023-03-03 16:36:39 +00:00
|
|
|
ephemeral bool,
|
|
|
|
) {
|
2018-03-05 19:39:50 +00:00
|
|
|
contract.Requiref(e != nil, "e", "!= nil")
|
|
|
|
|
2023-11-16 16:54:03 +00:00
|
|
|
e.sendEvent(NewEvent(DiagEventPayload{
|
2020-07-17 06:52:31 +00:00
|
|
|
URN: d.URN,
|
|
|
|
Prefix: logging.FilterString(prefix),
|
|
|
|
Message: logging.FilterString(msg),
|
|
|
|
Color: colors.Raw,
|
|
|
|
Severity: sev,
|
|
|
|
StreamID: d.StreamID,
|
|
|
|
Ephemeral: ephemeral,
|
2022-08-25 16:43:10 +00:00
|
|
|
}))
|
2017-10-05 21:08:46 +00:00
|
|
|
}
|
|
|
|
|
Implement status sinks
This commit reverts most of #1853 and replaces it with functionally
identical logic, using the notion of status message-specific sinks.
In other words, where the original commit implemented ephemeral status
messages by adding an `isStatus` parameter to most of the logging
methdos in pulumi/pulumi, this implements ephemeral status messages as a
parallel logging sink, which emits _only_ ephemeral status messages.
The original commit message in that PR was:
> Allow log events to be marked "status" events
>
> This commit will introduce a field, IsStatus to LogRequest. A "status"
> logging event will be displayed in the Info column of the main
> display, but will not be printed out at the end, when resource
> operations complete.
>
> For example, for complex resource initialization, we'd like to display
> a series of intermediate results: [1/4] Service object created, for
> example. We'd like these to appear in the Info column, but not at the
> end, where they are not helpful to the user.
2018-08-31 20:12:40 +00:00
|
|
|
func (e *eventEmitter) diagDebugEvent(d *diag.Diag, prefix, msg string, ephemeral bool) {
|
|
|
|
diagEvent(e, d, prefix, msg, diag.Debug, ephemeral)
|
2018-04-10 00:20:55 +00:00
|
|
|
}
|
2018-03-05 19:39:50 +00:00
|
|
|
|
Implement status sinks
This commit reverts most of #1853 and replaces it with functionally
identical logic, using the notion of status message-specific sinks.
In other words, where the original commit implemented ephemeral status
messages by adding an `isStatus` parameter to most of the logging
methdos in pulumi/pulumi, this implements ephemeral status messages as a
parallel logging sink, which emits _only_ ephemeral status messages.
The original commit message in that PR was:
> Allow log events to be marked "status" events
>
> This commit will introduce a field, IsStatus to LogRequest. A "status"
> logging event will be displayed in the Info column of the main
> display, but will not be printed out at the end, when resource
> operations complete.
>
> For example, for complex resource initialization, we'd like to display
> a series of intermediate results: [1/4] Service object created, for
> example. We'd like these to appear in the Info column, but not at the
> end, where they are not helpful to the user.
2018-08-31 20:12:40 +00:00
|
|
|
func (e *eventEmitter) diagInfoEvent(d *diag.Diag, prefix, msg string, ephemeral bool) {
|
|
|
|
diagEvent(e, d, prefix, msg, diag.Info, ephemeral)
|
2017-10-05 21:08:46 +00:00
|
|
|
}
|
|
|
|
|
Implement status sinks
This commit reverts most of #1853 and replaces it with functionally
identical logic, using the notion of status message-specific sinks.
In other words, where the original commit implemented ephemeral status
messages by adding an `isStatus` parameter to most of the logging
methdos in pulumi/pulumi, this implements ephemeral status messages as a
parallel logging sink, which emits _only_ ephemeral status messages.
The original commit message in that PR was:
> Allow log events to be marked "status" events
>
> This commit will introduce a field, IsStatus to LogRequest. A "status"
> logging event will be displayed in the Info column of the main
> display, but will not be printed out at the end, when resource
> operations complete.
>
> For example, for complex resource initialization, we'd like to display
> a series of intermediate results: [1/4] Service object created, for
> example. We'd like these to appear in the Info column, but not at the
> end, where they are not helpful to the user.
2018-08-31 20:12:40 +00:00
|
|
|
func (e *eventEmitter) diagInfoerrEvent(d *diag.Diag, prefix, msg string, ephemeral bool) {
|
|
|
|
diagEvent(e, d, prefix, msg, diag.Infoerr, ephemeral)
|
2017-10-05 21:08:46 +00:00
|
|
|
}
|
|
|
|
|
Implement status sinks
This commit reverts most of #1853 and replaces it with functionally
identical logic, using the notion of status message-specific sinks.
In other words, where the original commit implemented ephemeral status
messages by adding an `isStatus` parameter to most of the logging
methdos in pulumi/pulumi, this implements ephemeral status messages as a
parallel logging sink, which emits _only_ ephemeral status messages.
The original commit message in that PR was:
> Allow log events to be marked "status" events
>
> This commit will introduce a field, IsStatus to LogRequest. A "status"
> logging event will be displayed in the Info column of the main
> display, but will not be printed out at the end, when resource
> operations complete.
>
> For example, for complex resource initialization, we'd like to display
> a series of intermediate results: [1/4] Service object created, for
> example. We'd like these to appear in the Info column, but not at the
> end, where they are not helpful to the user.
2018-08-31 20:12:40 +00:00
|
|
|
func (e *eventEmitter) diagErrorEvent(d *diag.Diag, prefix, msg string, ephemeral bool) {
|
|
|
|
diagEvent(e, d, prefix, msg, diag.Error, ephemeral)
|
2017-10-05 21:08:46 +00:00
|
|
|
}
|
|
|
|
|
Implement status sinks
This commit reverts most of #1853 and replaces it with functionally
identical logic, using the notion of status message-specific sinks.
In other words, where the original commit implemented ephemeral status
messages by adding an `isStatus` parameter to most of the logging
methdos in pulumi/pulumi, this implements ephemeral status messages as a
parallel logging sink, which emits _only_ ephemeral status messages.
The original commit message in that PR was:
> Allow log events to be marked "status" events
>
> This commit will introduce a field, IsStatus to LogRequest. A "status"
> logging event will be displayed in the Info column of the main
> display, but will not be printed out at the end, when resource
> operations complete.
>
> For example, for complex resource initialization, we'd like to display
> a series of intermediate results: [1/4] Service object created, for
> example. We'd like these to appear in the Info column, but not at the
> end, where they are not helpful to the user.
2018-08-31 20:12:40 +00:00
|
|
|
func (e *eventEmitter) diagWarningEvent(d *diag.Diag, prefix, msg string, ephemeral bool) {
|
|
|
|
diagEvent(e, d, prefix, msg, diag.Warning, ephemeral)
|
2017-10-05 21:08:46 +00:00
|
|
|
}
|
2022-04-06 18:01:06 +00:00
|
|
|
|
|
|
|
func filterResourceProperties(m resource.PropertyMap, debug bool) resource.PropertyMap {
|
|
|
|
return filterPropertyValue(resource.NewObjectProperty(m), debug).ObjectValue()
|
|
|
|
}
|
|
|
|
|
|
|
|
func filterPropertyValue(v resource.PropertyValue, debug bool) resource.PropertyValue {
|
|
|
|
switch {
|
|
|
|
case v.IsNull(), v.IsBool(), v.IsNumber():
|
|
|
|
return v
|
|
|
|
case v.IsString():
|
|
|
|
// have to ensure we filter out secrets.
|
|
|
|
return resource.NewStringProperty(logging.FilterString(v.StringValue()))
|
|
|
|
case v.IsAsset():
|
|
|
|
return resource.NewAssetProperty(filterAsset(v.AssetValue(), debug))
|
|
|
|
case v.IsArchive():
|
|
|
|
return resource.NewArchiveProperty(filterArchive(v.ArchiveValue(), debug))
|
|
|
|
case v.IsArray():
|
|
|
|
arr := make([]resource.PropertyValue, len(v.ArrayValue()))
|
|
|
|
for i, v := range v.ArrayValue() {
|
|
|
|
arr[i] = filterPropertyValue(v, debug)
|
|
|
|
}
|
|
|
|
return resource.NewArrayProperty(arr)
|
|
|
|
case v.IsObject():
|
|
|
|
obj := make(resource.PropertyMap, len(v.ObjectValue()))
|
|
|
|
for k, v := range v.ObjectValue() {
|
|
|
|
obj[k] = filterPropertyValue(v, debug)
|
|
|
|
}
|
|
|
|
return resource.NewObjectProperty(obj)
|
|
|
|
case v.IsComputed():
|
|
|
|
return resource.MakeComputed(filterPropertyValue(v.Input().Element, debug))
|
|
|
|
case v.IsOutput():
|
|
|
|
return resource.MakeComputed(filterPropertyValue(v.OutputValue().Element, debug))
|
|
|
|
case v.IsSecret():
|
|
|
|
return resource.MakeSecret(resource.NewStringProperty("[secret]"))
|
|
|
|
case v.IsResourceReference():
|
|
|
|
ref := v.ResourceReferenceValue()
|
|
|
|
return resource.NewResourceReferenceProperty(resource.ResourceReference{
|
|
|
|
URN: resource.URN(logging.FilterString(string(ref.URN))),
|
|
|
|
ID: filterPropertyValue(ref.ID, debug),
|
|
|
|
PackageVersion: logging.FilterString(ref.PackageVersion),
|
|
|
|
})
|
|
|
|
default:
|
|
|
|
contract.Failf("unexpected property value type %T", v.V)
|
|
|
|
return resource.PropertyValue{}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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 filterAsset(v *asset.Asset, debug bool) *asset.Asset {
|
2022-04-06 18:01:06 +00:00
|
|
|
if !v.IsText() {
|
|
|
|
return v
|
|
|
|
}
|
|
|
|
|
|
|
|
// we don't want to include the full text of an asset as we serialize it over as
|
|
|
|
// events. They represent user files and are thus are unbounded in size. Instead,
|
|
|
|
// we only include the text if it represents a user's serialized program code, as
|
|
|
|
// that is something we want the receiver to see to display as part of
|
|
|
|
// progress/diffs/etc.
|
|
|
|
var text string
|
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
|
|
|
if codeasset.IsUserProgramCode(v) {
|
2022-04-06 18:01:06 +00:00
|
|
|
// also make sure we filter this in case there are any secrets in the code.
|
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
|
|
|
text = logging.FilterString(codeasset.MassageIfUserProgramCodeAsset(v, debug).Text)
|
2022-04-06 18:01:06 +00:00
|
|
|
} else {
|
|
|
|
// We need to have some string here so that we preserve that this is a
|
|
|
|
// text-asset
|
|
|
|
text = "<contents elided>"
|
|
|
|
}
|
|
|
|
|
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
|
|
|
return &asset.Asset{
|
2022-04-06 18:01:06 +00:00
|
|
|
Sig: v.Sig,
|
|
|
|
Hash: v.Hash,
|
|
|
|
Text: text,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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 filterArchive(v *archive.Archive, debug bool) *archive.Archive {
|
2022-04-06 18:01:06 +00:00
|
|
|
if !v.IsAssets() {
|
|
|
|
return v
|
|
|
|
}
|
|
|
|
|
|
|
|
assets := make(map[string]interface{})
|
|
|
|
for k, v := range v.Assets {
|
|
|
|
switch v := v.(type) {
|
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:
|
2022-04-06 18:01:06 +00:00
|
|
|
assets[k] = filterAsset(v, debug)
|
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:
|
2022-04-06 18:01:06 +00:00
|
|
|
assets[k] = filterArchive(v, debug)
|
|
|
|
default:
|
|
|
|
contract.Failf("Unrecognized asset map type %T", 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
|
|
|
return &archive.Archive{
|
2022-04-06 18:01:06 +00:00
|
|
|
Sig: v.Sig,
|
|
|
|
Hash: v.Hash,
|
|
|
|
Assets: assets,
|
|
|
|
}
|
|
|
|
}
|
2022-08-25 16:43:10 +00:00
|
|
|
|
|
|
|
// Sends an event like a normal send but recovers from a panic on a
|
|
|
|
// closed channel. This is generally a design smell and should be used
|
|
|
|
// very sparingly and every use of this function needs to document the
|
|
|
|
// need.
|
|
|
|
//
|
|
|
|
// eventEmitter uses tryEventSend to recover in the scenario of
|
|
|
|
// cancelSource.Terminate being called (such as user pressing Ctrl+C
|
|
|
|
// twice), when straggler stepExecutor workers are sending diag events
|
|
|
|
// but the engine is shutting down.
|
|
|
|
//
|
|
|
|
// See https://github.com/pulumi/pulumi/issues/10431 for the details.
|
|
|
|
func trySendEvent(ch chan<- Event, ev Event) (sent bool) {
|
|
|
|
sent = true
|
|
|
|
defer func() {
|
|
|
|
if recover() != nil {
|
|
|
|
sent = false
|
|
|
|
if logging.V(9) {
|
|
|
|
logging.V(9).Infof(
|
|
|
|
"Ignoring %v send on a closed channel %p",
|
|
|
|
ev.Type, ch)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
ch <- ev
|
|
|
|
return sent
|
|
|
|
}
|
|
|
|
|
|
|
|
// Tries to close a channel but recovers from a panic of closing a
|
|
|
|
// closed channel. Restrictions on use are similarly to those of
|
|
|
|
// trySendEvent.
|
|
|
|
func tryCloseEventChan(ch chan<- Event) (closed bool) {
|
|
|
|
closed = true
|
|
|
|
defer func() {
|
|
|
|
if recover() != nil {
|
|
|
|
closed = false
|
|
|
|
if logging.V(9) {
|
|
|
|
logging.V(9).Infof(
|
|
|
|
"Ignoring close of a closed event channel %p",
|
|
|
|
ch)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
close(ch)
|
|
|
|
return closed
|
|
|
|
}
|