@@ -59,7 +59,7 @@ export class MicrocksContainer extends GenericContainer {
5959 /**
6060 * Provide urls of remote artifacts that will be imported as primary or main ones within the Microcks container
6161 * once it will be started and healthy.
62- * @param {[String ] } remoteArtifactUrls The urls or remote artifacts (OpenAPI, Postman collection, Protobuf, GraphQL schema, ...)
62+ * @param {[RemoteArtifact ] } remoteArtifactUrls Array of URLs (strings) or objects with {url, secretName} (OpenAPI, Postman collection, Protobuf, GraphQL schema, ...)
6363 * @returns this
6464 */
6565 public withMainRemoteArtifacts ( remoteArtifactUrls : RemoteArtifact [ ] ) : this {
@@ -70,7 +70,7 @@ export class MicrocksContainer extends GenericContainer {
7070 /**
7171 * Provide urls of remote artifacts that will be imported as secondary ones within the Microcks container
7272 * once it will be started and healthy.
73- * @param {[String ] } remoteArtifactUrls The furls or remote (OpenAPI, Postman collection, Protobuf, GraphQL schema, ...)
73+ * @param {[RemoteArtifact ] } remoteArtifactUrls Array of URLs (strings) or objects with {url, secretName} (OpenAPI, Postman collection, Protobuf, GraphQL schema, ...)
7474 * @returns this
7575 */
7676 public withSecondaryRemoteArtifacts ( remoteArtifactUrls : RemoteArtifact [ ] ) : this {
@@ -115,14 +115,14 @@ export class MicrocksContainer extends GenericContainer {
115115 }
116116 // Load remote artifacts before local ones.
117117 for ( let i = 0 ; i < this . mainRemoteArtifacts . length ; i ++ ) {
118- const { url , secretName} = this . mainRemoteArtifacts [ i ] ;
118+ const { url , secretName } = this . extractArtifactInfo ( this . mainRemoteArtifacts [ i ] ) ;
119119 await startedContainer . downloadAsMainArtifact ( url , secretName ) ;
120120 }
121121 for ( let i = 0 ; i < this . secondaryRemoteArtifacts . length ; i ++ ) {
122- const { url , secretName} = this . mainRemoteArtifacts [ i ] ;
122+ const { url , secretName } = this . extractArtifactInfo ( this . secondaryRemoteArtifacts [ i ] ) ;
123123 await startedContainer . downloadAsSecondaryArtifact ( url , secretName ) ;
124124 }
125- // Import artifacts declared in configuration.
125+ // Import artifacts declared in configuration.
126126 for ( let i = 0 ; i < this . mainArtifacts . length ; i ++ ) {
127127 await startedContainer . importAsMainArtifact ( this . mainArtifacts [ i ] ) ;
128128 }
@@ -135,6 +135,12 @@ export class MicrocksContainer extends GenericContainer {
135135
136136 return startedContainer ;
137137 }
138+
139+ private extractArtifactInfo ( artifact : RemoteArtifact ) : { url : string ; secretName ?: string } {
140+ return typeof artifact === 'string'
141+ ? { url : artifact }
142+ : { url : artifact . url , secretName : artifact . secretName } ;
143+ }
138144}
139145
140146export enum OAuth2GrantType {
@@ -289,7 +295,7 @@ export interface DailyInvocationStatistic {
289295 minuteCount : { string : number } ;
290296}
291297
292- export interface RemoteArtifact {
298+ export type RemoteArtifact = string | {
293299 url : string ;
294300 secretName ?: string ;
295301}
@@ -604,7 +610,6 @@ export class StartedMicrocksContainer extends AbstractStartedContainer {
604610 return invocationStats . dailyCount ;
605611 }
606612
607-
608613 private async importArtifact ( artifactPath : string , mainArtifact : boolean ) : Promise < void > {
609614 const isFile = await this . isFile ( artifactPath ) ;
610615 if ( ! isFile ) {
0 commit comments