-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support plugin configurations #4
Comments
I've adjusted the issue according to the discussion in https://gist.github.com/Andrew-Morozko/fec36c1dcbca62fc9fea500a64f198a9 one question there -- does hcl parser support the same name for an attribute and a block? Can it support both |
Moved the milestone, I'll include it in parser rewrite |
What do we do with shadowing global configs? Right now if two files contain clashing global config for the same plugin it would be considered an error. We can scope However, some way of shadowing default configs may be useful. For example: a.fabric: config content plugin_a{
param = 1
} feels_bad.fabric: config content plugin_a "cfg2"{
param = 2
}
document "test-document" {
content plugin_a {
config = config.content.plugin_a.cfg2
text = 1
}
content plugin_a {
config = config.content.plugin_a.cfg2
text = 2
}
content plugin_a {
config = config.content.plugin_a.cfg2
text = 3
}
} What if we allow scoped default config blocks? feels_good.fabric: document "test-document" {
config content plugin_a{
param = 2
}
content plugin_a {
text = 1
}
content plugin_a {
text = 2
}
content plugin_a {
text = 3
}
} Pros:
Cons:
We can decide this later, I was just trying to determine valid block nestings and thought up a use case for the nested config blocks in the |
I think it is better to separate the configuration of the plugins from the document as much as possible because it reduces the reusability of the template. We have 3 ways to define the plugin config right now:
I think this is already a bit over-engineered 😃 but there might be the need for config shadowing approach you described. It definitely looks cleaner but I would like to postpone adding something like that until it is really needed. Let me try to walk through the cons you listed:
How so? There is one global config per plugin type / name that is used if no explicit config ref is set in
I had this flow in my head, when we parse the template files:
It's a bit of a mix of parsing and execution, I agree. It is easy to understand though, I think -- tell me if the code for it will be messy though
do you mean using the
I wonder about that too. I think it might be a rare occurrence and one of the approaches defined above will be enough. Let's see how it will be used. We can always add more complexity later! |
Background
Some plugins require additional configuration, like credentials / API keys, etc, similar to Terraform's provider configuration.
Design
In the input
*.fabric
files, there can be configuration blocks that contain additional configuration properties for the plugins.If the plugin exposes config schema with the required attributes, the config must be present. If it is only optional fields, the config block is not required.
Config blocks examples:
each
config
block must have 3 labels:data
orcontent
)elasticsearch
, for example)clusterA
or none)each
content_config
block must have 2 labels:table
for example)llama2
or none)both
content
ordata
blocks can haveconfig
attribute set orconfig
block specified. The attribute must point to an existing config block (content_config
ordata_config
correspondingly). For example:if the
config
block is specified, it is applied only to the invocation of its parent blockthe config is parsed according to the "configuration parameters" schema the plugin provides
a request to a plugin must support a config properties in addition to execution parameters
config
attribute is set in a block, it is resolved and the value is passed as a config object in a plugin requestconfig
attribute in a block is not set, a default config - a config object for data/content type without a name - is usedconfig
attribute in a block is not set and a default config object is not specified,nil
is passed in a requestFor example, when this template is executed:
a call to
elasticsearch
plugin has 2 inputs: config object (withusername
andpassword
fields set) and execution parameters (withindex
,query
andsize
set). The same applies tocontent
blocks.The text was updated successfully, but these errors were encountered: