Skip to content

Commit

Permalink
Merge pull request elastic#5 from cyrilleverrier/improve_makefile
Browse files Browse the repository at this point in the history
Improve makefile and README.md
  • Loading branch information
ruflin committed Jan 25, 2016
2 parents 0d1a82e + 192f8be commit 3bbb9de
Show file tree
Hide file tree
Showing 7 changed files with 94 additions and 21 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This generator makes it possible to generate your own beat in seconds and build
To create your own beat based on this template, run inside your GOPATH where you want to create the beat:

```
cookiecutter github.com/elastic/beats
cookiecutter elastic/beat-generator
```

This requires python and cookiecutter to be installed (`pip install cookiecutter`).
7 changes: 2 additions & 5 deletions cookiecutter.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
"project_name": "Examplebeat",
"github_name": "your-github-name",
"beat": "{{ cookiecutter.project_name|lower }}",
"beat_path": "github.com/{{ cookiecutter.github_name|lower }}/{{cookiecutter.beat}}",
"full_name": "Firstname Lastname",
"_copy_without_render": [
"*.j2"
]
"beat_path": "github.com/{{ cookiecutter.github_name|lower }}",
"full_name": "Firstname Lastname"
}
25 changes: 23 additions & 2 deletions {{cookiecutter.beat}}/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,27 @@
BEATNAME={{cookiecutter.beat}}
BEAT_DIR={{cookiecutter.beat_path}}
SYSTEM_TESTS=false
TEST_ENVIRONMENT=false

# Path to the libbeat Makefile
include vendor/github.com/elastic/beats/libbeat/scripts/Makefile
PREFIX?=.
ES_BEATS=./vendor/github.com/elastic/beats
GOPACKAGES=$(shell glide novendor)
include $(ES_BEATS)/libbeat/scripts/Makefile

.PHONY: generate
generate:
python scripts/generate_template.py etc/fields.yml etc/{{cookiecutter.beat}}.template.json
python scripts/generate_field_docs.py etc/fields.yml etc/{{cookiecutter.beat}}.asciidoc

.PHONY: install-cfg
install-cfg:
mkdir -p $(PREFIX)
cp etc/{{cookiecutter.beat}}.template.json $(PREFIX)/{{cookiecutter.beat}}.template.json
cp etc/{{cookiecutter.beat}}.yml $(PREFIX)/{{cookiecutter.beat}}.yml
cp etc/{{cookiecutter.beat}}.yml $(PREFIX)/{{cookiecutter.beat}}-linux.yml
cp etc/{{cookiecutter.beat}}.yml $(PREFIX)/{{cookiecutter.beat}}-binary.yml
cp etc/{{cookiecutter.beat}}.yml $(PREFIX)/{{cookiecutter.beat}}-darwin.yml
cp etc/{{cookiecutter.beat}}.yml $(PREFIX)/{{cookiecutter.beat}}-win.yml

update-deps:
glide update --no-recursive
65 changes: 60 additions & 5 deletions {{cookiecutter.beat}}/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# {{cookiecutter.beat|capitalize}}

Welcome to {{cookiecutter.beat}}.
Welcome to {{cookiecutter.beat|capitalize}}.

To get running with your beat, run the following commands:
Ensure that this folder is at the following location:
`${GOPATH}/{{cookiecutter.beat_path}}`

## To get running with {{cookiecutter.beat|capitalize}}, run the following commands:

```
glide init
Expand All @@ -11,16 +14,68 @@ make update
make
```

To run your beat with debugging output enabled, run:

## To generate etc/{{cookiecutter.beat}}.template.json and etc/{{cookiecutter.beat}}.asciidoc

```
make generate
```

## To run {{cookiecutter.beat|capitalize}} with debugging output enabled, run:

```
./{{cookiecutter.beat}} -c etc/{{cookiecutter.beat}}.yml -e -d "*"
```

For further development, check out the [beat developer guide](https://www.elastic.co/guide/en/beats/libbeat/current/new-beat.html).
## To test {{cookiecutter.beat|capitalize}}, run the following commands:

```
make testsuite
```

alternatively:
```
make unit-tests
make system-tests
make integration-tests
make coverage-report
```


The test coverage is reported in the folder `./build/coverage/`

## To clean {{cookiecutter.beat|capitalize}} source code, run the following commands:

```
make fmt
make simplify
```

## To package {{cookiecutter.beat|capitalize}} for all platforms, run the following commands:

```
cd packer
make
```

To start it as a git repository, run

## To push {{cookiecutter.beat|capitalize}} in the git repository, run the following commands:

```
git init
git add .
git commit
git remote set-url origin https://{{cookiecutter.beat_path}}/{{cookiecutter.beat}}
git push origin master
```

## To clone {{cookiecutter.beat|capitalize}} from the git repository, run the following commands:

```
mkdir -p ${GOPATH}/{{cookiecutter.beat_path}}
cd ${GOPATH}/{{cookiecutter.beat_path}}
git clone https://{{cookiecutter.beat_path}}/{{cookiecutter.beat}}
```


## For further development, check out the [beat developer guide](https://www.elastic.co/guide/en/beats/libbeat/current/new-beat.html).
2 changes: 1 addition & 1 deletion {{cookiecutter.beat}}/beater/{{cookiecutter.beat}}.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/elastic/beats/libbeat/beat"
"github.com/elastic/beats/libbeat/cfgfile"

"{{cookiecutter.beat_path}}/config"
"{{cookiecutter.beat_path}}/{{cookiecutter.beat}}/config"
)

type {{cookiecutter.beat|capitalize}} struct {
Expand Down
2 changes: 1 addition & 1 deletion {{cookiecutter.beat}}/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package main

import (
"github.com/elastic/beats/libbeat/beat"
"{{cookiecutter.beat_path}}/beater"
"{{cookiecutter.beat_path}}/{{cookiecutter.beat}}/beater"
)

func main() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ output:
enabled: true

# Path to the directory where to save the generated files. The option is mandatory.
path: {{ output_file_path|default(beat.working_dir + "/output") }}
path: {{ '{{' }} output_file_path|default(beat.working_dir + "/output") {{ '}}' }}


# Name of the generated files. The default is `topbeat` and it generates
# files: `topbeat`, `topbeat.1`, `topbeat.2`, etc.
filename: "{{ output_file_filename|default("topbeat") }}"
# Name of the generated files. The default is `{{cookiecutter.beat}}` and it generates
# files: `{{cookiecutter.beat}}`, `{{cookiecutter.beat}}.1`, `{{cookiecutter.beat}}.2`, etc.
filename: "{{ '{{' }} output_file_filename|default("{{cookiecutter.beat}}") {{ '}}' }}"

# Maximum size in kilobytes of each file. When this size is reached, the files are
# rotated. The default value is 10 MB.
Expand Down Expand Up @@ -70,10 +70,10 @@ shipper:

#files:
# The directory where the log files will written to.
#path: /var/log/mybeat
#path: /var/log/{{cookiecutter.beat}}

# The name of the files where the logs are written to.
#name: mybeat
#name: {{cookiecutter.beat}}

# Configure log file size limit. If limit is reached, log file will be
# automatically rotated
Expand Down

0 comments on commit 3bbb9de

Please sign in to comment.