Set/get version number of community beats


#1

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

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 / set_version

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


(Tudor Golubenco) #2

Sounds good to me. Thanks @cyrilleverrier!


(ruflin) #3

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.

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.


#4

I am assuming that my build server is using set_version to update its application number.

Because it is easier to reuse the set_version script to update version.go than main.go

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

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


(ruflin) #5

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


#6

See Pull request : https://github.com/elastic/beats/pull/3203


(system) #7

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