@metadata_reactor.provides( 'woodpecker-agent/environment', 'woodpecker-agent/version', ) def environment(metadata): env = {} server = repo.get_node(metadata.get('woodpecker-agent/server')) domain = server.metadata.get('woodpecker-server/domain') port = server.metadata.get('woodpecker-server/environment/WOODPECKER_GRPC_ADDR') env['WOODPECKER_SERVER'] = f'{domain}{port}' env['WOODPECKER_AGENT_SECRET'] = server.metadata.get('woodpecker-server/environment/WOODPECKER_AGENT_SECRET') env['WOODPECKER_MAX_PROCS'] = int(int(metadata.get('vm/cpu'))/2) env['WOODPECKER_HOSTNAME'] = metadata.get('hostname') env['WOODPECKER_LOG_LEVEL'] = server.metadata.get('woodpecker-server/environment/WOODPECKER_LOG_LEVEL') debug = server.metadata.get('woodpecker-server/environment/GODEBUG', None) if debug: env['GODEBUG'] = debug return { 'woodpecker-agent': { 'environment': env, 'version': server.metadata.get('woodpecker-server/version'), }, }