Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
20 changes: 15 additions & 5 deletions fleetpkg.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
type Integration struct {
Build *BuildManifest `json:"build,omitempty" yaml:"build,omitempty"`
Manifest Manifest `json:"manifest,omitempty" yaml:"manifest,omitempty"`
Input *DataStream `json:"input,omitempty" yaml:"input,omitempty"`
DataStreams map[string]*DataStream `json:"data_streams,omitempty" yaml:"data_streams,omitempty"`
Changelog Changelog `json:"changelog,omitempty" yaml:"changelog,omitempty"`

Expand Down Expand Up @@ -436,7 +437,6 @@ func Read(path string) (*Integration, error) {
}
integration.Manifest.sourceFile = sourceFile
annotateFileMetadata(integration.Manifest.sourceFile, &integration.Manifest)

sourceFile = filepath.Join(path, "changelog.yml")
if err := readYAML(sourceFile, &integration.Changelog, true); err != nil {
return nil, err
Expand All @@ -455,15 +455,25 @@ func Read(path string) (*Integration, error) {
integration.Build.sourceFile = sourceFile
}

dataStreams, err := filepath.Glob(filepath.Join(path, "data_stream/*/manifest.yml"))
if err != nil {
return nil, err
var dataStreams []string
if integration.Manifest.Type == "input" {
dataStreams = []string{filepath.Join(path, "manifest.yml")}
} else {
var err error
dataStreams, err = filepath.Glob(filepath.Join(path, "data_stream/*/manifest.yml"))
if err != nil {
return nil, err
}
}
for _, manifestPath := range dataStreams {
ds := &DataStream{
sourceDir: filepath.Dir(manifestPath),
}
integration.DataStreams[filepath.Base(ds.sourceDir)] = ds
if integration.Manifest.Type == "input" {
integration.Input = ds
} else {
integration.DataStreams[filepath.Base(ds.sourceDir)] = ds
}

if err := readYAML(manifestPath, &ds.Manifest, true); err != nil {
return nil, err
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably want to conditionally omit this and the following couple of lines when we are an input package.

Expand Down
97 changes: 97 additions & 0 deletions testdata/cel.golden.json
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,103 @@
"github": "elastic/security-external-integrations"
}
},
"input": {
"manifest": {
"title": "CEL Custom API",
"type": "input"
},
"sample_event": {
"event": {
"@timestamp": "2023-03-23T00:04:52.561Z",
"agent": {
"ephemeral_id": "0b7c0c2b-32aa-4b65-95a4-d34416b8a7eb",
"id": "8c8782fa-cd5b-4ae8-94a0-ee8e3ea9a8df",
"name": "docker-fleet-agent",
"type": "filebeat",
"version": "8.6.1"
},
"data_stream": {
"dataset": "cel.cel",
"namespace": "ep",
"type": "logs"
},
"ecs": {
"version": "8.0.0"
},
"elastic_agent": {
"id": "8c8782fa-cd5b-4ae8-94a0-ee8e3ea9a8df",
"snapshot": false,
"version": "8.6.1"
},
"event": {
"dataset": "cel.cel"
},
"input": {
"type": "cel"
},
"message": "success",
"tags": [
"forwarded"
]
}
},
"fields": {
"input.yml": {
"fields": [
{
"name": "@timestamp",
"external": "ecs"
},
{
"name": "ecs.version",
"external": "ecs"
},
{
"name": "message",
"external": "ecs"
},
{
"name": "input.name",
"type": "constant_keyword"
},
{
"name": "input.type",
"type": "keyword"
},
{
"name": "data_stream.type",
"type": "constant_keyword",
"external": "ecs"
},
{
"name": "data_stream.dataset",
"type": "constant_keyword",
"external": "ecs"
},
{
"name": "data_stream.namespace",
"type": "constant_keyword",
"external": "ecs"
},
{
"name": "event.module",
"type": "constant_keyword",
"value": "cel",
"external": "ecs"
},
{
"name": "event.dataset",
"type": "constant_keyword",
"external": "ecs"
},
{
"name": "tags",
"external": "ecs"
}
]
}
}
},
"changelog": {
"releases": [
{
Expand Down
61 changes: 61 additions & 0 deletions testdata/cel.golden.yml
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,67 @@ manifest:
show_user: false
owner:
github: elastic/security-external-integrations
input:
manifest:
title: CEL Custom API
type: input
sample_event:
event:
'@timestamp': "2023-03-23T00:04:52.561Z"
agent:
ephemeral_id: 0b7c0c2b-32aa-4b65-95a4-d34416b8a7eb
id: 8c8782fa-cd5b-4ae8-94a0-ee8e3ea9a8df
name: docker-fleet-agent
type: filebeat
version: 8.6.1
data_stream:
dataset: cel.cel
namespace: ep
type: logs
ecs:
version: 8.0.0
elastic_agent:
id: 8c8782fa-cd5b-4ae8-94a0-ee8e3ea9a8df
snapshot: false
version: 8.6.1
event:
dataset: cel.cel
input:
type: cel
message: success
tags:
- forwarded
fields:
input.yml:
fields:
- name: '@timestamp'
external: ecs
- name: ecs.version
external: ecs
- name: message
external: ecs
- name: input.name
type: constant_keyword
- name: input.type
type: keyword
- name: data_stream.type
type: constant_keyword
external: ecs
- name: data_stream.dataset
type: constant_keyword
external: ecs
- name: data_stream.namespace
type: constant_keyword
external: ecs
- name: event.module
type: constant_keyword
value: cel
external: ecs
- name: event.dataset
type: constant_keyword
external: ecs
- name: tags
external: ecs
changelog:
releases:
- version: 0.3.0
Expand Down