-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathvalidate_inputs.py
44 lines (33 loc) · 1.1 KB
/
validate_inputs.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import os
import json
import sys
def validate_inputs(inputs):
errors = []
if 'TOKEN' not in inputs or not inputs['TOKEN']:
errors.append("Token is required.")
if 'TENANT_ID' not in inputs or not inputs['TENANT_ID']:
errors.append("Tenant ID is required.")
if 'REPOSITORY_NAME' not in inputs or not inputs['REPOSITORY_NAME']:
errors.append("Repository name is required.")
def main():
inputs = {
'DOCKERFILE_CONTEXT': os.getenv('DOCKERFILE_CONTEXT', ''),
'ENDPOINT': os.getenv('ENDPOINT', ''),
'TOKEN': os.getenv('TOKEN', ''),
'TENANT_ID': os.getenv('TENANT_ID', ''),
'REPOSITORY_NAME': os.getenv('REPOSITORY_NAME', ''),
'TAG': os.getenv('TAG', ''),
'SEVERITY': os.getenv('SEVERITY', ''),
'CODE': os.getenv('CODE', '')
}
errors = validate_inputs(inputs)
if errors:
print("Input validation failed:")
for error in errors:
print(f"- {error}")
sys.exit(1)
else:
print("Input validation passed.")
sys.exit(0)
if __name__ == "__main__":
main()