Skip to content

Commit 4a7bb2d

Browse files
authored
Update vars.py
Signed-off-by: prasant750h <[email protected]>
1 parent 952c52d commit 4a7bb2d

File tree

1 file changed

+29
-5
lines changed

1 file changed

+29
-5
lines changed

code/vars.py

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,35 @@
88
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
99
# See the License for the specific language governing permissions and
1010
# limitations under the License.
11+
"""
12+
Loads environment variables for remote connection and file transfer.
13+
14+
Expected variables:
15+
- DEST_IP
16+
- DEST_USER
17+
- DEST_PASS
18+
- LOCAL_FILE
19+
- REMOTE_PATH
20+
"""
1121

1222
import os
23+
import sys
24+
25+
DEST_IP: str = os.getenv("DEST_IP")
26+
DEST_USER: str = os.getenv("DEST_USER")
27+
DEST_PASS: str = os.getenv("DEST_PASS")
28+
LOCAL_FILE: str = os.getenv("LOCAL_FILE")
29+
REMOTE_PATH: str = os.getenv("REMOTE_PATH")
30+
31+
# Validate required variables
32+
REQUIRED_VARS = {
33+
"DEST_IP": DEST_IP,
34+
"DEST_USER": DEST_USER,
35+
"DEST_PASS": DEST_PASS,
36+
"LOCAL_FILE": LOCAL_FILE,
37+
"REMOTE_PATH": REMOTE_PATH,
38+
}
1339

14-
DEST_IP = os.environ["DEST_IP"]
15-
DEST_USER = os.environ["DEST_USER"]
16-
DEST_PASS = os.environ["DEST_PASS"]
17-
LOCAL_FILE = os.environ["LOCAL_FILE"]
18-
REMOTE_PATH = os.environ["REMOTE_PATH"]
40+
missing = [key for key, value in REQUIRED_VARS.items() if not value]
41+
if missing:
42+
sys.exit(f"Missing required environment variables: {', '.join(missing)}")

0 commit comments

Comments
 (0)