Skip to content

Commit

Permalink
kubernetes: the addon-manager now consists of two files sourcing each…
Browse files Browse the repository at this point in the history
…other
  • Loading branch information
Johan Thomsen committed Feb 19, 2021
1 parent e839f26 commit 4a821aa
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
11 changes: 10 additions & 1 deletion pkgs/applications/networking/cluster/kubernetes/default.nix
Expand Up @@ -33,6 +33,8 @@ stdenv.mkDerivation rec {

outputs = [ "out" "man" "pause" ];

patches = [ ./fixup-addonmanager-lib-path.patch ];

postPatch = ''
# go env breaks the sandbox
substituteInPlace "hack/lib/golang.sh" \
Expand Down Expand Up @@ -64,10 +66,17 @@ stdenv.mkDerivation rec {
install -D build/pause/linux/pause -t $pause/bin
installManPage docs/man/man1/*.[1-9]
cp cluster/addons/addon-manager/kube-addons.sh $out/bin/kube-addons
# Unfortunately, kube-addons-main.sh only looks for the lib file in either the current working dir
# or in /opt. We have to patch this for now.
substitute cluster/addons/addon-manager/kube-addons-main.sh $out/bin/kube-addons \
--subst-var out
chmod +x $out/bin/kube-addons
patchShebangs $out/bin/kube-addons
wrapProgram $out/bin/kube-addons --set "KUBECTL_BIN" "$out/bin/kubectl"
cp cluster/addons/addon-manager/kube-addons.sh $out/bin/kube-addons-lib.sh
cp ${./mk-docker-opts.sh} $out/bin/mk-docker-opts.sh
for tool in kubeadm kubectl; do
Expand Down
@@ -0,0 +1,23 @@
diff --git a/cluster/addons/addon-manager/kube-addons-main.sh b/cluster/addons/addon-manager/kube-addons-main.sh
index 849973470d1..e4fef30eaea 100755
--- a/cluster/addons/addon-manager/kube-addons-main.sh
+++ b/cluster/addons/addon-manager/kube-addons-main.sh
@@ -17,17 +17,7 @@
# Import required functions. The addon manager is installed to /opt in
# production use (see the Dockerfile)
# Disabling shellcheck following files as the full path would be required.
-if [ -f "kube-addons.sh" ]; then
- # shellcheck disable=SC1091
- source "kube-addons.sh"
-elif [ -f "/opt/kube-addons.sh" ]; then
- # shellcheck disable=SC1091
- source "/opt/kube-addons.sh"
-else
- # If the required source is missing, we have to fail.
- log ERR "== Could not find kube-addons.sh (not in working directory or /opt) at $(date -Is) =="
- exit 1
-fi
+source "@out@/bin/kube-addons-lib.sh"

# The business logic for whether a given object should be created
# was already enforced by salt, and /etc/kubernetes/addons is the

0 comments on commit 4a821aa

Please sign in to comment.