plans: Include backend settings in plan and plan files

On the first pass here we erroneously assumed that this was redundant with
the backend settings embedded in the configuration itself. In practice,
users can override backend configuration when running "terraform init"
and so we need to record the _effective_ backend configuration.

Along with this, we also return the selected workspace name at the time
the plan was created so we'll later be able to produce a specialized error
for the situation of having the wrong workspace selected. This isn't
strictly required because we'll also check the lineage of the state, but
the error message that would result from that failure would be relatively
opaque and thus less helpful to the user.
This commit is contained in:
Martin Atkins 2018-07-05 13:21:38 -07:00
parent 6dcaafa6ba
commit d9dfd135c6
6 changed files with 204 additions and 67 deletions

View File

@ -52,7 +52,7 @@ func (x Action) String() string {
return proto.EnumName(Action_name, int32(x))
}
func (Action) EnumDescriptor() ([]byte, []int) {
return fileDescriptor_planfile_8d966014b6720da2, []int{0}
return fileDescriptor_planfile_f722ed393ded62c3, []int{0}
}
type ResourceInstanceChange_ResourceMode int32
@ -75,7 +75,7 @@ func (x ResourceInstanceChange_ResourceMode) String() string {
return proto.EnumName(ResourceInstanceChange_ResourceMode_name, int32(x))
}
func (ResourceInstanceChange_ResourceMode) EnumDescriptor() ([]byte, []int) {
return fileDescriptor_planfile_8d966014b6720da2, []int{2, 0}
return fileDescriptor_planfile_f722ed393ded62c3, []int{3, 0}
}
// Plan is the root message type for the tfplan file
@ -105,17 +105,20 @@ type Plan struct {
TerraformVersion string `protobuf:"bytes,14,opt,name=terraform_version,json=terraformVersion,proto3" json:"terraform_version,omitempty"`
// SHA256 digests of all of the provider plugin binaries that were used
// in the creation of this plan.
ProviderHashes map[string]*Hash `protobuf:"bytes,15,rep,name=provider_hashes,json=providerHashes,proto3" json:"provider_hashes,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
ProviderHashes map[string]*Hash `protobuf:"bytes,15,rep,name=provider_hashes,json=providerHashes,proto3" json:"provider_hashes,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
// Backend is a description of the backend configuration and other related
// settings at the time the plan was created.
Backend *Backend `protobuf:"bytes,13,opt,name=backend,proto3" json:"backend,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *Plan) Reset() { *m = Plan{} }
func (m *Plan) String() string { return proto.CompactTextString(m) }
func (*Plan) ProtoMessage() {}
func (*Plan) Descriptor() ([]byte, []int) {
return fileDescriptor_planfile_8d966014b6720da2, []int{0}
return fileDescriptor_planfile_f722ed393ded62c3, []int{0}
}
func (m *Plan) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_Plan.Unmarshal(m, b)
@ -177,6 +180,68 @@ func (m *Plan) GetProviderHashes() map[string]*Hash {
return nil
}
func (m *Plan) GetBackend() *Backend {
if m != nil {
return m.Backend
}
return nil
}
// Backend is a description of backend configuration and other related settings.
type Backend struct {
Type string `protobuf:"bytes,1,opt,name=type,proto3" json:"type,omitempty"`
Config *DynamicValue `protobuf:"bytes,2,opt,name=config,proto3" json:"config,omitempty"`
Workspace string `protobuf:"bytes,3,opt,name=workspace,proto3" json:"workspace,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *Backend) Reset() { *m = Backend{} }
func (m *Backend) String() string { return proto.CompactTextString(m) }
func (*Backend) ProtoMessage() {}
func (*Backend) Descriptor() ([]byte, []int) {
return fileDescriptor_planfile_f722ed393ded62c3, []int{1}
}
func (m *Backend) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_Backend.Unmarshal(m, b)
}
func (m *Backend) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_Backend.Marshal(b, m, deterministic)
}
func (dst *Backend) XXX_Merge(src proto.Message) {
xxx_messageInfo_Backend.Merge(dst, src)
}
func (m *Backend) XXX_Size() int {
return xxx_messageInfo_Backend.Size(m)
}
func (m *Backend) XXX_DiscardUnknown() {
xxx_messageInfo_Backend.DiscardUnknown(m)
}
var xxx_messageInfo_Backend proto.InternalMessageInfo
func (m *Backend) GetType() string {
if m != nil {
return m.Type
}
return ""
}
func (m *Backend) GetConfig() *DynamicValue {
if m != nil {
return m.Config
}
return nil
}
func (m *Backend) GetWorkspace() string {
if m != nil {
return m.Workspace
}
return ""
}
// Change represents a change made to some object, transforming it from an old
// state to a new state.
type Change struct {
@ -202,7 +267,7 @@ func (m *Change) Reset() { *m = Change{} }
func (m *Change) String() string { return proto.CompactTextString(m) }
func (*Change) ProtoMessage() {}
func (*Change) Descriptor() ([]byte, []int) {
return fileDescriptor_planfile_8d966014b6720da2, []int{1}
return fileDescriptor_planfile_f722ed393ded62c3, []int{2}
}
func (m *Change) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_Change.Unmarshal(m, b)
@ -288,7 +353,7 @@ func (m *ResourceInstanceChange) Reset() { *m = ResourceInstanceChange{}
func (m *ResourceInstanceChange) String() string { return proto.CompactTextString(m) }
func (*ResourceInstanceChange) ProtoMessage() {}
func (*ResourceInstanceChange) Descriptor() ([]byte, []int) {
return fileDescriptor_planfile_8d966014b6720da2, []int{2}
return fileDescriptor_planfile_f722ed393ded62c3, []int{3}
}
func (m *ResourceInstanceChange) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_ResourceInstanceChange.Unmarshal(m, b)
@ -490,7 +555,7 @@ func (m *OutputChange) Reset() { *m = OutputChange{} }
func (m *OutputChange) String() string { return proto.CompactTextString(m) }
func (*OutputChange) ProtoMessage() {}
func (*OutputChange) Descriptor() ([]byte, []int) {
return fileDescriptor_planfile_8d966014b6720da2, []int{3}
return fileDescriptor_planfile_f722ed393ded62c3, []int{4}
}
func (m *OutputChange) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_OutputChange.Unmarshal(m, b)
@ -554,7 +619,7 @@ func (m *DynamicValue) Reset() { *m = DynamicValue{} }
func (m *DynamicValue) String() string { return proto.CompactTextString(m) }
func (*DynamicValue) ProtoMessage() {}
func (*DynamicValue) Descriptor() ([]byte, []int) {
return fileDescriptor_planfile_8d966014b6720da2, []int{4}
return fileDescriptor_planfile_f722ed393ded62c3, []int{5}
}
func (m *DynamicValue) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_DynamicValue.Unmarshal(m, b)
@ -600,7 +665,7 @@ func (m *Hash) Reset() { *m = Hash{} }
func (m *Hash) String() string { return proto.CompactTextString(m) }
func (*Hash) ProtoMessage() {}
func (*Hash) Descriptor() ([]byte, []int) {
return fileDescriptor_planfile_8d966014b6720da2, []int{5}
return fileDescriptor_planfile_f722ed393ded62c3, []int{6}
}
func (m *Hash) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_Hash.Unmarshal(m, b)
@ -641,7 +706,7 @@ func (m *Path) Reset() { *m = Path{} }
func (m *Path) String() string { return proto.CompactTextString(m) }
func (*Path) ProtoMessage() {}
func (*Path) Descriptor() ([]byte, []int) {
return fileDescriptor_planfile_8d966014b6720da2, []int{6}
return fileDescriptor_planfile_f722ed393ded62c3, []int{7}
}
func (m *Path) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_Path.Unmarshal(m, b)
@ -682,7 +747,7 @@ func (m *Path_Step) Reset() { *m = Path_Step{} }
func (m *Path_Step) String() string { return proto.CompactTextString(m) }
func (*Path_Step) ProtoMessage() {}
func (*Path_Step) Descriptor() ([]byte, []int) {
return fileDescriptor_planfile_8d966014b6720da2, []int{6, 0}
return fileDescriptor_planfile_f722ed393ded62c3, []int{7, 0}
}
func (m *Path_Step) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_Path_Step.Unmarshal(m, b)
@ -811,6 +876,7 @@ func init() {
proto.RegisterType((*Plan)(nil), "tfplan.Plan")
proto.RegisterMapType((map[string]*Hash)(nil), "tfplan.Plan.ProviderHashesEntry")
proto.RegisterMapType((map[string]*DynamicValue)(nil), "tfplan.Plan.VariablesEntry")
proto.RegisterType((*Backend)(nil), "tfplan.Backend")
proto.RegisterType((*Change)(nil), "tfplan.Change")
proto.RegisterType((*ResourceInstanceChange)(nil), "tfplan.ResourceInstanceChange")
proto.RegisterType((*OutputChange)(nil), "tfplan.OutputChange")
@ -822,59 +888,62 @@ func init() {
proto.RegisterEnum("tfplan.ResourceInstanceChange_ResourceMode", ResourceInstanceChange_ResourceMode_name, ResourceInstanceChange_ResourceMode_value)
}
func init() { proto.RegisterFile("planfile.proto", fileDescriptor_planfile_8d966014b6720da2) }
func init() { proto.RegisterFile("planfile.proto", fileDescriptor_planfile_f722ed393ded62c3) }
var fileDescriptor_planfile_8d966014b6720da2 = []byte{
// 804 bytes of a gzipped FileDescriptorProto
var fileDescriptor_planfile_f722ed393ded62c3 = []byte{
// 862 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x55, 0xdb, 0x6e, 0xe3, 0x36,
0x10, 0xb5, 0x6c, 0x45, 0xb1, 0xc7, 0x5e, 0x45, 0xcb, 0x16, 0x0b, 0x21, 0x2d, 0xb6, 0x86, 0x80,
0x76, 0x8d, 0xdd, 0xc2, 0x01, 0x52, 0xb4, 0xe9, 0xb6, 0x0f, 0x45, 0x2e, 0x02, 0x12, 0xec, 0x25,
0x06, 0xbb, 0xcd, 0x43, 0x1f, 0x6a, 0x30, 0xd2, 0x24, 0x26, 0x56, 0xa2, 0x54, 0x92, 0x36, 0xe0,
0xb7, 0xfe, 0x4c, 0xbf, 0xa7, 0xbf, 0x54, 0x90, 0xba, 0x44, 0x01, 0x02, 0x3f, 0x59, 0x73, 0xe6,
0xcc, 0x88, 0xe7, 0xcc, 0x50, 0x06, 0xbf, 0xcc, 0x98, 0xb8, 0xe3, 0x19, 0xce, 0x4b, 0x59, 0xe8,
0x82, 0x78, 0xfa, 0xce, 0x20, 0xd1, 0x3f, 0x2e, 0xb8, 0x8b, 0x8c, 0x09, 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x7a, 0x65, 0xd0, 0xa6, 0x69, 0x1c, 0x9d, 0x4c, 0xdf, 0x9f, 0x5f, 0x4e, 0x7c, 0xd7, 0x38, 0xae,
0x26, 0xef, 0x27, 0x9f, 0x26, 0xfe, 0xe1, 0xc5, 0xdb, 0xdf, 0xcf, 0x16, 0x5c, 0x2f, 0x57, 0xf3,
0x51, 0x94, 0xa5, 0xa7, 0xe6, 0x91, 0xe5, 0x51, 0x26, 0xf3, 0xd3, 0xfa, 0x2d, 0x3e, 0x35, 0xc9,
0xa9, 0x53, 0x2e, 0x34, 0x4a, 0xc1, 0x12, 0x6b, 0xda, 0x3f, 0xae, 0x79, 0xcb, 0xfe, 0x7c, 0xf7,
0x5f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x95, 0x91, 0xf6, 0x8e, 0xd1, 0x06, 0x00, 0x00,
}

View File

@ -38,6 +38,17 @@ message Plan {
// SHA256 digests of all of the provider plugin binaries that were used
// in the creation of this plan.
map<string, Hash> provider_hashes = 15;
// Backend is a description of the backend configuration and other related
// settings at the time the plan was created.
Backend backend = 13;
}
// Backend is a description of backend configuration and other related settings.
message Backend {
string type = 1;
DynamicValue config = 2;
string workspace = 3;
}
// Action describes the type of action planned for an object.

View File

@ -21,6 +21,26 @@ type Plan struct {
VariableValues map[string]DynamicValue
Changes *Changes
ProviderSHA256s map[string][]byte
Backend Backend
}
// Backend represents the backend-related configuration and other data as it
// existed when a plan was created.
type Backend struct {
// Type is the type of backend that the plan will apply against.
Type string
// Config is the configuration of the backend, whose schema is decided by
// the backend Type.
Config DynamicValue
// Workspace is the name of the workspace that was active when the plan
// was created. It is illegal to apply a plan created for one workspace
// to the state of another workspace.
// (This constraint is already enforced by the statefile lineage mechanism,
// but storing this explicitly allows us to return a better error message
// in the situation where the user has the wrong workspace selected.)
Workspace string
}
// ProviderAddrs returns a list of all of the provider configuration addresses

View File

@ -52,6 +52,11 @@ func TestRoundtrip(t *testing.T) {
VariableValues: map[string]plans.DynamicValue{
"foo": plans.DynamicValue([]byte("foo placeholder")),
},
Backend: plans.Backend{
Type: "local",
Config: plans.DynamicValue([]byte("config placeholder")),
Workspace: "default",
},
}
workDir, err := ioutil.TempDir("", "tf-planfile")

View File

@ -98,6 +98,20 @@ func readTfplan(r io.Reader) (*plans.Plan, error) {
plan.VariableValues[name] = val
}
if rawBackend := rawPlan.Backend; rawBackend == nil {
return nil, fmt.Errorf("plan file has no backend settings; backend settings are required")
} else {
config, err := valueFromTfplan(rawBackend.Config)
if err != nil {
return nil, fmt.Errorf("plan file has invalid backend configuration: %s", err)
}
plan.Backend = plans.Backend{
Type: rawBackend.Type,
Config: config,
Workspace: rawBackend.Workspace,
}
}
return plan, nil
}
@ -296,6 +310,12 @@ func writeTfplan(plan *plans.Plan, w io.Writer) error {
rawPlan.Variables[name] = valueToTfplan(val)
}
rawPlan.Backend = &planproto.Backend{
Type: plan.Backend.Type,
Config: valueToTfplan(plan.Backend.Config),
Workspace: plan.Backend.Workspace,
}
src, err := proto.Marshal(rawPlan)
if err != nil {
return fmt.Errorf("serialization error: %s", err)

View File

@ -93,6 +93,18 @@ func TestTFPlanRoundTrip(t *testing.T) {
0x70, 0x7a, 0x11, 0xed, 0xb0, 0x07, 0xab, 0x1e,
},
},
Backend: plans.Backend{
Type: "local",
Config: mustNewDynamicValue(
cty.ObjectVal(map[string]cty.Value{
"foo": cty.StringVal("bar"),
}),
cty.Object(map[string]cty.Type{
"foo": cty.String,
}),
),
Workspace: "default",
},
}
var buf bytes.Buffer