1
1
import retry , { Options } from 'async-retry'
2
2
import { mkdirSync , rmdirSync , writeFileSync } from 'fs'
3
- import { cloneDeep , isEmpty } from 'lodash'
3
+ import { cloneDeep } from 'lodash'
4
4
import { prepareDomainSuffix } from 'src/common/bootstrap'
5
5
import { cleanupHandler , prepareEnvironment } from 'src/common/cli'
6
6
import { logLevelString , terminal } from 'src/common/debug'
@@ -14,7 +14,13 @@ import { ProcessOutputTrimmed } from 'src/common/zx-enhance'
14
14
import { Argv , CommandModule } from 'yargs'
15
15
import { $ , nothrow } from 'zx'
16
16
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'
18
24
import { upgrade } from './upgrade'
19
25
20
26
const cmdName = getFilename ( __filename )
@@ -35,9 +41,9 @@ const setup = (): void => {
35
41
const applyAll = async ( ) => {
36
42
const d = terminal ( `cmd:${ cmdName } :applyAll` )
37
43
const prevState = await getDeploymentState ( )
38
- const intitalInstall = isEmpty ( prevState . version )
39
44
const argv : HelmArguments = getParsedArgs ( )
40
- const hfArgs = intitalInstall
45
+ const initialInstall = ! argv . tekton
46
+ const hfArgs = initialInstall
41
47
? [ 'sync' , '--concurrency=1' , '--sync-args' , '--disable-openapi-validation --qps=20' ]
42
48
: [ 'apply' , '--sync-args' , '--qps=20' ]
43
49
@@ -83,7 +89,7 @@ const applyAll = async () => {
83
89
await prepareDomainSuffix ( )
84
90
85
91
let labelOpts = [ '' ]
86
- if ( intitalInstall ) {
92
+ if ( initialInstall ) {
87
93
// When Otomi is installed for the very first time and ArgoCD is not yet there.
88
94
// Only install the core apps
89
95
labelOpts = [ 'app=core' ]
@@ -109,7 +115,7 @@ const applyAll = async () => {
109
115
await upgrade ( { when : 'post' } )
110
116
if ( ! ( env . isDev && env . DISABLE_SYNC ) ) {
111
117
await commit ( )
112
- if ( intitalInstall ) {
118
+ if ( initialInstall ) {
113
119
await hf (
114
120
{
115
121
// 'fileOpts' limits the hf scope and avoids parse errors (we only have basic values in this statege):
@@ -120,7 +126,8 @@ const applyAll = async () => {
120
126
{ streams : { stdout : d . stream . log , stderr : d . stream . error } } ,
121
127
)
122
128
await cloneOtomiChartsInGitea ( )
123
- await retryCheckingForPipelinerun ( )
129
+ await retryCheckingForPipelineRun ( )
130
+ await retryIsOAuth2ProxyRunning ( )
124
131
await printWelcomeMessage ( )
125
132
}
126
133
}
@@ -167,8 +174,14 @@ const apply = async (): Promise<void> => {
167
174
export const module : CommandModule = {
168
175
command : cmdName ,
169
176
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
+ } ) ,
172
185
handler : async ( argv : HelmArguments ) : Promise < void > => {
173
186
setParsedArgs ( argv )
174
187
setup ( )
0 commit comments