diff --git a/hexa/pipeline_templates/graphql/schema.graphql b/hexa/pipeline_templates/graphql/schema.graphql index ab7d20b53..b9334ec8e 100644 --- a/hexa/pipeline_templates/graphql/schema.graphql +++ b/hexa/pipeline_templates/graphql/schema.graphql @@ -89,6 +89,7 @@ type PipelineTemplate { config: String # The configuration of the pipeline template. versions: [PipelineTemplateVersion!] # The list of versions of the pipeline template. currentVersion: PipelineTemplateVersion # The current version of the pipeline template. + sourcePipeline: Pipeline # The source pipeline of the pipeline template. } """ diff --git a/hexa/pipeline_templates/models.py b/hexa/pipeline_templates/models.py index 9ceb9c57b..8782e60fd 100644 --- a/hexa/pipeline_templates/models.py +++ b/hexa/pipeline_templates/models.py @@ -107,7 +107,7 @@ def create_pipeline(self, code, workspace, user): source_template=self.template, code=code, name=source_pipeline.name, - description=source_pipeline.description, + description=self.template.description, config=source_pipeline.config, workspace=workspace, ) diff --git a/hexa/pipeline_templates/schema/mutations.py b/hexa/pipeline_templates/schema/mutations.py index 2cc60f905..c5e8ecf02 100644 --- a/hexa/pipeline_templates/schema/mutations.py +++ b/hexa/pipeline_templates/schema/mutations.py @@ -94,7 +94,7 @@ def resolve_create_pipeline_from_template_version(_, info, **kwargs): except PipelineTemplateVersion.DoesNotExist: return {"success": False, "errors": ["PIPELINE_TEMPLATE_VERSION_NOT_FOUND"]} - pipeline_code = f"{template_version.template.source_pipeline.code} (from Template)" + pipeline_code = template_version.template.source_pipeline.code if Pipeline.objects.filter(workspace=workspace, code=pipeline_code).exists(): return {"success": False, "errors": ["PIPELINE_ALREADY_EXISTS"]} pipeline = template_version.create_pipeline(pipeline_code, workspace, request.user) diff --git a/hexa/pipeline_templates/schema/types.py b/hexa/pipeline_templates/schema/types.py index ac6793d3d..565b53b63 100644 --- a/hexa/pipeline_templates/schema/types.py +++ b/hexa/pipeline_templates/schema/types.py @@ -29,12 +29,19 @@ def resolve_pipeline_template_versions( @pipeline_template_object.field("currentVersion") -def resolve_pipeline_current_version( +def resolve_pipeline_template_current_version( pipeline_template: PipelineTemplate, info, **kwargs ): return pipeline_template.last_version +@pipeline_template_object.field("sourcePipeline") +def resolve_pipeline_template_source_pipeline( + pipeline_template: PipelineTemplate, info, **kwargs +): + return pipeline_template.source_pipeline + + bindables = [ pipeline_template_object, pipeline_template_permissions,