MCPcopy Create free account
hub / github.com/cloudflare/cloudflared / component_tests_config

Function component_tests_config

component-tests/conftest.py:19–49  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

17
18@pytest.fixture(scope="session")
19def component_tests_config():
20 config_file = os.getenv("COMPONENT_TESTS_CONFIG")
21 if config_file is None:
22 raise Exception(
23 "Need to provide path to config file in COMPONENT_TESTS_CONFIG")
24 with open(config_file, 'r') as stream:
25 config = yaml.safe_load(stream)
26 LOGGER.info(f"component tests base config {config}")
27
28 def _component_tests_config(additional_config={}, cfd_mode=CfdModes.NAMED, provide_ingress=True):
29 # Allows the ingress rules to be omitted from the provided config
30 ingress = []
31 if provide_ingress:
32 ingress = config['ingress']
33
34 # Provide the hostname to allow routing to the tunnel even if the ingress rule isn't defined in the config
35 hostname = config['ingress'][0]['hostname']
36
37 if cfd_mode is CfdModes.NAMED:
38 return NamedTunnelConfig(additional_config=additional_config,
39 cloudflared_binary=config['cloudflared_binary'],
40 tunnel=config['tunnel'],
41 credentials_file=config['credentials_file'],
42 ingress=ingress,
43 hostname=hostname)
44 elif cfd_mode is CfdModes.QUICK:
45 return QuickTunnelConfig(additional_config=additional_config, cloudflared_binary=config['cloudflared_binary'])
46 else:
47 raise Exception(f"Unknown cloudflared mode {cfd_mode}")
48
49 return _component_tests_config
50
51
52# This fixture is automatically called before each tests to make sure the previous cloudflared has been shutdown

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…