From 074db8863659b63ef8bdadb6ca4b9568e779c7ef Mon Sep 17 00:00:00 2001 From: Martin Atkins Date: Tue, 10 Jul 2018 14:34:32 -0700 Subject: [PATCH] plans: Include target addresses in the plan We shouldn't really need these because the plan is already filtered to include diffs only for targeted resources, but we currently rely on this to filter out non-resource items from the diff, and so we'll retain it for now to avoid reworking how the apply-time graph builder works. --- plans/internal/planproto/planfile.pb.go | 149 +++++++++++++----------- plans/internal/planproto/planfile.proto | 5 + plans/plan.go | 1 + plans/planfile/tfplan.go | 12 ++ plans/planfile/tfplan_test.go | 7 ++ 5 files changed, 106 insertions(+), 68 deletions(-) diff --git a/plans/internal/planproto/planfile.pb.go b/plans/internal/planproto/planfile.pb.go index 13b7bd1fc..0480caf85 100644 --- a/plans/internal/planproto/planfile.pb.go +++ b/plans/internal/planproto/planfile.pb.go @@ -52,7 +52,7 @@ func (x Action) String() string { return proto.EnumName(Action_name, int32(x)) } func (Action) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_planfile_f722ed393ded62c3, []int{0} + return fileDescriptor_planfile_99d56bc18c7b6e8d, []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_f722ed393ded62c3, []int{3, 0} + return fileDescriptor_planfile_99d56bc18c7b6e8d, []int{3, 0} } // Plan is the root message type for the tfplan file @@ -101,6 +101,10 @@ type Plan struct { // outputs that are not changing, as context for detecting inconsistencies // at apply time. OutputChanges []*OutputChange `protobuf:"bytes,4,rep,name=output_changes,json=outputChanges,proto3" json:"output_changes,omitempty"` + // An unordered set of target addresses to include when applying. If no + // target addresses are present, the plan applies to the whole + // configuration. + TargetAddrs []string `protobuf:"bytes,5,rep,name=target_addrs,json=targetAddrs,proto3" json:"target_addrs,omitempty"` // The version string for the Terraform binary that created this plan. 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 @@ -118,7 +122,7 @@ 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_f722ed393ded62c3, []int{0} + return fileDescriptor_planfile_99d56bc18c7b6e8d, []int{0} } func (m *Plan) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_Plan.Unmarshal(m, b) @@ -166,6 +170,13 @@ func (m *Plan) GetOutputChanges() []*OutputChange { return nil } +func (m *Plan) GetTargetAddrs() []string { + if m != nil { + return m.TargetAddrs + } + return nil +} + func (m *Plan) GetTerraformVersion() string { if m != nil { return m.TerraformVersion @@ -201,7 +212,7 @@ 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} + return fileDescriptor_planfile_99d56bc18c7b6e8d, []int{1} } func (m *Backend) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_Backend.Unmarshal(m, b) @@ -267,7 +278,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_f722ed393ded62c3, []int{2} + return fileDescriptor_planfile_99d56bc18c7b6e8d, []int{2} } func (m *Change) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_Change.Unmarshal(m, b) @@ -353,7 +364,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_f722ed393ded62c3, []int{3} + return fileDescriptor_planfile_99d56bc18c7b6e8d, []int{3} } func (m *ResourceInstanceChange) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_ResourceInstanceChange.Unmarshal(m, b) @@ -555,7 +566,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_f722ed393ded62c3, []int{4} + return fileDescriptor_planfile_99d56bc18c7b6e8d, []int{4} } func (m *OutputChange) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_OutputChange.Unmarshal(m, b) @@ -619,7 +630,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_f722ed393ded62c3, []int{5} + return fileDescriptor_planfile_99d56bc18c7b6e8d, []int{5} } func (m *DynamicValue) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_DynamicValue.Unmarshal(m, b) @@ -665,7 +676,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_f722ed393ded62c3, []int{6} + return fileDescriptor_planfile_99d56bc18c7b6e8d, []int{6} } func (m *Hash) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_Hash.Unmarshal(m, b) @@ -706,7 +717,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_f722ed393ded62c3, []int{7} + return fileDescriptor_planfile_99d56bc18c7b6e8d, []int{7} } func (m *Path) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_Path.Unmarshal(m, b) @@ -747,7 +758,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_f722ed393ded62c3, []int{7, 0} + return fileDescriptor_planfile_99d56bc18c7b6e8d, []int{7, 0} } func (m *Path_Step) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_Path_Step.Unmarshal(m, b) @@ -888,62 +899,64 @@ func init() { proto.RegisterEnum("tfplan.ResourceInstanceChange_ResourceMode", ResourceInstanceChange_ResourceMode_name, ResourceInstanceChange_ResourceMode_value) } -func init() { proto.RegisterFile("planfile.proto", fileDescriptor_planfile_f722ed393ded62c3) } +func init() { proto.RegisterFile("planfile.proto", fileDescriptor_planfile_99d56bc18c7b6e8d) } -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, 0x8d, 0x6c, 0xc5, 0x97, 0xb1, 0xa3, 0x68, 0xd9, 0x62, 0x21, 0xa4, 0x8b, 0xad, 0x21, 0xa0, - 0x5d, 0x77, 0xb7, 0x70, 0x00, 0x17, 0x6d, 0xba, 0xed, 0x43, 0x91, 0x8b, 0x81, 0x04, 0x7b, 0x89, - 0xc1, 0x6e, 0xf3, 0xd0, 0x87, 0x1a, 0xb4, 0x34, 0xb1, 0x89, 0x48, 0x94, 0x4a, 0xd2, 0x2e, 0xfc, - 0x41, 0x7d, 0xea, 0xc7, 0xf4, 0x97, 0x0a, 0x52, 0x17, 0x3b, 0x40, 0xea, 0x27, 0x6b, 0xce, 0x0c, - 0x0f, 0x67, 0xce, 0xcc, 0xd0, 0xe0, 0xe5, 0x09, 0x13, 0xf7, 0x3c, 0xc1, 0x51, 0x2e, 0x33, 0x9d, - 0x91, 0x96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x91, 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, +var fileDescriptor_planfile_99d56bc18c7b6e8d = []byte{ + // 883 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x55, 0x6d, 0x6f, 0xe3, 0x44, + 0x10, 0x8e, 0x63, 0xe7, 0x6d, 0x92, 0xba, 0xbe, 0x05, 0x9d, 0xac, 0x72, 0x3a, 0x82, 0x25, 0xb8, + 0x70, 0x87, 0x52, 0x29, 0x08, 0xca, 0xc1, 0x07, 0x94, 0xb6, 0x91, 0x5a, 0xdd, 0x4b, 0xa3, 0xa5, + 0xf4, 0x03, 0x1f, 0x88, 0x36, 0xf6, 0x34, 0xb1, 0xea, 0xd8, 0x66, 0x77, 0x13, 0x94, 0x1f, 0xc4, + 0xdf, 0x81, 0xbf, 0x84, 0x76, 0xd7, 0x76, 0x52, 0xa9, 0x97, 0x4f, 0xf1, 0x3c, 0x33, 0xfb, 0xec, + 0xcc, 0x33, 0xb3, 0x13, 0x70, 0xf3, 0x84, 0xa5, 0xf7, 0x71, 0x82, 0xc3, 0x9c, 0x67, 0x32, 0x23, + 0x4d, 0x79, 0xaf, 0x90, 0xe0, 0x5f, 0x07, 0x9c, 0x69, 0xc2, 0x52, 0xe2, 0x43, 0x6b, 0x83, 0x5c, + 0xc4, 0x59, 0xea, 0x5b, 0x7d, 0x6b, 0xe0, 0xd0, 0xd2, 0x24, 0x6f, 0xa1, 0xb3, 0x61, 0x3c, 0x66, + 0xf3, 0x04, 0x85, 0x5f, 0xef, 0xd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4, 0xff, 0x6d, + 0xf3, 0xa6, 0xfe, 0xf9, 0xfe, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0x3c, 0x04, 0xa1, 0x9e, 0xf4, + 0x06, 0x00, 0x00, } diff --git a/plans/internal/planproto/planfile.proto b/plans/internal/planproto/planfile.proto index 418b43c5a..2268e4db4 100644 --- a/plans/internal/planproto/planfile.proto +++ b/plans/internal/planproto/planfile.proto @@ -32,6 +32,11 @@ message Plan { // at apply time. repeated OutputChange output_changes = 4; + // An unordered set of target addresses to include when applying. If no + // target addresses are present, the plan applies to the whole + // configuration. + repeated string target_addrs = 5; + // The version string for the Terraform binary that created this plan. string terraform_version = 14; diff --git a/plans/plan.go b/plans/plan.go index c55578123..b28820e53 100644 --- a/plans/plan.go +++ b/plans/plan.go @@ -20,6 +20,7 @@ import ( type Plan struct { VariableValues map[string]DynamicValue Changes *Changes + TargetAddrs []addrs.Targetable ProviderSHA256s map[string][]byte Backend Backend } diff --git a/plans/planfile/tfplan.go b/plans/planfile/tfplan.go index 76d3c2f9a..a4f8b1d54 100644 --- a/plans/planfile/tfplan.go +++ b/plans/planfile/tfplan.go @@ -82,6 +82,14 @@ func readTfplan(r io.Reader) (*plans.Plan, error) { plan.Changes.Resources = append(plan.Changes.Resources, change) } + for _, rawTargetAddr := range rawPlan.TargetAddrs { + target, diags := addrs.ParseTargetStr(rawTargetAddr) + if diags.HasErrors() { + return nil, fmt.Errorf("plan contains invalid target address %q: %s", target, diags.Err()) + } + plan.TargetAddrs = append(plan.TargetAddrs, target.Subject) + } + for name, rawHashObj := range rawPlan.ProviderHashes { if len(rawHashObj.Sha256) == 0 { return nil, fmt.Errorf("no SHA256 hash for provider %q plugin", name) @@ -300,6 +308,10 @@ func writeTfplan(plan *plans.Plan, w io.Writer) error { rawPlan.ResourceChanges = append(rawPlan.ResourceChanges, rawRC) } + for _, targetAddr := range plan.TargetAddrs { + rawPlan.TargetAddrs = append(rawPlan.TargetAddrs, targetAddr.String()) + } + for name, hash := range plan.ProviderSHA256s { rawPlan.ProviderHashes[name] = &planproto.Hash{ Sha256: hash, diff --git a/plans/planfile/tfplan_test.go b/plans/planfile/tfplan_test.go index c110b7aec..55d5dbb9f 100644 --- a/plans/planfile/tfplan_test.go +++ b/plans/planfile/tfplan_test.go @@ -85,6 +85,13 @@ func TestTFPlanRoundTrip(t *testing.T) { }, }, }, + TargetAddrs: []addrs.Targetable{ + addrs.Resource{ + Mode: addrs.ManagedResourceMode, + Type: "test_thing", + Name: "woot", + }.Absolute(addrs.RootModuleInstance), + }, ProviderSHA256s: map[string][]byte{ "test": []byte{ 0xba, 0x5e, 0x1e, 0x55, 0xb0, 0x1d, 0xfa, 0xce,