@@ -24,7 +24,7 @@ import {Exec} from '../exec';
2424import { Util } from '../util' ;
2525
2626import { ExecOptions } from '@actions/exec' ;
27- import { BakeDefinition , CacheEntry , ExportEntry , SecretEntry , SSHEntry } from '../types/buildx/bake' ;
27+ import { AttestEntry , BakeDefinition , CacheEntry , ExportEntry , SecretEntry , SSHEntry } from '../types/buildx/bake' ;
2828import { BuildMetadata } from '../types/buildx/build' ;
2929import { VertexWarning } from '../types/buildkit/client' ;
3030
@@ -183,6 +183,11 @@ export class Bake {
183183 // convert to composable attributes: https://github.com/docker/buildx/pull/2758
184184 for ( const name in definition . target ) {
185185 const target = definition . target [ name ] ;
186+ if ( target [ 'attest' ] && Array . isArray ( target [ 'attest' ] ) ) {
187+ target [ 'attest' ] = target [ 'attest' ] . map ( ( item : string | AttestEntry ) : AttestEntry => {
188+ return Bake . parseAttestEntry ( item ) ;
189+ } ) ;
190+ }
186191 if ( target [ 'cache-from' ] && Array . isArray ( target [ 'cache-from' ] ) ) {
187192 target [ 'cache-from' ] = target [ 'cache-from' ] . map ( ( item : string | CacheEntry ) : CacheEntry => {
188193 return Bake . parseCacheEntry ( item ) ;
@@ -213,6 +218,34 @@ export class Bake {
213218 return definition ;
214219 }
215220
221+ private static parseAttestEntry ( item : AttestEntry | string ) : AttestEntry {
222+ if ( typeof item !== 'string' ) {
223+ return item ;
224+ }
225+
226+ const attestEntry : AttestEntry = { type : '' } ;
227+ const fields = parse ( item , {
228+ relaxColumnCount : true ,
229+ skipEmptyLines : true
230+ } ) [ 0 ] ;
231+
232+ for ( const field of fields ) {
233+ const [ key , value ] = field
234+ . toString ( )
235+ . split ( / (?< = ^ [ ^ = ] + ?) = / )
236+ . map ( ( item : string ) => item . trim ( ) ) ;
237+ switch ( key ) {
238+ case 'type' :
239+ attestEntry . type = value ;
240+ break ;
241+ default :
242+ attestEntry [ key ] = value ;
243+ }
244+ }
245+
246+ return attestEntry ;
247+ }
248+
216249 private static parseCacheEntry ( item : CacheEntry | string ) : CacheEntry {
217250 if ( typeof item !== 'string' ) {
218251 return item ;
0 commit comments