Skip to content

Importing multiple versions of a template at once for the first time creates several templates in the UI #1294

@andresmanelli

Description

@andresmanelli

if the template does not exist, then using this kind of declaration:

locals {
  start_container_template_versions = {
    "v0.4.0" = {
      is_stable   = false
    }
    "v0.5.0" = {
      is_stable   = true
    }
  }
}

resource "harness_platform_template" "start_container_template" {
  identifier      = "start_container_template"
  name            = "Start Container"
  org_id          =  [...]
  project_id      =  [...]
  for_each      = local.start_container_template_versions
  version         = each.key
  is_stable       = each.value.is_stable
  import_from_git = true
  git_import_details {
    branch_name   = [...]
    file_path     = "${each.key}.yaml"
    connector_ref = [...]
    repo_name     = [...]
  }
  template_import_request {
    template_name        = [...]
    template_version     = "${each.key}"
    template_description = [...]
  }
}

or this one:

resource "harness_platform_template" "start_container_template_v_0_4_0" {
  identifier      = "start_container_template"
  name            = "Start Container"
  org_id          =  [...]
  project_id      =  [...]
  version         = "v0.4.0"
  is_stable       = false
  import_from_git = true
  git_import_details {
    branch_name   =  [...]
    file_path     = "v0.4.0.yaml"
    connector_ref =  [...]
    repo_name     =  [...]
  }
  template_import_request {
    template_name        =  [...]
    template_version     = "v0.4.0"
    template_description =  [...]
  }
}

resource "harness_platform_template" "start_container_template_v_0_5_0" {
  identifier      = "start_container_template"
  name            = "Start Container"
  org_id          =  [...]
  project_id      =  [...]
  version         = "v0.5.0"
  is_stable       = true
  import_from_git = true
  git_import_details {
    branch_name   =  [...]
    file_path     = "v0.5.0.yaml"
    connector_ref = [...]
    repo_name     =  [...]
  }
  template_import_request {
    template_name        =  [...]
    template_version     = "v0.5.0"
    template_description =  [...]
  }
}

creates two UI elements:

Image

However, if the template already exists, adding elements to for_each or another version manually correctly adds a version to the same template.

This is not a significant problem in itself, but attempting to import the entire history of a plugin at once causes this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions