Skip to content

Commit

Permalink
Tag googlepubsub docker image (elastic#18773) (elastic#18784)
Browse files Browse the repository at this point in the history
Add compose targets to x-pack filebeat, adding support for INPUT
environment variable in a similar fashion to the MODULE one.

Add supported-versions file to googlepubsub so this image can be built
with `mage compose:buildSupportedVersions`. Tag the version in docker
compose file so image can be build and reused if already exists.

Remove googlepubsub from main docker compose file, it is not needed
there and images defined there are always rebuilt.

(cherry picked from commit cdc7e07)
  • Loading branch information
jsoriano authored May 27, 2020
1 parent ac2b6e6 commit b28c811
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 23 deletions.
5 changes: 5 additions & 0 deletions dev-tools/mage/target/compose/compose.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ func findSupportedVersionsFiles() ([]string, error) {
return []string{path}, nil
}

if input := os.Getenv("INPUT"); len(input) > 0 {
path := filepath.Join("input", input, "_meta/supported-versions.yml")
return []string{path}, nil
}

return devtools.FindFilesRecursive(func(path string, _ os.FileInfo) bool {
return filepath.Base(path) == "supported-versions.yml"
})
Expand Down
6 changes: 0 additions & 6 deletions x-pack/filebeat/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,12 @@ services:
- BEAT_STRICT_PERMS=false
- ES_HOST=elasticsearch
- ES_PORT=9200
- PUBSUB_EMULATOR_HOST=googlepubsub:8432
working_dir: /go/src/github.com/elastic/beats/x-pack/filebeat
volumes:
- ${PWD}/../..:/go/src/github.com/elastic/beats/
- /var/run/docker.sock:/var/run/docker.sock
command: make

googlepubsub:
build: input/googlepubsub/_meta
ports:
- 8432

# This is a proxy used to block beats until all services are healthy.
# See: https://github.com/docker/compose/issues/4369
proxy_dep:
Expand Down
5 changes: 3 additions & 2 deletions x-pack/filebeat/input/googlepubsub/_meta/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
FROM debian:stretch
ARG SDK_VERSION

RUN \
apt-get update \
Expand All @@ -20,8 +21,8 @@ RUN \
RUN \
apt-get update \
&& apt-get install -y \
google-cloud-sdk \
google-cloud-sdk-pubsub-emulator \
google-cloud-sdk=${SDK_VERSION} \
google-cloud-sdk-pubsub-emulator=${SDK_VERSION} \
&& rm -rf /var/lib/apt/lists/*

RUN \
Expand Down
7 changes: 0 additions & 7 deletions x-pack/filebeat/input/googlepubsub/_meta/docker-compose.yml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
variants:
- SDK_VERSION: 293.0.0-0
11 changes: 11 additions & 0 deletions x-pack/filebeat/input/googlepubsub/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: '2.3'

services:
googlepubsub:
image: docker.elastic.co/integrations-ci/beats-googlepubsub:emulator-${SDK_VERSION:-293.0.0-0}-1
build:
context: ./_meta
args:
SDK_VERSION: ${SDK_VERSION:-293.0.0-0}
ports:
- 8432
18 changes: 10 additions & 8 deletions x-pack/filebeat/input/googlepubsub/pubsub_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,19 @@ var once sync.Once
func testSetup(t *testing.T) (*pubsub.Client, context.CancelFunc) {
t.Helper()

host := os.Getenv("PUBSUB_EMULATOR_HOST")
if host == "" {
t.Skip("PUBSUB_EMULATOR_HOST is not set in environment. You can start " +
"the emulator with \"docker-compose up\" from the _meta directory. " +
"The default address is PUBSUB_EMULATOR_HOST=localhost:8432")
}

var host string
if isInDockerIntegTestEnv() {
// We're running inside out integration test environment so
// make sure that that googlepubsub container is running.
compose.EnsureUp(t, "googlepubsub")
host = compose.EnsureUp(t, "googlepubsub").Host()
os.Setenv("PUBSUB_EMULATOR_HOST", host)
} else {
host = os.Getenv("PUBSUB_EMULATOR_HOST")
if host == "" {
t.Skip("PUBSUB_EMULATOR_HOST is not set in environment. You can start " +
"the emulator with \"docker-compose up\" from the _meta directory. " +
"The default address is PUBSUB_EMULATOR_HOST=localhost:8432")
}
}

once.Do(func() {
Expand Down
2 changes: 2 additions & 0 deletions x-pack/filebeat/magefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import (
// mage:import generate
_ "github.com/elastic/beats/v7/filebeat/scripts/mage/generate"
// mage:import
_ "github.com/elastic/beats/v7/dev-tools/mage/target/compose"
// mage:import
_ "github.com/elastic/beats/v7/dev-tools/mage/target/unittest"
// mage:import
"github.com/elastic/beats/v7/dev-tools/mage/target/test"
Expand Down

0 comments on commit b28c811

Please sign in to comment.