How to use the @f5devcentral/f5-cloud-libs.util.createBufferFrom function in @f5devcentral/f5-cloud-libs

To help you get started, we’ve selected a few @f5devcentral/f5-cloud-libs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github F5Networks / f5-cloud-libs-gce / lib / gceCloudProvider.js View on Github external
}
    }

    this.region = providerOptions ? providerOptions.region : undefined;
    if (providerOptions.secret) {
        this.logger.silly('Got credentials from providerOptions');

        if (!this.region) {
            const message = 'providerOptions.region is required when providing credentials';
            this.logger.info(message);
            return q.reject(new Error(message));
        }

        let credentials;
        try {
            const credentialsBuf = cloudUtil.createBufferFrom(providerOptions.secret, 'base64');
            credentials = JSON.parse(credentialsBuf.toString());
        } catch (err) {
            this.logger.info('Error parsing credentials');
            return q.reject(err);
        }

        this.compute = new Compute({ credentials });
        this.storage = new Storage({ credentials });

        // TODO: Add credentials handling to our pubSub client
    } else {
        this.logger.silly('No provider credentials - assuming we are running in Google Cloud');
        this.compute = new Compute();
        this.storage = new Storage();

        if (this.initOptions.autoscale) {
github F5Networks / f5-declarative-onboarding / src / nodejs / restWorker.js View on Github external
.then((port) => {
                const credentials = cloudUtil.createBufferFrom(
                    `${wrapper.targetUsername}:${updatedPassword}`,
                    'ascii'
                ).toString('base64');
                const auth = `Basic ${credentials}`;
                const restOperation = this.restOperationFactory.createRestOperationInstance()
                    .setUri(
                        `https://${wrapper.targetHost}:${port}/mgmt/shared/authn/root`
                    )
                    .setIsSetBasicAuthHeader(true)
                    .setBasicAuthorization(auth)
                    .setContentType('application/json')
                    .setBody(
                        {
                            oldPassword: updatedPassword,
                            newPassword: updatedPassword
                        }