Skip to content
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

Allow template_path field on inputs #655

Merged
merged 5 commits into from
Nov 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

Add "traces" as legal event type. [#656](https://github.com/elastic/package-registry/pull/656)
* Add "traces" as legal event type. [#656](https://github.com/elastic/package-registry/pull/656)
* Add input-level `template_path` field. [#655](https://github.com/elastic/package-registry/pull/655)

### Deprecated

Expand Down
2 changes: 1 addition & 1 deletion testdata/generated/categories-experimental.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
{
"id": "custom",
"title": "Custom",
"count": 9
"count": 10
},
{
"id": "message_queue",
Expand Down
2 changes: 1 addition & 1 deletion testdata/generated/categories.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
{
"id": "custom",
"title": "Custom",
"count": 9
"count": 10
},
{
"id": "message_queue",
Expand Down
61 changes: 61 additions & 0 deletions testdata/generated/package/input_level_templates/1.0.0/index.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{
"name": "input_level_templates",
"title": "Input level templates",
"version": "1.0.0",
"release": "beta",
"description": "This is a test package showing input-level agent yaml templates",
"type": "solution",
"download": "/epr/input_level_templates/input_level_templates-1.0.0.zip",
"path": "/package/input_level_templates/1.0.0",
"format_version": "1.0.0",
"readme": "/package/input_level_templates/1.0.0/docs/README.md",
"license": "basic",
"categories": [
"custom"
],
"conditions": {
"kibana.version": "\u003e=7.11.0"
},
"assets": [
"/package/input_level_templates/1.0.0/manifest.yml",
"/package/input_level_templates/1.0.0/docs/README.md",
"/package/input_level_templates/1.0.0/agent/input/template.yml.hbs"
],
"policy_templates": [
{
"name": "input_level_templates",
"title": "Input level templates",
"description": "Input with input-level template to use input-level vars with",
"inputs": [
{
"type": "logs",
"vars": [
{
"name": "paths",
"type": "text",
"title": "Paths",
"multi": true,
"required": true,
"show_user": false,
"default": [
"/foo/bar",
"/test/path"
]
},
{
"name": "host",
"type": "text",
"title": "Host",
"multi": false,
"required": true,
"show_user": false
}
],
"title": "Collect logs",
"template_path": "template.yml.hbs"
}
],
"multiple": true
}
]
}
10 changes: 10 additions & 0 deletions testdata/generated/search-all.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,16 @@
"download": "/epr/foo/foo-1.0.0.zip",
"path": "/package/foo/1.0.0"
},
{
"name": "input_level_templates",
"title": "Input level templates",
"version": "1.0.0",
"release": "beta",
"description": "This is a test package showing input-level agent yaml templates",
"type": "solution",
"download": "/epr/input_level_templates/input_level_templates-1.0.0.zip",
"path": "/package/input_level_templates/1.0.0"
},
{
"name": "longdocs",
"title": "Long Docs",
Expand Down
10 changes: 10 additions & 0 deletions testdata/generated/search-category-custom.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@
"download": "/epr/foo/foo-1.0.0.zip",
"path": "/package/foo/1.0.0"
},
{
"name": "input_level_templates",
"title": "Input level templates",
"version": "1.0.0",
"release": "beta",
"description": "This is a test package showing input-level agent yaml templates",
"type": "solution",
"download": "/epr/input_level_templates/input_level_templates-1.0.0.zip",
"path": "/package/input_level_templates/1.0.0"
},
{
"name": "longdocs",
"title": "Long Docs",
Expand Down
10 changes: 10 additions & 0 deletions testdata/generated/search-package-experimental.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,16 @@
"download": "/epr/foo/foo-1.0.0.zip",
"path": "/package/foo/1.0.0"
},
{
"name": "input_level_templates",
"title": "Input level templates",
"version": "1.0.0",
"release": "beta",
"description": "This is a test package showing input-level agent yaml templates",
"type": "solution",
"download": "/epr/input_level_templates/input_level_templates-1.0.0.zip",
"path": "/package/input_level_templates/1.0.0"
},
{
"name": "longdocs",
"title": "Long Docs",
Expand Down
10 changes: 10 additions & 0 deletions testdata/generated/search-package-internal.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,16 @@
"download": "/epr/foo/foo-1.0.0.zip",
"path": "/package/foo/1.0.0"
},
{
"name": "input_level_templates",
"title": "Input level templates",
"version": "1.0.0",
"release": "beta",
"description": "This is a test package showing input-level agent yaml templates",
"type": "solution",
"download": "/epr/input_level_templates/input_level_templates-1.0.0.zip",
"path": "/package/input_level_templates/1.0.0"
},
{
"name": "internal",
"title": "Internal",
Expand Down
10 changes: 10 additions & 0 deletions testdata/generated/search.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,16 @@
"download": "/epr/foo/foo-1.0.0.zip",
"path": "/package/foo/1.0.0"
},
{
"name": "input_level_templates",
"title": "Input level templates",
"version": "1.0.0",
"release": "beta",
"description": "This is a test package showing input-level agent yaml templates",
"type": "solution",
"download": "/epr/input_level_templates/input_level_templates-1.0.0.zip",
"path": "/package/input_level_templates/1.0.0"
},
{
"name": "longdocs",
"title": "Long Docs",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
fixedField: some value
paths:
{{#each paths}}
- {{this}}
{{/each}}
host: {{host}}
Empty file.
33 changes: 33 additions & 0 deletions testdata/package/input_level_templates/1.0.0/manifest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
format_version: 1.0.0

name: input_level_templates
description: This is a test package showing input-level agent yaml templates
version: 1.0.0
title: Input level templates
categories: ["custom"]
type: solution
release: beta

conditions:
kibana:
version: ">=7.11.0"

policy_templates:
- name: input_level_templates
title: Input level templates
description: Input with input-level template to use input-level vars with
inputs:
- type: logs
title: Collect logs
vars:
- name: paths
title: Paths
default: ["/foo/bar", "/test/path"]
required: true
multi: true
type: text
- name: host
title: Host
required: true
type: text
template_path: "template.yml.hbs"
11 changes: 6 additions & 5 deletions util/data_stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,12 @@ type DataStream struct {
}

type Input struct {
Type string `config:"type" json:"type" validate:"required"`
Vars []Variable `config:"vars" json:"vars,omitempty" yaml:"vars,omitempty"`
Title string `config:"title" json:"title,omitempty" yaml:"title,omitempty"`
Description string `config:"description" json:"description,omitempty" yaml:"description,omitempty"`
Streams []Stream `config:"streams" json:"streams,omitempty" yaml:"streams,omitempty"`
Type string `config:"type" json:"type" validate:"required"`
Vars []Variable `config:"vars" json:"vars,omitempty" yaml:"vars,omitempty"`
Title string `config:"title" json:"title,omitempty" yaml:"title,omitempty"`
Description string `config:"description" json:"description,omitempty" yaml:"description,omitempty"`
Streams []Stream `config:"streams" json:"streams,omitempty" yaml:"streams,omitempty"`
TemplatePath string `config:"template_path" json:"template_path,omitempty" yaml:"template_path,omitempty"`
}

type Stream struct {
Expand Down