From c246fa7d4e372a6f611fd46c0acd96b3b54a3676 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milio=20Gonzalez?= Date: Thu, 24 Oct 2024 13:11:43 -0400 Subject: [PATCH 1/3] Fix a bug where App_Base.getSplunkbasePath() was broken and did not work at all. Fixes #295. --- contentctl/objects/config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contentctl/objects/config.py b/contentctl/objects/config.py index 9057a4c4..c50ab900 100644 --- a/contentctl/objects/config.py +++ b/contentctl/objects/config.py @@ -47,7 +47,7 @@ class App_Base(BaseModel,ABC): def getSplunkbasePath(self)->HttpUrl: - return HttpUrl(SPLUNKBASE_URL.format(uid=self.uid, release=self.version)) + return HttpUrl(SPLUNKBASE_URL.format(uid=self.uid, version=self.version)) @abstractmethod def getApp(self, config:test, stage_file:bool=False)->str: From ea34bb1459bf249d1d68cd879b293a2cfae3d1be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milio=20Gonzalez?= Date: Thu, 24 Oct 2024 15:45:58 -0400 Subject: [PATCH 2/3] Do not serialize TestApp.hardcoded_path if it has value None. Fixes #319. --- contentctl/objects/config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contentctl/objects/config.py b/contentctl/objects/config.py index 9057a4c4..6f5ee070 100644 --- a/contentctl/objects/config.py +++ b/contentctl/objects/config.py @@ -65,7 +65,7 @@ class TestApp(App_Base): hardcoded_path: Optional[Union[FilePath,HttpUrl]] = Field(default=None, description="This may be a relative or absolute link to a file OR an HTTP URL linking to your app.") - @field_serializer('hardcoded_path',when_used='always') + @field_serializer('hardcoded_path',when_used='unless-none') def serialize_path(path: Union[AnyUrl, pathlib.Path])->str: return str(path) From e33011560e8f12ece38609189a524ae90e19f369 Mon Sep 17 00:00:00 2001 From: pyth0n1c Date: Mon, 4 Nov 2024 15:47:36 -0800 Subject: [PATCH 3/3] Manually port changed raised by Res260. --- contentctl/objects/config.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/contentctl/objects/config.py b/contentctl/objects/config.py index cbf6929f..7c9afb52 100644 --- a/contentctl/objects/config.py +++ b/contentctl/objects/config.py @@ -830,10 +830,18 @@ 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: None | 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: None | 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: Any): + if "SPLUNKBASE_USERNAME" in environ: + kwargs['splunk_api_username'] = environ["SPLUNKBASE_USERNAME"] + if "SPLUNKBASE_PASSWORD" in environ: + kwargs['splunk_api_password'] = environ["SPLUNKBASE_PASSWORD"] + super().__init__(**kwargs) + def getContainerInfrastructureObjects(self)->Self: try: self.test_instances = self.container_settings.getContainers()