Closed Andrew-Morozko closed 1 month ago
@dobarx
My plugin fails TestAllPluginSchemaValidity/blackstork/builtin/rss
test, presumably here because I'm using embedded block inside of a config block.
It works perfectly fine in the binary. Is it ok to loosen the restrictions in this test, or is something in your code relies on this property?
@dobarx
My plugin fails
TestAllPluginSchemaValidity/blackstork/builtin/rss
test, presumably here because I'm using embedded block inside of a config block.It works perfectly fine in the binary. Is it ok to loosen the restrictions in this test, or is something in your code relies on this property?
I think it's Ok to use block, but then maybe update that test to allow including block types also. Also, check plugin doc generation templates just generate-docs
. They probably do not expect blocks atm so it needs to be updated if you want to use block specs inside plugin configs.
Finally done with it. Some notes:
json_schema
. It is fully generated from plugin metadata; no need to store it in the plugin metadata as a blob.plugin.md.gotempl
there is a placeholder for tags. Tags on plugins: yay or nay?Doc
instead of Description
, does it matter?This PR doesn't include the regenerated docs:
After this is merged we should create a PR that adds a bunch of documentation.
P.S.: @dobarx we talked in DM about refactoring the code a bit more, but I'd rather do it in a separate PR. Also I very much enjoy the formatting of protobuf files, but buf
has a builtin formatter, perhaps we should use it to be a bit more standardized? Dealing with whitespace in surrounding lines is a bit of a mess :/
Here's an example of generated docs for RSS:
---
title: rss
plugin:
name: blackstork/builtin
description: "Fetches an rss or atom feed"
tags: ["rss","http"]
version: "v0.4.1"
source_github: "https://github.com/blackstork-io/fabric/tree/main/internal/builtin/"
resource:
type: data-source
type: docs
---
{{< breadcrumbs 2 >}}
{{< plugin-resource-header "blackstork/builtin" "builtin" "v0.4.1" "rss" "data source" >}}
## Description
Fetches an rss or atom feed
The data source is built-in, which means it's a part of `fabric` binary. It's available out-of-the-box, no installation required.
## Configuration
The data source supports the following configuration parameters:
config "data" "rss" {
# Authentication parameters used while accessing the rss source.
#
# Optional
basic_auth {
# Required. For example:
username = "user@example.com"
# Note: you can use function like "from_env()" to avoid storing credentials in plaintext
#
# Required. For example:
password = "passwd"
}
}
## Usage
The data source supports the following parameters in the data blocks:
data "rss" {
# Required. For example:
url = "https://www.elastic.co/security-labs/rss/feed.xml"
}
I don't see a reason to store json_schema. It is fully generated from plugin metadata; no need to store it in the plugin metadata as a blob.
Sure, let's add it when we have a clearer use case!
There are no tags on plugins, but in the frontmatter of the plugin.md.gotempl there is a placeholder for tags. Tags on plugins: yay or nay?
It would be great to have the tags! It simplifies filtering/discovery in the docs for humans -- I'll add a search to the docs soon. On that note, could you please check if the code that generates plugins.json
in docgen
needs adjustments? It's also fine if you prefer to do that together with the docs PR
I renamed all documentation strings to Doc instead of Description, does it matter?
All fine with me!
Much appreciated, thank you, @Andrew-Morozko !
All done, ready to merge @dobarx
Implements #128
A couple of diviation from the spec: config options are represented like so:
not
This seemed nicer to look at, but also it allows for
basic_auth
to be an optional block, butusername
andpassword
are both required if thebasic_auth
block is present. In the original spec you could've specifiedbasic_auth_username
without a password, for example.Also, in addition to
pub_date
as text I providepub_timestamp
(a unix-timestamp of pub_date) on a best effort basis (because sometimespub_date
can't be parsed)