2018-05-22 21:43:36 +02:00
|
|
|
// Copyright 2016-2018, Pulumi Corporation.
|
|
|
|
//
|
|
|
|
// 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-08-30 03:24:12 +02:00
|
|
|
|
2017-08-23 02:15:16 +02:00
|
|
|
package engine
|
|
|
|
|
|
|
|
import (
|
2018-05-05 02:01:35 +02:00
|
|
|
"github.com/opentracing/opentracing-go"
|
|
|
|
|
2020-04-14 10:30:25 +02:00
|
|
|
"github.com/pulumi/pulumi/pkg/v2/resource/deploy"
|
|
|
|
"github.com/pulumi/pulumi/pkg/v2/util/cancel"
|
|
|
|
"github.com/pulumi/pulumi/sdk/v2/go/common/workspace"
|
2017-08-23 02:15:16 +02:00
|
|
|
)
|
|
|
|
|
General prep work for refresh
This change includes a bunch of refactorings I made in prep for
doing refresh (first, the command, see pulumi/pulumi#1081):
* The primary change is to change the way the engine's core update
functionality works with respect to deploy.Source. This is the
way we can plug in new sources of resource information during
planning (and, soon, diffing). The way I intend to model refresh
is by having a new kind of source, deploy.RefreshSource, which
will let us do virtually everything about an update/diff the same
way with refreshes, which avoid otherwise duplicative effort.
This includes changing the planOptions (nee deployOptions) to
take a new SourceFunc callback, which is responsible for creating
a source specific to the kind of plan being requested.
Preview, Update, and Destroy now are primarily differentiated by
the kind of deploy.Source that they return, rather than sprinkling
things like `if Destroying` throughout. This tidies up some logic
and, more importantly, gives us precisely the refresh hook we need.
* Originally, we used the deploy.NullSource for Destroy operations.
This simply returns nothing, which is how Destroy works. For some
reason, we were no longer doing this, and instead had some
`if Destroying` cases sprinkled throughout the deploy.EvalSource.
I think this is a vestige of some old way we did configuration, at
least judging by a comment, which is apparently no longer relevant.
* Move diff and diff-printing logic within the engine into its own
pkg/engine/diff.go file, to prepare for upcoming work.
* I keep noticing benign diffs anytime I regenerate protobufs. I
suspect this is because we're also on different versions. I changed
generate.sh to also dump the version into grpc_version.txt. At
least we can understand where the diffs are coming from, decide
whether to take them (i.e., a newer version), and ensure that as
a team we are monotonically increasing, and not going backwards.
* I also tidied up some tiny things I noticed while in there, like
comments, incorrect types, lint suppressions, and so on.
2018-03-28 16:45:23 +02:00
|
|
|
// UpdateInfo abstracts away information about an apply, preview, or destroy.
|
|
|
|
type UpdateInfo interface {
|
2018-01-08 22:01:40 +01:00
|
|
|
// GetRoot returns the root directory for this update. This defines the scope for any filesystem resources
|
|
|
|
// accessed by this update.
|
|
|
|
GetRoot() string
|
2018-02-14 22:56:16 +01:00
|
|
|
// GetProject returns information about the project associated with this update. This includes information such as
|
2018-01-08 22:01:40 +01:00
|
|
|
// the runtime that will be used to execute the Pulumi program and the program's relative working directory.
|
2018-02-14 22:56:16 +01:00
|
|
|
GetProject() *workspace.Project
|
2018-01-08 22:01:40 +01:00
|
|
|
// GetTarget returns information about the target of this update. This includes the name of the stack being
|
|
|
|
// updated, the configuration values associated with the target and the target's latest snapshot.
|
|
|
|
GetTarget() *deploy.Target
|
2017-08-30 03:19:10 +02:00
|
|
|
}
|
2018-04-20 03:59:14 +02:00
|
|
|
|
2019-08-12 09:22:42 +02:00
|
|
|
// QueryInfo abstracts away information about a query operation.
|
|
|
|
type QueryInfo interface {
|
|
|
|
// GetRoot returns the root directory for this update. This defines the scope for any filesystem resources
|
|
|
|
// accessed by this update.
|
|
|
|
GetRoot() string
|
|
|
|
// GetProject returns information about the project associated with this update. This includes information such as
|
|
|
|
// the runtime that will be used to execute the Pulumi program and the program's relative working directory.
|
|
|
|
GetProject() *workspace.Project
|
|
|
|
}
|
|
|
|
|
2018-04-23 23:12:13 +02:00
|
|
|
// Context provides cancellation, termination, and eventing options for an engine operation. It also provides
|
|
|
|
// a way for the engine to persist snapshots, using the `SnapshotManager`.
|
2018-04-20 03:59:14 +02:00
|
|
|
type Context struct {
|
2018-04-23 23:12:13 +02:00
|
|
|
Cancel *cancel.Context
|
|
|
|
Events chan<- Event
|
|
|
|
SnapshotManager SnapshotManager
|
2018-11-14 22:33:35 +01:00
|
|
|
BackendClient deploy.BackendClient
|
2018-05-05 02:01:35 +02:00
|
|
|
ParentSpan opentracing.SpanContext
|
2018-04-20 03:59:14 +02:00
|
|
|
}
|