@@ -12,6 +12,8 @@ import { Argv } from 'yargs'
12
12
import { $ , cd } from 'zx'
13
13
import { Arguments as DroneArgs } from './gen-drone'
14
14
import { validateValues } from './validate-values'
15
+ import { CustomObjectsApi , KubeConfig } from '@kubernetes/client-node'
16
+ import retry from 'async-retry'
15
17
16
18
const cmdName = getFilename ( __filename )
17
19
@@ -104,17 +106,57 @@ export const cloneOtomiChartsInGitea = async (): Promise<void> => {
104
106
d . info ( 'Cloned apl-charts in Gitea' )
105
107
}
106
108
109
+ export async function retryCheckingForPipelinerun ( ) {
110
+ const d = terminal ( `cmd:${ cmdName } :apply` )
111
+ await retry (
112
+ async ( ) => {
113
+ await checkIfPipelineRunExists ( )
114
+ } ,
115
+ { retries : env . RETRIES , randomize : env . RANDOM , minTimeout : env . MIN_TIMEOUT , factor : env . FACTOR } ,
116
+ ) . catch ( ( e ) => {
117
+ d . error ( 'Error retrieving PipelineRuns:' , e )
118
+ throw e
119
+ } )
120
+ }
121
+
122
+ export async function checkIfPipelineRunExists ( ) : Promise < void > {
123
+ const d = terminal ( `cmd:${ cmdName } :pipelinerun` )
124
+ const kc = new KubeConfig ( )
125
+ kc . loadFromDefault ( )
126
+ const customObjectsApi = kc . makeApiClient ( CustomObjectsApi )
127
+
128
+ const response = await customObjectsApi . listNamespacedCustomObject (
129
+ 'tekton.dev' ,
130
+ 'v1beta1' ,
131
+ 'otomi-pipelines' ,
132
+ 'pipelineruns' ,
133
+ )
134
+
135
+ const pipelineRuns = ( response . body as { items : any [ ] } ) . items
136
+ if ( pipelineRuns . length === 0 ) {
137
+ d . info ( `No Tekton pipeline runs found, triggering a new one...` )
138
+ await $ `git commit --allow-empty -m "[apl-trigger]"`
139
+ await $ `git push`
140
+ throw new Error ( 'PipelineRun not found in otomi-pipelines namespace' )
141
+ }
142
+ d . info ( `There is a Tekton PipelineRuns continuing...` )
143
+ }
144
+
107
145
export const printWelcomeMessage = async ( ) : Promise < void > => {
108
146
const d = terminal ( `cmd:${ cmdName } :commit` )
109
147
const values = ( await hfValues ( ) ) as Record < string , any >
110
148
const credentials = values . apps . keycloak
111
149
const message = `
112
- ########################################################################################################################################
113
- #
114
- # To start using APL, go to https://console.${ values . cluster . domainSuffix } and sign in to the web console
115
- # with username "${ credentials . adminUsername } " and password "${ credentials . adminPassword } ".
116
- #
117
- ########################################################################################################################################`
150
+ ########################################################################################################################################
151
+ #
152
+ # Core apps installation complete! ArgoCD will now deploy the remaining applications.
153
+ # To monitor the progress, run: kubectl get applications -A
154
+ # Once ArgoCD finishes, you can start using APL. Visit: https://console.${ values . cluster . domainSuffix }
155
+ # Sign in to the web console with the following credentials:
156
+ # - Username: "${ credentials . adminUsername } "
157
+ # - Password: "${ credentials . adminPassword } "
158
+ #
159
+ ########################################################################################################################################`
118
160
d . info ( message )
119
161
}
120
162
0 commit comments