Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transition from Helm Repositories to OCI Artifacts for Storing Helm Charts - update to helm3 command #1271

Merged
merged 67 commits into from
Oct 15, 2024
Merged
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
70e272e
update to helm3 command
NickAzureDevops Sep 30, 2024
7bbde56
update to helm3 command
NickAzureDevops Sep 30, 2024
6b4ac3c
update to helm3 command
NickAzureDevops Oct 1, 2024
ede882d
re-add addrepo function
NickAzureDevops Oct 1, 2024
6d67c21
re-add addrepo function
NickAzureDevops Oct 1, 2024
8afc417
re-add addrepo function
NickAzureDevops Oct 1, 2024
58165cb
Revert "add debug to function"
NickAzureDevops Oct 1, 2024
5d0a0d2
add verbose logging
NickAzureDevops Oct 1, 2024
7a951c2
add verbose logging
NickAzureDevops Oct 1, 2024
2e353a6
remove add repo function
NickAzureDevops Oct 1, 2024
1a11bf0
readd function
NickAzureDevops Oct 1, 2024
004c527
fix indendation
NickAzureDevops Oct 1, 2024
0cc773c
edit helm push command
NickAzureDevops Oct 1, 2024
e84527b
edit helm push command
NickAzureDevops Oct 2, 2024
1b38f11
edit helm push command
NickAzureDevops Oct 2, 2024
2df5c6d
edit helm push command
NickAzureDevops Oct 2, 2024
f0e88e2
edit helm push command
NickAzureDevops Oct 2, 2024
06352bf
revert addrepo function helm push command
NickAzureDevops Oct 2, 2024
81add51
add env variable
NickAzureDevops Oct 2, 2024
870f2f4
add env variable
NickAzureDevops Oct 2, 2024
8e55d2c
edit add repo function
NickAzureDevops Oct 2, 2024
b146be3
edit add repo function
NickAzureDevops Oct 2, 2024
a6fb9c3
edit add repo function
NickAzureDevops Oct 2, 2024
98d4c64
edit add repo function
NickAzureDevops Oct 2, 2024
d68b921
add removerepo function
NickAzureDevops Oct 2, 2024
7259c42
add removerepo function
NickAzureDevops Oct 2, 2024
69c3fc4
add removerepo function
NickAzureDevops Oct 2, 2024
044a712
fix typo on indendation
NickAzureDevops Oct 2, 2024
3044ad7
fix typo on indendation
NickAzureDevops Oct 2, 2024
ab09c21
fix typo on indendation
NickAzureDevops Oct 2, 2024
07b460d
git registry name
NickAzureDevops Oct 2, 2024
d40cecf
git registry name
NickAzureDevops Oct 3, 2024
98a893f
fix white spaces
NickAzureDevops Oct 3, 2024
ce99925
fix addrepo function
NickAzureDevops Oct 3, 2024
7fa2e5c
fix typo
NickAzureDevops Oct 3, 2024
5484108
fix typo
NickAzureDevops Oct 3, 2024
ecc65ad
fix typo
NickAzureDevops Oct 3, 2024
2693d5f
add az login before helm command
NickAzureDevops Oct 3, 2024
fdda5bc
fix duplicate
NickAzureDevops Oct 3, 2024
10b3ada
hardcore clientid
NickAzureDevops Oct 3, 2024
8eb5d10
hardcore clientid
NickAzureDevops Oct 3, 2024
8865b42
revert configacr function
NickAzureDevops Oct 3, 2024
190faae
revert configacr function
NickAzureDevops Oct 3, 2024
652fd63
run az acr login
NickAzureDevops Oct 3, 2024
98c963a
remove add function
NickAzureDevops Oct 3, 2024
71cf49f
remove add function
NickAzureDevops Oct 3, 2024
d3a44f5
fix issue with add repo function
NickAzureDevops Oct 3, 2024
bba6ac3
edit helm push command
NickAzureDevops Oct 3, 2024
3fa7a6b
re-add addrepo function
NickAzureDevops Oct 3, 2024
ccb14c6
re-add addrepo function
NickAzureDevops Oct 3, 2024
afc6ccf
remove az login --identity to test
NickAzureDevops Oct 3, 2024
2ec06e9
re-add az-login --identity
NickAzureDevops Oct 3, 2024
4a796fa
comment out az login --identity
NickAzureDevops Oct 3, 2024
10574d4
add a exeption on az login
NickAzureDevops Oct 3, 2024
a5c234f
test acr.az login
NickAzureDevops Oct 3, 2024
aa63421
test acr.az login
NickAzureDevops Oct 3, 2024
b477909
test acr.az login
NickAzureDevops Oct 3, 2024
98159b2
test acr.az login
NickAzureDevops Oct 3, 2024
3fea38c
remove duplicate bracket
NickAzureDevops Oct 3, 2024
313222c
remove duplicate bracket
NickAzureDevops Oct 3, 2024
df0fb5b
remove duplicate bracket
NickAzureDevops Oct 3, 2024
330b4b7
edit authenticateAcr function
NickAzureDevops Oct 3, 2024
c3fa2d8
edit authenticateAcr function
NickAzureDevops Oct 3, 2024
1bab55f
remove extra spacing
NickAzureDevops Oct 3, 2024
463e13e
add authenticateAcr to be called first before other operation
NickAzureDevops Oct 4, 2024
4b1e665
Merge branch 'master' into update-to-helm3-command
NickAzureDevops Oct 9, 2024
7d51b0a
Merge branch 'master' into update-to-helm3-command
NickAzureDevops Oct 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 17 additions & 11 deletions src/uk/gov/hmcts/contino/Helm.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class Helm {
}

def setup() {
authenticateAcr()
configureAcr()
removeRepo()
addRepo()
Expand All @@ -46,43 +47,50 @@ class Helm {

def removeRepo() {
this.steps.echo "Clear out helm repo before re-adding"
this.steps.sh(label: "helm repo rm ${registryName}", script: "helm repo rm ${registryName} || echo 'Helm repo may not exist on disk, skipping remove'")
this.steps.sh(label: "helm repo rm ${registryName}", script: 'helm repo rm $REGISTRY_NAME || echo "Helm repo may not exist on disk, skipping remove"', env: [REGISTRY_NAME: registryName])
}

def addRepo() {
this.acr.az "acr helm repo add --subscription ${registrySubscription} --name ${registryName}"
}

def authenticateAcr() {
this.acr.az "acr login --name ${registryName}"
}

def publishIfNotExists(List<String> values) {
configureAcr()
removeRepo()
addRepo()
authenticateAcr()
dependencyUpdate()
lint(values)

def version = this.steps.sh(script: "helm inspect chart ${this.chartLocation} | grep ^version | cut -d ':' -f 2", returnStdout: true).trim()
def version = this.steps.sh(script: "helm inspect chart ${this.chartLocation} | grep ^version | cut -d ':' -f 2", returnStdout: true).trim()
this.steps.echo "Version of chart locally is: ${version}"
def resultOfSearch
try {
resultOfSearch = this.acr.az "acr helm show --subscription ${registrySubscription} --name ${registryName} ${this.chartName} --version ${version} --query version -o tsv"
addRepo()
this.steps.sh(script: "helm pull ${registryName}/${this.chartName} --version ${version} -d .", returnStdout: true).trim()
resultOfSearch = version
} catch(ignored) {
resultOfSearch = notFoundMessage
resultOfSearch = notFoundMessage
}
this.steps.echo "Searched remote repo ${registryName}, result was ${resultOfSearch}"

if (resultOfSearch == notFoundMessage) {
this.steps.echo "Publishing new version of ${this.chartName}"

this.steps.sh "helm package ${this.chartLocation}"
this.acr.az "acr helm push --subscription ${registrySubscription} --name ${registryName} ${this.chartName}-${version}.tgz"
this.steps.sh(script: "helm push ${this.chartLocation}-${version}.tgz oci://${registryName}.azurecr.io/helm/${this.chartName}")

this.steps.echo "Published ${this.chartName}-${version} to ${registryName}"
} else {
this.steps.echo "Chart already published, skipping publish, bump the version in ${this.chartLocation}/Chart.yaml if you want it to be published"
this.steps.echo "Chart already published, skipping publish, bump the version in ${this.chartLocation}/Chart.yaml if you want it to be published"
}
}

def publishToGitIfNotExists(List<String> values) {
authenticateAcr()
addRepo()
lint(values)

Expand All @@ -103,7 +111,6 @@ class Helm {
}
}


def lint(List<String> values) {
this.execute("lint", this.chartLocation, values, null)
}
Expand Down Expand Up @@ -163,5 +170,4 @@ class Helm {
def valuesStr = (values == null ? "" : "${' -f ' + values.join(' -f ')}")
helm command, name, "${valuesStr} ${optionsStr}"
}

}
}