cloudflare/cloudflared

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
d22b37420803a8ff4c7e564fd8ea19a4229b2f9a

Branches

Tags

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

Clone

HTTPS

Download ZIP

component-tests/util.py

26lines · modecode

1import logging
2import os
3import subprocess
4import yaml
5
6LOGGER = logging.getLogger(__name__)
7
8def write_config(path, config):
9 config_path = path / "config.yaml"
10 with open(config_path, 'w') as outfile:
11 yaml.dump(config, outfile)
12 return config_path
13
14
15def start_cloudflared(path, component_test_config, cfd_args, cfd_pre_args=[], classic=False):
16 if classic:
17 config = component_test_config.classic_tunnel_config
18 else:
19 config = component_test_config.named_tunnel_config
20 config_path = write_config(path, config)
21 cmd = [component_test_config.cloudflared_binary]
22 cmd += cfd_pre_args
23 cmd += ["--config", config_path]
24 cmd += cfd_args
25 LOGGER.info(f"Run cmd {cmd} with config {config}")
26 return subprocess.run(cmd, capture_output=True)