Update find logic for newly shared objects

We need to discover the tags and assume the Shared flag, or else the
objects will always be dirty.
This commit is contained in:
Justin Santa Barbara 2018-03-03 22:27:57 -05:00
parent e634143c43
commit 8c5a4a2d07
5 changed files with 12 additions and 2 deletions

View File

@ -79,6 +79,7 @@ func (e *DHCPOptions) Find(c *fi.Context) (*DHCPOptions, error) {
actual := &DHCPOptions{ actual := &DHCPOptions{
ID: o.DhcpOptionsId, ID: o.DhcpOptionsId,
Name: findNameTag(o.Tags), Name: findNameTag(o.Tags),
Tags: intersectTags(o.Tags, e.Tags),
} }
for _, s := range o.DhcpConfigurations { for _, s := range o.DhcpConfigurations {
@ -104,6 +105,7 @@ func (e *DHCPOptions) Find(c *fi.Context) (*DHCPOptions, error) {
// Avoid spurious changes // Avoid spurious changes
actual.Lifecycle = e.Lifecycle actual.Lifecycle = e.Lifecycle
actual.Shared = e.Shared
return actual, nil return actual, nil
} }

View File

@ -93,6 +93,7 @@ func (e *InternetGateway) Find(c *fi.Context) (*InternetGateway, error) {
actual := &InternetGateway{ actual := &InternetGateway{
ID: igw.InternetGatewayId, ID: igw.InternetGatewayId,
Name: findNameTag(igw.Tags), Name: findNameTag(igw.Tags),
Tags: intersectTags(igw.Tags, e.Tags),
} }
glog.V(2).Infof("found matching InternetGateway %q", *actual.ID) glog.V(2).Infof("found matching InternetGateway %q", *actual.ID)

View File

@ -89,6 +89,7 @@ func TestSharedInternetGatewayDoesNotRename(t *testing.T) {
VPC: vpc1, VPC: vpc1,
Shared: fi.Bool(true), Shared: fi.Bool(true),
ID: internetGateway.InternetGateway.InternetGatewayId, ID: internetGateway.InternetGateway.InternetGatewayId,
Tags: make(map[string]string),
} }
return map[string]fi.Task{ return map[string]fi.Task{

View File

@ -62,12 +62,14 @@ func (e *RouteTable) Find(c *fi.Context) (*RouteTable, error) {
ID: rt.RouteTableId, ID: rt.RouteTableId,
VPC: &VPC{ID: rt.VpcId}, VPC: &VPC{ID: rt.VpcId},
Name: e.Name, Name: e.Name,
Tags: intersectTags(rt.Tags, e.Tags),
} }
glog.V(2).Infof("found matching RouteTable %q", *actual.ID) glog.V(2).Infof("found matching RouteTable %q", *actual.ID)
e.ID = actual.ID e.ID = actual.ID
// Prevent spurious changes // Prevent spurious changes
actual.Lifecycle = e.Lifecycle actual.Lifecycle = e.Lifecycle
actual.Shared = e.Shared
return actual, nil return actual, nil
} }

View File

@ -215,12 +215,16 @@ func (t *DryRunTarget) PrintReport(taskMap map[string]Task, out io.Writer) error
if err != nil { if err != nil {
return err return err
} }
taskName := getTaskName(r.changes)
fmt.Fprintf(b, " %s/%s\n", taskName, idForTask(taskMap, r.e))
if len(changeList) == 0 { if len(changeList) == 0 {
fmt.Fprintf(b, " internal consistency error!\n")
fmt.Fprintf(b, " actual: %+v\n", r.a)
fmt.Fprintf(b, " expect: %+v\n", r.e)
continue continue
} }
taskName := getTaskName(r.changes)
fmt.Fprintf(b, " %s/%s\n", taskName, idForTask(taskMap, r.e))
for _, change := range changeList { for _, change := range changeList {
lines := strings.Split(change.Description, "\n") lines := strings.Split(change.Description, "\n")
if len(lines) == 1 { if len(lines) == 1 {