Comments (8)
By the way, regarding screenshots, I hope this does not sound like cheap advertisement, but these kind of screenshot were actually the reason why I started to write https://github.com/homeport/termshot. You can give it a try, if you want.
from dyff.
Interesting. Thanks for the files to reproduce it. I will have a look.
from dyff.
Thanks for letting me know. I do not know where this happens, but I have a feeling. Support for comments was definitely done in a later iteration when I changed the YAML libraries. So this sounds very much like a gap in the implementation there.
from dyff.
I saw that utility, but I think maybe not until after I filed this. Looks nice.
from dyff.
👋 any updates on getting to the bottom of this? thanks! 🎉
from dyff.
Thanks for the nudge. I checked with the latest version of dyff
and the output looks different from the original bug report.
From what I can see in the provided files, this kind of looks as expected. In this case dyff
compares a multiline string (because of the pipe character for top
) in YAML. For these scenarios, it will try to highlight the differences within the text using the same familiar green and red colors. Visually comparing them, it returns what I expect: There are new lines added and some removed.
I do not recall what exactly, but there must have been a fix between the time the issue was opened and now, which addressed the weird stutter when rendering the differences in this multiline output.
from dyff.
Interesting, we still run into it periodically with multiline text (mostly things like ConfigMap
values). Here's a repro you can use for debugging, there's still some cases where we get the weird behavior:
I ran prettier
against the a portion of a shell script we have inside a ConfigMap
and it shows up pretty weirdly in the dyff
output:
a.yaml
:
kind: ConfigMap
apiVersion: v1
metadata:
name: foo
namespace: bar
data:
baz.sh: |
HOSTNAME="$(hostname)"
INDEX="${HOSTNAME##*-}"
DISCOVERY_IPS="$(nslookup ${SERVICE}${JOIN_DOMAIN} | grep -A 1 ^Name | grep ^Address | cut -f2 -d':' | cut -f2 -d' ')"
# Validate the IPs or exit with error so we don't incorrectly set ordinal 0 pod to primary by default
for IP in $DISCOVERY_IPS; do
echo "checking $IP is valid..."
echo $IP | grep -qE '^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$' && echo ok || exit 1
done
MASTER="$(for IP in ${DISCOVERY_IPS};do timeout 5 redis-cli -h ${IP} -p 26379 sentinel get-master-addr-by-name ${SERVICE}-master | grep -E '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' && break;done)"
MASTER_GROUP="${SERVICE}-master"
REDIS_CONF=/data/conf/redis.conf
REDIS_PORT=6379
SENTINEL_CONF=/data/conf/sentinel.conf
SENTINEL_PORT=26379
set -eu
setup_defaults() {
echo "Setting up defaults"
if [ "$INDEX" = "0" ]; then
echo "Setting this pod as the default master"
redis_update "$ANNOUNCE_IP"
sentinel_update "$ANNOUNCE_IP"
sed -i "s/^.*slaveof.*//" "$REDIS_CONF"
else
DEFAULT_MASTER="$(getent hosts "$SERVICE-0.$SERVICE" | awk '{ print $1 }')"
if [ -z "$DEFAULT_MASTER" ]; then
echo "Unable to resolve host"
exit 1
fi
echo "Setting default slave config.."
redis_update "$DEFAULT_MASTER"
sentinel_update "$DEFAULT_MASTER"
fi
}
b.yaml
:
kind: ConfigMap
apiVersion: v1
metadata:
name: foo
namespace: bar
data:
baz.sh: |
HOSTNAME="$(hostname)"
INDEX="${HOSTNAME##*-}"
DISCOVERY_IPS="$(nslookup ${SERVICE}${JOIN_DOMAIN} | grep -A 1 ^Name | grep ^Address | cut -f2 -d':' | cut -f2 -d' ')"
# Validate the IPs or exit with error so we don't incorrectly set ordinal 0 pod to primary by default
for IP in $DISCOVERY_IPS; do
echo "checking $IP is valid..."
echo $IP | grep -qE '^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$' && echo ok || exit 1
done
MASTER="$(for IP in ${DISCOVERY_IPS}; do timeout 5 redis-cli -h ${IP} -p 26379 sentinel get-master-addr-by-name ${SERVICE}-master | grep -E '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' && break; done)"
MASTER_GROUP="${SERVICE}-master"
REDIS_CONF=/data/conf/redis.conf
REDIS_PORT=6379
SENTINEL_CONF=/data/conf/sentinel.conf
SENTINEL_PORT=26379
set -eu
setup_defaults() {
echo "Setting up defaults"
if [ "$INDEX" = "0" ]; then
echo "Setting this pod as the default master"
redis_update "$ANNOUNCE_IP"
sentinel_update "$ANNOUNCE_IP"
sed -i "s/^.*slaveof.*//" "$REDIS_CONF"
else
DEFAULT_MASTER="$(getent hosts "$SERVICE-0.$SERVICE" | awk '{ print $1 }')"
if [ -z "$DEFAULT_MASTER" ]; then
echo "Unable to resolve host"
exit 1
fi
echo "Setting default slave config.."
redis_update "$DEFAULT_MASTER"
sentinel_update "$DEFAULT_MASTER"
fi
}
from dyff.
Dealt with this issue by splitting ConfigMap
s off and using diff
on them for now
Using casey/just
and mikefarah/yq
tmpdir := `mktemp -d`
diff-manifests:
# generate your manifests in {{tmpdir / "from"}} and {{tmpdir / "to"}}
mkdir {{tmpdir / "from-cm-only"}} {{tmpdir / "to-cm-only"}}
yq 'select(.kind != "ConfigMap")' {{tmpdir / "from"}} > {{tmpdir / "from-no-cm"}}
yq 'select(.kind != "ConfigMap")' {{tmpdir / "to"}} > {{tmpdir / "to-no-cm"}}
yq 'select(.kind == "ConfigMap") | sort_keys(..)' \
-s 'filename + "-cm-only/" + .metadata.namespace + ":" + .metadata.name + ".yaml"' \
{{tmpdir / "from"}} {{tmpdir / "to"}}
dyff between -i --color=on {{tmpdir / "from-no-cm"}} {{tmpdir / "to-no-cm"}}
diff -u --color=always {{tmpdir / "from-cm-only"}} {{tmpdir / "to-cm-only"}} || true
from dyff.
Related Issues (20)
- used as a library HOT 2
- interaction between regular expressions and YAML path segments is unclear HOT 2
- Replace `github.com/gorilla/mux` package HOT 2
- Truncate/Filter Diff Output HOT 6
- [bug] Wrong version in latest release HOT 2
- contribute a new language model to highlight.js / github's linguist HOT 1
- Restore release of Windows binaries HOT 1
- Ability to exclude additions
- Retain color codes when piped? HOT 1
- No documentation for format of --exclude and --include options HOT 1
- `dyff yaml` incorrectly converts boolstring to bool HOT 1
- Comment breaks yaml output
- Tab completion HOT 5
- Support outputting "between" to yaml
- feature request: Bring in some diff options: ignore-all-space, recursive, brief HOT 1
- Feature request: aarch64/arm64 binaries HOT 2
- Feature request: GitHub markdown compatible diffs HOT 3
- Comments breaks nested indentation
- Different boolean represenatations of the same value treated differently
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dyff.