conductor

CI task system
git clone git://git.finwo.net/app/conductor
Log | Files | Refs | README | LICENSE

outputs.js (1107B)


      1 // src/lib/outputs.js - values a task produced, as the conductor sees them
      2 //
      3 // The worker parses these out of a log stream and has its own copy of the
      4 // rules; it shares no code with the conductor. These are the conductor's,
      5 // applied to what a worker reports rather than trusted from it.
      6 
      7 export const OUTPUT_NAME = /^[A-Za-z_][A-Za-z0-9_-]*(?:\.[A-Za-z_][A-Za-z0-9_-]*)*$/;
      8 export const MAX_OUTPUT_VALUE = 8192;
      9 export const MAX_OUTPUTS = 64;
     10 
     11 // Binds a sealed value to where it is stored, so a row copied onto another
     12 // task or name fails to open.
     13 export const outputAad = (taskId, name) => `task:${taskId}/output:${name}`;
     14 
     15 export function readOutputList(value) {
     16   if (!Array.isArray(value)) return [];
     17   const out = [];
     18   for (const entry of value.slice(0, MAX_OUTPUTS)) {
     19     if (!entry || typeof entry !== 'object') continue;
     20     const { name, value: v } = entry;
     21     if (typeof name !== 'string' || !OUTPUT_NAME.test(name)) continue;
     22     if (typeof v !== 'string' || v.length > MAX_OUTPUT_VALUE) continue;
     23     out.push({ name, value: v, masked: entry.masked !== false });
     24   }
     25   return out;
     26 }