Coverage for ocp_resources/cluster_deployment.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 

2from ocp_resources.resource import NamespacedResource 

3 

4 

5class ClusterDeployment(NamespacedResource): 

6 """ 

7 https://github.com/openshift/hive/blob/master/docs/using-hive.md#clusterdeployment 

8 """ 

9 

10 api_group: str = NamespacedResource.ApiGroup.HIVE_OPENSHIFT_IO 

11 

12 def __init__( 

13 self, 

14 base_domain: str = "", 

15 cluster_name: str = "", 

16 platform: Dict[str, Any] | None = None, 

17 provisioning: Dict[str, Any] | None = None, 

18 pull_secret_ref_name: str = "", 

19 **kwargs: Any, 

20 ) -> None: 

21 """ 

22 Args: 

23 base_domain (str): ClusterDeployment base domain 

24 cluster_name (str): ClusterDeployment cluster name 

25 platform (dict): ClusterDeployment platform 

26 provisioning (dict): ClusterDeployment provisioning 

27 pull_secret_ref_name (str): ClusterDeployment pull secret name 

28 """ 

29 super().__init__(**kwargs) 

30 self.base_domain = base_domain 

31 self.cluster_name = cluster_name 

32 self.platform = platform 

33 self.provisioning = provisioning 

34 self.pull_secret_ref_name = pull_secret_ref_name 

35 

36 def to_dict(self) -> None: 

37 super().to_dict() 

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

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

40 _spec = self.res["spec"] 

41 

42 if self.base_domain: 

43 _spec["baseDomain"] = self.base_domain 

44 

45 if self.cluster_name: 

46 _spec["clusterName"] = self.cluster_name 

47 

48 if self.platform: 

49 _spec["platform"] = self.platform 

50 

51 if self.provisioning: 

52 _spec["provisioning"] = self.provisioning 

53 

54 if self.pull_secret_ref_name: 

55 _spec["pullSecretRef"] = {"name": self.pull_secret_ref_name}