pulumi/pkg/backend/updates.go
Matt Ellis 6845f9ed20 Add pulumi config refresh to fetch most recent configuration
The newly added `pulumi config refresh` updates your local copy of the
Pulumi.<stack-name>.yaml file to have the same configuration as the
most recent deployment in the cloud.

This can be used in a varirty of ways. One place we plan to use it is
in automation to clean up "leaked" stacks we have in CI. With the
changes you'll now be able to do the following:

```
$ cd $(mktemp -d)
$ echo -e "name: who-cares\nruntime: nodejs" > Pulumi.yaml
$ pulumi stack select <leaked-stack-name>
$ pulumi config refresh -f
$ pulumi destroy --force
```

Having a simpler gesture for the above is something we'll want to do
long term (we should be able to support `pulumi destory <stack-name>`
from a completely empty folder, today you need a Pulumi.yaml file
present, even if the contents don't matter).

But this gets us a little closer to where we want to be and introduces
a helpful primitive in the system.

Contributes to #814
2018-05-14 10:28:42 -07:00

88 lines
3.1 KiB
Go

// Copyright 2018, Pulumi Corporation. All rights reserved.
package backend
import (
"github.com/pulumi/pulumi/pkg/engine"
"github.com/pulumi/pulumi/pkg/resource/config"
)
// UpdateMetadata describes optional metadata about an update.
type UpdateMetadata struct {
// Message is an optional message associated with the update.
Message string `json:"message"`
// Environment contains optional data from the deploying environment. e.g. the current
// source code control commit information.
Environment map[string]string `json:"environment"`
}
// UpdateKind is an enum for the type of update performed.
type UpdateKind string
const (
// DeployUpdate is the prototypical Pulumi program update.
DeployUpdate UpdateKind = "update"
// PreviewUpdate is a preview of an update, without impacting resources.
PreviewUpdate UpdateKind = "preview"
// RefreshUpdate is an update that adopts a cloud's existing resource state.
RefreshUpdate UpdateKind = "refresh"
// DestroyUpdate is an update which removes all resources.
DestroyUpdate UpdateKind = "destroy"
)
// UpdateResult is an enum for the result of the update.
type UpdateResult string
const (
// InProgressResult is for updates that have not yet completed.
InProgressResult = "in-progress"
// SucceededResult is for updates that completed successfully.
SucceededResult UpdateResult = "succeeded"
// FailedResult is for updates that have failed.
FailedResult = "failed"
)
// Keys we use for values put into UpdateInfo.Environment.
const (
// GitHead is the commit hash of HEAD.
GitHead = "git.head"
// GitDirty ("true", "false") indiciates if there are any unstaged or modified files in the local repo.
GitDirty = "git.dirty"
// GitCommitter is the name of the person who committed the commit at HEAD.
GitCommitter = "git.committer"
// GitCommitterEmail is the Email address associated with the committer.
GitCommitterEmail = "git.committer.email"
// GitAuthor is the name of the person who authored the commit at HEAD.
GitAuthor = "git.author"
// GitAuthorEmail is the email address associated with the commit's author.
GitAuthorEmail = "git.author.email"
// GitHubLogin is the user/organization who owns the local repo, if the origin remote is hosted on GitHub.com.
GitHubLogin = "github.login"
// GitHubRepo is the name of the GitHub repo, if the local git repo's remote origin is hosted on GitHub.com.
GitHubRepo = "github.repo"
)
// UpdateInfo describes a previous update.
type UpdateInfo struct {
// Information known before an update is started.
Kind UpdateKind `json:"kind"`
StartTime int64 `json:"startTime"`
// Message is an optional message associated with the update.
Message string `json:"message"`
// Environment contains optional data from the deploying environment. e.g. the current
// source code control commit information.
Environment map[string]string `json:"environment"`
// Config used for the update.
Config config.Map `json:"config"`
// Information obtained from an update completing.
Result UpdateResult `json:"result"`
EndTime int64 `json:"endTime"`
ResourceChanges engine.ResourceChanges `json:"resourceChanges,omitempty"`
}