11import Table from "cli-table" ;
22import commander from "commander" ;
3- import Deployment from "spektate/lib/Deployment" ;
3+ import {
4+ duration ,
5+ getDeploymentsBasedOnFilters ,
6+ IDeployment ,
7+ status as getDeploymentStatus
8+ } from "spektate/lib/IDeployment" ;
49import AzureDevOpsPipeline from "spektate/lib/pipeline/AzureDevOpsPipeline" ;
5- import { AzureDevOpsRepo } from "spektate/lib/repository/AzureDevOpsRepo" ;
6- import { GitHub } from "spektate/lib/repository/GitHub" ;
7- import { IRepository } from "spektate/lib/repository/Repository" ;
10+ import {
11+ getManifestSyncState as getAzureManifestSyncState ,
12+ IAzureDevOpsRepo
13+ } from "spektate/lib/repository/IAzureDevOpsRepo" ;
14+ import {
15+ getManifestSyncState as getGithubManifestSyncState ,
16+ IGitHub
17+ } from "spektate/lib/repository/IGitHub" ;
818import { ITag } from "spektate/lib/repository/Tag" ;
919import { Config } from "../../config" ;
1020import { build as buildCmd , exit as exitCmd } from "../../lib/commandBuilder" ;
@@ -152,10 +162,10 @@ export const processOutputFormat = (outputFormat: string): OUTPUT_FORMAT => {
152162export const getDeployments = (
153163 initObj : IInitObject ,
154164 values : IValidatedOptions
155- ) : Promise < Deployment [ ] > => {
165+ ) : Promise < IDeployment [ ] > => {
156166 const config = initObj . config ;
157167 const syncStatusesPromise = getClusterSyncStatuses ( initObj ) ;
158- const deploymentsPromise = Deployment . getDeploymentsBasedOnFilters (
168+ const deploymentsPromise = getDeploymentsBasedOnFilters (
159169 config . introspection ! . azure ! . account_name ! ,
160170 initObj . key ,
161171 config . introspection ! . azure ! . table_name ! ,
@@ -172,8 +182,8 @@ export const getDeployments = (
172182 ) ;
173183 return new Promise ( ( resolve , reject ) => {
174184 Promise . all ( [ deploymentsPromise , syncStatusesPromise ] )
175- . then ( ( tuple : [ Deployment [ ] | undefined , ITag [ ] | undefined ] ) => {
176- const deployments : Deployment [ ] | undefined = tuple [ 0 ] ;
185+ . then ( ( tuple : [ IDeployment [ ] | undefined , ITag [ ] | undefined ] ) => {
186+ const deployments : IDeployment [ ] | undefined = tuple [ 0 ] ;
177187 const syncStatuses : ITag [ ] | undefined = tuple [ 1 ] ;
178188 if ( values . outputFormat === OUTPUT_FORMAT . JSON ) {
179189 // tslint:disable-next-line: no-console
@@ -212,14 +222,15 @@ export const getClusterSyncStatuses = (
212222 const manifestUrlSplit = config . azure_devops ?. manifest_repository . split (
213223 "/"
214224 ) ;
215- const manifestRepo : IRepository = new AzureDevOpsRepo (
216- manifestUrlSplit [ 3 ] ,
217- manifestUrlSplit [ 4 ] ,
218- manifestUrlSplit [ 6 ] ,
225+ const manifestRepo : IAzureDevOpsRepo = {
226+ org : manifestUrlSplit [ 3 ] ,
227+ project : manifestUrlSplit [ 4 ] ,
228+ repo : manifestUrlSplit [ 6 ]
229+ } ;
230+ getAzureManifestSyncState (
231+ manifestRepo ,
219232 config . azure_devops . access_token
220- ) ;
221- manifestRepo
222- . getManifestSyncState ( )
233+ )
223234 . then ( ( syncCommits : ITag [ ] ) => {
224235 resolve ( syncCommits ) ;
225236 } )
@@ -233,13 +244,15 @@ export const getClusterSyncStatuses = (
233244 const manifestUrlSplit = config . azure_devops ?. manifest_repository . split (
234245 "/"
235246 ) ;
236- const manifestRepo : IRepository = new GitHub (
237- manifestUrlSplit [ 3 ] ,
238- manifestUrlSplit [ 4 ] ,
247+ const manifestRepo : IGitHub = {
248+ reponame : manifestUrlSplit [ 4 ] ,
249+ username : manifestUrlSplit [ 3 ]
250+ } ;
251+
252+ getGithubManifestSyncState (
253+ manifestRepo ,
239254 config . azure_devops . access_token
240- ) ;
241- manifestRepo
242- . getManifestSyncState ( )
255+ )
243256 . then ( ( syncCommits : ITag [ ] ) => {
244257 resolve ( syncCommits ) ;
245258 } )
@@ -330,7 +343,7 @@ export const watchGetDeployments = async (
330343 * @param outputFormat output format: normal | wide | json
331344 */
332345export const printDeployments = (
333- deployments : Deployment [ ] | undefined ,
346+ deployments : IDeployment [ ] | undefined ,
334347 outputFormat : OUTPUT_FORMAT ,
335348 limit ?: number ,
336349 syncStatuses ?: ITag [ ] | undefined
@@ -440,8 +453,8 @@ export const printDeployments = (
440453 : ""
441454 ) ;
442455 if ( outputFormat === OUTPUT_FORMAT . WIDE ) {
443- row . push ( deployment . duration ( ) + " mins" ) ;
444- row . push ( deployment . status ( ) ) ;
456+ row . push ( duration ( deployment ) + " mins" ) ;
457+ row . push ( getDeploymentStatus ( deployment ) ) ;
445458 row . push ( deployment . manifestCommitId || "-" ) ;
446459 row . push (
447460 deployment . hldToManifestBuild &&
@@ -481,7 +494,7 @@ export const printDeployments = (
481494 * @param syncStatuses list of sync statuses for manifest
482495 */
483496export const getClusterSyncStatusForDeployment = (
484- deployment : Deployment ,
497+ deployment : IDeployment ,
485498 syncStatuses : ITag [ ]
486499) : ITag | undefined => {
487500 return syncStatuses . find ( tag => tag . commit === deployment . manifestCommitId ) ;
0 commit comments