Skip to content

Commit

Permalink
Merge pull request #262 from abryko/kswitch-curl-zones
Browse files Browse the repository at this point in the history
kswitch: fix error handling of caascad-zones call
  • Loading branch information
abryko authored Sep 27, 2021
2 parents 8e2ff0f + c3bce0e commit 779ec46
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pkgs/kswitch/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

stdenv.mkDerivation rec {
pname = "kswitch";
version = "1.8.4";
version = "1.8.5";

buildInputs = [ makeWrapper ];
passAsFile = [ "buildCommand" ];
Expand Down
11 changes: 6 additions & 5 deletions pkgs/kswitch/kswitch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -383,8 +383,9 @@ refresh_zones_or_cache() {
refresh_zones() {
log_debug "Refreshing caascad-zones..."
local httpCode
httpCode="$(curl -w "%{response_code}" --connect-timeout 2 -s -o "${CAASCAD_ZONES_FILE}.tmp" "${CAASCAD_ZONES_URL}")" || { [ "${httpCode}" != "200" ] && log-error "Refreshing caascad-zones failed!" && return 1; }
mv "${CAASCAD_ZONES_FILE}.tmp" "${CAASCAD_ZONES_FILE}" || { log-error "Unable to write ${CAASCAD_ZONES_FILE}" && return 1; }
httpCode="$(curl -w "%{response_code}" --connect-timeout 2 -s -o "${CAASCAD_ZONES_FILE}.tmp" "${CAASCAD_ZONES_URL}")"
[ "${httpCode}" != "200" ] && { log-error "Refreshing caascad-zones failed!"; return 1; }
mv "${CAASCAD_ZONES_FILE}.tmp" "${CAASCAD_ZONES_FILE}" || { log-error "Unable to write ${CAASCAD_ZONES_FILE}"; return 1; }
}

zone_exists() {
Expand Down Expand Up @@ -506,16 +507,16 @@ while (("$#")); do
exit 1
;;
*)
[ "$zone" != "" ] && (log-error "too much arguments" && usage && exit 1)
[ "$zone" != "" ] && { log-error "too much arguments"; usage; exit 1; }
zone=$1
shift
;;
esac
done

exitNow=0
[ "${cleanCache}" -eq 1 ] && clean_cache && exitNow=1
[ "${forceUnlock}" -eq 1 ] && force_unlock && exitNow=1
[ "${cleanCache}" -eq 1 ] && { clean_cache; exitNow=1; }
[ "${forceUnlock}" -eq 1 ] && { force_unlock; exitNow=1; }
[ "${exitNow}" -eq 1 ] && exit 0

# Makes sure to use ~/.kube/config
Expand Down

0 comments on commit 779ec46

Please sign in to comment.