NOTE: Currently all of these require going through these collections that are returned and wrapping them in an Object.
This helps to just get the cleaned up tags from the imported format in the console
const tags = [Array of Tag Objects];
tags.forEach(parseTags);
function parseTags(tag) {
var result = 'tags {\n';
Object.keys(tag).forEach(key => {
result += `\t${key.replace(/tags./g, '')} = "${tag[key]}"\n`
});
result += '}'
console.log(result)
}
This helps to parse out the long collection of settings and display in the console
function mapSettings(settings) {
if (Array.isArray(settings)) {
return settings.forEach(formatSettings);
}
return new Error('Settings must be an array');
}
function formatSettings(settings) {
var namespace, name, value;
Object.keys(settings).forEach(key => {
if (key.includes('name') && key.includes('namespace')) {
namespace = settings[key];
} else if (key.includes('name') && !key.includes('namespace')) {
name = settings[key];
} else {
value = settings[key]
}
})
if (value === "") return; // check for default or undefined values and remove as TF will handle them
if (namespace && name && value) {
console.log((`setting {\n \tnamespace = "${namespace}"\n \tname = "${name}"\n \tvalue = "${value}" \n}\n`))
}
}