blackstork-io / fabric

An open-source command-line tool for reporting workflow automation and a configuration language for reusable templates. Reporting-as-Code
https://blackstork.io/fabric/
Apache License 2.0
10 stars 0 forks source link

Ability to distribute Fabric templates inside a plugin #151

Open traut opened 1 month ago

traut commented 1 month ago

Background

With the content libraries, like Fabric Templates, accumulating useful templates for various use cases, and vendors producing integration-specific templates, there should be an easy way for the users to access the templates.

Design

Utilize our existing plugin infrastructure (plugin registry and dependency installation logic) to deliver content by including the templates inside the plugins.

Requirements

Full example:


fabric {
  plugin_versions = {
    "blackstork/elastic" = ">= 1.2.3",
    "blackstork/fabric_templates" = ">= 0.1.1",
  }
}

document "my-doc" {

  data ref "my_alerts" {
    base = elastic/data.elasticsearch.alerts_with_aggregations
    query = "@timestamp:[now-7d TO now]"
  }

  section ref {
    base = fabric_templates/section.ctid_executive_summary
  }
}

Implementation

TBD in the comments

Constraints

traut commented 1 month ago

an alternative namespacing schema that does not break HCL identifier constraint is to use -- as a separator:

document "my-doc" {
  section ref {
    base = fabric_templates--section.ctid_executive_summary
  }
}

However, it is less "namespacy" -- the prefix is not perceived as a namespace at a glance.

dobarx commented 1 month ago

@traut What about separating namespace with prefix import.<plugin>.<path>? Usage:

document "my-doc" {
  section ref {
    base = import.fabric_templates.section.ctid_executive_summary
  }

We could also choose different prefix like template.<plugin>.<path> or plugin.<plugin>.<path>

traut commented 1 month ago

@dobarx oh, that's neat! I like import.<plugin-name>.<path> a lot, awesome idea!

It is clear that it is an import while the name is nicely namespaced. Let's go with it!

traut commented 5 days ago

One thing that occurred to me:

We talked about adding a manifest-like to the plugins. Another argument and use case for it, in the context of template distribution in the plugins, is the need to have a list of template dependencies -- what plugins must be installed for the templates to work?