From f2db8d9df7accd2ac504f964f763b0cf52f75744 Mon Sep 17 00:00:00 2001 From: Robert Fratto Date: Fri, 5 Apr 2024 13:55:16 -0400 Subject: [PATCH] misc: other fixes * Fix issue where the Drone CI couldn't push Windows container images to other registries. * Update go.mod to use github.com/grafana/alloy/syntax v0.1.0. --- .drone/drone.yml | 10 +++++++-- .drone/pipelines/publish.jsonnet | 10 ++++++++- go.mod | 2 +- tools/ci/docker-containers-windows | 33 +++++++++++++----------------- 4 files changed, 32 insertions(+), 23 deletions(-) diff --git a/.drone/drone.yml b/.drone/drone.yml index 2592f92081..ee7d7e773f 100644 --- a/.drone/drone.yml +++ b/.drone/drone.yml @@ -373,12 +373,18 @@ platform: version: "1809" steps: - commands: - - '& "C:/Program Files/git/bin/bash.exe" ./tools/ci/docker-containers-windows alloy' + - '& "C:/Program Files/git/bin/bash.exe" -c "mkdir -p $HOME/.docker"' + - '& "C:/Program Files/git/bin/bash.exe" -c "printenv GCR_CREDS > $HOME/.docker/config.json"' + - '& "C:/Program Files/git/bin/bash.exe" -c "docker login -u $DOCKER_LOGIN -p $DOCKER_PASSWORD"' + - '& "C:/Program Files/git/bin/bash.exe" -c "./tools/ci/docker-containers-windows + alloy"' environment: DOCKER_LOGIN: from_secret: docker_login DOCKER_PASSWORD: from_secret: docker_password + GCR_CREDS: + from_secret: gcr_admin image: grafana/agent-build-image:0.40.2-windows name: Build containers volumes: @@ -553,6 +559,6 @@ kind: secret name: updater_private_key --- kind: signature -hmac: 8dfa15c0fd4f3dde68d7099e77e6a4f90f3fd6685288805e6927f6ad24b9359a +hmac: 21df6cb02f24c4eab41dc3425f43c865141d400b2ad00571bde9a1803577e77c ... diff --git a/.drone/pipelines/publish.jsonnet b/.drone/pipelines/publish.jsonnet index 8b4ecab764..cc035e76ba 100644 --- a/.drone/pipelines/publish.jsonnet +++ b/.drone/pipelines/publish.jsonnet @@ -136,6 +136,10 @@ local linux_containers_jobs = std.map(function(container) ( } ), linux_containers); + +local windows_bash_command = function(command) + '& "C:/Program Files/git/bin/bash.exe" -c "%s"' % command; + local windows_containers_jobs = std.map(function(container) ( pipelines.windows('Publish Windows %s container' % container) { trigger: { @@ -151,9 +155,13 @@ local windows_containers_jobs = std.map(function(container) ( environment: { DOCKER_LOGIN: secrets.docker_login.fromSecret, DOCKER_PASSWORD: secrets.docker_password.fromSecret, + GCR_CREDS: secrets.gcr_admin.fromSecret, }, commands: [ - '& "C:/Program Files/git/bin/bash.exe" ./tools/ci/docker-containers-windows %s' % container, + windows_bash_command('mkdir -p $HOME/.docker'), + windows_bash_command('printenv GCR_CREDS > $HOME/.docker/config.json'), + windows_bash_command('docker login -u $DOCKER_LOGIN -p $DOCKER_PASSWORD'), + windows_bash_command('./tools/ci/docker-containers-windows %s' % container), ], }], volumes: [{ diff --git a/go.mod b/go.mod index 473a823f77..7dafbff17b 100644 --- a/go.mod +++ b/go.mod @@ -53,7 +53,7 @@ require ( github.com/google/uuid v1.6.0 github.com/gorilla/mux v1.8.1 github.com/grafana/agent-remote-config v0.0.2 - github.com/grafana/alloy/syntax v0.0.0-00010101000000-000000000000 + github.com/grafana/alloy/syntax v0.1.0 github.com/grafana/beyla v1.4.1-0.20240328093156-fca861576b2c github.com/grafana/ckit v0.0.0-20230906125525-c046c99a5c04 github.com/grafana/cloudflare-go v0.0.0-20230110200409-c627cf6792f2 diff --git a/tools/ci/docker-containers-windows b/tools/ci/docker-containers-windows index 11e4b177bd..0d757655fe 100644 --- a/tools/ci/docker-containers-windows +++ b/tools/ci/docker-containers-windows @@ -79,24 +79,19 @@ case "$TARGET_CONTAINER" in ;; esac -# Push images only if we have docker credentials and a drone tag is set -if [ -n "$DOCKER_LOGIN" ] && [ -n "$DOCKER_PASSWORD" ]; then - docker login -u "$DOCKER_LOGIN" -p "$DOCKER_PASSWORD" - - case "$TARGET_CONTAINER" in - alloy) - docker push "$RELEASE_ALLOY_IMAGE:$VERSION_TAG" - docker push "$RELEASE_ALLOY_IMAGE:$BRANCH_TAG" - ;; +case "$TARGET_CONTAINER" in + alloy) + docker push "$RELEASE_ALLOY_IMAGE:$VERSION_TAG" + docker push "$RELEASE_ALLOY_IMAGE:$BRANCH_TAG" + ;; - alloy-devel) - docker push "$DEVEL_ALLOY_IMAGE:$VERSION_TAG" - docker push "$DEVEL_ALLOY_IMAGE:$BRANCH_TAG" - ;; + alloy-devel) + docker push "$DEVEL_ALLOY_IMAGE:$VERSION_TAG" + docker push "$DEVEL_ALLOY_IMAGE:$BRANCH_TAG" + ;; - *) - echo "Usage: $0 alloy|alloy-devel" - exit 1 - ;; - esac -fi + *) + echo "Usage: $0 alloy|alloy-devel" + exit 1 + ;; +esac