Skip to content

Commit

Permalink
Sync config via mage respecting docker defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
graphaelli authored and jalvz committed Jun 28, 2019
1 parent 8a51acb commit 4710853
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 6 deletions.
5 changes: 1 addition & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,9 @@ endif
is-beats-updated: python-env
@$(PYTHON_ENV)/bin/python ./script/is_beats_updated.py ${BEATS_VERSION}

apm-server.docker.yml: _meta/beat.yml
@sed -E -e 's/^ hosts: \["localhost:9200"\]/ hosts: ["elasticsearch:9200"]/' -e 's/ host: "localhost:8200"/ host: "0.0.0.0:8200"/' < _meta/beat.yml > apm-server.docker.yml

# Collects all dependencies and then calls update
.PHONY: collect
collect: fields go-generate add-headers create-docs notice apm-server.docker.yml
collect: fields go-generate add-headers create-docs notice

.PHONY: go-generate
go-generate:
Expand Down
4 changes: 2 additions & 2 deletions _meta/beat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

apm-server:
# Defines the host and port the server is listening on. use "unix:/path/to.sock" to listen on a unix domain socket.
host: "localhost:8200"
host: "{{ .listen_hostport }}"

# Maximum permitted size in bytes of a request's header accepted by the server to be processed.
#max_header_size: 1048576
Expand Down Expand Up @@ -315,7 +315,7 @@ output.elasticsearch:
# Scheme and port can be left out and will be set to the default (http and 9200)
# In case you specify and additional path, the scheme is required: http://localhost:9200/path
# IPv6 addresses should always be defined as: https://[2001:db8::1]:9200
hosts: ["localhost:9200"]
hosts: ["{{ .elasticsearch_hostport }}"]

# Boolean flag to enable or disable the output module.
#enabled: true
Expand Down
31 changes: 31 additions & 0 deletions magefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,37 @@ func Clean() error {
return mage.Clean()
}

func Config() error {
if err := mage.Config(mage.ShortConfigType, shortConfigFileParams(), "."); err != nil {
return err
}
return mage.Config(mage.DockerConfigType, dockerConfigFileParams(), ".")
}

func shortConfigFileParams() mage.ConfigFileParams {
return mage.ConfigFileParams{
ShortParts: []string{
mage.OSSBeatDir("_meta/beat.yml"),
},
ExtraVars: map[string]interface{}{
"elasticsearch_hostport": "localhost:9200",
"listen_hostport": "localhost:" + beater.DefaultPort,
},
}
}

func dockerConfigFileParams() mage.ConfigFileParams {
return mage.ConfigFileParams{
DockerParts: []string{
mage.OSSBeatDir("_meta/beat.yml"),
},
ExtraVars: map[string]interface{}{
"elasticsearch_hostport": "elasticsearch:9200",
"listen_hostport": "0.0.0.0:" + beater.DefaultPort,
},
}
}

// Package packages the Beat for distribution.
// Use SNAPSHOT=true to build snapshots.
// Use PLATFORMS to control the target platforms.
Expand Down

0 comments on commit 4710853

Please sign in to comment.