Report docker systems in version and user agents (#2136)

This commit is contained in:
mmetc 2023-03-22 11:57:29 +01:00 committed by GitHub
parent a3e5f0a3a0
commit 80de87ac34
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 24 additions and 2 deletions

View file

@ -10,7 +10,7 @@ COPY . .
# wizard.sh requires GNU coreutils # wizard.sh requires GNU coreutils
RUN apk add --no-cache git gcc libc-dev make bash gettext binutils-gold coreutils && \ RUN apk add --no-cache git gcc libc-dev make bash gettext binutils-gold coreutils && \
echo "githubciXXXXXXXXXXXXXXXXXXXXXXXX" > /etc/machine-id && \ echo "githubciXXXXXXXXXXXXXXXXXXXXXXXX" > /etc/machine-id && \
make clean release && \ make clean release DOCKER_BUILD=1 && \
cd crowdsec-v* && \ cd crowdsec-v* && \
./wizard.sh --docker-mode && \ ./wizard.sh --docker-mode && \
cd - >/dev/null && \ cd - >/dev/null && \

View file

@ -14,7 +14,7 @@ ENV DEBCONF_NOWARNINGS="yes"
RUN apt-get update && \ RUN apt-get update && \
apt-get install -y -q git gcc libc-dev make bash gettext binutils-gold coreutils tzdata && \ apt-get install -y -q git gcc libc-dev make bash gettext binutils-gold coreutils tzdata && \
echo "githubciXXXXXXXXXXXXXXXXXXXXXXXX" > /etc/machine-id && \ echo "githubciXXXXXXXXXXXXXXXXXXXXXXXX" > /etc/machine-id && \
make clean release && \ make clean release DOCKER_BUILD=1 && \
cd crowdsec-v* && \ cd crowdsec-v* && \
./wizard.sh --docker-mode && \ ./wizard.sh --docker-mode && \
cd - >/dev/null && \ cd - >/dev/null && \

View file

@ -36,6 +36,10 @@ LD_OPTS_VARS= \
-X '$(GO_MODULE_NAME)/pkg/csconfig.defaultConfigDir=$(DEFAULT_CONFIGDIR)' \ -X '$(GO_MODULE_NAME)/pkg/csconfig.defaultConfigDir=$(DEFAULT_CONFIGDIR)' \
-X '$(GO_MODULE_NAME)/pkg/csconfig.defaultDataDir=$(DEFAULT_DATADIR)' -X '$(GO_MODULE_NAME)/pkg/csconfig.defaultDataDir=$(DEFAULT_DATADIR)'
ifneq (,$(DOCKER_BUILD))
LD_OPTS_VARS += -X '$(GO_MODULE_NAME)/pkg/cwversion.System=docker'
endif
ifdef BUILD_STATIC ifdef BUILD_STATIC
export LD_OPTS=-ldflags "-s -w $(LD_OPTS_VARS) -extldflags '-static'" -tags netgo,osusergo,sqlite_omit_load_extension export LD_OPTS=-ldflags "-s -w $(LD_OPTS_VARS) -extldflags '-static'" -tags netgo,osusergo,sqlite_omit_load_extension
else else

View file

@ -0,0 +1,18 @@
#!/usr/bin/env python
import pytest
pytestmark = pytest.mark.docker
def test_version_docker_platform(crowdsec, flavor):
with crowdsec(flavor=flavor) as cs:
for waiter in cs.log_waiters():
with waiter as matcher:
matcher.fnmatch_lines(["*Starting processing data*"])
res = cs.cont.exec_run('cscli version')
assert res.exit_code == 0
assert 'Platform: docker' in res.output.decode()
res = cs.cont.exec_run('crowdsec -version')
assert res.exit_code == 0
assert 'Platform: docker' in res.output.decode()