Skip to content

Commit ea8fa1a

Browse files
authored
chore: fix rsync helper (#5196)
* fix rsync helper * comments * merge common logic
1 parent ab49682 commit ea8fa1a

File tree

1 file changed

+26
-11
lines changed

1 file changed

+26
-11
lines changed

sky/utils/kubernetes/rsync_helper.sh

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,35 @@
1-
# When using pod@namespace+context, rsync passes args as: {us} -l pod namespace+context
2-
# We need to split the pod@namespace+context into pod, namespace and context
1+
# We need to determine the pod, namespace and context from the args
32
# For backward compatibility, we use + as the separator between namespace and context and add handling when context is not provided
4-
shift
5-
pod=$1
6-
shift
7-
echo "pod: $pod" >&2
8-
encoded_namespace_context=$1
9-
# Revert the encoded namespace+context to the original string.
10-
namespace_context=$(echo "$encoded_namespace_context" | sed 's|%40|@|g' | sed 's|%3A|:|g' | sed 's|%2B|+|g' | sed 's|%2F|/|g')
11-
echo "namespace_context: $namespace_context" >&2
3+
if [ "$1" = "-l" ]; then
4+
# -l pod namespace+context ...
5+
# used by normal rsync
6+
shift
7+
pod=$1
8+
shift
9+
encoded_namespace_context=$1
10+
shift
11+
echo "pod: $pod" >&2
12+
# Revert the encoded namespace+context to the original string.
13+
namespace_context=$(echo "$encoded_namespace_context" | sed 's|%40|@|g' | sed 's|%3A|:|g' | sed 's|%2B|+|g' | sed 's|%2F|/|g')
14+
echo "namespace_context: $namespace_context" >&2
15+
else
16+
# pod@namespace+context ...
17+
# used by openrsync
18+
encoded_pod_namespace_context=$1
19+
shift
20+
pod_namespace_context=$(echo "$encoded_pod_namespace_context" | sed 's|%40|@|g' | sed 's|%3A|:|g' | sed 's|%2B|+|g' | sed 's|%2F|/|g')
21+
echo "pod_namespace_context: $pod_namespace_context" >&2
22+
pod=$(echo $pod_namespace_context | cut -d@ -f1)
23+
echo "pod: $pod" >&2
24+
namespace_context=$(echo $pod_namespace_context | cut -d@ -f2-)
25+
echo "namespace_context: $namespace_context" >&2
26+
fi
1227
namespace=$(echo $namespace_context | cut -d+ -f1)
1328
echo "namespace: $namespace" >&2
1429
context=$(echo $namespace_context | grep '+' >/dev/null && echo $namespace_context | cut -d+ -f2- || echo "")
1530
echo "context: $context" >&2
1631
context_lower=$(echo "$context" | tr '[:upper:]' '[:lower:]')
17-
shift
32+
1833
if [ -z "$context" ] || [ "$context_lower" = "none" ]; then
1934
# If context is none, it means we are using incluster auth. In this case,
2035
# use need to set KUBECONFIG to /dev/null to avoid using kubeconfig file.

0 commit comments

Comments
 (0)