@@ -7,7 +7,6 @@ import { create as createACR } from "../lib/azure/containerRegistryService";
7
7
import { create as createResourceGroup } from "../lib/azure/resourceService" ;
8
8
import { build as buildCmd , exit as exitCmd } from "../lib/commandBuilder" ;
9
9
import {
10
- ACR ,
11
10
RequestContext ,
12
11
RESOURCE_GROUP ,
13
12
RESOURCE_GROUP_LOCATION ,
@@ -18,10 +17,16 @@ import { getGitApi } from "../lib/setup/gitService";
18
17
import { createHLDtoManifestPipeline } from "../lib/setup/pipelineService" ;
19
18
import { createProjectIfNotExist } from "../lib/setup/projectService" ;
20
19
import { getAnswerFromFile , prompt } from "../lib/setup/prompt" ;
21
- import { hldRepo , manifestRepo } from "../lib/setup/scaffold" ;
20
+ import {
21
+ appRepo ,
22
+ helmRepo ,
23
+ hldRepo ,
24
+ manifestRepo
25
+ } from "../lib/setup/scaffold" ;
22
26
import { create as createSetupLog } from "../lib/setup/setupLog" ;
23
27
import { logger } from "../logger" ;
24
28
import decorator from "./setup.decorator.json" ;
29
+ import { IGitApi } from "azure-devops-node-api/GitApi" ;
25
30
26
31
interface CommandOptions {
27
32
file : string | undefined ;
@@ -79,6 +84,40 @@ export const getErrorMessage = (
79
84
return err . toString ( ) ;
80
85
} ;
81
86
87
+ export const createAppRepoTasks = async (
88
+ gitAPI : IGitApi ,
89
+ rc : RequestContext
90
+ ) : Promise < void > => {
91
+ if (
92
+ rc . toCreateAppRepo &&
93
+ rc . servicePrincipalId &&
94
+ rc . servicePrincipalPassword &&
95
+ rc . servicePrincipalTenantId &&
96
+ rc . subscriptionId &&
97
+ rc . acrName
98
+ ) {
99
+ rc . createdResourceGroup = await createResourceGroup (
100
+ rc . servicePrincipalId ,
101
+ rc . servicePrincipalPassword ,
102
+ rc . servicePrincipalTenantId ,
103
+ rc . subscriptionId ,
104
+ RESOURCE_GROUP ,
105
+ RESOURCE_GROUP_LOCATION
106
+ ) ;
107
+ rc . createdACR = await createACR (
108
+ rc . servicePrincipalId ,
109
+ rc . servicePrincipalPassword ,
110
+ rc . servicePrincipalTenantId ,
111
+ rc . subscriptionId ,
112
+ RESOURCE_GROUP ,
113
+ rc . acrName ,
114
+ RESOURCE_GROUP_LOCATION
115
+ ) ;
116
+ await helmRepo ( gitAPI , rc ) ;
117
+ await appRepo ( gitAPI , rc ) ;
118
+ }
119
+ } ;
120
+
82
121
/**
83
122
* Executes the command, can all exit function with 0 or 1
84
123
* when command completed successfully or failed respectively.
@@ -106,32 +145,7 @@ export const execute = async (
106
145
await hldRepo ( gitAPI , requestContext ) ;
107
146
await manifestRepo ( gitAPI , requestContext ) ;
108
147
await createHLDtoManifestPipeline ( buildAPI , requestContext ) ;
109
-
110
- if (
111
- requestContext . toCreateAppRepo &&
112
- requestContext . servicePrincipalId &&
113
- requestContext . servicePrincipalPassword &&
114
- requestContext . servicePrincipalTenantId &&
115
- requestContext . subscriptionId
116
- ) {
117
- requestContext . createdResourceGroup = await createResourceGroup (
118
- requestContext . servicePrincipalId ,
119
- requestContext . servicePrincipalPassword ,
120
- requestContext . servicePrincipalTenantId ,
121
- requestContext . subscriptionId ,
122
- RESOURCE_GROUP ,
123
- RESOURCE_GROUP_LOCATION
124
- ) ;
125
- requestContext . createdACR = await createACR (
126
- requestContext . servicePrincipalId ,
127
- requestContext . servicePrincipalPassword ,
128
- requestContext . servicePrincipalTenantId ,
129
- requestContext . subscriptionId ,
130
- RESOURCE_GROUP ,
131
- ACR ,
132
- RESOURCE_GROUP_LOCATION
133
- ) ;
134
- }
148
+ await createAppRepoTasks ( gitAPI , requestContext ) ;
135
149
136
150
createSetupLog ( requestContext ) ;
137
151
await exitFn ( 0 ) ;
0 commit comments