-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #243 from QCDIS/242-add-secret-creation-endpoint
add secret creation endpoint
- Loading branch information
Showing
3 changed files
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import json | ||
import logging | ||
import os | ||
|
||
import requests | ||
|
||
from django.conf import settings | ||
|
||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class K8sSecretCreator: | ||
def __init__(self): | ||
self.url = os.environ['K8S_SECRET_CREATOR_URL'] | ||
self.token = os.environ['K8S_SECRET_CREATOR_TOKEN'] | ||
|
||
def create_secret(self, data): | ||
resp = requests.post( | ||
self.url, | ||
verify=(not settings.ALLOW_INSECURE_TLS), | ||
headers={ | ||
'accept': 'application/json', | ||
'Content-Type': 'application/json', | ||
'X-Auth': self.token, | ||
}, | ||
data=json.dumps(data), | ||
) | ||
if resp.status_code != 200: | ||
logger.error(f"Secret submission failed: {resp.json()}") | ||
resp.raise_for_status() | ||
return resp.json() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters