cloudflare/cloudflared

Public

mirrored from https://github.com/cloudflare/cloudflaredAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
b0e69c4b8ad27dcc74283f0cdaa6744cf8fe41a4

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

component-tests/util.py

27lines · modecode

1import logging
2import os
3import subprocess
4import yaml
5
6LOGGER = logging.getLogger(__name__)
7
8def get_cloudflared():
9 cfd_binary = os.getenv('CFD_BINARY')
10 return "cloudflared" if cfd_binary is None else cfd_binary
11
12
13def write_config(path, config):
14 config_path = path / "config.yaml"
15 with open(config_path, 'w') as outfile:
16 yaml.dump(config, outfile)
17 return config_path
18
19
20def start_cloudflared(path, config, args, pre_args=[]):
21 config_path = write_config(path, config)
22 cmd = [get_cloudflared()]
23 cmd += pre_args
24 cmd += ["--config", config_path]
25 cmd += args
26 LOGGER.info(f"Run cmd {cmd} with config {config}")
27 return subprocess.run(cmd, capture_output=True)