Open
Description
The splunk_api_username
and splunk_api_password
keys in contentctl.yml
should be allowed to be provided as environment variables, to avoid putting credentials in YAML files.
Here is a git patch file that adds this change:
From f74ae37c6ec9e3b5da84029cb3afade71cca48f2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=89milio=20Gonzalez?= <little.moon6016@fastmail.com>
Date: Mon, 4 Nov 2024 20:34:30 +0000
Subject: Merged PR 114299: Allow test.splunk_api_username and
test.splunk_api_password to be specified w...
Allow test.splunk_api_username and test.splunk_api_password to be specified with environment variables SPLUNKBASE_USERNAME and SPLUNKBASE_PASSWORD to avoid putting credentials in YAML files.
---
contentctl/objects/config.py | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/contentctl/objects/config.py b/contentctl/objects/config.py
index cbf6929..4228ba9 100644
--- a/contentctl/objects/config.py
+++ b/contentctl/objects/config.py
@@ -1,5 +1,6 @@
from __future__ import annotations
+import os
from os import environ
from datetime import datetime, UTC
from typing import Optional, Any, List, Union, Self
@@ -830,10 +831,17 @@ class test(test_common):
model_config = ConfigDict(use_enum_values=True,validate_default=True, arbitrary_types_allowed=True)
container_settings:ContainerSettings = ContainerSettings()
test_instances: List[Container] = Field([], exclude = True, validate_default=True)
- splunk_api_username: Optional[str] = Field(default=None, exclude = True,description="Splunk API username used for running appinspect or installating apps from Splunkbase")
- splunk_api_password: Optional[str] = Field(default=None, exclude = True, description="Splunk API password used for running appinspect or installaing apps from Splunkbase")
-
-
+ splunk_api_username: Optional[str] = Field(default=None, exclude = True,description="Splunk API username used for running appinspect or installating apps from Splunkbase. Can be replaced by the 'SPLUNKBASE_USERNAME' environment variable.")
+ splunk_api_password: Optional[str] = Field(default=None, exclude = True, description="Splunk API password used for running appinspect or installaing apps from Splunkbase. Can be replaced by the 'SPLUNKBASE_PASSWORD' environment variable.")
+
+ def __init__(self, **kwargs):
+ if "SPLUNKBASE_USERNAME" in os.environ:
+ breakpoint()
+ kwargs['splunk_api_username'] = os.environ["SPLUNKBASE_USERNAME"]
+ if "SPLUNKBASE_PASSWORD" in os.environ:
+ kwargs['splunk_api_password'] = os.environ["SPLUNKBASE_PASSWORD"]
+ super().__init__(**kwargs)
+
def getContainerInfrastructureObjects(self)->Self:
try:
self.test_instances = self.container_settings.getContainers()
--
2.34.1
To fix bugs and add features in a timely manner, I maintain a private fork of contentctl and the content has drifted, so I cannot easily open a PR at the moment for this feature, but would like it to be included upstream.
Metadata
Metadata
Assignees
Labels
No labels