pulumi/pkg/apitype/history.go
joeduffy cd5707f483 Clarify refresh text
The wording for refresh doesn't accurately convey that the operations
aren't actually mutating your resources, but instead are simply changing
your checkpoint state. This change (hopefully) helps in two ways:

First, put text just before the prompt:

Do you want to perform this refresh?
No resources will be modified as part of this refresh; just your stack's state will be.

Second, alter the summary ever-so-slightly, from:

info: 2 changes performed:
    ~ 2 resources updated
      3 resources unchanged

to:

info: 2 changes refreshed:
    ~ 2 resources updated
      3 resources unchanged

This reads just slightly better, and removes any sense of panic I might
have otherwise had that my refresh just did something wrong.

As I was in here, since I had to pass UpdateKind information to new
places, I cleaned up the situation where we had three mostly-similar
enums (but which actually diverged) and several areas where we were
using untyped strings for this same information. Now there's just one.

This fixes pulumi/pulumi#1551.
2018-08-29 17:09:14 -07:00

103 lines
4 KiB
Go

// 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.
package apitype
import "encoding/json"
// UpdateKind is an enum for the type of update performed.
//
// Should generally mirror backend.UpdateKind, but we clone it in this package to add
// flexibility in case there is a breaking change in the backend-type.
type UpdateKind string
const (
// UpdateUpdate is the prototypical Pulumi program update.
UpdateUpdate UpdateKind = "update"
// PreviewUpdate is a preview of an update, without impacting resources.
PreviewUpdate UpdateKind = "preview"
// RefreshUpdate is an update that came from a refresh operation.
RefreshUpdate UpdateKind = "refresh"
// DestroyUpdate is an update which removes all resources.
DestroyUpdate UpdateKind = "destroy"
// ImportUpdate is an update that entails importing a raw checkpoint file.
ImportUpdate UpdateKind = "import"
)
// UpdateResult is an enum for the result of the update.
//
// Should generally mirror backend.UpdateResult, but we clone it in this package to add
// flexibility in case there is a breaking change in the backend-type.
type UpdateResult string
const (
// NotStartedResult is for updates that have not started.
NotStartedResult UpdateResult = "not-started"
// InProgressResult is for updates that have not yet completed.
InProgressResult UpdateResult = "in-progress"
// SucceededResult is for updates that completed successfully.
SucceededResult UpdateResult = "succeeded"
// FailedResult is for updates that have failed.
FailedResult UpdateResult = "failed"
)
// OpType describes the type of operation performed to a resource managed by Pulumi.
//
// Should generally mirror deploy.StepOp, but we clone it in this package to add
// flexibility in case there is a breaking change in the backend-type.
type OpType string
const (
// OpSame indiciates no change was made.
OpSame OpType = "same"
// OpCreate indiciates a new resource was created.
OpCreate OpType = "create"
// OpUpdate indicates an existing resource was updated.
OpUpdate OpType = "update"
// OpDelete indiciates an existing resource was deleted.
OpDelete OpType = "delete"
// OpReplace indicates an existing resource was replaced with a new one.
OpReplace OpType = "replace"
// OpCreateReplacement indiciates a new resource was created for a replacement.
OpCreateReplacement OpType = "create-replacement"
// OpDeleteReplaced indiciates an existing resource was deleted after replacement.
OpDeleteReplaced OpType = "delete-replaced"
)
// UpdateInfo describes a previous update.
//
// Should generally mirror backend.UpdateInfo, but we clone it in this package to add
// flexibility in case there is a breaking change in the backend-type.
type UpdateInfo struct {
// Information known before an update is started.
Kind UpdateKind `json:"kind"`
StartTime int64 `json:"startTime"`
Message string `json:"message"`
Environment map[string]string `json:"environment"`
Config map[string]ConfigValue `json:"config"`
// Information obtained from an update completing.
Result UpdateResult `json:"result"`
EndTime int64 `json:"endTime"`
Version int `json:"version"`
Deployment json.RawMessage `json:"deployment,omitempty"`
ResourceChanges map[OpType]int `json:"resourceChanges,omitempty"`
}
// GetHistoryResponse is the response from the Pulumi Service when requesting
// a stack's history.
type GetHistoryResponse struct {
Updates []UpdateInfo `json:"updates"`
}