# Set/get version number of community beats

**URL:** <https://discuss.elastic.co/t/set-get-version-number-of-community-beats/68990>\
**Category:** Beats\
**Tags:** beats-development\
**Created:** [December 14, 2016, 9:35am UTC](https://discuss.elastic.co/t/set-get-version-number-of-community-beats/68990 "2016-12-14T09:35:19Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![cyrilleverrier](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cyrilleverrier/32/9926_2.png) [@cyrilleverrier](https://discuss.elastic.co/u/cyrilleverrier)\
**Post date:** [December 14, 2016, 9:35am UTC](https://discuss.elastic.co/t/set-get-version-number-of-community-beats/68990/1 "2016-12-14T09:35:19Z")

</div>

The current implementation of libbeat does not fully support setting a version number for the community beat apps.

If you are happy with the following changes, I am going to implement them right away

##Suggested changes:

### mybeat/main.go

(This file is generated by the community beat generator)

Community beat application specifies its own version

```
func main() {
    err := beat.Run("myapp", appVersion, beater.New)
    if err != nil {
        os.Exit(1)
    }
}

```

or the Community beat application reuses the version from libbeat

```
func main() {
    err := beat.Run("myapp", "", beater.New)
    if err != nil {
        os.Exit(1)
    }
}

```

### mybeat/version.go (optional)

- This file is optional, only used when the community beat application specifies its own version
- This file is updated by set\_version script

Content:

```
package main
const appVersion = "0.1.0-alpha1" 

```

### mybeat/version.yml (optional)

- This file is optional, only used when the community beat application specifies its own version
- This file is updated by set\_version script

Content:

```
version: "0.1.0-alpha1" 

```

### [github.com/elastic/beats/libbeat/scripts/Makefile](http://github.com/elastic/beats/libbeat/scripts/Makefile)

Paths can be specified through `VERSION_GOFILEPATH` and `VERSION_YAMLFILEPATH` environment variables.

Default values:

- `VERSION_GOFILEPATH` = `github.com/elastic/beats/libbeat/beat/version.go`
- `VERSION_YAMLFILEPATH` = `github.com/elastic/beats/dev-tools/packer/version.yml`

### [github.com/elastic/beats/dev-tools/get\_version](http://github.com/elastic/beats/dev-tools/get_version) / set\_version

Changes the scripts to use the paths of `version.go` and `version.yml` as specified by the environment variables .

---

<div class="post-metadata">

**Author:** ![tudor](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tudor/32/3753_2.png) [@tudor](https://discuss.elastic.co/u/tudor)\
**Post date:** [December 14, 2016, 10:10am UTC](https://discuss.elastic.co/t/set-get-version-number-of-community-beats/68990/2 "2016-12-14T10:10:18Z")

</div>

Sounds good to me. Thanks @cyrilleverrier!

---

<div class="post-metadata">

**Author:** ![ruflin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ruflin/32/3116_2.png) [@ruflin](https://discuss.elastic.co/u/ruflin)\
**Post date:** [December 14, 2016, 12:02pm UTC](https://discuss.elastic.co/t/set-get-version-number-of-community-beats/68990/3 "2016-12-14T12:02:13Z")

</div>

The part I don't understand is why the `version.go`file would be needed. Because if in the main.go file the version is set, the defaultVersion coming from `version.go` is ignored I think.

Would the main.go generated by the generator still be the same as we have today?

I see the need for the version.yml file. The question I would have is if we must support set\_version and get\_version for community beats? This would make the change smaller. My current understanding is that introduce `VERSION_YAMLFILEPATH` should be enough?

@cyrilleverrier Feel free to already open a PR. I'm sure we find an agreement here and the details are probably better to discuss on a PR.

---

<div class="post-metadata">

**Author:** ![cyrilleverrier](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cyrilleverrier/32/9926_2.png) [@cyrilleverrier](https://discuss.elastic.co/u/cyrilleverrier)\
**Post date:** [December 14, 2016, 12:14pm UTC](https://discuss.elastic.co/t/set-get-version-number-of-community-beats/68990/4 "2016-12-14T12:14:10Z")

</div>

### I am assuming that my build server is using set\_version to update its application number.

> [@ruflin](#):
>
> The part I don't understand is why the version.gofile would be needed. Because if in the main.go file the version is set, the defaultVersion coming from version.go is ignored I think.

Because it is easier to reuse the set\_version script to update `version.go` than `main.go`

> [@ruflin](#):
>
> The question I would have is if we must support set\_version and get\_version for community beats?

That is my intention. I'd like to reuse set\_version/get\_version from libbeat in my build server.

### If I don't use set\_version script

> [@ruflin](#):
>
> My current understanding is that introduce VERSION\_YAMLFILEPATH should be enough?

Then you are right, only `VERSION_YAMLFILEPATH` is required.  
And I will have to make a script to update my own `version.yml` and `main.go`

---

<div class="post-metadata">

**Author:** ![ruflin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ruflin/32/3116_2.png) [@ruflin](https://discuss.elastic.co/u/ruflin)\
**Post date:** [December 14, 2016, 12:47pm UTC](https://discuss.elastic.co/t/set-get-version-number-of-community-beats/68990/5 "2016-12-14T12:47:45Z")

</div>

I see, you are as fanatic about automation as we are 🙂 Fully understood. Lets do it then as you proposed ...

---

<div class="post-metadata">

**Author:** ![cyrilleverrier](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cyrilleverrier/32/9926_2.png) [@cyrilleverrier](https://discuss.elastic.co/u/cyrilleverrier)\
**Post date:** [December 16, 2016, 11:02am UTC](https://discuss.elastic.co/t/set-get-version-number-of-community-beats/68990/6 "2016-12-16T11:02:05Z")

</div>

See Pull request : [https://github.com/elastic/beats/pull/3203](https://github.com/elastic/beats/pull/3203)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [January 13, 2017, 11:02am UTC](https://discuss.elastic.co/t/set-get-version-number-of-community-beats/68990/7 "2017-01-13T11:02:09Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
