Skip to content

Commit 9c35894

Browse files
committed
Revert "Added insert_proxy_config.sh to edit configuration.py in client"
This reverts commit b295c2d.
1 parent b295c2d commit 9c35894

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

scripts/insert_proxy_config.sh

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
#!/usr/bin/env bash
2-
2+
# insert_proxy_config.sh - run this after openapi-generator release.sh
33
CONFIG_PATH="../python_kubernetes/kubernetes/client"
44

5+
# Compute the full file path
56
CONFIG_FILE="$CONFIG_PATH/configuration.py"
67

7-
# Normalize
8+
# --- Normalize Windows-style backslashes to Unix forward slashes ---
89
CONFIG_FILE="$(echo "$CONFIG_FILE" | sed 's|\\|/|g')"
910

10-
11+
# --- Ensure the target file exists and is writable ---
1112
if [ ! -f "$CONFIG_FILE" ] || [ ! -w "$CONFIG_FILE" ]; then
1213
echo "Error: $CONFIG_FILE does not exist or is not writable." >&2
1314
exit 1
1415
fi
1516

16-
# Import OS
17+
# --- Step 1: Ensure 'import os' follows existing imports (idempotent) ---
1718
if ! grep -qE '^import os$' "$CONFIG_FILE"; then
1819
LAST_IMPORT=$(grep -nE '^(import |from )' "$CONFIG_FILE" | tail -n1 | cut -d: -f1)
1920
if [ -n "$LAST_IMPORT" ]; then
@@ -30,12 +31,13 @@ else
3031
echo "'import os' already present; no changes made."
3132
fi
3233

33-
# Ensure proxy and no_proxy
34+
# --- Step 2: Insert proxy & no_proxy environment code (idempotent) ---
3435
if ! grep -q 'os.getenv("HTTPS_PROXY"' "$CONFIG_FILE"; then
3536
LINE=$(grep -n "self.proxy = None" "$CONFIG_FILE" | cut -d: -f1)
3637
if [ -n "$LINE" ]; then
3738
INDENT=$(sed -n "${LINE}s/^\( *\).*/\1/p" "$CONFIG_FILE")
3839

40+
# Build the insertion block with correct indentation
3941

4042
BLOCK+="${INDENT}# Load proxy from environment variables (if set)\n"
4143
BLOCK+="${INDENT}if os.getenv(\"HTTPS_PROXY\"): self.proxy = os.getenv(\"HTTPS_PROXY\")\n"
@@ -47,6 +49,7 @@ if ! grep -q 'os.getenv("HTTPS_PROXY"' "$CONFIG_FILE"; then
4749
BLOCK+="${INDENT}if os.getenv(\"NO_PROXY\"): self.no_proxy = os.getenv(\"NO_PROXY\")\n"
4850
BLOCK+="${INDENT}if os.getenv(\"no_proxy\"): self.no_proxy = os.getenv(\"no_proxy\")"
4951

52+
# Insert the block after the proxy default line
5053
sed -i "${LINE}a $BLOCK" "$CONFIG_FILE"
5154
echo "Proxy and no_proxy environment code inserted into $CONFIG_FILE."
5255
else

0 commit comments

Comments
 (0)