Skip to content

Commit

Permalink
Provide an override on the go version for eks snaps
Browse files Browse the repository at this point in the history
  • Loading branch information
addyess committed Oct 9, 2024
1 parent ace4e61 commit 1cc7836
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
6 changes: 6 additions & 0 deletions jobs/build-snaps.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@
default: ''
description: |
Snap base to use as an override while building snaps
- string:
name: eks_go_override
default: ''
description: |
Snap go version to use as an override while building snaps
Can be in format '1.22' or 'go/1.23/edge'
- string:
name: k8s_tag
default: 'v{version}'
Expand Down
20 changes: 19 additions & 1 deletion jobs/build-snaps/build-release-eks-snaps.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,22 @@ def _find_eks_base(version, override){
def f_version = Float.parseFloat(version.substring(1, version.lastIndexOf('.')))
return f_version >= 1.99 ? "core22" : "core20";
}
def _build_go_version(override){
if (override.length() == 0) {
return override
}
else if ((m = override =~ /^(\d+).(\d+)$/)) {
return "go/${m[0][1]}.${m[0][2]}/stable"
}
else if ((m = override =~ /^go\/(\d+).(\d+)\/\S+$/)) {
return override
}
throw new IllegalArgumentException("Invalid Go snap version $override")
}
def eks_base_override = params.eks_base_override
def eks_go_version = params.eks_go_override
def EKS_BASE = _find_eks_base(kube_version, eks_base_override)
def GO_VERSION = _build_go_version(eks_go_version)

pipeline {
agent {
Expand Down Expand Up @@ -43,6 +57,10 @@ pipeline {
}
}
stage('Setup Source') {
//# update the go version if overriden
//if [ -n "${GO_VERSION}" ]; then
// sed -i -e "s#go/.*#${GO_VERSION}#g" snapcraft.yaml
//fi
steps {
sh """
CK_SNAP_BRANCH="${kube_version}"
Expand All @@ -67,7 +85,7 @@ pipeline {
sed -i -e "s/^name: \${snap}/name: \${EKS_SNAP}/" \
-e "s/^base: .*/base: ${EKS_BASE}/" \
-e "s/install-mode: .*/install-mode: disable/" snapcraft.yaml
# if we don't have any base defined at this point, add one
grep -q "^base: " snapcraft.yaml || echo "base: ${EKS_BASE}" >> snapcraft.yaml
Expand Down

0 comments on commit 1cc7836

Please sign in to comment.