github.com/hanks177/podman/v4@v4.1.3-0.20220613032544-16d90015bc83/pkg/domain/entities/images.go (about) 1 package entities 2 3 import ( 4 "net/url" 5 "time" 6 7 "github.com/containers/common/pkg/config" 8 "github.com/containers/image/v5/manifest" 9 "github.com/containers/image/v5/types" 10 "github.com/hanks177/podman/v4/pkg/inspect" 11 "github.com/hanks177/podman/v4/pkg/trust" 12 "github.com/docker/docker/api/types/container" 13 "github.com/opencontainers/go-digest" 14 v1 "github.com/opencontainers/image-spec/specs-go/v1" 15 ) 16 17 type Image struct { 18 ID string `json:"Id"` 19 RepoTags []string `json:",omitempty"` 20 RepoDigests []string `json:",omitempty"` 21 Parent string `json:",omitempty"` 22 Comment string `json:",omitempty"` 23 Created string `json:",omitempty"` 24 Container string `json:",omitempty"` 25 ContainerConfig *container.Config `json:",omitempty"` 26 DockerVersion string `json:",omitempty"` 27 Author string `json:",omitempty"` 28 Config *container.Config `json:",omitempty"` 29 Architecture string `json:",omitempty"` 30 Variant string `json:",omitempty"` 31 Os string `json:",omitempty"` 32 OsVersion string `json:",omitempty"` 33 Size int64 `json:",omitempty"` 34 VirtualSize int64 `json:",omitempty"` 35 GraphDriver string `json:",omitempty"` 36 RootFS string `json:",omitempty"` 37 Metadata string `json:",omitempty"` 38 39 // Podman extensions 40 Digest digest.Digest `json:",omitempty"` 41 PodmanVersion string `json:",omitempty"` 42 ManifestType string `json:",omitempty"` 43 User string `json:",omitempty"` 44 History []v1.History `json:",omitempty"` 45 NamesHistory []string `json:",omitempty"` 46 HealthCheck *manifest.Schema2HealthConfig `json:",omitempty"` 47 } 48 49 func (i *Image) Id() string { // nolint 50 return i.ID 51 } 52 53 // swagger:model LibpodImageSummary 54 type ImageSummary struct { 55 ID string `json:"Id"` 56 ParentId string // nolint 57 RepoTags []string 58 RepoDigests []string 59 Created int64 60 Size int64 61 SharedSize int 62 VirtualSize int64 63 Labels map[string]string 64 Containers int 65 ReadOnly bool `json:",omitempty"` 66 Dangling bool `json:",omitempty"` 67 68 // Podman extensions 69 Names []string `json:",omitempty"` 70 Digest string `json:",omitempty"` 71 History []string `json:",omitempty"` 72 } 73 74 func (i *ImageSummary) Id() string { // nolint 75 return i.ID 76 } 77 78 func (i *ImageSummary) IsReadOnly() bool { 79 return i.ReadOnly 80 } 81 82 func (i *ImageSummary) IsDangling() bool { 83 return i.Dangling 84 } 85 86 // ImageRemoveOptions can be used to alter image removal. 87 type ImageRemoveOptions struct { 88 // All will remove all images. 89 All bool 90 // Foce will force image removal including containers using the images. 91 Force bool 92 // Ignore if a specified image does not exist and do not throw an error. 93 Ignore bool 94 // Confirms if given name is a manifest list and removes it, otherwise returns error. 95 LookupManifest bool 96 } 97 98 // ImageRemoveReport is the response for removing one or more image(s) from storage 99 // and images what was untagged vs actually removed. 100 type ImageRemoveReport struct { 101 // Deleted images. 102 Deleted []string `json:",omitempty"` 103 // Untagged images. Can be longer than Deleted. 104 Untagged []string `json:",omitempty"` 105 // ExitCode describes the exit codes as described in the `podman rmi` 106 // man page. 107 ExitCode int 108 } 109 110 type ImageHistoryOptions struct{} 111 112 type ImageHistoryLayer struct { 113 ID string `json:"id"` 114 Created time.Time `json:"created,omitempty"` 115 CreatedBy string `json:",omitempty"` 116 Tags []string `json:"tags,omitempty"` 117 Size int64 `json:"size"` 118 Comment string `json:"comment,omitempty"` 119 } 120 121 type ImageHistoryReport struct { 122 Layers []ImageHistoryLayer 123 } 124 125 // ImagePullOptions are the arguments for pulling images. 126 type ImagePullOptions struct { 127 // AllTags can be specified to pull all tags of an image. Note 128 // that this only works if the image does not include a tag. 129 AllTags bool 130 // Authfile is the path to the authentication file. Ignored for remote 131 // calls. 132 Authfile string 133 // CertDir is the path to certificate directories. Ignored for remote 134 // calls. 135 CertDir string 136 // Username for authenticating against the registry. 137 Username string 138 // Password for authenticating against the registry. 139 Password string 140 // Arch will overwrite the local architecture for image pulls. 141 Arch string 142 // OS will overwrite the local operating system (OS) for image 143 // pulls. 144 OS string 145 // Variant will overwrite the local variant for image pulls. 146 Variant string 147 // Quiet can be specified to suppress pull progress when pulling. Ignored 148 // for remote calls. 149 Quiet bool 150 // SignaturePolicy to use when pulling. Ignored for remote calls. 151 SignaturePolicy string 152 // SkipTLSVerify to skip HTTPS and certificate verification. 153 SkipTLSVerify types.OptionalBool 154 // PullPolicy whether to pull new image 155 PullPolicy config.PullPolicy 156 } 157 158 // ImagePullReport is the response from pulling one or more images. 159 type ImagePullReport struct { 160 // Stream used to provide output from c/image 161 Stream string `json:"stream,omitempty"` 162 // Error contains text of errors from c/image 163 Error string `json:"error,omitempty"` 164 // Images contains the ID's of the images pulled 165 Images []string `json:"images,omitempty"` 166 // ID contains image id (retained for backwards compatibility) 167 ID string `json:"id,omitempty"` 168 } 169 170 // ImagePushOptions are the arguments for pushing images. 171 type ImagePushOptions struct { 172 // All indicates that all images referenced in an manifest list should be pushed 173 All bool 174 // Authfile is the path to the authentication file. Ignored for remote 175 // calls. 176 Authfile string 177 // CertDir is the path to certificate directories. Ignored for remote 178 // calls. 179 CertDir string 180 // Compress tarball image layers when pushing to a directory using the 'dir' 181 // transport. Default is same compression type as source. Ignored for remote 182 // calls. 183 Compress bool 184 // Username for authenticating against the registry. 185 Username string 186 // Password for authenticating against the registry. 187 Password string 188 // DigestFile, after copying the image, write the digest of the resulting 189 // image to the file. Ignored for remote calls. 190 DigestFile string 191 // Format is the Manifest type (oci, v2s1, or v2s2) to use when pushing an 192 // image. Default is manifest type of source, with fallbacks. 193 // Ignored for remote calls. 194 Format string 195 // Quiet can be specified to suppress pull progress when pulling. Ignored 196 // for remote calls. 197 Quiet bool 198 // Rm indicates whether to remove the manifest list if push succeeds 199 Rm bool 200 // RemoveSignatures, discard any pre-existing signatures in the image. 201 // Ignored for remote calls. 202 RemoveSignatures bool 203 // SignaturePolicy to use when pulling. Ignored for remote calls. 204 SignaturePolicy string 205 // SignBy adds a signature at the destination using the specified key. 206 // Ignored for remote calls. 207 SignBy string 208 // SkipTLSVerify to skip HTTPS and certificate verification. 209 SkipTLSVerify types.OptionalBool 210 // Progress to get progress notifications 211 Progress chan types.ProgressProperties 212 // CompressionFormat is the format to use for the compression of the blobs 213 CompressionFormat string 214 } 215 216 // ImageSearchOptions are the arguments for searching images. 217 type ImageSearchOptions struct { 218 // Authfile is the path to the authentication file. Ignored for remote 219 // calls. 220 Authfile string 221 // Filters for the search results. 222 Filters []string 223 // Limit the number of results. 224 Limit int 225 // SkipTLSVerify to skip HTTPS and certificate verification. 226 SkipTLSVerify types.OptionalBool 227 // ListTags search the available tags of the repository 228 ListTags bool 229 } 230 231 // ImageSearchReport is the response from searching images. 232 type ImageSearchReport struct { 233 // Index is the image index (e.g., "docker.io" or "quay.io") 234 Index string 235 // Name is the canonical name of the image (e.g., "docker.io/library/alpine"). 236 Name string 237 // Description of the image. 238 Description string 239 // Stars is the number of stars of the image. 240 Stars int 241 // Official indicates if it's an official image. 242 Official string 243 // Automated indicates if the image was created by an automated build. 244 Automated string 245 // Tag is the repository tag 246 Tag string 247 } 248 249 // Image List Options 250 type ImageListOptions struct { 251 All bool `json:"all" schema:"all"` 252 Filter []string `json:"Filter,omitempty"` 253 } 254 255 type ImagePruneOptions struct { 256 All bool `json:"all" schema:"all"` 257 External bool `json:"external" schema:"external"` 258 Filter []string `json:"filter" schema:"filter"` 259 } 260 261 type ImageTagOptions struct{} 262 type ImageUntagOptions struct{} 263 264 // ImageInspectReport is the data when inspecting an image. 265 type ImageInspectReport struct { 266 *inspect.ImageData 267 } 268 269 type ImageLoadOptions struct { 270 Input string 271 Quiet bool 272 SignaturePolicy string 273 } 274 275 type ImageLoadReport struct { 276 Names []string 277 } 278 279 type ImageImportOptions struct { 280 Architecture string 281 Variant string 282 Changes []string 283 Message string 284 OS string 285 Quiet bool 286 Reference string 287 SignaturePolicy string 288 Source string 289 SourceIsURL bool 290 } 291 292 type ImageImportReport struct { 293 Id string // nolint 294 } 295 296 // ImageSaveOptions provide options for saving images. 297 type ImageSaveOptions struct { 298 // Compress layers when saving to a directory. 299 Compress bool 300 // Format of saving the image: oci-archive, oci-dir (directory with oci 301 // manifest type), docker-archive, docker-dir (directory with v2s2 302 // manifest type). 303 Format string 304 // MultiImageArchive denotes if the created archive shall include more 305 // than one image. Additional tags will be interpreted as references 306 // to images which are added to the archive. 307 MultiImageArchive bool 308 // Accept uncompressed layers when copying OCI images. 309 OciAcceptUncompressedLayers bool 310 // Output - write image to the specified path. 311 Output string 312 // Quiet - suppress output when copying images 313 Quiet bool 314 } 315 316 // ImageScpOptions provide options for securely copying images to and from a remote host 317 type ImageScpOptions struct { 318 // Remote determines if this entity is operating on a remote machine 319 Remote bool `json:"remote,omitempty"` 320 // File is the input/output file for the save and load Operation 321 File string `json:"file,omitempty"` 322 // Quiet Determines if the save and load operation will be done quietly 323 Quiet bool `json:"quiet,omitempty"` 324 // Image is the image the user is providing to save and load 325 Image string `json:"image,omitempty"` 326 // User is used in conjunction with Transfer to determine if a valid user was given to save from/load into 327 User string `json:"user,omitempty"` 328 } 329 330 // ImageScpConnections provides the ssh related information used in remote image transfer 331 type ImageScpConnections struct { 332 // Connections holds the raw string values for connections (ssh or unix) 333 Connections []string 334 // URI contains the ssh connection URLs to be used by the client 335 URI []*url.URL 336 // Identities contains ssh identity keys to be used by the client 337 Identities []string 338 } 339 340 // ImageTreeOptions provides options for ImageEngine.Tree() 341 type ImageTreeOptions struct { 342 WhatRequires bool // Show all child images and layers of the specified image 343 } 344 345 // ImageTreeReport provides results from ImageEngine.Tree() 346 type ImageTreeReport struct { 347 Tree string // TODO: Refactor move presentation work out of server 348 } 349 350 // ShowTrustOptions are the cli options for showing trust 351 type ShowTrustOptions struct { 352 JSON bool 353 PolicyPath string 354 Raw bool 355 RegistryPath string 356 } 357 358 // ShowTrustReport describes the results of show trust 359 type ShowTrustReport struct { 360 Raw []byte 361 SystemRegistriesDirPath string 362 JSONOutput []byte 363 Policies []*trust.Policy 364 } 365 366 // SetTrustOptions describes the CLI options for setting trust 367 type SetTrustOptions struct { 368 PolicyPath string 369 PubKeysFile []string 370 Type string 371 } 372 373 // SignOptions describes input options for the CLI signing 374 type SignOptions struct { 375 Directory string 376 SignBy string 377 CertDir string 378 Authfile string 379 All bool 380 } 381 382 // SignReport describes the result of signing 383 type SignReport struct{} 384 385 // ImageMountOptions describes the input values for mounting images 386 // in the CLI 387 type ImageMountOptions struct { 388 All bool 389 Format string 390 } 391 392 // ImageUnmountOptions are the options from the cli for unmounting 393 type ImageUnmountOptions struct { 394 All bool 395 Force bool 396 } 397 398 // ImageMountReport describes the response from image mount 399 type ImageMountReport struct { 400 Id string // nolint 401 Name string 402 Repositories []string 403 Path string 404 } 405 406 // ImageUnmountReport describes the response from umounting an image 407 type ImageUnmountReport struct { 408 Err error 409 Id string // nolint 410 }