Coverage for ocp_resources/image_image_openshift_io.py: 0%

39 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, Dict, List, Optional 

4from ocp_resources.resource import Resource 

5 

6 

7class Image(Resource): 

8 """ 

9 Image is an immutable representation of a container image and metadata at a point in time. Images are named by taking a hash of their contents (metadata and content) and any change in format, content, or metadata results in a new name. The images resource is primarily for use by cluster administrators and integrations like the cluster image registry - end users instead access images via the imagestreamtags or imagestreamimages resources. While image metadata is stored in the API, any integration that implements the container image registry API must provide its own storage for the raw manifest data, image config, and layer contents. 

10 

11 Compatibility level 1: Stable within a major release for a minimum of 12 months or 3 minor releases (whichever is longer). 

12 """ 

13 

14 api_group: str = Resource.ApiGroup.IMAGE_OPENSHIFT_IO 

15 

16 def __init__( 

17 self, 

18 docker_image_config: Optional[str] = "", 

19 docker_image_layers: Optional[List[Any]] = None, 

20 docker_image_manifest: Optional[str] = "", 

21 docker_image_manifest_media_type: Optional[str] = "", 

22 docker_image_manifests: Optional[List[Any]] = None, 

23 docker_image_metadata: Optional[Dict[str, Any]] = None, 

24 docker_image_metadata_version: Optional[str] = "", 

25 docker_image_reference: Optional[str] = "", 

26 docker_image_signatures: Optional[List[Any]] = None, 

27 signatures: Optional[List[Any]] = None, 

28 **kwargs: Any, 

29 ) -> None: 

30 """ 

31 Args: 

32 docker_image_config (str): DockerImageConfig is a JSON blob that the runtime uses to set up the 

33 container. This is a part of manifest schema v2. Will not be set 

34 when the image represents a manifest list. 

35 

36 docker_image_layers (List[Any]): DockerImageLayers represents the layers in the image. May not be set 

37 if the image does not define that data or if the image represents 

38 a manifest list. 

39 

40 docker_image_manifest (str): DockerImageManifest is the raw JSON of the manifest 

41 

42 docker_image_manifest_media_type (str): DockerImageManifestMediaType specifies the mediaType of manifest. This 

43 is a part of manifest schema v2. 

44 

45 docker_image_manifests (List[Any]): DockerImageManifests holds information about sub-manifests when the 

46 image represents a manifest list. When this field is present, no 

47 DockerImageLayers should be specified. 

48 

49 docker_image_metadata (Dict[str, Any]): RawExtension is used to hold extensions in external versions. To use 

50 this, make a field which has RawExtension as its type in your 

51 external, versioned struct, and Object in your internal struct. 

52 You also need to register your various plugin types. // Internal 

53 package: type MyAPIObject struct { 

54 runtime.TypeMeta `json:",inline"` MyPlugin 

55 runtime.Object `json:"myPlugin"` } type PluginA 

56 struct { AOption string `json:"aOption"` } 

57 // External package: type MyAPIObject struct { 

58 runtime.TypeMeta `json:",inline"` MyPlugin 

59 runtime.RawExtension `json:"myPlugin"` } type 

60 PluginA struct { AOption string `json:"aOption"` 

61 } // On the wire, the JSON will look something like this: 

62 { "kind":"MyAPIObject", 

63 "apiVersion":"v1", "myPlugin": { 

64 "kind":"PluginA", "aOption":"foo", 

65 }, } So what happens? Decode first uses json or yaml to 

66 unmarshal the serialized data into your external MyAPIObject. That 

67 causes the raw JSON to be stored, but not unpacked. The next step 

68 is to copy (using pkg/conversion) into the internal struct. The 

69 runtime package's DefaultScheme has conversion functions installed 

70 which will unpack the JSON stored in RawExtension, turning it into 

71 the correct object type, and storing it in the Object. (TODO: In 

72 the case where the object is of an unknown type, a runtime.Unknown 

73 object will be created and stored.) 

74 

75 docker_image_metadata_version (str): DockerImageMetadataVersion conveys the version of the object, which if 

76 empty defaults to "1.0" 

77 

78 docker_image_reference (str): DockerImageReference is the string that can be used to pull this 

79 image. 

80 

81 docker_image_signatures (List[Any]): DockerImageSignatures provides the signatures as opaque blobs. This is 

82 a part of manifest schema v1. 

83 

84 signatures (List[Any]): Signatures holds all signatures of the image. 

85 

86 """ 

87 super().__init__(**kwargs) 

88 

89 self.docker_image_config = docker_image_config 

90 self.docker_image_layers = docker_image_layers 

91 self.docker_image_manifest = docker_image_manifest 

92 self.docker_image_manifest_media_type = docker_image_manifest_media_type 

93 self.docker_image_manifests = docker_image_manifests 

94 self.docker_image_metadata = docker_image_metadata 

95 self.docker_image_metadata_version = docker_image_metadata_version 

96 self.docker_image_reference = docker_image_reference 

97 self.docker_image_signatures = docker_image_signatures 

98 self.signatures = signatures 

99 

100 def to_dict(self) -> None: 

101 super().to_dict() 

102 

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

104 if self.docker_image_config: 

105 self.res["dockerImageConfig"] = self.docker_image_config 

106 

107 if self.docker_image_layers: 

108 self.res["dockerImageLayers"] = self.docker_image_layers 

109 

110 if self.docker_image_manifest: 

111 self.res["dockerImageManifest"] = self.docker_image_manifest 

112 

113 if self.docker_image_manifest_media_type: 

114 self.res["dockerImageManifestMediaType"] = self.docker_image_manifest_media_type 

115 

116 if self.docker_image_manifests: 

117 self.res["dockerImageManifests"] = self.docker_image_manifests 

118 

119 if self.docker_image_metadata: 

120 self.res["dockerImageMetadata"] = self.docker_image_metadata 

121 

122 if self.docker_image_metadata_version: 

123 self.res["dockerImageMetadataVersion"] = self.docker_image_metadata_version 

124 

125 if self.docker_image_reference: 

126 self.res["dockerImageReference"] = self.docker_image_reference 

127 

128 if self.docker_image_signatures: 

129 self.res["dockerImageSignatures"] = self.docker_image_signatures 

130 

131 if self.signatures: 

132 self.res["signatures"] = self.signatures 

133 

134 # End of generated code