diff --git a/concourse/model/traits/image_scan.py b/concourse/model/traits/image_scan.py index 4f3fbd739..5d185527c 100644 --- a/concourse/model/traits/image_scan.py +++ b/concourse/model/traits/image_scan.py @@ -9,6 +9,8 @@ import dacite +import github.issue + from concourse.model.job import ( JobVariant, ) @@ -67,12 +69,6 @@ class Notify(enum.Enum): GITHUB_ISSUES = 'github_issues' -@dataclasses.dataclass -class GithubIssueTemplateCfg: - body: str - type: str - - @dataclasses.dataclass(frozen=True) class IssuePolicies: max_processing_time_days: gcm.MaxProcessingTimesDays = gcm.MaxProcessingTimesDays() @@ -117,7 +113,7 @@ class IssuePolicies: - delivery_dashboard_url ''', - type=list[GithubIssueTemplateCfg], + type=list[github.issue.GithubIssueTemplateCfg], ), AttributeSpec.optional( name='github_issue_labels_to_preserve', @@ -166,20 +162,20 @@ def notify(self) -> Notify: def overwrite_github_issues_tgt_repository_url(self) -> typing.Optional[str]: return self.raw.get('overwrite_github_issues_tgt_repository_url') - def github_issue_templates(self) -> list[GithubIssueTemplateCfg]: + def github_issue_templates(self) -> list[github.issue.GithubIssueTemplateCfg]: if not (raw := self.raw.get('github_issue_templates')): return None template_cfgs = [ dacite.from_dict( - data_class=GithubIssueTemplateCfg, + data_class=github.issue.GithubIssueTemplateCfg, data=cfg, ) for cfg in raw ] return template_cfgs - def github_issue_template(self, type: str) -> typing.Optional[GithubIssueTemplateCfg]: + def github_issue_template(self, type: str) -> github.issue.GithubIssueTemplateCfg | None: if not (template_cfgs := self.github_issue_templates()): return None diff --git a/concourse/model/traits/scan_sources.py b/concourse/model/traits/scan_sources.py index 45b0be9f9..65e1630e4 100644 --- a/concourse/model/traits/scan_sources.py +++ b/concourse/model/traits/scan_sources.py @@ -20,10 +20,10 @@ import concourse.model.traits.component_descriptor from concourse.model.traits.image_scan import ( - GithubIssueTemplateCfg, IssuePolicies, Notify, ) +from github.issue import GithubIssueTemplateCfg CHECKMARX_ATTRIBUTES = ( diff --git a/concourse/steps/cfg_reporting.mako b/concourse/steps/cfg_reporting.mako index e7ba658f9..e7cd8b368 100644 --- a/concourse/steps/cfg_reporting.mako +++ b/concourse/steps/cfg_reporting.mako @@ -18,9 +18,9 @@ import ccc.delivery import ccc.github import cfg_mgmt.reporting as cmr import ci.util -import concourse.model.traits.image_scan import github.compliance.model as gcm import github.compliance.report as gcr +import github.issue import model import model.concourse @@ -62,7 +62,7 @@ grouped_no_undefined_policy = scan_result_group_collection_for_undefined_policy( github_issue_template_cfgs = [ dacite.from_dict( - data_class=concourse.model.traits.image_scan.GithubIssueTemplateCfg, + data_class=github.issue.GithubIssueTemplateCfg, data=template_cfg_raw, ) for template_cfg_raw in ${github_issue_template_cfgs_raw} diff --git a/concourse/steps/os_id.mako b/concourse/steps/os_id.mako index 7efc066f6..278a4e0e2 100644 --- a/concourse/steps/os_id.mako +++ b/concourse/steps/os_id.mako @@ -30,10 +30,10 @@ import ccc.delivery import ccc.github import ccc.oci import ci.util -import concourse.model.traits.image_scan as image_scan import cnudie.retrieve import github.compliance.model import github.compliance.report +import github.issue ${concourse.steps.step_lib('os_id')} ${concourse.steps.step_lib('component_descriptor_util')} @@ -76,7 +76,7 @@ overwrite_repository = None % if github_issue_templates: github_issue_template_cfgs = [dacite.from_dict( - data_class=image_scan.GithubIssueTemplateCfg, + data_class=github.issue.GithubIssueTemplateCfg, data=raw ) for raw in ${[dataclasses.asdict(ghit) for ghit in github_issue_templates]} ] diff --git a/concourse/steps/scan_sources.mako b/concourse/steps/scan_sources.mako index ebc2778e3..df36527e9 100644 --- a/concourse/steps/scan_sources.mako +++ b/concourse/steps/scan_sources.mako @@ -45,10 +45,9 @@ import delivery.client import github.compliance.model import github.compliance.report from concourse.model.traits.image_scan import ( - GithubIssueTemplateCfg, - IssuePolicies, Notify, ) +from github.issue import GithubIssueTemplateCfg cfg_factory = ci.util.ctx().cfg_factory() cfg_set = cfg_factory.cfg_set("${cfg_set.name()}") diff --git a/github/compliance/report.py b/github/compliance/report.py index bf1d1c3a1..2ae9a505f 100644 --- a/github/compliance/report.py +++ b/github/compliance/report.py @@ -21,13 +21,13 @@ import checkmarx.model import cfg_mgmt.model as cmm import ci.util -import concourse.model.traits.image_scan as image_scan import delivery.client import delivery.model import github.codeowners import github.compliance.issue import github.compliance.milestone as gcmi import github.compliance.model as gcm +import github.issue import github.retry import github.user import github.util @@ -517,7 +517,7 @@ def create_or_update_github_issues( gh_api: github3.GitHub=None, overwrite_repository: github3.repos.Repository=None, preserve_labels_regexes: typing.Iterable[str]=(), - github_issue_template_cfgs: list[image_scan.GithubIssueTemplateCfg]=None, + github_issue_template_cfgs: list[github.issue.GithubIssueTemplateCfg]=None, delivery_svc_client: delivery.client.DeliveryServiceClient=None, delivery_svc_endpoints: model.delivery.DeliveryEndpointsCfg=None, gh_quota_minimum: int = 2000, # skip issue updates if remaining quota falls below this threshold diff --git a/github/issue.py b/github/issue.py new file mode 100644 index 000000000..adedc7966 --- /dev/null +++ b/github/issue.py @@ -0,0 +1,7 @@ +import dataclasses + + +@dataclasses.dataclass +class GithubIssueTemplateCfg: + body: str + type: str