Skip to content

Commit

Permalink
Add first pass of secret tool testing
Browse files Browse the repository at this point in the history
  • Loading branch information
danudey committed Jan 8, 2025
1 parent 4cb796d commit b1cad8f
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 12 deletions.
28 changes: 18 additions & 10 deletions .semaphore/push_images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,29 @@ global_job_config:
- name: oss-release-secrets
# Mount the github SSH secret for pulling private repositories.
- name: private-repo
- name: secret-manager-gcloud-credentials
prologue:
commands:
- echo $DOCKERHUB_PASSWORD | docker login --username "$DOCKERHUB_USERNAME" --password-stdin
# Correct permissions since they are too open by default:
- chmod 0600 ~/.keys/*
# Add the key to the ssh agent:
- ssh-add ~/.keys/*
# Free up some space
- sudo rm -rf ~/.kiex ~/.phpbrew ~/.rbenv ~/.nvm ~/.kerl
# Semaphore mounts a copy-on-write FS as /var/lib/docker in order to provide a pre-loaded cache of
# some images. However, the cache is not useful to us and the copy-on-write FS is a big problem given
# how much we churn docker containers during testing. Disable it.
- sudo systemctl stop docker
- sudo umount /var/lib/docker && sudo killall qemu-nbd || true
- sudo systemctl start docker

# Clone our secret tool from Github and install it
- git config --global url."ssh://[email protected]/".insteadOf "https://github.com/"
- export GOPRIVATE="github.com/tigera/*,github.com/danudey/*"
- git clone -b add-secret-tool-properly [email protected]:danudey/go-tools.git go-tools
- cd go-tools && go install -v ./cmd/secret-tool

# Add default GOBIN to our path
- export PATH=$HOME/go/bin:$PATH

# Log into docker hub (we log into quay.io later for some reason)
- secret-tool fetch-secret DOCKERHUB_PASSWORD | docker login --username $(secret-tool fetch-secret DOCKERHUB_USERNAME) --password-stdin

# Checkout our code
- checkout

# Restore all the build specific caches
- 'cache restore bin-amd64-${SEMAPHORE_GIT_SHA}'
- 'cache restore go-pkg-cache-amd64-${SEMAPHORE_GIT_SHA}'
Expand All @@ -48,7 +55,8 @@ blocks:
- name: operator-redhat-connect
prologue:
commands:
- docker login -u="$QUAY_USERNAME" -p="$QUAY_TOKEN" quay.io;
# Sign in to quay.io using fetched secrets
- secret-tool fetch-secret QUAY_TOKEN | docker login --username $(secret-tool fetch-secret QUAY_USERNAME) --password-stdin quay.io
- export BRANCH_NAME=$SEMAPHORE_GIT_BRANCH
jobs:
- name: Build
Expand Down
11 changes: 9 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ define yq_cmd
endef
YQ_V4 = $(call yq_cmd,4)

define get-secret
$(shell echo "[secret] Fetching secret $1" > /dev/stderr; secret-tool fetch-secret $1)
endef

# These secrets should be lazily-loaded when accessed
GITHUB_TOKEN = $(call get-secret,GITHUB_TOKEN)

GIT_CMD = git
CURL_CMD = curl -fL

Expand Down Expand Up @@ -480,9 +487,9 @@ endif
maybe-build-release:
./hack/maybe-build-release.sh

release-notes: var-require-all-VERSION-GITHUB_TOKEN clean
release-notes: var-require-all-VERSION clean
@docker build -t tigera/release-notes -f build/Dockerfile.release-notes .
@docker run --rm -v $(CURDIR):/workdir -e GITHUB_TOKEN=$(GITHUB_TOKEN) -e VERSION=$(VERSION) tigera/release-notes
@docker run --rm -v $(CURDIR):/workdir -e GITHUB_TOKEN=$(GITHUB_TOKEN) -e VERSION=$(VERSION) tigera/release-notes

## Tags and builds a release from start to finish.
release: release-prereqs
Expand Down

0 comments on commit b1cad8f

Please sign in to comment.