Skip to content

Commit

Permalink
Merge pull request #15 from slok/slok/plugin-examples
Browse files Browse the repository at this point in the history
Add plugin list on readme
  • Loading branch information
slok authored Aug 11, 2022
2 parents 1b978c6 + b5b908c commit 36a150f
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 2 deletions.
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,14 @@ The famous and well known [YQ] processor for your YAML inputs.

### Go plugins v1

Check examples [here](examples/plugins).
Check [examples](examples/plugins):

- [FS check](examples/plugins/check_fs/): Checks files exist on disk. Shows how you can access the FS outside the plugin.
- [Complex validation](examples/plugins/complex_validation): Validate Prometheus Rules. Shows how to create advanced logic plugins.
- [Data structure transformation](examples/plugins/data_structure_transformation/): Transforms a data structure into another. Shows how to transform data for easier consumption by different terraform providers.
- [Filtering](examples/plugins/filtering/): Filters a list of usernames based on a regex. Shows how to filter terraform data to avoid HCL complex logic.
- [Remote plugin](examples/plugins/remote_plugin/): Uses a plugin that is hosted in github. Shows how plugins can be shared and create plugin repos.
- [Simple validation](examples/plugins/simple_validation/): Validates the length of a string. Shows that simple validation plugins can be powerful (like small functions), perfect to be used as a remote plugin.

The processor for everything :tada:, is the most powerful of all. You can use _almost_ (e.g `unsafe` package is banned) all the Go standard library. These are the requirements to create a plugin:

Expand Down
11 changes: 11 additions & 0 deletions docs/data-sources/go_plugin_v1.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ description: |-
Written in Go.No external dependencies, only Go standard library.Implemented in a single file (or string block).Implement the plugin API (Check the examples to know how to do it).
The Filter function should be called: ProcessorPluginV1.The Filter function should have this signature: ProcessorPluginV1(ctx context.Context, inputData string, vars map[string]string) (result string, error error).
Check examples https://github.com/slok/terraform-provider-dataprocessor/tree/main/examples:
FS check https://github.com/slok/terraform-provider-dataprocessor/tree/main/examples/plugins/check_fs/: Checks files exist on disk. Shows how you can access the FS outside the plugin.Complex validation https://github.com/slok/terraform-provider-dataprocessor/tree/main/examples/plugins/complex_validation: Validate Prometheus Rules. Shows how to create advanced logic plugins.Data structure transformation https://github.com/slok/terraform-provider-dataprocessor/tree/main/examples/plugins/data_structure_transformation/: Transforms a data structure into another. Shows how to transform data for easier consumption by different terraform providers.Filtering https://github.com/slok/terraform-provider-dataprocessor/tree/main/examples/plugins/filtering/: Filters a list of usernames based on a regex. Shows how to filter terraform data to avoid HCL complex logic.Remote plugin https://github.com/slok/terraform-provider-dataprocessor/tree/main/examples/plugins/remote_plugin/: Uses a plugin that is hosted in github. Shows how plugins can be shared and create plugin repos.Simple validation https://github.com/slok/terraform-provider-dataprocessor/tree/main/examples/plugins/simple_validation/: Validates the length of a string. Shows that simple validation plugins can be powerful (like small functions), perfect to be used as a remote plugin.
---

# dataprocessor_go_plugin_v1 (Data Source)
Expand All @@ -23,6 +25,15 @@ The requirements for a plugin are:
- The Filter function should be called: _ProcessorPluginV1_.
- The Filter function should have this signature: _ProcessorPluginV1(ctx context.Context, inputData string, vars map[string]string) (result string, error error)_.

Check [examples](https://github.com/slok/terraform-provider-dataprocessor/tree/main/examples):

- [FS check](https://github.com/slok/terraform-provider-dataprocessor/tree/main/examples/plugins/check_fs/): Checks files exist on disk. Shows how you can access the FS outside the plugin.
- [Complex validation](https://github.com/slok/terraform-provider-dataprocessor/tree/main/examples/plugins/complex_validation): Validate Prometheus Rules. Shows how to create advanced logic plugins.
- [Data structure transformation](https://github.com/slok/terraform-provider-dataprocessor/tree/main/examples/plugins/data_structure_transformation/): Transforms a data structure into another. Shows how to transform data for easier consumption by different terraform providers.
- [Filtering](https://github.com/slok/terraform-provider-dataprocessor/tree/main/examples/plugins/filtering/): Filters a list of usernames based on a regex. Shows how to filter terraform data to avoid HCL complex logic.
- [Remote plugin](https://github.com/slok/terraform-provider-dataprocessor/tree/main/examples/plugins/remote_plugin/): Uses a plugin that is hosted in github. Shows how plugins can be shared and create plugin repos.
- [Simple validation](https://github.com/slok/terraform-provider-dataprocessor/tree/main/examples/plugins/simple_validation/): Validates the length of a string. Shows that simple validation plugins can be powerful (like small functions), perfect to be used as a remote plugin.

## Example Usage

```terraform
Expand Down
1 change: 0 additions & 1 deletion examples/plugins/complex_validation/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,3 @@ data "dataprocessor_go_plugin_v1" "validate_prometheus_rules" {
check_team = false
}
}

10 changes: 10 additions & 0 deletions internal/provider/data_source_go_plugin_v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,16 @@ The requirements for a plugin are:
- Implement the plugin API (Check the examples to know how to do it).
- The Filter function should be called: _ProcessorPluginV1_.
- The Filter function should have this signature: _ProcessorPluginV1(ctx context.Context, inputData string, vars map[string]string) (result string, error error)_.
Check [examples](https://github.com/slok/terraform-provider-dataprocessor/tree/main/examples):
- [FS check](https://github.com/slok/terraform-provider-dataprocessor/tree/main/examples/plugins/check_fs/): Checks files exist on disk. Shows how you can access the FS outside the plugin.
- [Complex validation](https://github.com/slok/terraform-provider-dataprocessor/tree/main/examples/plugins/complex_validation): Validate Prometheus Rules. Shows how to create advanced logic plugins.
- [Data structure transformation](https://github.com/slok/terraform-provider-dataprocessor/tree/main/examples/plugins/data_structure_transformation/): Transforms a data structure into another. Shows how to transform data for easier consumption by different terraform providers.
- [Filtering](https://github.com/slok/terraform-provider-dataprocessor/tree/main/examples/plugins/filtering/): Filters a list of usernames based on a regex. Shows how to filter terraform data to avoid HCL complex logic.
- [Remote plugin](https://github.com/slok/terraform-provider-dataprocessor/tree/main/examples/plugins/remote_plugin/): Uses a plugin that is hosted in github. Shows how plugins can be shared and create plugin repos.
- [Simple validation](https://github.com/slok/terraform-provider-dataprocessor/tree/main/examples/plugins/simple_validation/): Validates the length of a string. Shows that simple validation plugins can be powerful (like small functions), perfect to be used as a remote plugin.
`,
Attributes: map[string]tfsdk.Attribute{
"plugin": {
Expand Down

0 comments on commit 36a150f

Please sign in to comment.