Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function decode(auth) {
try {
return base64.decode(auth.substr(6));
} catch (e) {
return auth;
}
}
var secret = require('./secret.json');
var decode = require('base-64').decode;
var Api = require('kubernetes-client');
var config = {
url: 'https://' + secret.clusterIp,
ca: decode(secret.data['ca.crt']),
auth: {
bearer: decode(secret.data.token)
}
};
const core = new Api.Core(config);
exports['container-deploy-trigger'] = function helloPubSub (event, callback) {
console.log("called!");
const pubsubMessage = event.data;
const result = JSON.parse(Buffer.from(pubsubMessage.data, 'base64').toString());
console.log("result", result);
if (result.status !== 'SUCCESS'){
return callback();
}
this.json = ():any => {
switch(this.type) {
case 'base64':
return JSON.parse(base64.decode(this.data))
case 'path':
return fs.readFile(this.data, 'utf8')
.then((text) => Promise.resolve(JSON.parse(text)))
default:
return JSON.parse(this.data)
}
}
/**
<i></i>
<input disabled="" placeholder="Enter URL" name="recipeURL" id="recipeURL" type="text">
<i></i>
<input required="" value="{Base64.decode(this.state.file)}" placeholder="Enter profile file code" name="recipeCode" id="recipeCode" type="textarea">
<button href="#/profiles" color="primary" size="lg">
<i></i> Back
</button>
export function mergeConfigs (remoteConfig) {
const config = defaultConfig
if (remoteConfig && remoteConfig.content) {
var userConfig = JSON.parse(decode(remoteConfig.content))
Object.keys(userConfig).forEach((key) => {
if (Array.isArray(userConfig[key])) {
config[key] = userConfig[key].map((item) => decodeURIComponent(item))
} else if (typeof userConfig[key] === 'string') {
config[key] = decodeURIComponent(userConfig[key])
} else {
config[key] = userConfig[key]
}
})
}
return config
}
const b64decode = (string) => {
const base64Decode = require('base-64').decode;
const utf8Decode = require('utf8').decode;
return utf8Decode(base64Decode(string));
};
const decode = str => base64.decode(str);
this.text = () => {
return base64.decode(this.data)
}
/**
return command(normalizeFilePath(filepath)).then((b64) => {
var contents;
if (options.encoding === 'utf8') {
contents = utf8.decode(base64.decode(b64));
} else if (options.encoding === 'ascii') {
contents = base64.decode(b64);
} else if (options.encoding === 'base64') {
contents = b64;
} else {
throw new Error('Invalid encoding type "' + String(options.encoding) + '"');
}
return contents;
});
}