@@ -21,6 +21,18 @@ import {parse} from 'csv-parse/sync';
2121
2222import { Context } from '../context' ;
2323
24+ const parseKvp = ( kvp : string ) : [ string , string ] => {
25+ const delimiterIndex = kvp . indexOf ( '=' ) ;
26+ const key = kvp . substring ( 0 , delimiterIndex ) ;
27+ const value = kvp . substring ( delimiterIndex + 1 ) ;
28+
29+ if ( key . length == 0 || value . length == 0 ) {
30+ throw new Error ( `${ kvp } is not a valid secret` ) ;
31+ }
32+
33+ return [ key , value ] ;
34+ } ;
35+
2436export class Inputs {
2537 public static getBuildImageIDFilePath ( ) : string {
2638 return path . join ( Context . tmpDir ( ) , 'iidfile' ) ;
@@ -70,13 +82,17 @@ export class Inputs {
7082 return Inputs . resolveBuildSecret ( kvp , true ) ;
7183 }
7284
85+ public static resolveBuildSecretEnv ( kvp : string ) : string {
86+ const [ key , value ] = parseKvp ( kvp ) ;
87+
88+ return `id=${ key } ,env="${ value } "` ;
89+ }
90+
7391 public static resolveBuildSecret ( kvp : string , file : boolean ) : string {
74- const delimiterIndex = kvp . indexOf ( '=' ) ;
75- const key = kvp . substring ( 0 , delimiterIndex ) ;
76- let value = kvp . substring ( delimiterIndex + 1 ) ;
77- if ( key . length == 0 || value . length == 0 ) {
78- throw new Error ( `${ kvp } is not a valid secret` ) ;
79- }
92+ const [ key , _value ] = parseKvp ( kvp ) ;
93+
94+ let value = _value ;
95+
8096 if ( file ) {
8197 if ( ! fs . existsSync ( value ) ) {
8298 throw new Error ( `secret file ${ value } not found` ) ;
0 commit comments