Skip to content

Commit 278f2f6

Browse files
committed
feat: release changes for version 0.4.14
1 parent 0824c89 commit 278f2f6

File tree

9 files changed

+44
-18
lines changed

9 files changed

+44
-18
lines changed

galaxy/core/exceptions.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
class GalaxyError(Exception):
77
"""Base class for all Galaxy errors."""
88

9+
@property
10+
def error_type(self) -> str:
11+
return self.__class__.__name__
12+
913

1014
class GalaxyWarning(GalaxyError):
1115
"""Base class for all Galaxy warnings."""

galaxy/core/main.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ async def main(
4545
if dry_run is False:
4646
integration_config = await magneto_client.get_plugin(str(config.integration.id))
4747

48+
# Get the properties from the integration config. Using `pop` to remove them from the original dict
49+
integration_config_properties = integration_config.pop("properties", None)
50+
4851
logger.debug("Config entity from magneto: %r", integration_config)
4952
if integration_config["dataSource"].lower() != integration_type:
5053
logger.error(
@@ -54,9 +57,8 @@ async def main(
5457
)
5558
raise Exception("Integration type mismatch between the integration and magneto config")
5659

57-
config_entity_properties = integration_config.get("properties", None)
58-
if config_entity_properties is not None:
59-
for key, value in config_entity_properties.items():
60+
if integration_config_properties is not None:
61+
for key, value in integration_config_properties.items():
6062
# Only set the property if it doesn't already exist or is empty
6163
if not config.integration.properties.get(key) or (
6264
# This OR is to handle the scenario of a nested dict with keys but no values
@@ -65,7 +67,6 @@ async def main(
6567
):
6668
config.integration.properties[key] = value
6769

68-
logger.debug("Config entity properties: %r", config.integration.properties)
6970
if integration_config is None:
7071
logger.error("Integration not found in magneto")
7172
raise Exception("Integration not found in magneto")

galaxy/core/models.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ class RelyConfig(BaseModel):
2424
token: str = Field(..., alias="token")
2525
url: str = Field(..., alias="url")
2626

27+
def __repr__(self) -> str:
28+
return f"RelyConfig(url={self.url!r})"
29+
2730

2831
class IntegrationConfig(BaseModel):
2932
model_config = ConfigDict(extra="forbid")
@@ -39,6 +42,18 @@ class IntegrationConfig(BaseModel):
3942
wait_for_tasks_enabled: bool = Field(True, alias="waitForTasksEnabled")
4043
wait_for_tasks_timeout_seconds: int | None = Field(600, alias="waitForTasksTimeout")
4144

45+
def __repr__(self) -> str:
46+
"""Return a string representation of the IntegrationConfig.
47+
48+
Properties are not included as they may contain sensitive information.
49+
"""
50+
return (
51+
f"IntegrationConfig(id={self.id}, type={self.type}, execution_type={self.execution_type}, "
52+
f"scheduled_interval={self.scheduled_interval}, default_model_mappings={self.default_model_mappings}, "
53+
f"dry_run={self.dry_run}, wait_for_tasks_enabled={self.wait_for_tasks_enabled}, "
54+
f"wait_for_tasks_timeout_seconds={self.wait_for_tasks_timeout_seconds})"
55+
)
56+
4257

4358
class Config(BaseModel):
4459
@classmethod
@@ -52,6 +67,9 @@ def from_yaml(cls, file_path):
5267
rely: RelyConfig
5368
integration: IntegrationConfig
5469

70+
def __repr__(self) -> str:
71+
return f"Config(rely={self.rely!r}, integration={self.integration!r})"
72+
5573

5674
class FileCheck(BaseModel):
5775
path: str

galaxy/integrations/gitlab/.rely/automations.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -695,7 +695,8 @@
695695
"updatedAt": "{{ data.properties.updatedAt if data.properties.updatedAt else none }}",
696696
"closedAt": "{{ data.properties.finishedAt if data.properties.finishedAt else none }}",
697697
"sourceCommit": "{{ data.properties.commit if data.properties.commit else none }}",
698-
"triggeredBy": "{{ actions.fetch_author.output.title if actions.fetch_author else none }}"
698+
"triggeredBy": "{{ actions.fetch_author.output.title if actions.fetch_author else none }}",
699+
"successful": "{{ true if data.properties.status == 'SUCCESS' else false }}"
699700
},
700701
"relations": {
701702
"service": {

galaxy/integrations/gitlab/.rely/mappings.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ resources:
6666
closedAt: .node.closedAt
6767
url: .node.webUrl
6868
state: .node.state
69-
labels: '[.node.labels.edges[].node.title]'
69+
labels: 'try [.node.labels.edges[].node.title] catch []'
7070
relations:
7171
repository:
7272
value: '"gitlab_repo_" + (.context.repository.id | split("/") | last)'
@@ -90,7 +90,7 @@ resources:
9090
updatedAt: .node.updatedAt
9191
closedAt: .node.closedAt
9292
state: .node.state
93-
labels: '[.node.labels.edges[].node.title]'
93+
labels: 'try [.node.labels.edges[].node.title] catch []'
9494
sourceBranch: .node.sourceBranch
9595
targetBranch: .node.targetBranch
9696
mergedAt: .node.mergedAt

galaxy/integrations/gitlab/client.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,16 +178,18 @@ async def get_environments(self, repository: dict) -> list[dict]:
178178
self.session, "POST", self.url_graphql, json=query, retry_policy=self.retry_policy
179179
)
180180

181-
environments = data["data"]["project"]["environments"]
181+
environments = data.get("data", {}).get("project", {}).get("environments")
182182
if not environments:
183183
return all_environments
184184

185-
edges = environments["edges"]
185+
all_environments.extend(environments["edges"])
186+
186187
page_info = environments["pageInfo"]
187-
all_environments.extend(edges)
188188
if not page_info["hasNextPage"]:
189189
break
190+
190191
cursor = page_info["endCursor"]
192+
191193
return all_environments
192194

193195
async def get_deployments(self, repository: dict, environment: str, history_days: int) -> list[dict]:
@@ -294,7 +296,7 @@ async def get_user_by_username(self, username: str) -> dict:
294296

295297
data = await make_request(self.session, "POST", self.url_graphql, json=query, retry_policy=self.retry_policy)
296298

297-
return data["data"]["user"]
299+
return data.get("data", {}).get("user", {})
298300

299301
async def get_file(self, repository_path: str, file_path: str) -> dict:
300302
query = self.queries.get_file(repository_path, file_path)

galaxy/integrations/gitlab/main.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,12 @@ async def get_repo_files(self, repo_full_path: str) -> dict:
127127
if file_check["regex"]:
128128
result = re.search(file_check["regex"], file["content"]) if file_check["regex"] else None
129129
repo_file_checks[file_check["destination"]] = (
130-
result.group(1) if result else FileCheckStatus.FILE_FOUND_NO_MATCH
130+
result.group(1) if result else FileCheckStatus.FILE_FOUND_NO_MATCH.value
131131
)
132132
else:
133-
repo_file_checks[file_check["destination"]] = FileCheckStatus.FILE_FOUND
133+
repo_file_checks[file_check["destination"]] = FileCheckStatus.FILE_FOUND.value
134134
else:
135-
repo_file_checks[file_check["destination"]] = FileCheckStatus.FILE_NOT_FOUND
135+
repo_file_checks[file_check["destination"]] = FileCheckStatus.FILE_NOT_FOUND.value
136136

137137
return repo_file_checks
138138

galaxy/integrations/snyk/client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def __init__(self, config: Config, logger: Logger):
3838
raise ValueError(f"Invalid Snyk hosting region: {region}")
3939

4040
async def __aenter__(self) -> "SnykClient":
41-
self._session = create_session(timeout=30, headers=self._headers, **self._session_kwargs)
41+
self._session = create_session(timeout=60, headers=self._headers, **self._session_kwargs)
4242
return self
4343

4444
async def __aexit__(self, exc_type: type, exc: Exception, tb: TracebackType) -> None:
@@ -79,7 +79,7 @@ async def get_projects(self, org_id: str, target_id: str) -> list[dict]:
7979
f"/rest/orgs/{org_id}/projects", params={"target_id": [target_id], "meta.latest_issue_counts": "true"}
8080
)
8181

82-
async def get_issues(self, org_id: str, project_id: str, history_start_date: datetime = None) -> list[dict]:
82+
async def get_issues(self, org_id: str, project_id: str, history_start_date: datetime | None = None) -> list[dict]:
8383
params = {"scan_item.type": "project", "scan_item.id": project_id}
8484
if history_start_date is not None:
8585
params["created_after"] = history_start_date.strftime("%Y-%m-%dT%H:%M:%S.%f")[:-3] + "Z"

galaxy/integrations/snyk/main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def __init__(self, config: Config):
1414
super().__init__(config)
1515
self.client = SnykClient(self.config, self.logger)
1616

17-
self._organizations = []
17+
self._organizations = {}
1818
self._all_projects = []
1919

2020
async def __aenter__(self) -> "Snyk":
@@ -66,7 +66,7 @@ async def projects(self) -> tuple[Any]:
6666
return mapped_projects
6767

6868
@register(_methods, group=3)
69-
async def issues(self) -> tuple[Any]:
69+
async def issues(self) -> list[Any]:
7070
organization_target_project_triples = [
7171
(
7272
item["relationships"]["organization"]["data"]["id"],

0 commit comments

Comments
 (0)