-
Notifications
You must be signed in to change notification settings - Fork 40.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes bsd / gnu sed compatibility for local-up-cluster script #68970
Fixes bsd / gnu sed compatibility for local-up-cluster script #68970
Conversation
hack/local-up-cluster.sh
Outdated
# Fixes compatibility between BSD and GNU sed b/c this script is rather frequently used locally. | ||
case "$(uname -s)" in | ||
Darwin) | ||
sed -i "" "s/{{ pillar\['dns_domain'\] }}/${DNS_DOMAIN}/g" kube-dns.yaml |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The GNU vs BSD sed strikes again. :)
But wow that this has lingered for so long in the local-up-cluster script! I'm surprised we didn't find this sooner.
Instead of checking this here, we can use ensure-gnu-sed
:
Lines 782 to 797 in 488f0fc
# kube::util::ensure-gnu-sed | |
# Determines which sed binary is gnu-sed on linux/darwin | |
# | |
# Sets: | |
# SED: The name of the gnu-sed binary | |
# | |
function kube::util::ensure-gnu-sed { | |
if LANG=C sed --help 2>&1 | grep -q GNU; then | |
SED="sed" | |
elif which gsed &>/dev/null; then | |
SED="gsed" | |
else | |
kube::log::error "Failed to find GNU sed as sed or gsed. If you are on Mac: brew install gnu-sed." >&2 | |
return 1 | |
fi | |
} |
ensure-gnu-sed
is being used in https://github.com/kubernetes/kubernetes/blob/master/test/images/image-util.sh#L52 nicely.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of checking this here, we can use ensure-gnu-sed:
💯nice catch! much cleaner w/ this util. and ptal if i'm using correctly.
I've never used a Mac so I don't have a reliable way of testing/reviewing this. /assign @sttts |
a1e187f
to
fbff5fd
Compare
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: sttts, yue9944882 The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Fixes #68716
commands like
sed -i -e foo bar
will unexpectedly create a backup file with suffix-e
when using BSD sed (OSX). i see lots of such usage in the project and it might be impossible to provide compatibility for every scripts. but at least, we can start with some frequently used ones. in this pull, we fixlocal-up-cluster.sh
only./kind bug
/sig cluster-lifecycle
Release note: