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 f1326fb commit 9cc45df
Showing 1 changed file with 16 additions and 27 deletions.
43 changes: 16 additions & 27 deletions src/secrets.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,12 @@ async function exportDynamicSecrets(akeylessToken, dynamicSecrets, apiUrl, expor

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

// check if the inner value is another json object
if(actualValue.constructor === Array || actualValue.constructor === Object){
// 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

// Options 1 - output each subkey
for (const subkey in actualValue) {
const subkeyValue = actualValue[subkey];

Expand All @@ -135,35 +137,22 @@ async function exportDynamicSecrets(akeylessToken, dynamicSecrets, apiUrl, expor
exportValue(subkey, subkeyValue, variableName, exportSecretsToOutputs, exportSecretsToEnvironment);
}

// 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);
}

// // 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

// for (const subkey in actualValue) {
// const subkeyValue = actualValue[subkey];

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

// exportValue(subkey, subkeyValue, variableName, exportSecretsToOutputs, exportSecretsToEnvironment);
// }

// 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);
// }
}

outputArray = [];
Expand Down

0 comments on commit 9cc45df

Please sign in to comment.