srevinsaju / togomak

A declarative pipeline orchestrator with the magic of HCL as a configuration language, inspired from Terraform's architecture.
https://togomak.srev.in
Mozilla Public License 2.0
146 stars 5 forks source link

add ability to import data sources #25

Closed jgangemi closed 7 months ago

jgangemi commented 1 year ago

it's not possible to access a file in a git repository that is comprised of other files in the repo.

  version = 1
}

## data

data env version {
  key     = "CI_PIPELINE_VERSION"
  default = ""
}

data git cicd {
  url   = "..."
  tag   = data.env.version.value
  files = [
    "python/togomak/build.hcl", "python/togomak/docs.hcl", "python/togomak/publish.hcl"
  ]
}

## macros

macro build {
  files = {
    "build.hcl" : data.git.cicd.files["python/togomak/build.hcl"]
  }
}

macro docs {
  files = {
    "docs.hcl" : data.git.cicd.files["python/togomak/docs.hcl"]
  }
}

macro deploy {
  files = {
    "publish.hcl" : data.git.cicd.files["python/togomak/publish.hcl"]
  }
}

## stages

stage build {
  use {
    macro = macro.build
  }
}

stage docs {
  use {
    macro = macro.docs
  }
}

stage deploy {
  use {
    macro = macro.deploy
  }
}

i'd like to condense most of this into a single hcl file store in a separate repository that can then be imported as a data source by the caller. there needs to be a way for the imported file to be able to access the other files it imports.

srevinsaju commented 1 year ago

It is now possible to import other terraform files from git repositories using pipeline.path, which expands to the path of the togomak ci file, that means that, you can now do something like "${dirname(pipeline.path)}/somefolder/somepath.hcl" to get relative path, and so on. Let me know if that solves the issue.

srevinsaju commented 1 year ago

Possibly covered by this as well #35

srevinsaju commented 7 months ago

Closing this as done.