Skip to content

Commit

Permalink
Update secrets.js
Browse files Browse the repository at this point in the history
  • Loading branch information
LanceMcCarthy committed Sep 26, 2023
1 parent 9cc45df commit c66850d
Showing 1 changed file with 24 additions and 28 deletions.
52 changes: 24 additions & 28 deletions src/secrets.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,10 @@ async function exportDynamicSecrets(akeylessToken, dynamicSecrets, apiUrl, expor
core.setFailed(`getDynamicSecretValue Failed: ${JSON.stringify(error)}`);
});

// core.info(`\u001b[38;2;255;0;0mRESULT - api.getDynamicSecretValue (raw): ${dynamicSecret}`);
// core.info(`\u001b[38;2;255;0;0mRESULT - api.getDynamicSecretValue (stringified): ${JSON.stringify(dynamicSecret)}`);
// CHECKING STRAIGHT VALUE FROM AKEYLESS
core.info(`\u001b[38;2;255;0;0mPRE-PROCESSING CHECK: STRAIGHT AKEYLESS VALUES`);
core.info(`\u001b[38;2;255;0;0mRESULT - api.getDynamicSecretValue (raw): ${dynamicSecret}`);
core.info(`\u001b[38;2;255;0;0mRESULT - api.getDynamicSecretValue (stringified): ${JSON.stringify(dynamicSecret)}`);

if (dynamicSecret === null || dynamicSecret === undefined) {
return;
Expand Down Expand Up @@ -123,36 +125,30 @@ async function exportDynamicSecrets(akeylessToken, dynamicSecrets, apiUrl, expor

core.info(`\u001b[38;2;133;238;144mKEY: ${actualKey}, VALUE: ${actualValue}`);

// AKEYLESS TROUBLESHOOTING IF/ELSE
if (actualKey === 'secret' || actualKey === 'id') {
// At this point, actualValue for 'secret' equals "[Object, object]" and not an actual json object
core.info(`\u001b[38;2;232;191;70mChecking the keys of ${actualKey}:`); // #E8BF46
if (actualValue.constructor === Array || actualValue.constructor === Object) {
let stringifiedValue = JSON.stringify(actualValue);
exportValue(actualKey, stringifiedValue, variableName, exportSecretsToOutputs, exportSecretsToEnvironment);
}
else{
exportValue(actualKey, actualValue, variableName, exportSecretsToOutputs, exportSecretsToEnvironment);
}

// Options 1 - output each subkey
for (const subkey in actualValue) {
const subkeyValue = actualValue[subkey];
// AKEYLESS TROUBLESHOOTING IF/ELSE
// if (actualKey === 'secret') {
// // At this point, actualValue for 'secret' equals the string "[Object, object]"
// core.info(`\u001b[38;2;232;191;70mChecking the keys of ${actualKey}:`); // #E8BF46

core.info(`\u001b[38;2;219;212;77mSUBKEY: ${subkey}, SUBKEYVALUE: ${subkeyValue}`); // #DBD44D
// for (const subkey in actualValue) {
// const subkeyValue = actualValue[subkey];

exportValue(subkey, subkeyValue, variableName, exportSecretsToOutputs, exportSecretsToEnvironment);
}
// core.info(`\u001b[38;2;219;212;77mSUBKEY: ${subkey}, SUBKEYVALUE: ${subkeyValue}`); // #DBD44D

// Option 2 Just output the entire value as usual
//exportValue(actualKey, actualValue, variableName, exportSecretsToOutputs, exportSecretsToEnvironment);

// Option 3 - experimenting with array/object constructor detection
// if (actualValue.constructor === Array || actualValue.constructor === Object) {
// let stringifiedValue = JSON.stringify(actualValue);
// exportValue(actualKey, stringifiedValue, variableName, exportSecretsToOutputs, exportSecretsToEnvironment);
// }
// else{
// exportValue(actualKey, actualValue, variableName, exportSecretsToOutputs, exportSecretsToEnvironment);
// }

} else {
// all other keys work as expected
exportValue(actualKey, actualValue, variableName, exportSecretsToOutputs, exportSecretsToEnvironment);
}
// exportValue(subkey, subkeyValue, variableName, exportSecretsToOutputs, exportSecretsToEnvironment);
// }
// } else {
// // all other keys work as expected
// exportValue(actualKey, actualValue, variableName, exportSecretsToOutputs, exportSecretsToEnvironment);
// }
}

outputArray = [];
Expand Down

0 comments on commit c66850d

Please sign in to comment.