Skip to content

Commit d3e0783

Browse files
feat: improve installer job feedback (#1755)
Co-authored-by: jeho <[email protected]>
1 parent b64c334 commit d3e0783

File tree

8 files changed

+494
-55
lines changed

8 files changed

+494
-55
lines changed

charts/otomi-pipelines/templates/tekton-otomi-task.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,4 @@ spec:
8282
set -e
8383
# Prevent the detected dubious ownership in repository error
8484
git config --global --add safe.directory '*'
85-
binzx/otomi apply
85+
binzx/otomi apply --tekton

package-lock.json

+31-31
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/cmd/apply.ts

+22-9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import retry, { Options } from 'async-retry'
22
import { mkdirSync, rmdirSync, writeFileSync } from 'fs'
3-
import { cloneDeep, isEmpty } from 'lodash'
3+
import { cloneDeep } from 'lodash'
44
import { prepareDomainSuffix } from 'src/common/bootstrap'
55
import { cleanupHandler, prepareEnvironment } from 'src/common/cli'
66
import { logLevelString, terminal } from 'src/common/debug'
@@ -14,7 +14,13 @@ import { ProcessOutputTrimmed } from 'src/common/zx-enhance'
1414
import { Argv, CommandModule } from 'yargs'
1515
import { $, nothrow } from 'zx'
1616
import { applyAsApps } from './apply-as-apps'
17-
import { cloneOtomiChartsInGitea, commit, printWelcomeMessage, retryCheckingForPipelinerun } from './commit'
17+
import {
18+
cloneOtomiChartsInGitea,
19+
commit,
20+
printWelcomeMessage,
21+
retryCheckingForPipelineRun,
22+
retryIsOAuth2ProxyRunning,
23+
} from './commit'
1824
import { upgrade } from './upgrade'
1925

2026
const cmdName = getFilename(__filename)
@@ -35,9 +41,9 @@ const setup = (): void => {
3541
const applyAll = async () => {
3642
const d = terminal(`cmd:${cmdName}:applyAll`)
3743
const prevState = await getDeploymentState()
38-
const intitalInstall = isEmpty(prevState.version)
3944
const argv: HelmArguments = getParsedArgs()
40-
const hfArgs = intitalInstall
45+
const initialInstall = !argv.tekton
46+
const hfArgs = initialInstall
4147
? ['sync', '--concurrency=1', '--sync-args', '--disable-openapi-validation --qps=20']
4248
: ['apply', '--sync-args', '--qps=20']
4349

@@ -83,7 +89,7 @@ const applyAll = async () => {
8389
await prepareDomainSuffix()
8490

8591
let labelOpts = ['']
86-
if (intitalInstall) {
92+
if (initialInstall) {
8793
// When Otomi is installed for the very first time and ArgoCD is not yet there.
8894
// Only install the core apps
8995
labelOpts = ['app=core']
@@ -109,7 +115,7 @@ const applyAll = async () => {
109115
await upgrade({ when: 'post' })
110116
if (!(env.isDev && env.DISABLE_SYNC)) {
111117
await commit()
112-
if (intitalInstall) {
118+
if (initialInstall) {
113119
await hf(
114120
{
115121
// 'fileOpts' limits the hf scope and avoids parse errors (we only have basic values in this statege):
@@ -120,7 +126,8 @@ const applyAll = async () => {
120126
{ streams: { stdout: d.stream.log, stderr: d.stream.error } },
121127
)
122128
await cloneOtomiChartsInGitea()
123-
await retryCheckingForPipelinerun()
129+
await retryCheckingForPipelineRun()
130+
await retryIsOAuth2ProxyRunning()
124131
await printWelcomeMessage()
125132
}
126133
}
@@ -167,8 +174,14 @@ const apply = async (): Promise<void> => {
167174
export const module: CommandModule = {
168175
command: cmdName,
169176
describe: 'Apply all, or supplied, k8s resources',
170-
builder: (parser: Argv): Argv => helmOptions(parser),
171-
177+
builder: (parser: Argv): Argv =>
178+
helmOptions(parser).option({
179+
tekton: {
180+
type: 'boolean',
181+
description: 'Apply flag when run in tekton pipeline',
182+
default: false,
183+
},
184+
}),
172185
handler: async (argv: HelmArguments): Promise<void> => {
173186
setParsedArgs(argv)
174187
setup()

0 commit comments

Comments
 (0)