Skip to content

Commit

Permalink
Display text-based diff if yaml/json diff is semantically equal
Browse files Browse the repository at this point in the history
  • Loading branch information
aq17 committed Jan 18, 2023
1 parent 12eeb4f commit cdd95f8
Show file tree
Hide file tree
Showing 17 changed files with 653 additions and 72 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
changes:
- type: fix
scope: cli/display
description: Display text-based diff if yaml/json diff is semantically equal
14 changes: 7 additions & 7 deletions pkg/backend/display/object_diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ func (p *propertyPrinter) printObject(props resource.PropertyMap) {

// Now print out the values intelligently based on the type.
for _, k := range keys {
if v := props[k]; !resource.IsInternalPropertyKey(k) && shouldPrintPropertyValue(v, p.planning) {
if v := props[k]; !resource.IsInternalPropertyKey(k) {
p.printObjectProperty(k, v, maxkey)
}
}
Expand Down Expand Up @@ -477,9 +477,6 @@ func shouldPrintPropertyValue(v resource.PropertyValue, outs bool) bool {
if v.IsObject() && len(v.ObjectValue()) == 0 {
return false // skip objects with no properties, since they are also uninteresting.
}
if v.IsObject() && len(v.ObjectValue()) == 0 {
return false // skip objects with no properties, since they are also uninteresting.
}
if v.IsOutput() && !outs {
// also don't show output properties until the outs parameter tells us to.
return false
Expand Down Expand Up @@ -1180,10 +1177,13 @@ func (p *propertyPrinter) printEncodedValueDiff(old, new string) bool {
return false
}

if oldKind == newKind {
p.write("(%s) ", oldKind)
} else {
if oldKind != newKind {
p.write("(%s => %s) ", oldKind, newKind)
} else if old != new {
p.printTextDiff(strconv.Quote(old), strconv.Quote(new))
return true
} else {
p.write("(%s) ", oldKind)
}

diff := oldValue.Diff(newValue, resource.IsInternalPropertyKey)
Expand Down
2 changes: 2 additions & 0 deletions pkg/backend/display/testdata/not-truncated/template-body.json

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -2435,6 +2435,52 @@
<{%reset%}> <{%reset%}> │ │ ├─ aws:ec2:RouteTable vpc-private-1 
<{%reset%}> <{%reset%}> │ │ ├─ aws:ec2:Subnet vpc-private-1 
<{%reset%}> <{%reset%}> │ │ ├─ aws:ec2:RouteTableAssociation vpc-private-1 
<{%reset%}> <{%reset%}> │ │ └─ aws:ec2:Route vpc-private-1-nat-1 
more⬇  <{%underline%}><{%fg 12%}>Type<{%reset%}> <{%underline%}><{%fg 12%}>Name<{%reset%}> 
<{%bold%}><{%reset%}> <{%reset%}> pulumi:pulumi:Stack aws-ts-eks-dev 
<{%reset%}> <{%reset%}> ├─ awsx:x:ec2:Vpc vpc 
<{%reset%}> <{%reset%}> │ ├─ awsx:x:ec2:NatGateway vpc-0 
<{%reset%}> <{%reset%}> │ │ ├─ aws:ec2:Eip vpc-0 
<{%reset%}> <{%reset%}> │ │ └─ aws:ec2:NatGateway vpc-0 
<{%reset%}> <{%reset%}> │ ├─ awsx:x:ec2:Subnet vpc-public-0 
<{%reset%}> <{%reset%}> │ │ ├─ aws:ec2:RouteTable vpc-public-0 
<{%reset%}> <{%reset%}> │ │ ├─ aws:ec2:Subnet vpc-public-0 
<{%reset%}> <{%reset%}> │ │ ├─ aws:ec2:Route vpc-public-0-ig 
<{%reset%}> <{%reset%}> │ │ └─ aws:ec2:RouteTableAssociation vpc-public-0 
<{%reset%}> <{%reset%}> │ ├─ awsx:x:ec2:Subnet vpc-private-0 
<{%reset%}> <{%reset%}> │ │ ├─ aws:ec2:RouteTable vpc-private-0 
<{%reset%}> <{%reset%}> │ │ ├─ aws:ec2:Subnet vpc-private-0 
<{%reset%}> <{%reset%}> │ │ ├─ aws:ec2:RouteTableAssociation vpc-private-0 
<{%reset%}> <{%reset%}> │ │ └─ aws:ec2:Route vpc-private-0-nat-0 
<{%reset%}> <{%reset%}> │ ├─ awsx:x:ec2:InternetGateway vpc 
<{%reset%}> <{%reset%}> │ │ └─ aws:ec2:InternetGateway vpc 
<{%reset%}> <{%reset%}> │ ├─ awsx:x:ec2:Subnet vpc-private-1 
<{%reset%}> <{%reset%}> │ │ ├─ aws:ec2:RouteTable vpc-private-1 
<{%reset%}> <{%reset%}> │ │ ├─ aws:ec2:Subnet vpc-private-1 
<{%reset%}> <{%reset%}> │ │ ├─ aws:ec2:RouteTableAssociation vpc-private-1 
<{%reset%}> <{%reset%}> │ │ └─ aws:ec2:Route vpc-private-1-nat-1 
more⬇  <{%underline%}><{%fg 12%}>Type<{%reset%}> <{%underline%}><{%fg 12%}>Name<{%reset%}> 
<{%bold%}><{%reset%}> <{%reset%}> pulumi:pulumi:Stack aws-ts-eks-dev 
<{%reset%}> <{%reset%}> ├─ awsx:x:ec2:Vpc vpc 
<{%reset%}> <{%reset%}> │ ├─ awsx:x:ec2:NatGateway vpc-0 
<{%reset%}> <{%reset%}> │ │ ├─ aws:ec2:Eip vpc-0 
<{%reset%}> <{%reset%}> │ │ └─ aws:ec2:NatGateway vpc-0 
<{%reset%}> <{%reset%}> │ ├─ awsx:x:ec2:Subnet vpc-public-0 
<{%reset%}> <{%reset%}> │ │ ├─ aws:ec2:RouteTable vpc-public-0 
<{%reset%}> <{%reset%}> │ │ ├─ aws:ec2:Subnet vpc-public-0 
<{%reset%}> <{%reset%}> │ │ ├─ aws:ec2:Route vpc-public-0-ig 
<{%reset%}> <{%reset%}> │ │ └─ aws:ec2:RouteTableAssociation vpc-public-0 
<{%reset%}> <{%reset%}> │ ├─ awsx:x:ec2:Subnet vpc-private-0 
<{%reset%}> <{%reset%}> │ │ ├─ aws:ec2:RouteTable vpc-private-0 
<{%reset%}> <{%reset%}> │ │ ├─ aws:ec2:Subnet vpc-private-0 
<{%reset%}> <{%reset%}> │ │ ├─ aws:ec2:RouteTableAssociation vpc-private-0 
<{%reset%}> <{%reset%}> │ │ └─ aws:ec2:Route vpc-private-0-nat-0 
<{%reset%}> <{%reset%}> │ ├─ awsx:x:ec2:InternetGateway vpc 
<{%reset%}> <{%reset%}> │ │ └─ aws:ec2:InternetGateway vpc 
<{%reset%}> <{%reset%}> │ ├─ awsx:x:ec2:Subnet vpc-private-1 
<{%reset%}> <{%reset%}> │ │ ├─ aws:ec2:RouteTable vpc-private-1 
<{%reset%}> <{%reset%}> │ │ ├─ aws:ec2:Subnet vpc-private-1 
<{%reset%}> <{%reset%}> │ │ ├─ aws:ec2:RouteTableAssociation vpc-private-1 
<{%reset%}> <{%reset%}> │ │ └─ aws:ec2:Route vpc-private-1-nat-1 
more⬇  <{%underline%}><{%fg 12%}>Type<{%reset%}> <{%underline%}><{%fg 12%}>Name<{%reset%}> 
<{%reset%}> <{%reset%}> pulumi:pulumi:Stack aws-ts-eks-dev 
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2435,6 +2435,52 @@
<{%reset%}> <{%reset%}> │ │ ├─ aws:ec2:RouteTable vpc-private-1 
<{%reset%}> <{%reset%}> │ │ ├─ aws:ec2:Subnet vpc-private-1 
<{%reset%}> <{%reset%}> │ │ ├─ aws:ec2:RouteTableAssociation vpc-private-1 
<{%reset%}> <{%reset%}> │ │ └─ aws:ec2:Route vpc-private-1-nat-1 
more⬇  <{%underline%}><{%fg 12%}>Type<{%reset%}> <{%underline%}><{%fg 12%}>Name<{%reset%}> 
<{%bold%}><{%reset%}> <{%reset%}> pulumi:pulumi:Stack aws-ts-eks-dev 
<{%reset%}> <{%reset%}> ├─ awsx:x:ec2:Vpc vpc 
<{%reset%}> <{%reset%}> │ ├─ awsx:x:ec2:NatGateway vpc-0 
<{%reset%}> <{%reset%}> │ │ ├─ aws:ec2:Eip vpc-0 
<{%reset%}> <{%reset%}> │ │ └─ aws:ec2:NatGateway vpc-0 
<{%reset%}> <{%reset%}> │ ├─ awsx:x:ec2:Subnet vpc-public-0 
<{%reset%}> <{%reset%}> │ │ ├─ aws:ec2:RouteTable vpc-public-0 
<{%reset%}> <{%reset%}> │ │ ├─ aws:ec2:Subnet vpc-public-0 
<{%reset%}> <{%reset%}> │ │ ├─ aws:ec2:Route vpc-public-0-ig 
<{%reset%}> <{%reset%}> │ │ └─ aws:ec2:RouteTableAssociation vpc-public-0 
<{%reset%}> <{%reset%}> │ ├─ awsx:x:ec2:Subnet vpc-private-0 
<{%reset%}> <{%reset%}> │ │ ├─ aws:ec2:RouteTable vpc-private-0 
<{%reset%}> <{%reset%}> │ │ ├─ aws:ec2:Subnet vpc-private-0 
<{%reset%}> <{%reset%}> │ │ ├─ aws:ec2:RouteTableAssociation vpc-private-0 
<{%reset%}> <{%reset%}> │ │ └─ aws:ec2:Route vpc-private-0-nat-0 
<{%reset%}> <{%reset%}> │ ├─ awsx:x:ec2:InternetGateway vpc 
<{%reset%}> <{%reset%}> │ │ └─ aws:ec2:InternetGateway vpc 
<{%reset%}> <{%reset%}> │ ├─ awsx:x:ec2:Subnet vpc-private-1 
<{%reset%}> <{%reset%}> │ │ ├─ aws:ec2:RouteTable vpc-private-1 
<{%reset%}> <{%reset%}> │ │ ├─ aws:ec2:Subnet vpc-private-1 
<{%reset%}> <{%reset%}> │ │ ├─ aws:ec2:RouteTableAssociation vpc-private-1 
<{%reset%}> <{%reset%}> │ │ └─ aws:ec2:Route vpc-private-1-nat-1 
more⬇  <{%underline%}><{%fg 12%}>Type<{%reset%}> <{%underline%}><{%fg 12%}>Name<{%reset%}> 
<{%bold%}><{%reset%}> <{%reset%}> pulumi:pulumi:Stack aws-ts-eks-dev 
<{%reset%}> <{%reset%}> ├─ awsx:x:ec2:Vpc vpc 
<{%reset%}> <{%reset%}> │ ├─ awsx:x:ec2:NatGateway vpc-0 
<{%reset%}> <{%reset%}> │ │ ├─ aws:ec2:Eip vpc-0 
<{%reset%}> <{%reset%}> │ │ └─ aws:ec2:NatGateway vpc-0 
<{%reset%}> <{%reset%}> │ ├─ awsx:x:ec2:Subnet vpc-public-0 
<{%reset%}> <{%reset%}> │ │ ├─ aws:ec2:RouteTable vpc-public-0 
<{%reset%}> <{%reset%}> │ │ ├─ aws:ec2:Subnet vpc-public-0 
<{%reset%}> <{%reset%}> │ │ ├─ aws:ec2:Route vpc-public-0-ig 
<{%reset%}> <{%reset%}> │ │ └─ aws:ec2:RouteTableAssociation vpc-public-0 
<{%reset%}> <{%reset%}> │ ├─ awsx:x:ec2:Subnet vpc-private-0 
<{%reset%}> <{%reset%}> │ │ ├─ aws:ec2:RouteTable vpc-private-0 
<{%reset%}> <{%reset%}> │ │ ├─ aws:ec2:Subnet vpc-private-0 
<{%reset%}> <{%reset%}> │ │ ├─ aws:ec2:RouteTableAssociation vpc-private-0 
<{%reset%}> <{%reset%}> │ │ └─ aws:ec2:Route vpc-private-0-nat-0 
<{%reset%}> <{%reset%}> │ ├─ awsx:x:ec2:InternetGateway vpc 
<{%reset%}> <{%reset%}> │ │ └─ aws:ec2:InternetGateway vpc 
<{%reset%}> <{%reset%}> │ ├─ awsx:x:ec2:Subnet vpc-private-1 
<{%reset%}> <{%reset%}> │ │ ├─ aws:ec2:RouteTable vpc-private-1 
<{%reset%}> <{%reset%}> │ │ ├─ aws:ec2:Subnet vpc-private-1 
<{%reset%}> <{%reset%}> │ │ ├─ aws:ec2:RouteTableAssociation vpc-private-1 
<{%reset%}> <{%reset%}> │ │ └─ aws:ec2:Route vpc-private-1-nat-1 
more⬇  <{%underline%}><{%fg 12%}>Type<{%reset%}> <{%underline%}><{%fg 12%}>Name<{%reset%}> 
<{%reset%}> <{%reset%}> pulumi:pulumi:Stack aws-ts-eks-dev 
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@
<{%bold%}><{%reset%}> <{%reset%}> aws:ec2:LaunchConfiguration cluster-nodeLaunchConfiguration <{%bold%}><{%reset%}><{%reset%}>
<{%bold%}><{%fg 3%}>~ <{%reset%}> aws:cloudformation:Stack cluster-nodes <{%bold%}><{%fg 3%}>updating<{%reset%}> [diff: <{%fg 3%}>~templateBody<{%reset%}><{%reset%}>]
<{%fg 3%}>~ <{%reset%}> aws:cloudformation:Stack cluster-nodes <{%fg 3%}>updated<{%reset%}> [diff: <{%fg 3%}>~templateBody<{%reset%}><{%reset%}>]
<{%fg 3%}>~ <{%reset%}> aws:cloudformation:Stack cluster-nodes <{%fg 3%}>updated<{%reset%}> [diff: <{%fg 3%}>~templateBody<{%reset%}><{%reset%}>]
<{%fg 3%}>~ <{%reset%}> aws:cloudformation:Stack cluster-nodes <{%fg 3%}>updated<{%reset%}> [diff: <{%fg 3%}>~templateBody<{%reset%}><{%reset%}>]
<{%bold%}><{%reset%}> <{%reset%}> pulumi:providers:kubernetes cluster-provider <{%bold%}><{%reset%}><{%reset%}>
<{%reset%}> <{%reset%}> pulumi:pulumi:Stack aws-ts-eks-dev <{%reset%}><{%reset%}>

Expand Down
Loading

0 comments on commit cdd95f8

Please sign in to comment.