From 7cb8096d4ea0e5b59f74c5c35b996736ab55ca66 Mon Sep 17 00:00:00 2001 From: Jacob Gillespie Date: Mon, 6 Jun 2022 10:34:13 +0100 Subject: [PATCH] Log error if unable to acquire OIDC token --- dist/index.js | 2 +- src/depot.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/dist/index.js b/dist/index.js index 9229063..24a18ba 100644 --- a/dist/index.js +++ b/dist/index.js @@ -31,7 +31,7 @@ Expecting `+g1.join(", ")+", got '"+(this.terminals_[A]||A)+"'":V="Parse error o `.trim()},blockValue:function(e){var a=this.aliasable("container.hooks.blockHelperMissing"),r=[this.contextName(0)];this.setupHelperArgs(e,0,r);var p=this.popStack();r.splice(1,0,p),this.push(this.source.functionCall(a,"call",r))},ambiguousBlockValue:function(){var e=this.aliasable("container.hooks.blockHelperMissing"),a=[this.contextName(0)];this.setupHelperArgs("",0,a,!0),this.flushInline();var r=this.topStack();a.splice(1,0,r),this.pushSource(["if (!",this.lastHelper,") { ",r," = ",this.source.functionCall(e,"call",a),"}"])},appendContent:function(e){this.pendingContent?e=this.pendingContent+e:this.pendingLocation=this.source.currentLocation,this.pendingContent=e},append:function(){if(this.isInline())this.replaceStack(function(a){return[" != null ? ",a,' : ""']}),this.pushSource(this.appendToBuffer(this.popStack()));else{var e=this.popStack();this.pushSource(["if (",e," != null) { ",this.appendToBuffer(e,void 0,!0)," }"]),this.environment.isSimple&&this.pushSource(["else { ",this.appendToBuffer("''",void 0,!0)," }"])}},appendEscaped:function(){this.pushSource(this.appendToBuffer([this.aliasable("container.escapeExpression"),"(",this.popStack(),")"]))},getContext:function(e){this.lastContext=e},pushContext:function(){this.pushStackLiteral(this.contextName(this.lastContext))},lookupOnContext:function(e,a,r,p){var i=0;!p&&this.options.compat&&!this.lastContext?this.push(this.depthedLookup(e[i++])):this.pushContext(),this.resolvePath("context",e,i,a,r)},lookupBlockParam:function(e,a){this.useBlockParams=!0,this.push(["blockParams[",e[0],"][",e[1],"]"]),this.resolvePath("context",a,1)},lookupData:function(e,a,r){e?this.pushStackLiteral("container.data(data, "+e+")"):this.pushStackLiteral("data"),this.resolvePath("data",a,0,!0,r)},resolvePath:function(e,a,r,p,i){var s=this;if(this.options.strict||this.options.assumeObjects){this.push(D9(this.options.strict&&i,this,a,e));return}for(var o=a.length;rthis.stackVars.length&&this.stackVars.push("stack"+this.stackSlot),this.topStackName()},topStackName:function(){return"stack"+this.stackSlot},flushInline:function(){var e=this.inlineStack;this.inlineStack=[];for(var a=0,r=e.length;a{"use strict";Ra.__esModule=!0;function wt(t){return t&&t.__esModule?t:{default:t}}var k9=On(),A9=wt(k9),C9=np(),R9=wt(C9),Rp=Fn(),Gp=Mn(),G9=Ed(),L9=wt(G9),V9=ya(),I9=wt(V9),x9=pp(),F9=wt(x9),U9=A9.default.create;function yd(){var t=U9();return t.compile=function(e,a){return Gp.compile(e,a,t)},t.precompile=function(e,a){return Gp.precompile(e,a,t)},t.AST=R9.default,t.Compiler=Gp.Compiler,t.JavaScriptCompiler=L9.default,t.Parser=Rp.parser,t.parse=Rp.parse,t.parseWithoutProcessing=Rp.parseWithoutProcessing,t}var M1=yd();M1.create=yd;F9.default(M1);M1.Visitor=I9.default;M1.default=M1;Ra.default=M1;Td.exports=Ra.default});var Od=c(Ga=>{"use strict";Ga.__esModule=!0;Ga.print=j9;Ga.PrintVisitor=q;function B9(t){return t&&t.__esModule?t:{default:t}}var q9=ya(),M9=B9(q9);function j9(t){return new q().accept(t)}function q(){this.padding=0}q.prototype=new M9.default;q.prototype.pad=function(t){for(var e="",a=0,r=this.padding;a "+e+" }}")};q.prototype.PartialBlockStatement=function(t){var e="PARTIAL BLOCK:"+t.name.original;return t.params[0]&&(e+=" "+this.accept(t.params[0])),t.hash&&(e+=" "+this.accept(t.hash)),e+=" "+this.pad("PROGRAM:"),this.padding++,e+=this.accept(t.program),this.padding--,this.pad("{{> "+e+" }}")};q.prototype.ContentStatement=function(t){return this.pad("CONTENT[ '"+t.value+"' ]")};q.prototype.CommentStatement=function(t){return this.pad("{{! '"+t.value+"' }}")};q.prototype.SubExpression=function(t){for(var e=t.params,a=[],r=void 0,p=0,i=e.length;p=this.size&&(this.resize(),a>=this.size))throw Error("INVALID_BUFFER_STATE");let r=this.buf;this.buf=Buffer.allocUnsafe(this.size),e.copy(this.buf,0),r.copy(this.buf,e.length),this.length+=e.length}else{let a=this.length++;a===this.size&&this.resize();let r=this.clone();this.buf[0]=e,r.copy(this.buf,1,0,a)}}append(e){let a=this.length++;a===this.size&&this.resize(),this.buf[a]=e}clone(){return Buffer.from(this.buf.slice(0,this.length))}resize(){let e=this.length;this.size=this.size*2;let a=Buffer.allocUnsafe(this.size);this.buf.copy(a,0,0,e),this.buf=a}toString(e){return e?this.buf.slice(0,this.length).toString(e):Uint8Array.prototype.slice.call(this.buf.slice(0,this.length))}toJSON(){return this.toString("utf8")}reset(){this.length=0}},Gr=Rr;var so=function(t){return{bomSkipped:!1,bufBytesStart:0,castField:t.cast_function,commenting:!1,error:void 0,enabled:t.from_line===1,escaping:!1,escapeIsQuote:Buffer.isBuffer(t.escape)&&Buffer.isBuffer(t.quote)&&Buffer.compare(t.escape,t.quote)===0,expectedRecordLength:Array.isArray(t.columns)?t.columns.length:void 0,field:new Gr(20),firstLineToHeaders:t.cast_first_line_to_header,needMoreDataSize:Math.max(t.comment!==null?t.comment.length:0,...t.delimiter.map(e=>e.length),t.quote!==null?t.quote.length:0),previousBuf:void 0,quoting:!1,stop:!1,rawBuffer:new Gr(100),record:[],recordHasError:!1,record_length:0,recordDelimiterMaxLength:t.record_delimiter.length===0?2:Math.max(...t.record_delimiter.map(e=>e.length)),trimChars:[Buffer.from(" ",t.encoding)[0],Buffer.from(" ",t.encoding)[0]],wasQuoting:!1,wasRowDelimiter:!1}};var oo=function(t){return t.replace(/([A-Z])/g,function(e,a){return"_"+a.toLowerCase()})};var Lr=function(t){let e={};for(let r in t)e[oo(r)]=t[r];if(e.encoding===void 0||e.encoding===!0)e.encoding="utf8";else if(e.encoding===null||e.encoding===!1)e.encoding=null;else if(typeof e.encoding!="string"&&e.encoding!==null)throw new P("CSV_INVALID_OPTION_ENCODING",["Invalid option encoding:","encoding must be a string or null to return a buffer,",`got ${JSON.stringify(e.encoding)}`],e);if(e.bom===void 0||e.bom===null||e.bom===!1)e.bom=!1;else if(e.bom!==!0)throw new P("CSV_INVALID_OPTION_BOM",["Invalid option bom:","bom must be true,",`got ${JSON.stringify(e.bom)}`],e);if(e.cast_function=null,e.cast===void 0||e.cast===null||e.cast===!1||e.cast==="")e.cast=void 0;else if(typeof e.cast=="function")e.cast_function=e.cast,e.cast=!0;else if(e.cast!==!0)throw new P("CSV_INVALID_OPTION_CAST",["Invalid option cast:","cast must be true or a function,",`got ${JSON.stringify(e.cast)}`],e);if(e.cast_date===void 0||e.cast_date===null||e.cast_date===!1||e.cast_date==="")e.cast_date=!1;else if(e.cast_date===!0)e.cast_date=function(r){let p=Date.parse(r);return isNaN(p)?r:new Date(p)};else throw new P("CSV_INVALID_OPTION_CAST_DATE",["Invalid option cast_date:","cast_date must be true or a function,",`got ${JSON.stringify(e.cast_date)}`],e);if(e.cast_first_line_to_header=null,e.columns===!0)e.cast_first_line_to_header=void 0;else if(typeof e.columns=="function")e.cast_first_line_to_header=e.columns,e.columns=!0;else if(Array.isArray(e.columns))e.columns=qt(e.columns);else if(e.columns===void 0||e.columns===null||e.columns===!1)e.columns=!1;else throw new P("CSV_INVALID_OPTION_COLUMNS",["Invalid option columns:","expect an array, a function or true,",`got ${JSON.stringify(e.columns)}`],e);if(e.group_columns_by_name===void 0||e.group_columns_by_name===null||e.group_columns_by_name===!1)e.group_columns_by_name=!1;else{if(e.group_columns_by_name!==!0)throw new P("CSV_INVALID_OPTION_GROUP_COLUMNS_BY_NAME",["Invalid option group_columns_by_name:","expect an boolean,",`got ${JSON.stringify(e.group_columns_by_name)}`],e);if(e.columns===!1)throw new P("CSV_INVALID_OPTION_GROUP_COLUMNS_BY_NAME",["Invalid option group_columns_by_name:","the `columns` mode must be activated."],e)}if(e.comment===void 0||e.comment===null||e.comment===!1||e.comment==="")e.comment=null;else if(typeof e.comment=="string"&&(e.comment=Buffer.from(e.comment,e.encoding)),!Buffer.isBuffer(e.comment))throw new P("CSV_INVALID_OPTION_COMMENT",["Invalid option comment:","comment must be a buffer or a string,",`got ${JSON.stringify(e.comment)}`],e);let a=JSON.stringify(e.delimiter);if(Array.isArray(e.delimiter)||(e.delimiter=[e.delimiter]),e.delimiter.length===0)throw new P("CSV_INVALID_OPTION_DELIMITER",["Invalid option delimiter:","delimiter must be a non empty string or buffer or array of string|buffer,",`got ${a}`],e);if(e.delimiter=e.delimiter.map(function(r){if(r==null||r===!1)return Buffer.from(",",e.encoding);if(typeof r=="string"&&(r=Buffer.from(r,e.encoding)),!Buffer.isBuffer(r)||r.length===0)throw new P("CSV_INVALID_OPTION_DELIMITER",["Invalid option delimiter:","delimiter must be a non empty string or buffer or array of string|buffer,",`got ${a}`],e);return r}),e.escape===void 0||e.escape===!0?e.escape=Buffer.from('"',e.encoding):typeof e.escape=="string"?e.escape=Buffer.from(e.escape,e.encoding):(e.escape===null||e.escape===!1)&&(e.escape=null),e.escape!==null&&!Buffer.isBuffer(e.escape))throw new Error(`Invalid Option: escape must be a buffer, a string or a boolean, got ${JSON.stringify(e.escape)}`);if(e.from===void 0||e.from===null)e.from=1;else if(typeof e.from=="string"&&/\d+/.test(e.from)&&(e.from=parseInt(e.from)),Number.isInteger(e.from)){if(e.from<0)throw new Error(`Invalid Option: from must be a positive integer, got ${JSON.stringify(t.from)}`)}else throw new Error(`Invalid Option: from must be an integer, got ${JSON.stringify(e.from)}`);if(e.from_line===void 0||e.from_line===null)e.from_line=1;else if(typeof e.from_line=="string"&&/\d+/.test(e.from_line)&&(e.from_line=parseInt(e.from_line)),Number.isInteger(e.from_line)){if(e.from_line<=0)throw new Error(`Invalid Option: from_line must be a positive integer greater than 0, got ${JSON.stringify(t.from_line)}`)}else throw new Error(`Invalid Option: from_line must be an integer, got ${JSON.stringify(t.from_line)}`);if(e.ignore_last_delimiters===void 0||e.ignore_last_delimiters===null)e.ignore_last_delimiters=!1;else if(typeof e.ignore_last_delimiters=="number")e.ignore_last_delimiters=Math.floor(e.ignore_last_delimiters),e.ignore_last_delimiters===0&&(e.ignore_last_delimiters=!1);else if(typeof e.ignore_last_delimiters!="boolean")throw new P("CSV_INVALID_OPTION_IGNORE_LAST_DELIMITERS",["Invalid option `ignore_last_delimiters`:","the value must be a boolean value or an integer,",`got ${JSON.stringify(e.ignore_last_delimiters)}`],e);if(e.ignore_last_delimiters===!0&&e.columns===!1)throw new P("CSV_IGNORE_LAST_DELIMITERS_REQUIRES_COLUMNS",["The option `ignore_last_delimiters`","requires the activation of the `columns` option"],e);if(e.info===void 0||e.info===null||e.info===!1)e.info=!1;else if(e.info!==!0)throw new Error(`Invalid Option: info must be true, got ${JSON.stringify(e.info)}`);if(e.max_record_size===void 0||e.max_record_size===null||e.max_record_size===!1)e.max_record_size=0;else if(!(Number.isInteger(e.max_record_size)&&e.max_record_size>=0))if(typeof e.max_record_size=="string"&&/\d+/.test(e.max_record_size))e.max_record_size=parseInt(e.max_record_size);else throw new Error(`Invalid Option: max_record_size must be a positive integer, got ${JSON.stringify(e.max_record_size)}`);if(e.objname===void 0||e.objname===null||e.objname===!1)e.objname=void 0;else if(Buffer.isBuffer(e.objname)){if(e.objname.length===0)throw new Error("Invalid Option: objname must be a non empty buffer");e.encoding===null||(e.objname=e.objname.toString(e.encoding))}else if(typeof e.objname=="string"){if(e.objname.length===0)throw new Error("Invalid Option: objname must be a non empty string")}else if(typeof e.objname!="number")throw new Error(`Invalid Option: objname must be a string or a buffer, got ${e.objname}`);if(e.objname!==void 0){if(typeof e.objname=="number"){if(e.columns!==!1)throw Error("Invalid Option: objname index cannot be combined with columns or be defined as a field")}else if(e.columns===!1)throw Error("Invalid Option: objname field must be combined with columns or be defined as an index")}if(e.on_record===void 0||e.on_record===null)e.on_record=void 0;else if(typeof e.on_record!="function")throw new P("CSV_INVALID_OPTION_ON_RECORD",["Invalid option `on_record`:","expect a function,",`got ${JSON.stringify(e.on_record)}`],e);if(e.quote===null||e.quote===!1||e.quote==="")e.quote=null;else if(e.quote===void 0||e.quote===!0?e.quote=Buffer.from('"',e.encoding):typeof e.quote=="string"&&(e.quote=Buffer.from(e.quote,e.encoding)),!Buffer.isBuffer(e.quote))throw new Error(`Invalid Option: quote must be a buffer or a string, got ${JSON.stringify(e.quote)}`);if(e.raw===void 0||e.raw===null||e.raw===!1)e.raw=!1;else if(e.raw!==!0)throw new Error(`Invalid Option: raw must be true, got ${JSON.stringify(e.raw)}`);if(e.record_delimiter===void 0)e.record_delimiter=[];else if(typeof e.record_delimiter=="string"||Buffer.isBuffer(e.record_delimiter)){if(e.record_delimiter.length===0)throw new P("CSV_INVALID_OPTION_RECORD_DELIMITER",["Invalid option `record_delimiter`:","value must be a non empty string or buffer,",`got ${JSON.stringify(e.record_delimiter)}`],e);e.record_delimiter=[e.record_delimiter]}else if(!Array.isArray(e.record_delimiter))throw new P("CSV_INVALID_OPTION_RECORD_DELIMITER",["Invalid option `record_delimiter`:","value must be a string, a buffer or array of string|buffer,",`got ${JSON.stringify(e.record_delimiter)}`],e);if(e.record_delimiter=e.record_delimiter.map(function(r,p){if(typeof r!="string"&&!Buffer.isBuffer(r))throw new P("CSV_INVALID_OPTION_RECORD_DELIMITER",["Invalid option `record_delimiter`:","value must be a string, a buffer or array of string|buffer",`at index ${p},`,`got ${JSON.stringify(r)}`],e);if(r.length===0)throw new P("CSV_INVALID_OPTION_RECORD_DELIMITER",["Invalid option `record_delimiter`:","value must be a non empty string or buffer",`at index ${p},`,`got ${JSON.stringify(r)}`],e);return typeof r=="string"&&(r=Buffer.from(r,e.encoding)),r}),typeof e.relax_column_count!="boolean")if(e.relax_column_count===void 0||e.relax_column_count===null)e.relax_column_count=!1;else throw new Error(`Invalid Option: relax_column_count must be a boolean, got ${JSON.stringify(e.relax_column_count)}`);if(typeof e.relax_column_count_less!="boolean")if(e.relax_column_count_less===void 0||e.relax_column_count_less===null)e.relax_column_count_less=!1;else throw new Error(`Invalid Option: relax_column_count_less must be a boolean, got ${JSON.stringify(e.relax_column_count_less)}`);if(typeof e.relax_column_count_more!="boolean")if(e.relax_column_count_more===void 0||e.relax_column_count_more===null)e.relax_column_count_more=!1;else throw new Error(`Invalid Option: relax_column_count_more must be a boolean, got ${JSON.stringify(e.relax_column_count_more)}`);if(typeof e.relax_quotes!="boolean")if(e.relax_quotes===void 0||e.relax_quotes===null)e.relax_quotes=!1;else throw new Error(`Invalid Option: relax_quotes must be a boolean, got ${JSON.stringify(e.relax_quotes)}`);if(typeof e.skip_empty_lines!="boolean")if(e.skip_empty_lines===void 0||e.skip_empty_lines===null)e.skip_empty_lines=!1;else throw new Error(`Invalid Option: skip_empty_lines must be a boolean, got ${JSON.stringify(e.skip_empty_lines)}`);if(typeof e.skip_records_with_empty_values!="boolean")if(e.skip_records_with_empty_values===void 0||e.skip_records_with_empty_values===null)e.skip_records_with_empty_values=!1;else throw new Error(`Invalid Option: skip_records_with_empty_values must be a boolean, got ${JSON.stringify(e.skip_records_with_empty_values)}`);if(typeof e.skip_records_with_error!="boolean")if(e.skip_records_with_error===void 0||e.skip_records_with_error===null)e.skip_records_with_error=!1;else throw new Error(`Invalid Option: skip_records_with_error must be a boolean, got ${JSON.stringify(e.skip_records_with_error)}`);if(e.rtrim===void 0||e.rtrim===null||e.rtrim===!1)e.rtrim=!1;else if(e.rtrim!==!0)throw new Error(`Invalid Option: rtrim must be a boolean, got ${JSON.stringify(e.rtrim)}`);if(e.ltrim===void 0||e.ltrim===null||e.ltrim===!1)e.ltrim=!1;else if(e.ltrim!==!0)throw new Error(`Invalid Option: ltrim must be a boolean, got ${JSON.stringify(e.ltrim)}`);if(e.trim===void 0||e.trim===null||e.trim===!1)e.trim=!1;else if(e.trim!==!0)throw new Error(`Invalid Option: trim must be a boolean, got ${JSON.stringify(e.trim)}`);if(e.trim===!0&&t.ltrim!==!1?e.ltrim=!0:e.ltrim!==!0&&(e.ltrim=!1),e.trim===!0&&t.rtrim!==!1?e.rtrim=!0:e.rtrim!==!0&&(e.rtrim=!1),e.to===void 0||e.to===null)e.to=-1;else if(typeof e.to=="string"&&/\d+/.test(e.to)&&(e.to=parseInt(e.to)),Number.isInteger(e.to)){if(e.to<=0)throw new Error(`Invalid Option: to must be a positive integer greater than 0, got ${JSON.stringify(t.to)}`)}else throw new Error(`Invalid Option: to must be an integer, got ${JSON.stringify(t.to)}`);if(e.to_line===void 0||e.to_line===null)e.to_line=-1;else if(typeof e.to_line=="string"&&/\d+/.test(e.to_line)&&(e.to_line=parseInt(e.to_line)),Number.isInteger(e.to_line)){if(e.to_line<=0)throw new Error(`Invalid Option: to_line must be a positive integer greater than 0, got ${JSON.stringify(t.to_line)}`)}else throw new Error(`Invalid Option: to_line must be an integer, got ${JSON.stringify(t.to_line)}`);return e};var no=function(t){return t.every(e=>e==null||e.toString&&e.toString().trim()==="")},y6=9,Mt=10,T6=12,Vr=13,S6=32,jt={utf8:Buffer.from([239,187,191]),utf16le:Buffer.from([255,254])},lo=function(t={}){let e={bytes:0,comment_lines:0,empty_lines:0,invalid_field_length:0,lines:1,records:0},a=Lr(t);return{info:e,original_options:t,options:a,state:so(a),__needMoreData:function(r,p,i){if(i)return!1;let{quote:s}=this.options,{quoting:o,needMoreDataSize:n,recordDelimiterMaxLength:d}=this.state,m=p-r-1,l=Math.max(n,d,o?s.length+d:0);return mD){this.state.stop=!0,s();return}this.state.quoting===!1&&A.length===0&&this.__autoDiscoverRecordDelimiter(C,b)&&(A=this.options.record_delimiter);let k=C[b];if(v===!0&&J.append(k),(k===Vr||k===Mt)&&this.state.wasRowDelimiter===!1&&(this.state.wasRowDelimiter=!0),this.state.escaping===!0)this.state.escaping=!1;else{if(d!==null&&this.state.quoting===!0&&this.__isEscape(C,b,k)&&b+d.length=m){this.state.enabled=!0,this.__resetField(),this.__resetRecord(),b+=V-1;continue}if(y===!0&&this.state.wasQuoting===!1&&this.state.record.length===0&&this.state.field.length===0){this.info.empty_lines++,b+=V-1;continue}this.info.bytes=this.state.bufBytesStart+b;let yt=this.__onField();if(yt!==void 0)return yt;this.info.bytes=this.state.bufBytesStart+b+V;let H1=this.__onRecord(i);if(H1!==void 0)return H1;if(E!==-1&&this.info.records>=E){this.state.stop=!0,s();return}}this.state.commenting=!1,b+=V-1;continue}if(this.state.commenting)continue;if((n===null?0:this.__compareBytes(n,C,b,k))!==0){this.state.commenting=!0;continue}let Et=this.__isDelimiter(C,b,k);if(Et!==0){this.info.bytes=this.state.bufBytesStart+b;let j1=this.__onField();if(j1!==void 0)return j1;b+=Et-1;continue}}}if(this.state.commenting===!1&&u!==0&&this.state.record_length+this.state.field.length>u){let V=this.__error(new P("CSV_MAX_RECORD_SIZE",["Max Record Size:","record exceed the maximum number of tolerated bytes",`of ${u}`,`at line ${this.info.lines}`],this.options,this.__infoField()));if(V!==void 0)return V}let De=l===!1||this.state.quoting===!0||this.state.field.length!==0||!this.__isCharTrimable(k),g1=O===!1||this.state.wasQuoting===!1;if(De===!0&&g1===!0)this.state.field.append(k);else if(O===!0&&!this.__isCharTrimable(k)){let V=this.__error(new P("CSV_NON_TRIMABLE_CHAR_AFTER_CLOSING_QUOTE",["Invalid Closing Quote:","found non trimable byte after quote",`at line ${this.info.lines}`],this.options,this.__infoField()));if(V!==void 0)return V}}if(p===!0)if(this.state.quoting===!0){let k=this.__error(new P("CSV_QUOTE_NOT_CLOSED",["Quote Not Closed:",`the parsing is finished with an opening quote at line ${this.info.lines}`],this.options,this.__infoField()));if(k!==void 0)return k}else if(this.state.wasQuoting===!0||this.state.record.length!==0||this.state.field.length!==0){this.info.bytes=this.state.bufBytesStart+b;let k=this.__onField();if(k!==void 0)return k;let De=this.__onRecord(i);if(De!==void 0)return De}else this.state.wasRowDelimiter===!0?this.info.empty_lines++:this.state.commenting===!0&&this.info.comment_lines++;else this.state.bufBytesStart+=b,this.state.previousBuf=C.slice(b);this.state.wasRowDelimiter===!0&&(this.info.lines++,this.state.wasRowDelimiter=!1)},__onRecord:function(r){let{columns:p,group_columns_by_name:i,encoding:s,info:o,from:n,relax_column_count:d,relax_column_count_less:m,relax_column_count_more:l,raw:u,skip_records_with_empty_values:h}=this.options,{enabled:v,record:_}=this.state;if(v===!1)return this.__resetRecord();let O=_.length;if(p===!0){if(h===!0&&no(_)){this.__resetRecord();return}return this.__firstLineToColumns(_)}if(p===!1&&this.info.records===0&&(this.state.expectedRecordLength=O),O!==this.state.expectedRecordLength){let y=p===!1?new P("CSV_RECORD_INCONSISTENT_FIELDS_LENGTH",["Invalid Record Length:",`expect ${this.state.expectedRecordLength},`,`got ${O} on line ${this.info.lines}`],this.options,this.__infoField(),{record:_}):new P("CSV_RECORD_INCONSISTENT_COLUMNS",["Invalid Record Length:",`columns length is ${p.length},`,`got ${O} on line ${this.info.lines}`],this.options,this.__infoField(),{record:_});if(d===!0||m===!0&&Othis.state.expectedRecordLength)this.info.invalid_field_length++,this.state.error=y;else{let E=this.__error(y);if(E)return E}}if(h===!0&&no(_)){this.__resetRecord();return}if(this.state.recordHasError===!0){this.__resetRecord(),this.state.recordHasError=!1;return}if(this.info.records++,n===1||this.info.records>=n){let{objname:y}=this.options;if(p!==!1){let E={};for(let D=0,A=_.length;D=0},__compareBytes:function(r,p,i,s){if(r[0]!==s)return 0;let o=r.length;for(let n=1;nthis.state.record.length?r[this.state.record.length].name:null:this.state.record.length,quoting:this.state.wasQuoting})}}};var Ht=function(t,e={}){typeof t=="string"&&(t=Buffer.from(t));let a=e&&e.objname?{}:[],r=lo(e),p=n=>{r.options.objname===void 0?a.push(n):a[n[0]]=n[1]},i=()=>{},s=r.parse(t,!1,p,i);if(s!==void 0)throw s;let o=r.parse(void 0,!0,p,i);if(o!==void 0)throw o;return a};var $t=ee(require("fs")),ho=ee(require("os")),d1=ee(require("path"));function fo(){let t=Ir();return{addHosts:Wt(S.getInput("add-hosts")),allow:Wt(S.getInput("allow")),buildArgs:S.getMultilineInput("build-args"),buildContexts:S.getMultilineInput("build-contexts"),cacheFrom:S.getMultilineInput("cache-from"),cacheTo:S.getMultilineInput("cache-to"),cgroupParent:S.getInput("cgroup-parent"),context:S.getInput("context")||t,file:S.getInput("file"),githubToken:S.getInput("github-token"),labels:S.getMultilineInput("labels"),load:S.getBooleanInput("load"),network:S.getInput("network"),noCache:S.getBooleanInput("no-cache"),outputs:S.getMultilineInput("outputs"),platforms:Wt(S.getInput("platforms")),project:S.getInput("project"),pull:S.getBooleanInput("pull"),push:S.getBooleanInput("push"),secretFiles:S.getMultilineInput("secret-files"),secrets:S.getMultilineInput("secrets"),shmSize:S.getInput("shm-size"),ssh:S.getMultilineInput("ssh"),tags:Wt(S.getInput("tags")),target:S.getInput("target"),token:S.getInput("token")||process.env.DEPOT_TOKEN,ulimit:S.getMultilineInput("ulimit")}}var zt;function Ir(){if(zt)return zt;let t=process.env.GITHUB_SERVER_URL||"https://github.com",e=O6();return zt=`${t}/${r1.context.repo.owner}/${r1.context.repo.repo}.git#${e}`,zt}function O6(){let t=r1.context.ref;return r1.context.sha&&t&&!t.startsWith("refs/")&&(t=`refs/heads/${r1.context.ref}`),r1.context.sha&&!t.startsWith("refs/pull/")&&(t=r1.context.sha),t}var it;function R1(){return it||(S.getState("tempDir")?S.getState("tempDir"):(it=$t.mkdtempSync(d1.join(ho.tmpdir(),"depot-build-push-").split(d1.sep).join(d1.posix.sep)),S.saveState("tempDir",it),it))}var uo="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";function vo(){let t=0;for(;t<20;){let e;try{e=Jt.randomBytes(16)}catch{e=Jt.pseudoRandomBytes(16)}let a=[];for(let p=0;p<10;p++)a.push(uo[e.readUInt8(p)%uo.length]);let r=d1.join(R1(),a.join(""));if(!$t.existsSync(r))return r;t+=1}throw new Error("Unable to generate a temporary file")}var xr=!!S.getState("isPost");xr||S.saveState("isPost","true");function Kt(t,e){(0,co.issueCommand)("set-output",{name:t},e)}function Wt(t){return t=t.trim(),t===""?[]:Ht(t,{columns:!1,relaxColumnCount:!0,relaxQuotes:!0,skipEmptyLines:!0}).flatMap(a=>a).map(a=>a.trim()).filter(a=>a)}var v1=ee(W1()),bt=ee(xo()),Ad=ee(kt());var Fe=ee(require("fs")),Cd=ee(kd()),Je=ee(require("path"));var H9=new Ad.HttpClient("depot-build-push-action");async function Rd(){try{let{exitCode:t}=await bt.getExecOutput("depot",[],{ignoreReturnCode:!0,silent:!0});return t===0}catch{return!1}}async function Gd(){await bt.exec("depot",["version"],{failOnStdErr:!1})}async function Ld(t){var i,s;let e=Ir(),a=["build",...L("--add-host",t.addHosts),...L("--allow",t.allow.join(",")),...L("--build-arg",t.buildArgs),...L("--build-context",t.buildContexts),...L("--cache-from",t.cacheFrom),...L("--cache-to",t.cacheTo),...L("--cgroup-parent",t.cgroupParent),...L("--file",t.file),...L("--iidfile",z9(t.outputs)?!1:Vd()),...L("--label",t.labels),...L("--load",t.load),...L("--metadata-file",xd()),...L("--network",t.network),...L("--no-cache",t.noCache),...L("--output",t.outputs),...L("--platform",t.platforms.join(",")),...L("--project",t.project),...L("--pull",t.pull),...L("--push",t.push),...L("--shm-size",t.shmSize),...L("--ssh",t.ssh),...L("--tag",t.tags),...L("--target",t.target),...L("--ulimit",t.ulimit),...L("--secret",t.secrets.map(o=>Lp(o)).filter(o=>Boolean(o))),...L("--secret",t.secretFiles.map(o=>Lp(o,!0)).filter(o=>Boolean(o))),...L("--secret",t.githubToken&&!W9(t.secrets)&&t.context==e?Lp(`GIT_AUTH_TOKEN=${t.githubToken}`):!1),Cd.compile(t.context)({defaultContext:e})],r=t.token??process.env.DEPOT_TOKEN;if(!r)try{let o=await v1.getIDToken("https://depot.dev"),n=await H9.postJson("https://depot.dev/api/auth/oidc/github-actions",{token:o});n.result&&n.result.token&&(r=n.result.token,v1.info("Exchanged GitHub Actions OIDC token for temporary Depot token"))}catch{v1.info("Unable to exchange GitHub OIDC token for temporary Depot token")}let p=await bt.getExecOutput("depot",a,{ignoreReturnCode:!0,env:$e($e({},process.env),r?{DEPOT_TOKEN:r}:{})});if(p.stderr.length>0&&p.exitCode!=0)throw new Error(`depot failed with: ${((s=(i=p.stderr.match(/(.*)\s*$/))==null?void 0:i[0])==null?void 0:s.trim())??"unknown error"}`)}function L(t,e){return e?e===!0?[t]:Array.isArray(e)?e.flatMap(a=>[t,a]):[t,e]:[]}function z9(t){let e=Ht(t.join(` +`,i)),this.state.recordDelimiterMaxLength=1,1):0},__error:function(r){let{encoding:p,raw:i,skip_records_with_error:s}=this.options,o=typeof r=="string"?new Error(r):r;if(s){this.state.recordHasError=!0,this.options.on_skip!==void 0&&this.options.on_skip(o,i?this.state.rawBuffer.toString(p):void 0);return}else return o},__infoDataSet:function(){return z1($e({},this.info),{columns:this.options.columns})},__infoRecord:function(){let{columns:r,raw:p,encoding:i}=this.options;return z1($e({},this.__infoDataSet()),{error:this.state.error,header:r===!0,index:this.state.record.length,raw:p?this.state.rawBuffer.toString(i):void 0})},__infoField:function(){let{columns:r}=this.options,p=Array.isArray(r);return z1($e({},this.__infoRecord()),{column:p===!0?r.length>this.state.record.length?r[this.state.record.length].name:null:this.state.record.length,quoting:this.state.wasQuoting})}}};var Ht=function(t,e={}){typeof t=="string"&&(t=Buffer.from(t));let a=e&&e.objname?{}:[],r=lo(e),p=n=>{r.options.objname===void 0?a.push(n):a[n[0]]=n[1]},i=()=>{},s=r.parse(t,!1,p,i);if(s!==void 0)throw s;let o=r.parse(void 0,!0,p,i);if(o!==void 0)throw o;return a};var $t=ee(require("fs")),ho=ee(require("os")),d1=ee(require("path"));function fo(){let t=Ir();return{addHosts:Wt(S.getInput("add-hosts")),allow:Wt(S.getInput("allow")),buildArgs:S.getMultilineInput("build-args"),buildContexts:S.getMultilineInput("build-contexts"),cacheFrom:S.getMultilineInput("cache-from"),cacheTo:S.getMultilineInput("cache-to"),cgroupParent:S.getInput("cgroup-parent"),context:S.getInput("context")||t,file:S.getInput("file"),githubToken:S.getInput("github-token"),labels:S.getMultilineInput("labels"),load:S.getBooleanInput("load"),network:S.getInput("network"),noCache:S.getBooleanInput("no-cache"),outputs:S.getMultilineInput("outputs"),platforms:Wt(S.getInput("platforms")),project:S.getInput("project"),pull:S.getBooleanInput("pull"),push:S.getBooleanInput("push"),secretFiles:S.getMultilineInput("secret-files"),secrets:S.getMultilineInput("secrets"),shmSize:S.getInput("shm-size"),ssh:S.getMultilineInput("ssh"),tags:Wt(S.getInput("tags")),target:S.getInput("target"),token:S.getInput("token")||process.env.DEPOT_TOKEN,ulimit:S.getMultilineInput("ulimit")}}var zt;function Ir(){if(zt)return zt;let t=process.env.GITHUB_SERVER_URL||"https://github.com",e=O6();return zt=`${t}/${r1.context.repo.owner}/${r1.context.repo.repo}.git#${e}`,zt}function O6(){let t=r1.context.ref;return r1.context.sha&&t&&!t.startsWith("refs/")&&(t=`refs/heads/${r1.context.ref}`),r1.context.sha&&!t.startsWith("refs/pull/")&&(t=r1.context.sha),t}var it;function R1(){return it||(S.getState("tempDir")?S.getState("tempDir"):(it=$t.mkdtempSync(d1.join(ho.tmpdir(),"depot-build-push-").split(d1.sep).join(d1.posix.sep)),S.saveState("tempDir",it),it))}var uo="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";function vo(){let t=0;for(;t<20;){let e;try{e=Jt.randomBytes(16)}catch{e=Jt.pseudoRandomBytes(16)}let a=[];for(let p=0;p<10;p++)a.push(uo[e.readUInt8(p)%uo.length]);let r=d1.join(R1(),a.join(""));if(!$t.existsSync(r))return r;t+=1}throw new Error("Unable to generate a temporary file")}var xr=!!S.getState("isPost");xr||S.saveState("isPost","true");function Kt(t,e){(0,co.issueCommand)("set-output",{name:t},e)}function Wt(t){return t=t.trim(),t===""?[]:Ht(t,{columns:!1,relaxColumnCount:!0,relaxQuotes:!0,skipEmptyLines:!0}).flatMap(a=>a).map(a=>a.trim()).filter(a=>a)}var v1=ee(W1()),bt=ee(xo()),Ad=ee(kt());var Fe=ee(require("fs")),Cd=ee(kd()),Je=ee(require("path"));var H9=new Ad.HttpClient("depot-build-push-action");async function Rd(){try{let{exitCode:t}=await bt.getExecOutput("depot",[],{ignoreReturnCode:!0,silent:!0});return t===0}catch{return!1}}async function Gd(){await bt.exec("depot",["version"],{failOnStdErr:!1})}async function Ld(t){var i,s;let e=Ir(),a=["build",...L("--add-host",t.addHosts),...L("--allow",t.allow.join(",")),...L("--build-arg",t.buildArgs),...L("--build-context",t.buildContexts),...L("--cache-from",t.cacheFrom),...L("--cache-to",t.cacheTo),...L("--cgroup-parent",t.cgroupParent),...L("--file",t.file),...L("--iidfile",z9(t.outputs)?!1:Vd()),...L("--label",t.labels),...L("--load",t.load),...L("--metadata-file",xd()),...L("--network",t.network),...L("--no-cache",t.noCache),...L("--output",t.outputs),...L("--platform",t.platforms.join(",")),...L("--project",t.project),...L("--pull",t.pull),...L("--push",t.push),...L("--shm-size",t.shmSize),...L("--ssh",t.ssh),...L("--tag",t.tags),...L("--target",t.target),...L("--ulimit",t.ulimit),...L("--secret",t.secrets.map(o=>Lp(o)).filter(o=>Boolean(o))),...L("--secret",t.secretFiles.map(o=>Lp(o,!0)).filter(o=>Boolean(o))),...L("--secret",t.githubToken&&!W9(t.secrets)&&t.context==e?Lp(`GIT_AUTH_TOKEN=${t.githubToken}`):!1),Cd.compile(t.context)({defaultContext:e})],r=t.token??process.env.DEPOT_TOKEN;if(!r)try{let o=await v1.getIDToken("https://depot.dev"),n=await H9.postJson("https://depot.dev/api/auth/oidc/github-actions",{token:o});n.result&&n.result.token&&(r=n.result.token,v1.info("Exchanged GitHub Actions OIDC token for temporary Depot token"))}catch(o){v1.info(`Unable to exchange GitHub OIDC token for temporary Depot token: ${o}`)}let p=await bt.getExecOutput("depot",a,{ignoreReturnCode:!0,env:$e($e({},process.env),r?{DEPOT_TOKEN:r}:{})});if(p.stderr.length>0&&p.exitCode!=0)throw new Error(`depot failed with: ${((s=(i=p.stderr.match(/(.*)\s*$/))==null?void 0:i[0])==null?void 0:s.trim())??"unknown error"}`)}function L(t,e){return e?e===!0?[t]:Array.isArray(e)?e.flatMap(a=>[t,a]):[t,e]:[]}function z9(t){let e=Ht(t.join(` `),{columns:!1,relaxColumnCount:!0,trim:!0});for(let a of e){if(a.length===1&&!a[0].startsWith("type="))return!0;for(let[r,p]of a.map(i=>i.split("=").map(s=>s.trim())))if(r==="type"&&(p==="local"||p==="tar"))return!0}return!1}function W9(t){return t.some(e=>e.startsWith("GIT_AUTH_TOKEN="))}function Lp(t,e){try{let a=t.indexOf("="),r=t.substring(0,a),p=t.substring(a+1);if(!r||!p)throw new Error(`Invalid secret: ${t}`);if(e){if(!Fe.existsSync(p))throw new Error(`Secret file not found: ${p}`);p=Fe.readFileSync(p,"utf8")}let i=vo();return Fe.writeFileSync(i,p),`id=${r},src=${i}`}catch(a){v1.warning(a.message)}}function Vd(){return Je.join(R1(),"iidfile").split(Je.sep).join(Je.posix.sep)}function Id(){let t=Vd();if(!!Fe.existsSync(t))return Fe.readFileSync(t,{encoding:"utf-8"}).trim()}function xd(){return Je.join(R1(),"metadata-file").split(Je.sep).join(Je.posix.sep)}function Fd(){let t=xd();if(!Fe.existsSync(t))return;let e=Fe.readFileSync(t,{encoding:"utf-8"}).trim();if(e!=="null")return e}function Ud(t){return t===void 0?void 0:JSON.parse(t)["containerimage.digest"]}async function $9(){if(!await Rd())return Z.setFailed("Depot CLI is not installed. See https://github.com/depot/setup-action to install it before this step.");await Z.group("Depot version",async()=>{await Gd()});let t=fo();await Ld(t);let e=Id(),a=Fd(),r=Ud(a);e&&await Z.group("ImageID",async()=>{Z.info(e),Kt("imageid",e)}),r&&await Z.group("Digest",async()=>{Z.info(r),Kt("digest",r)}),a&&await Z.group("Metadata",async()=>{Z.info(a),Kt("metadata",a)})}async function K9(){let t=R1();t.length!==0&&(Z.startGroup(`Removing temp folder ${t}`),Bd.rmSync(t,{recursive:!0}),Z.endGroup())}(xr?K9():$9()).catch(t=>{t instanceof Error?Z.setFailed(t.message):Z.setFailed(`${t}`)}); /*! * is-plain-object diff --git a/src/depot.ts b/src/depot.ts index 1faaf8f..3214148 100644 --- a/src/depot.ts +++ b/src/depot.ts @@ -85,8 +85,8 @@ export async function build(inputs: Inputs) { token = res.result.token core.info(`Exchanged GitHub Actions OIDC token for temporary Depot token`) } - } catch { - core.info('Unable to exchange GitHub OIDC token for temporary Depot token') + } catch (err) { + core.info(`Unable to exchange GitHub OIDC token for temporary Depot token: ${err}`) } }