Coverage for ocp_resources/proxy.py: 0%

26 statements  

« prev     ^ index     » next       coverage.py v7.6.10, created at 2025-01-30 10:48 +0200

1from typing import Any, Dict, List, Optional 

2from ocp_resources.resource import Resource 

3 

4 

5class Proxy(Resource): 

6 """ 

7 https://docs.openshift.com/container-platform/4.15/rest_api/config_apis/proxy-config-openshift-io-v1.html 

8 """ 

9 

10 api_group = Resource.ApiGroup.CONFIG_OPENSHIFT_IO 

11 

12 def __init__( 

13 self, 

14 http_proxy: Optional[str] = "", 

15 https_proxy: Optional[str] = "", 

16 no_proxy: Optional[str] = "", 

17 readiness_endpoints: Optional[List[str]] = None, 

18 trusted_ca: Optional[Dict[str, str]] = None, 

19 **kwargs: Any, 

20 ) -> None: 

21 """ 

22 Args: 

23 http_proxy (str, optional): URL of the proxy for HTTP requests. 

24 https_proxy (str, optional): URL of the proxy for HTTPS requests. 

25 no_proxy (str, optional): Comma-separated list of hostnames for which the proxy should not be used. 

26 readiness_endpoints (list, optional): List of endpoints used to verify readiness of the proxy. 

27 trusted_ca (dict, optional): Reference to a ConfigMap containing a CA certificate bundle. 

28 Example: { 

29 "name": "trusted-ca-bundle", 

30 "namespace": "openshift-config" 

31 } 

32 """ 

33 super().__init__(**kwargs) 

34 self.http_proxy = http_proxy 

35 self.https_proxy = https_proxy 

36 self.no_proxy = no_proxy 

37 self.readiness_endpoints = readiness_endpoints 

38 self.trusted_ca = trusted_ca 

39 

40 def to_dict(self) -> None: 

41 super().to_dict() 

42 

43 if not self.kind_dict and not self.yaml_file: 

44 self.res["spec"] = {} 

45 _spec = self.res["spec"] 

46 

47 if self.http_proxy: 

48 _spec["httpProxy"] = self.http_proxy 

49 

50 if self.https_proxy: 

51 _spec["httpsProxy"] = self.https_proxy 

52 

53 if self.no_proxy: 

54 _spec["noProxy"] = self.no_proxy 

55 

56 if self.readiness_endpoints: 

57 _spec["readinessEndpoints"] = self.readiness_endpoints 

58 

59 if self.trusted_ca: 

60 _spec["trustedCA"] = self.trusted_ca