Skip to content

Commit

Permalink
[patch-announce] Move to golang tool
Browse files Browse the repository at this point in the history
Remove the bash implementation, move to the golang based tool.

The tool currently still shells out and has some external dependencies.
Therefore we, for now, just `go run` it in the `k8s-cloud-builder`
images, where we have all the tools available.
  • Loading branch information
hoegaarden committed Feb 5, 2020
1 parent 7f7ec9d commit 1b393f6
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 182 deletions.
16 changes: 10 additions & 6 deletions announce-patch
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,15 @@
#+ --freeze-date - The date we will freeze the branch and will not accept
#+ cherry-picks anymore.
#+ --cut-date - The date we will cut and publish the release.
#+ --from-name - The sender's name.
#+ --from-email - The sender's email address. Will also be used as a
#+ --sender-name - The sender's name.
#+ --sender-email - The sender's email address. Will also be used as a
#+ receiver when not in nomock mode.
#+ [--tail] - Stays attached to the cloud build process and streams
#+ in the logs
#+ [--k8s-git-url] - The git URL to clone kubernetes/kubernetes from.
#+ [--release-git-url] - The git URL to clone kubernetes/release from.
#+ [--release-git-branch] - The branch of kubernetes/release to use.
#+ [--log-level] - Set the loglevel for the patch announcement tool
#+
#+ ENVIRONMENT
#+ The GCP project can be changed by setting the PROJECT environment
Expand Down Expand Up @@ -116,7 +117,9 @@ main() {
return 1
fi

local subst=()
local subst=(
'_NOMOCK=false'
)
local opts=(
'--no-source'
"--config=${BASE_ROOT}/gcb/patch-announce/cloudbuild.yaml"
Expand All @@ -126,18 +129,19 @@ main() {
subst+=( "_K8S_GIT_BRANCH=${branch_name}" )
subst+=( "_FREEZE_DATE=$( flag_or_env_or_default 'freeze_date' )" )
subst+=( "_CUT_DATE=$( flag_or_env_or_default 'cut_date' )" )
subst+=( "_FROM_NAME=$( flag_or_env_or_default 'from_name' )" )
subst+=( "_FROM_EMAIL=$( flag_or_env_or_default 'from_email' )" )
subst+=( "_SENDER_NAME=$( flag_or_env_or_default 'sender_name' )" )
subst+=( "_SENDER_EMAIL=$( flag_or_env_or_default 'sender_email' )" )

# optional flags
subst+=( "_K8S_GIT_URL=$( flag_or_env_or_default 'k8s_git_url' 'https://github.com/kubernetes/kubernetes' )" )
subst+=( "_RELEASE_GIT_URL=$( flag_or_env_or_default 'release_git_url' 'https://github.com/kubernetes/release' )" )
subst+=( "_RELEASE_GIT_BRANCH=$( flag_or_env_or_default 'release_git_branch' 'master' )" )
subst+=( "_LOG_LEVEL=$( flag_or_env_or_default 'log-level' 'info' )" )

# shellcheck disable=2154
# ... because that is set by magick when sourcing common.sh
if ((FLAGS_nomock)) ; then
subst+=( "_RUN_TYPE=nomock" )
subst+=( "_NOMOCK=true" )
fi

# shellcheck disable=2154
Expand Down
60 changes: 43 additions & 17 deletions gcb/patch-announce/cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,49 @@ steps:
- id: prepare-and-send
name: "gcr.io/${PROJECT_ID}/k8s-cloud-builder"
env:
- "REL_MGR_NAME=${_REL_MGR_NAME}"
- "REL_MGR_EMAIL=${_REL_MGR_EMAIL}"
- "REL_MGR_SLACK=${_REL_MGR_SLACK}"
- "FROM_NAME=${_FROM_NAME}"
- "FROM_EMAIL=${_FROM_EMAIL}"
- "SENDER_NAME=${_SENDER_NAME}"
- "SENDER_EMAIL=${_SENDER_EMAIL}"
- "FREEZE_DATE=${_FREEZE_DATE}"
- "CUT_DATE=${_CUT_DATE}"
- "RUN_TYPE=${_RUN_TYPE}"
- "NOMOCK=${_NOMOCK}"
- "LOG_LEVEL=${_LOG_LEVEL}"
secretEnv:
- GITHUB_TOKEN
- SENDGRID_API_KEY
dir: "go/src/k8s.io/release"
entrypoint: bash
args:
- go/src/k8s.io/release/patch-release/announce
- -c
- |
set -e
set -u
set -o pipefail
export GOPATH="/workspace/go"
export GOBIN="$${GOPATH}/bin"
export PATH="$${PATH}:$${GOBIN}"
# TODO: Until we've switched away from the shell release note tool, we
# still need this binary in the PATH
go install ./cmd/blocking-testgrid-tests
# Notes:
# - GITHUB_TOKEN & SENDGRID_API_KEY need to be picked up by the
# application from the env, we don't want to log or pass those
# sensitive values as flags.
# - Once we've removed all external dependencies and the tool does not
# shell out any more, we can also compile, bake and release this tool
# as a container image and use that instead of `go run`ing it.
go run ./cmd/krel \
patch-announce \
--repo=../kubernetes \
--release-repo=. \
--sender-name="$${SENDER_NAME}" \
--sender-email="$${SENDER_EMAIL}" \
--cut-date="$${CUT_DATE}" \
--freeze-date="$${FREEZE_DATE}" \
--log-level="$${LOG_LEVEL}" \
--nomock="$${NOMOCK}"
substitutions:
# The branch of k/kubernetes to check out, the branch to announce a patch release for (e.g.: release-1.15)
Expand All @@ -63,20 +93,16 @@ substitutions:
# Date of planned cut, ISO 8601 (e.g.: 2019-12-11)
_CUT_DATE: null
# The mail sender's name. Will also be used as a receipient in mock mode. (e.g.: "Jane Doe")
_FROM_NAME: null
_SENDER_NAME: null
# The mail sender's email. Will also be used as a receipient in mock mode. (e.g.: jane.doe@example.org")
_FROM_EMAIL: null
# For the real run, set to 'nomock' (e.g.: "mock" or "nomock")
_RUN_TYPE: 'mock'
_SENDER_EMAIL: null
# For the real run, set to 'nomock' (e.g.: 0,1,f,t,false,true)
_NOMOCK: '0'
# git-clone'able URL for k/kubernetes
_K8S_GIT_URL: https://github.com/kubernetes/kubernetes
# git-clone'able URL for k/release
_RELEASE_GIT_URL: https://github.com/kubernetes/release
# The branch of k/release to check out
_RELEASE_GIT_BRANCH: master
# For the email message: the name of the group to contact
_REL_MGR_NAME: 'Kubernetes Release Managers'
# For the email message: the email of the group to contact
_REL_MGR_EMAIL: 'release-managers@kubernetes.io'
# For the email message: the slack channel of the group to contact
_REL_MGR_SLACK: 'sig-release'
# The log level to be used with the patch-announce tool
_LOG_LEVEL: info
125 changes: 0 additions & 125 deletions patch-release/announce

This file was deleted.

7 changes: 0 additions & 7 deletions patch-release/mail-head.md.tmpl

This file was deleted.

27 changes: 0 additions & 27 deletions patch-release/mail-style.css

This file was deleted.

0 comments on commit 1b393f6

Please sign in to comment.