Coverage for ocp_resources/image_caching_internal_knative_dev.py: 0%

21 statements  

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

1# Generated using https://github.com/RedHatQE/openshift-python-wrapper/blob/main/scripts/resource/README.md 

2 

3from typing import Any, List, Optional 

4from ocp_resources.resource import NamespacedResource, MissingRequiredArgumentError 

5 

6 

7class Image(NamespacedResource): 

8 """ 

9 Image is a Knative abstraction that encapsulates the interface by which Knative components express a desire to have a particular image cached. 

10 """ 

11 

12 api_group: str = NamespacedResource.ApiGroup.CACHING_INTERNAL_KNATIVE_DEV 

13 

14 def __init__( 

15 self, 

16 image: Optional[str] = "", 

17 image_pull_secrets: Optional[List[Any]] = None, 

18 service_account_name: Optional[str] = "", 

19 **kwargs: Any, 

20 ) -> None: 

21 """ 

22 Args: 

23 image (str): Image is the name of the container image url to cache across the 

24 cluster. 

25 

26 image_pull_secrets (List[Any]): ImagePullSecrets contains the names of the Kubernetes Secrets 

27 containing login information used by the Pods which will run this 

28 container. 

29 

30 service_account_name (str): ServiceAccountName is the name of the Kubernetes ServiceAccount as 

31 which the Pods will run this container. This is potentially used 

32 to authenticate the image pull if the service account has attached 

33 pull secrets. For more information: 

34 https://kubernetes.io/docs/tasks/configure-pod- 

35 container/configure-service-account/#add-imagepullsecrets-to-a- 

36 service-account 

37 

38 """ 

39 super().__init__(**kwargs) 

40 

41 self.image = image 

42 self.image_pull_secrets = image_pull_secrets 

43 self.service_account_name = service_account_name 

44 

45 def to_dict(self) -> None: 

46 super().to_dict() 

47 

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

49 if not self.image: 

50 raise MissingRequiredArgumentError(argument="self.image") 

51 

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

53 _spec = self.res["spec"] 

54 

55 _spec["image"] = self.image 

56 

57 if self.image_pull_secrets: 

58 _spec["imagePullSecrets"] = self.image_pull_secrets 

59 

60 if self.service_account_name: 

61 _spec["serviceAccountName"] = self.service_account_name 

62 

63 # End of generated code