def appconfig(): # don't import this at the top level, as it results in `blessings.Terminal` being # initialized in a situation where output is to a console, and it includes underlines # and bold and colors in the output, causing test failures from tcadmin.appconfig import AppConfig appconfig = AppConfig() with AppConfig._as_current(appconfig): yield appconfig
def appconfig(): # this is copied from: # https://github.com/taskcluster/tc-admin/blob/main/tcadmin/tests/conftest.py # @c21e32efb50034739fef990409dbb16c62438725 # don't import this at the top level, as it results in `blessings.Terminal` being # initialized in a situation where output is to a console, and it includes # underlines and bold and colors in the output, causing test failures from tcadmin.appconfig import AppConfig appconfig = AppConfig() with AppConfig._as_current(appconfig): yield appconfig
async def update_resources(resources): # Set up the resources to manage everything *except* externally managed # resources externally_managed_patterns = ( await projects.get_externally_managed_resource_patterns()) # ..and except static clients and user-generatd clients externally_managed_patterns.append("Client=(static|github)/.*") em_bar = "|".join(externally_managed_patterns) resources.manage(re.compile(r"(?!{}).*".format(em_bar))) secret_values = None if AppConfig.current().options.get("with_secrets"): secret_values = SecretValues() await projects.update_resources(resources, secret_values) await grants.update_resources(resources, secret_values)
async def tc_admin_boot(cls, resources): """Setup the workflow to be usable by tc-admin""" appconfig = AppConfig.current() local_path = appconfig.options.get("fuzzing_configuration") if local_path is not None: local_path = pathlib.Path(local_path) # Configure workflow using tc-admin options workflow = cls() config = workflow.configure( local_path=local_path, secret=appconfig.options.get("fuzzing_taskcluster_secret"), fuzzing_git_repository=appconfig.options.get("fuzzing_git_repository"), fuzzing_git_revision=appconfig.options.get("fuzzing_git_revision"), ) # Retrieve remote repositories workflow.clone(config) # Then generate all our Taskcluster resources workflow.generate(resources, config)
async def update_resources(resources): # Set up the resources to manage everything *except* externally managed # resources externally_managed_patterns = ( await projects.get_externally_managed_resource_patterns() ) # ..and except static clients and user-generatd clients externally_managed_patterns.append("Client=(static|github)/.*") em_bar = "|".join(externally_managed_patterns) resources.manage(re.compile(r"(?!{}).*".format(em_bar))) if AppConfig.current().options.get("with_secrets"): print( "Use --without-secrets; secret management is not yet supported", file=sys.stderr, ) os._exit(1) await projects.update_resources(resources) await grants.update_resources(resources)
# -*- coding: utf-8 -*- # This Source Code Form is subject to the terms of the Mozilla Public License, # v. 2.0. If a copy of the MPL was not distributed with this file, You can # obtain one at http://mozilla.org/MPL/2.0/. import os from tcadmin.appconfig import AppConfig from tcadmin.resources import Hook, WorkerPool from fuzzing_decision.decision.callbacks import cancel_pool_tasks, trigger_hook from fuzzing_decision.decision.workflow import Workflow appconfig = AppConfig() # Add options to get our own configuration appconfig.options.add( "--fuzzing-configuration", help="Local configuration file replacing Taskcluster secrets for fuzzing", ) appconfig.options.add( "--fuzzing-taskcluster-secret", help="Taskcluster Secret path for fuzzing", default=os.environ.get("TASKCLUSTER_SECRET"), ) appconfig.options.add( "--fuzzing-git-repository", help="A git repository containing the Fuzzing configuration", default=os.environ.get("FUZZING_GIT_REPOSITORY"), )