Coverage for ocp_resources/backup.py: 0%

24 statements  

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

1# -*- coding: utf-8 -*- 

2from __future__ import annotations 

3from typing import Any, List 

4 

5from ocp_resources.resource import NamespacedResource 

6 

7 

8class Backup(NamespacedResource): 

9 """ 

10 Backup in 'velero' official API: 

11 https://velero.io/docs/main/api-types/backup/ 

12 """ 

13 

14 api_group = NamespacedResource.ApiGroup.VELERO_IO 

15 

16 def __init__( 

17 self, 

18 included_namespaces: List[str] | None = None, 

19 excluded_resources: List[str] | None = None, 

20 snapshot_move_data: bool = False, 

21 storage_location: str = "", 

22 **kwargs: Any, 

23 ): 

24 """ 

25 Args: 

26 included_namespaces (list, optional): Namespaces to include in the backup. 

27 If unspecified, all namespaces are included. 

28 excluded_resources (list, optional): Resources to exclude from the backup. 

29 Resources may be shortcuts (e.g. 'po' for 'pods') or fully-qualified. 

30 snapshot_move_data (bool, optional): If set to true, deploys the volume snapshot mover 

31 controller and a modified CSI Data Mover plugin. 

32 storage_location (string, optional): Define the location for the DataMover. 

33 """ 

34 super().__init__(**kwargs) 

35 self.included_namespaces = included_namespaces 

36 self.excluded_resources = excluded_resources 

37 self.snapshot_move_data = snapshot_move_data 

38 self.storage_location = storage_location 

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_dict = self.res["spec"] 

46 

47 if self.included_namespaces: 

48 spec_dict["includedNamespaces"] = self.included_namespaces 

49 

50 if self.excluded_resources: 

51 spec_dict["excludedResources"] = self.excluded_resources 

52 

53 if self.snapshot_move_data: 

54 spec_dict["snapshotMoveData"] = self.snapshot_move_data 

55 

56 if self.storage_location: 

57 spec_dict["storageLocation"] = self.storage_location