brusnika-stage: honor IAM route in premises permissions client
This commit is contained in:
parent
c277aca334
commit
3ab786c0bd
@ -13,7 +13,7 @@ spec:
|
|||||||
labels:
|
labels:
|
||||||
app: premises-backend
|
app: premises-backend
|
||||||
annotations:
|
annotations:
|
||||||
checksum/kafka-compat: 2d571098fc185256dca02661d95be6f560dac96c96a1d7e2881bd687e5c90ca9
|
checksum/kafka-compat: 1cf33f659ec921de79cb8adb7b50901f2dab4748e3c5c871c867f0ca08ec706a
|
||||||
spec:
|
spec:
|
||||||
imagePullSecrets:
|
imagePullSecrets:
|
||||||
- name: regcred
|
- name: regcred
|
||||||
@ -118,6 +118,10 @@ spec:
|
|||||||
mountPath: /premises/src/app/api.py
|
mountPath: /premises/src/app/api.py
|
||||||
subPath: api.py
|
subPath: api.py
|
||||||
readOnly: true
|
readOnly: true
|
||||||
|
- name: patched-code
|
||||||
|
mountPath: /premises/src/service/premise/permission.py
|
||||||
|
subPath: permission.py
|
||||||
|
readOnly: true
|
||||||
tolerations:
|
tolerations:
|
||||||
- key: dedicated
|
- key: dedicated
|
||||||
operator: Equal
|
operator: Equal
|
||||||
|
|||||||
@ -15,3 +15,26 @@ data:
|
|||||||
patched = source.replace(old, new, 1)
|
patched = source.replace(old, new, 1)
|
||||||
compile(patched, "api.py", "exec")
|
compile(patched, "api.py", "exec")
|
||||||
Path("/patched/api.py").write_text(patched)
|
Path("/patched/api.py").write_text(patched)
|
||||||
|
|
||||||
|
source = Path("/premises/src/service/premise/permission.py").read_text()
|
||||||
|
old = " config=IAMConfig.from_environment(config.srx_sdk.iam_environment),"
|
||||||
|
new = " config=iam_config,"
|
||||||
|
if source.count(old) != 1:
|
||||||
|
raise RuntimeError("Unexpected IAM configuration in premises image")
|
||||||
|
imports = "from urllib.parse import urlsplit\nfrom srx_sdk.iam.config import IAMHttpConfig\n"
|
||||||
|
configuration = """
|
||||||
|
iam_config = IAMConfig.from_environment(config.srx_sdk.iam_environment)
|
||||||
|
if config.srx_sdk.iam_route:
|
||||||
|
iam_url = urlsplit(config.srx_sdk.iam_route)
|
||||||
|
iam_config.http_config = IAMHttpConfig(
|
||||||
|
host=iam_url.hostname,
|
||||||
|
port=iam_url.port or 80,
|
||||||
|
protocol=iam_url.scheme,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
"""
|
||||||
|
patched = imports + source.replace(old, new, 1)
|
||||||
|
patched = patched.replace("class PremisePermissionService:", configuration + "class PremisePermissionService:", 1)
|
||||||
|
compile(patched, "permission.py", "exec")
|
||||||
|
Path("/patched/permission.py").write_text(patched)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user