def __init__(self): self.auth = Auth(optionsFromEnvironment(), session=aiohttp_session()) self.secrets = Secrets(optionsFromEnvironment(), session=aiohttp_session()) self.hooks = Hooks(optionsFromEnvironment(), session=aiohttp_session()) self.worker_manager = WorkerManager(optionsFromEnvironment(), session=aiohttp_session())
async def _get_github_token(): try: root_url = os.environ["TASKCLUSTER_PROXY_URL"] except KeyError as e: raise KeyError( "You must provide `TASKCLUSTER_PROXY_URL` to run these tests" ) from e secrets = Secrets({"rootUrl": root_url}) secret = await secrets.get( "repo:github.com/mozilla-releng/scriptworker:github") return secret["secret"]["token"]
async def _get_github_token(): if os.environ.get("SCRIPTWORKER_GITHUB_TOKEN"): return os.environ["SCRIPTWORKER_GITHUB_TOKEN"] token = read_worker_creds(key="scriptworker_github_token") if token: return read_worker_creds(key="scriptworker_github_token") try: root_url = os.environ["TASKCLUSTER_PROXY_URL"] except KeyError as e: raise KeyError("You must provide `TASKCLUSTER_PROXY_URL` to run these tests") from e secrets = Secrets({"rootUrl": root_url}) secret = await secrets.get("repo:github.com/mozilla-releng/scriptworker:github") return secret["secret"]["token"]
async def fetch_secrets(resources, with_secrets): api = Secrets(optionsFromEnvironment(), session=aiohttp_session()) query = {} while True: res = await api.list(query=query) for secret_name in res["secrets"]: if resources.is_managed("Secret={}".format(secret_name)): # only call `get` if we are managing secrets if with_secrets: getres = await api.get(secret_name) secret = Secret.from_api(secret_name, getres) else: secret = Secret.from_api(secret_name) resources.add(secret) if "continuationToken" in res: query["continuationToken"] = res["continuationToken"] else: break
def __init__(self, options, session): "Use `Updater.create()` instead of calling this directly." self.auth = Auth(options, session) self.secrets = Secrets(options, session) self.hooks = Hooks(options, session) self.worker_manager = WorkerManager(options, session)