Skip to content

Commit

Permalink
introduce go.mod for env2yaml (#15921)
Browse files Browse the repository at this point in the history
Update the env2yaml to have a go.mod instead of relying on disabling go modules, otherwise building with golang 1.22 will fail in the future.
This change also directly uses the golang image to build the binary removing the need for an intermediate image.

(cherry picked from commit 5c3e64d)
  • Loading branch information
jsvd authored and logstashmachine committed Feb 8, 2024
1 parent 46df43b commit 54cdbb7
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
12 changes: 4 additions & 8 deletions docker/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -193,16 +193,12 @@ venv: requirements.txt
for i in 0 1 2 3 4 5; do sleep "$i"; pip install -r requirements.txt && break; done &&\
touch venv

# Make a Golang container that can compile our env2yaml tool.
golang:
docker build -t golang:env2yaml data/golang

# Compile "env2yaml", the helper for configuring logstash.yml via environment
# variables.
env2yaml: golang
docker run --rm -i \
-v $(PWD)/data/logstash/env2yaml:/usr/local/src/env2yaml:Z \
golang:env2yaml
env2yaml:
docker run --rm \
-v "$(PWD)/data/logstash/env2yaml:/usr/src/env2yaml" \
-w /usr/src/env2yaml golang:1 go build

# Generate the Dockerfiles from Jinja2 templates.
dockerfile: venv templates/Dockerfile.j2
Expand Down
4 changes: 0 additions & 4 deletions docker/data/golang/Dockerfile

This file was deleted.

5 changes: 5 additions & 0 deletions docker/data/logstash/env2yaml/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module logstash/env2yaml

go 1.21

require gopkg.in/yaml.v2 v2.4.0
3 changes: 3 additions & 0 deletions docker/data/logstash/env2yaml/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=

0 comments on commit 54cdbb7

Please sign in to comment.