bundlewrap/bundles/woodpecker-agent/metadata.py

31 lines
1 KiB
Python
Raw Normal View History

2022-12-24 16:41:27 +00:00
@metadata_reactor.provides(
'woodpecker-agent/environment',
'woodpecker-agent/version',
)
def environment(metadata):
2022-12-24 16:41:27 +00:00
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')
2022-12-24 16:41:27 +00:00
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'),
},
}