Skip to content

Commit 515ceca

Browse files
merllsvcAPLBotj-zimnowodaAni1357
authored
chore: Helmfile v1 compatibility [TOOLS][MINOR] (#2136)
Co-authored-by: svcAPLBot <[email protected]> Co-authored-by: jeho <[email protected]> Co-authored-by: Ani1357 <[email protected]>
1 parent 29c92ce commit 515ceca

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+51
-54
lines changed

.vscode/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
"aliases": "shellscript",
3939
"bin/hooks/*": "shellscript",
4040
"helmfile-*.yaml": "helm",
41+
"helmfile-*.yaml.gotmpl": "helm",
4142
"helmfile.yaml": "helm",
4243
"otomi": "shellscript"
4344
},

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM linode/apl-tools:v2.8.8 AS ci
1+
FROM linode/apl-tools:v2.9.0 AS ci
22

33
ENV APP_HOME=/home/app/stack
44

@@ -26,7 +26,7 @@ FROM ci AS clean
2626
# below command removes the packages specified in devDependencies and set NODE_ENV to production
2727
RUN npm prune --production
2828

29-
FROM linode/apl-tools:v2.8.8 AS prod
29+
FROM linode/apl-tools:v2.9.0 AS prod
3030
ENV APP_HOME=/home/app/stack
3131
ENV ENV_DIR=/home/app/stack/env
3232
ENV VERBOSITY='0'

bin/common.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,10 +242,10 @@ function hf_template() {
242242
QUIET=1
243243
if [ -n "$1" ]; then
244244
local out_dir="$1"
245-
[ -z "$FILE_OPT" ] && [ -z "$LABEL_OPT" ] && hf -f helmfile.tpl/helmfile-init.yaml template --skip-deps --output-dir="$out_dir" $SKIP_CLEANUP >/dev/null
245+
[ -z "$FILE_OPT" ] && [ -z "$LABEL_OPT" ] && hf -f helmfile.tpl/helmfile-init.yaml.gotmpl template --skip-deps --output-dir="$out_dir" $SKIP_CLEANUP >/dev/null
246246
hf template --skip-deps --output-dir="$out_dir" $SKIP_CLEANUP >/dev/null
247247
else
248-
[ -z "$FILE_OPT" ] && [ -z "$LABEL_OPT" ] && hf -f helmfile.tpl/helmfile-init.yaml template --skip-deps $SKIP_CLEANUP
248+
[ -z "$FILE_OPT" ] && [ -z "$LABEL_OPT" ] && hf -f helmfile.tpl/helmfile-init.yaml.gotmpl template --skip-deps $SKIP_CLEANUP
249249
hf template --skip-deps $SKIP_CLEANUP
250250
fi
251251
}

bin/job-presync.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ hf list | grep $release && is_deployed=true
1919
# - Always: remove job
2020

2121
if [ "$run_policy" = 'Always' ]; then
22-
hf -l name=$release destroy --args=--wait
22+
hf -l name=$release destroy --deleteWait
2323
else
2424
# OnSpecChange
2525
has_diff=false
2626
hf -l name=$release diff --skip-deps && has_diff=true
2727
[ -n "$VERBOSE" ] && echo "has_diff: $has_diff"
2828
if $has_diff && $is_deployed; then
29-
hf -l name=$release destroy --args=--wait
29+
hf -l name=$release destroy --deleteWait
3030
fi
3131
fi

chart/apl/localtest-minikube.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@ export CUSTOM_NETWORK='--network minikube'
2020
#####
2121
# apply
2222
#####
23-
binzx/otomi otomi apply-as-apps -f helmfile.tpl/helmfile-init.yaml
23+
binzx/otomi otomi apply-as-apps -f helmfile.tpl/helmfile-init.yaml.gotmpl
2424
binzx/otomi otomi apply-as-apps
2525
# minikube tunnel

docs/development.md

Lines changed: 20 additions & 20 deletions

helmfile.tpl/helmfile-connectivity.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ environments:
133133
- namespace: team-a2
134134
labels:
135135
otomi.io/app: c7
136+
---
136137
releases:
137138
- name: inter-team-connectivity
138139
installed: true

src/cmd/apply-e2e.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const applyE2e = async (): Promise<void> => {
2525

2626
await hf(
2727
{
28-
fileOpts: `${rootDir}/helmfile.tpl/helmfile-e2e.yaml`,
28+
fileOpts: `${rootDir}/helmfile.tpl/helmfile-e2e.yaml.gotmpl`,
2929
logLevel: logLevelString(),
3030
args: ['apply'],
3131
},

src/cmd/apply.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ const applyAll = async () => {
5858
await writeValuesToFile(`${env.ENV_DIR}/env/status.yaml`, { status: { otomi: state, helm: releases } }, true)
5959

6060
const output: ProcessOutputTrimmed = await hf(
61-
{ fileOpts: 'helmfile.tpl/helmfile-init.yaml', args: 'template' },
61+
{ fileOpts: 'helmfile.tpl/helmfile-init.yaml.gotmpl', args: 'template' },
6262
{ streams: { stderr: d.stream.error } },
6363
)
6464
if (output.exitCode > 0) {
@@ -78,7 +78,7 @@ const applyAll = async () => {
7878
await hf(
7979
{
8080
// 'fileOpts' limits the hf scope and avoids parse errors (we only have basic values in this statege):
81-
fileOpts: 'helmfile.d/helmfile-02.init.yaml',
81+
fileOpts: 'helmfile.d/helmfile-02.init.yaml.gotmpl',
8282
labelOpts: ['stage=prep'],
8383
logLevel: logLevelString(),
8484
args: hfArgs,
@@ -117,7 +117,7 @@ const applyAll = async () => {
117117
await hf(
118118
{
119119
// 'fileOpts' limits the hf scope and avoids parse errors (we only have basic values in this statege):
120-
fileOpts: `${rootDir}/helmfile.tpl/helmfile-e2e.yaml`,
120+
fileOpts: `${rootDir}/helmfile.tpl/helmfile-e2e.yaml.gotmpl`,
121121
logLevel: logLevelString(),
122122
args: hfArgs,
123123
},

src/cmd/destroy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const destroyAll = async () => {
3939
d.info('Uninstalled all charts.')
4040
d.info('Uninstalling applied manifests...')
4141
const output: ProcessOutputTrimmed = await hf(
42-
{ fileOpts: 'helmfile.tpl/helmfile-init.yaml', args: 'template' },
42+
{ fileOpts: 'helmfile.tpl/helmfile-init.yaml.gotmpl', args: 'template' },
4343
{ streams: debugStream },
4444
)
4545
if (output.exitCode > 0 || output.stderr.length > 0) {

src/cmd/migrate.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,7 @@ function renameKeyDeep(obj: any, oldKey: string, newKey: string): any {
620620

621621
export const migrateLegacyValues = async (envDir: string, deps = { writeFile }): Promise<boolean> => {
622622
const output = await hf(
623-
{ fileOpts: `${rootDir}/helmfile.tpl/helmfile-dump-files-old.yaml`, args: 'build' },
623+
{ fileOpts: `${rootDir}/helmfile.tpl/helmfile-dump-files-old.yaml.gotmpl`, args: 'build' },
624624
undefined,
625625
envDir,
626626
)

src/common/hf.ts

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -86,18 +86,22 @@ export const hfValues = async (
8686
let output: ProcessOutputTrimmed
8787
if (filesOnly)
8888
output = await hf(
89-
{ fileOpts: `${rootDir}/helmfile.tpl/helmfile-dump-files.yaml`, args: 'build' },
89+
{ fileOpts: `${rootDir}/helmfile.tpl/helmfile-dump-files.yaml.gotmpl`, args: 'build' },
9090
undefined,
9191
envDir,
9292
)
9393
else if (defaultValues)
9494
output = await hf(
95-
{ fileOpts: `${rootDir}/helmfile.tpl/helmfile-dump-defaults.yaml`, args: 'build' },
95+
{ fileOpts: `${rootDir}/helmfile.tpl/helmfile-dump-defaults.yaml.gotmpl`, args: 'build' },
9696
undefined,
9797
envDir,
9898
)
9999
else
100-
output = await hf({ fileOpts: `${rootDir}/helmfile.tpl/helmfile-dump-all.yaml`, args: 'build' }, undefined, envDir)
100+
output = await hf(
101+
{ fileOpts: `${rootDir}/helmfile.tpl/helmfile-dump-all.yaml.gotmpl`, args: 'build' },
102+
undefined,
103+
envDir,
104+
)
101105
const res = parse(replaceHFPaths(output.stdout, envDir)).renderedvalues
102106
if (excludeSecrets) {
103107
// strip secrets
@@ -135,13 +139,6 @@ export const getStandaloneFiles = async (envDir: string): Promise<Record<string,
135139
return files
136140
}
137141

138-
export const getHelmArgs = (argv: HelmArguments, args: string[] = []): string[] => {
139-
const argsArr: string[] = args
140-
if (argv.args) argsArr.push(argv.args)
141-
if (argv.kubeVersion) argsArr.push(`--kube-version=${argv.kubeVersion}`)
142-
return ['--args', argsArr.join(' ')]
143-
}
144-
145142
export const hfTemplate = async (
146143
argv: HelmArguments,
147144
outDir?: string,
@@ -150,16 +147,14 @@ export const hfTemplate = async (
150147
): Promise<string> => {
151148
const d = terminal('common:hf:hfTemplate')
152149
process.env.QUIET = '1'
153-
// const args = ['template', '--validate']
154-
const args = ['template', '--include-needs']
150+
const args = ['template', '--include-needs', '--skip-tests']
155151
if (outDir) args.push(`--output-dir=${outDir}`)
156152
if (argv.skipCleanup || isCore) args.push('--skip-cleanup')
157-
const helmArgs = getHelmArgs(argv, ['--skip-tests'])
158-
args.push(...helmArgs)
153+
if (argv.kubeVersion) args.push(`--kube-version=${argv.kubeVersion}`)
159154
let template = ''
160155
const params: HFParams = { args, fileOpts: argv.file, labelOpts: argv.label, logLevel: argv.logLevel }
161156
if (!argv.f && !argv.l) {
162-
const file = 'helmfile.tpl/helmfile-init.yaml'
157+
const file = 'helmfile.tpl/helmfile-init.yaml.gotmpl'
163158
d.debug(`# Templating ${file} started`)
164159
const outInit = await hf({ ...params, fileOpts: file }, { streams }, envDir)
165160
d.debug(`# Templating ${file} done`)

src/common/yargs.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ const helmOpts: { [key: string]: Options } = {
5555
file: {
5656
alias: 'f',
5757
array: true,
58-
describe: "Select helmfiles by filename, e.g. '-f helmfile.d/helmfile-15.ingress-core.yaml'",
58+
describe: "Select helmfiles by filename, e.g. '-f helmfile.d/helmfile-15.ingress-core.yaml.gotmpl'",
5959
nargs: 1,
6060
coerce: (files: string[]) => {
6161
if (!files || files.length === 0) return files

src/dev/addApp.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ const generateAppsFile = async (projectDir: string, name: string): Promise<void>
7070
}
7171

7272
const generateHelmfileFile = async (projectDir: string, name: string): Promise<void> => {
73-
const helmfilePath = `${projectDir}/helmfile-${name}.yaml`
73+
const helmfilePath = `${projectDir}/helmfile-${name}.yaml.gotmpl`
7474
const helmfileChunkPath = `${helmfilePath}.chunk`
7575
const helmfileReleaseChunk = {
7676
releases: [

src/dev/bootstrapCoreApp.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ const generateAppsFile = async (projectDir: string, name: string): Promise<void>
7373
}
7474

7575
const generateHelmfileFile = async (projectDir: string, name: string): Promise<void> => {
76-
const helmfilePath = `${projectDir}/helmfile-${name}.yaml`
76+
const helmfilePath = `${projectDir}/helmfile-${name}.yaml.gotmpl`
7777
const helmfileChunkPath = `${helmfilePath}.chunk`
7878
const helmfileReleaseChunk = {
7979
releases: [

tests/network-policies/Readme.md

Lines changed: 1 addition & 1 deletion

tests/network-policies/helmfile-connectivity.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ environments:
9999
- https://apl-docs.net
100100
- https://116.203.255.68
101101
- https://httpbin.org/headers
102+
---
102103
releases:
103104
- name: inter-team-connectivity
104105
installed: true

tools/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ ARG AGE_VERSION=1.2.0
1818
# https://github.com/noqcks/gucci/releases
1919
ARG GUCCI_VERSION=1.6.13
2020
# https://github.com/helmfile/helmfile/releases
21-
ARG HELMFILE_VERSION=0.171.0
21+
ARG HELMFILE_VERSION=1.0.0
2222
# https://nodejs.org/en/download/
2323
ARG NODE_VERSION=20
2424

values/harbor/harbor.gotmpl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,6 @@ redis:
179179
priorityClassName: otomi-critical
180180
image:
181181
tag: {{ $tag }}
182-
internal:
183182
resources: {{- $h.resources.redis | toYaml | nindent 6 }}
184183

185184
registry:

0 commit comments

Comments
 (0)