How to use the taskcluster-client.Secrets function in taskcluster-client

To help you get started, we’ve selected a few taskcluster-client 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 taskcluster / azure-entities / test / helper.js View on Github external
suiteSetup(async () => {
  credentials.accountId = process.env.AZURE_ACCOUNT;
  credentials.accessKey = process.env.AZURE_ACCOUNT_KEY;

  if (credentials.accountId && credentials.accessKey) {
    return;
  }

  // load credentials from the secret if running in CI
  if (process.env.TASKCLUSTER_PROXY_URL) {
    console.log('loading credentials from secret via TASKCLUSTER_PROXY_URL');
    const client = new taskcluster.Secrets({rootUrl: process.env.TASKCLUSTER_PROXY_URL});
    const res = await client.get('project/taskcluster/testing/azure');
    console.log(res.secret);
    credentials.accountId = res.secret.AZURE_ACCOUNT;
    credentials.accessKey = res.secret.AZURE_ACCOUNT_KEY;
    return;
  }

  console.error('set $AZURE_ACCOUNT and $AZURE_ACCOUNT_KEY to a testing Azure storage account.');
  process.exit(1);
});
github taskcluster / taskcluster-tools / src / secrets / secreteditor.jsx View on Github external
import {findDOMNode} from 'react-dom';
import {Alert, Button, ButtonToolbar, Glyphicon} from 'react-bootstrap';
import * as utils from '../lib/utils';
import taskcluster from 'taskcluster-client';
import * as format from '../lib/format';
import ConfirmAction from '../lib/ui/confirmaction';
import TimeInput from '../lib/ui/timeinput';
import _ from 'lodash';
import moment from 'moment';

const SecretEditor = React.createClass({
  /** Initialize mixins */
  mixins: [
    utils.createTaskClusterMixin({
      clients: {
        secrets: taskcluster.Secrets,
      },
      reloadOnProps: ['currentSecretId'],
    }),
  ],

  propTypes: {
    // Method to reload a client in the parent
    reloadSecrets: React.PropTypes.func.isRequired,
  },

  getDefaultProps() {
    return {
      // '' implies. "Create Secret"
      currentSecretId: '',
    };
  },
github taskcluster / taskcluster / test / shared-secrets.js View on Github external
const main = async () => {
  let configs;
  if (process.env.TASKCLUSTER_PROXY_URL) {
    configs = {
      rootUrl: process.env.TASKCLUSTER_PROXY_URL,
    };
  } else {
    configs = {
      rootUrl: process.env.TASKCLUSTER_ROOT_URL,
      credentials: {
        clientId: process.env.TASKCLUSTER_CLIENT_ID,
        accessToken: process.env.TASKCLUSTER_ACCESS_TOKEN,
      },
    };
  }
  const secrets = new taskcluster.Secrets(configs);
  for (let secretName of ['project/taskcluster/testing/codecov']) {
    const {secret: results} = await secrets.get(secretName);
    console.log(Object.entries(results).map(([key, val]) => `export ${key}=${val}`).join('\n'));
  }
};
github taskcluster / taskcluster / infrastructure / tooling / src / smoketest / checks / secrets.js View on Github external
run: async () => {
    let secrets = new taskcluster.Secrets(taskcluster.fromEnvVars());
    let secretName = taskcluster.slugid();
    let secretPrefix = `project/taskcluster/smoketest/${secretName}`;
    const payload = {
      "expires": taskcluster.fromNowJSON('2 minutes'),
      "secret": {
        "description": `Secret ${secretName}`,
        "type": "object",
      },
    };
    await secrets.set(secretPrefix, payload);
    const getSecret = await secrets.get(secretPrefix);
    assert.deepEqual(getSecret.secret, payload.secret);
    await secrets.remove(secretPrefix);
    await assert.rejects(
      () => secrets.get(secretPrefix),
      err => assert.equal(err.code, 404)
github taskcluster / taskcluster / services / web-server / src / clients.js View on Github external
module.exports = options => ({
  auth: new Auth(options),
  github: new Github(options),
  hooks: new Hooks(options),
  index: new Index(options),
  purgeCache: new PurgeCache(options),
  queue: new Queue(options),
  secrets: new Secrets(options),
  queueEvents: new QueueEvents(options),
  notify: new Notify(options),
  workerManager: new WorkerManager(options),
});
github taskcluster / taskcluster-tools / src / secrets / secretmanager.jsx View on Github external
import React from 'react';
import {Row, Col, ButtonToolbar, Button, Glyphicon, Table} from 'react-bootstrap';
import * as utils from '../lib/utils';
import taskcluster from 'taskcluster-client';
import SecretEditor from './secreteditor';

import './secretmanager.less';

const SecretsManager = React.createClass({
  /** Initialize mixins */
  mixins: [
    utils.createTaskClusterMixin({
      clients: {
        secrets: taskcluster.Secrets,
      },
    }),
    utils.createLocationHashMixin({
      keys: ['selectedSecretId'],
      type: 'string',
    }),
  ],

  /** Create an initial state */
  getInitialState() {
    return {
      selectedSecretId: '',
      secrets: undefined,
      secretsLoaded: false,
      secretsError: null,
    };
github taskcluster / taskcluster-docs / lib / userlist.js View on Github external
var getApiKey = () => {
  if (process.env.MOZILLIANS_API_KEY) {
    return Promise.resolve(process.env.MOZILLIANS_API_KEY);
  }

  if (process.env.MOZILLIANS_SECRET) {
    var secrets = new taskcluster.Secrets({baseUrl: 'http://taskcluster/secrets/v1/'});
    return secrets.get(process.env.MOZILLIANS_SECRET).then(secret => secret.secret['api-key']);
  }

  gutil.log('WARNING: $MOZILLIANS_API_KEY is not set; not generating mozillians links');
  return Promise.resolve(null);
}