Skip to content

Commit 8768ae9

Browse files
committed
improve configurator
1 parent 5567df4 commit 8768ae9

1 file changed

Lines changed: 16 additions & 10 deletions

File tree

varys/utils.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,39 +38,45 @@ def __init__(self, profile, config_path):
3838

3939
if self.use_tls:
4040
if os.environ.get("VARYS_CA_CERTIFICATE"):
41-
self.ca_certificate = os.environ.get("VARYS_CA_CERTIFICATE")
41+
self.ca_certificate = os.environ["VARYS_CA_CERTIFICATE"]
4242

4343
if profile_dict.get("ca_certificate"):
44-
self.ca_certificate = profile_dict.get("ca_certificate", None)
44+
self.ca_certificate = profile_dict["ca_certificate"]
4545

4646
if os.environ.get("VARYS_CLIENT_CERTIFICATE"):
47-
self.client_certificate = os.environ.get("VARYS_CLIENT_CERTIFICATE")
47+
self.client_certificate = os.environ["VARYS_CLIENT_CERTIFICATE"]
4848

4949
if profile_dict.get("client_certificate"):
5050
self.client_certificate = profile_dict["client_certificate"]
5151

5252
if os.environ.get("VARYS_CLIENT_KEY"):
53-
self.client_key = os.environ.get("VARYS_CLIENT_KEY")
53+
self.client_key = os.environ["VARYS_CLIENT_KEY"]
5454

5555
if profile_dict.get("client_key"):
5656
self.client_key = profile_dict["client_key"]
57-
58-
if not self.ca_certificate or not self.client_certificate or not self.client_key:
57+
58+
if (
59+
not self.ca_certificate
60+
or not self.client_certificate
61+
or not self.client_key
62+
):
5963
print(
6064
"Varys configuration JSON does not appear to contain the necessary fields for TLS configuration",
6165
file=sys.stderr,
6266
)
6367
sys.exit(11)
64-
65-
if not os.path.exists(self.ca_certificate) or not os.path.exists(self.client_certificate) or not os.path.exists(self.client_key):
68+
69+
if (
70+
not os.path.exists(self.ca_certificate)
71+
or not os.path.exists(self.client_certificate)
72+
or not os.path.exists(self.client_key)
73+
):
6674
print(
6775
"Varys configuration JSON does not appear to contain the necessary files for TLS configuration",
6876
file=sys.stderr,
6977
)
7078
sys.exit(11)
7179

72-
73-
7480
except KeyError:
7581
print(
7682
f"Varys configuration JSON does not appear to contain the necessary fields for profile: {profile}",

0 commit comments

Comments
 (0)