diff --git a/pkg/bindings/images/build.go b/pkg/bindings/images/build.go index 0f0f2dee89..d4089d0a40 100644 --- a/pkg/bindings/images/build.go +++ b/pkg/bindings/images/build.go @@ -18,11 +18,11 @@ import ( "strings" "github.com/containers/buildah/define" - "github.com/containers/image/v5/types" + imageTypes "github.com/containers/image/v5/types" ldefine "github.com/containers/podman/v4/libpod/define" "github.com/containers/podman/v4/pkg/auth" "github.com/containers/podman/v4/pkg/bindings" - "github.com/containers/podman/v4/pkg/domain/entities" + "github.com/containers/podman/v4/pkg/domain/entities/types" "github.com/containers/podman/v4/pkg/util" "github.com/containers/storage/pkg/fileutils" "github.com/containers/storage/pkg/ioutils" @@ -50,7 +50,7 @@ type BuildResponse struct { } // Build creates an image using a containerfile reference -func Build(ctx context.Context, containerFiles []string, options entities.BuildOptions) (*entities.BuildReport, error) { +func Build(ctx context.Context, containerFiles []string, options types.BuildOptions) (*types.BuildReport, error) { if options.CommonBuildOpts == nil { options.CommonBuildOpts = new(define.CommonBuildOptions) } @@ -255,9 +255,9 @@ func Build(ctx context.Context, containerFiles []string, options entities.BuildO } switch options.SkipUnusedStages { - case types.OptionalBoolTrue: + case imageTypes.OptionalBoolTrue: params.Set("skipunusedstages", "1") - case types.OptionalBoolFalse: + case imageTypes.OptionalBoolFalse: params.Set("skipunusedstages", "0") } @@ -342,9 +342,9 @@ func Build(ctx context.Context, containerFiles []string, options entities.BuildO params.Set("pullpolicy", options.PullPolicy.String()) switch options.CommonBuildOpts.IdentityLabel { - case types.OptionalBoolTrue: + case imageTypes.OptionalBoolTrue: params.Set("identitylabel", "1") - case types.OptionalBoolFalse: + case imageTypes.OptionalBoolFalse: params.Set("identitylabel", "0") } if options.Quiet { @@ -416,7 +416,7 @@ func Build(ctx context.Context, containerFiles []string, options entities.BuildO } else { headers, err = auth.MakeXRegistryConfigHeader(options.SystemContext, "", "") } - if options.SystemContext.DockerInsecureSkipTLSVerify == types.OptionalBoolTrue { + if options.SystemContext.DockerInsecureSkipTLSVerify == imageTypes.OptionalBoolTrue { params.Set("tlsVerify", "false") } } @@ -618,7 +618,7 @@ func Build(ctx context.Context, containerFiles []string, options entities.BuildO // even when the server quit but it seems desirable to // distinguish a proper build from a transient EOF. case <-response.Request.Context().Done(): - return &entities.BuildReport{ID: id, SaveFormat: saveFormat}, nil + return &types.BuildReport{ID: id, SaveFormat: saveFormat}, nil default: // non-blocking select } @@ -632,7 +632,7 @@ func Build(ctx context.Context, containerFiles []string, options entities.BuildO if errors.Is(err, io.EOF) && id != "" { break } - return &entities.BuildReport{ID: id, SaveFormat: saveFormat}, fmt.Errorf("decoding stream: %w", err) + return &types.BuildReport{ID: id, SaveFormat: saveFormat}, fmt.Errorf("decoding stream: %w", err) } switch { @@ -645,12 +645,12 @@ func Build(ctx context.Context, containerFiles []string, options entities.BuildO case s.Error != nil: // If there's an error, return directly. The stream // will be closed on return. - return &entities.BuildReport{ID: id, SaveFormat: saveFormat}, errors.New(s.Error.Message) + return &types.BuildReport{ID: id, SaveFormat: saveFormat}, errors.New(s.Error.Message) default: - return &entities.BuildReport{ID: id, SaveFormat: saveFormat}, errors.New("failed to parse build results stream, unexpected input") + return &types.BuildReport{ID: id, SaveFormat: saveFormat}, errors.New("failed to parse build results stream, unexpected input") } } - return &entities.BuildReport{ID: id, SaveFormat: saveFormat}, nil + return &types.BuildReport{ID: id, SaveFormat: saveFormat}, nil } func nTar(excludes []string, sources ...string) (io.ReadCloser, error) { diff --git a/pkg/bindings/images/images.go b/pkg/bindings/images/images.go index ef76bb9dfc..d9ef13ddc4 100644 --- a/pkg/bindings/images/images.go +++ b/pkg/bindings/images/images.go @@ -10,11 +10,11 @@ import ( "strconv" imageTypes "github.com/containers/image/v5/types" - "github.com/containers/podman/v4/pkg/api/handlers/types" + handlersTypes "github.com/containers/podman/v4/pkg/api/handlers/types" "github.com/containers/podman/v4/pkg/auth" "github.com/containers/podman/v4/pkg/bindings" - "github.com/containers/podman/v4/pkg/domain/entities" "github.com/containers/podman/v4/pkg/domain/entities/reports" + "github.com/containers/podman/v4/pkg/domain/entities/types" ) // Exists a lightweight way to determine if an image exists in local storage. It returns a @@ -35,11 +35,11 @@ func Exists(ctx context.Context, nameOrID string, options *ExistsOptions) (bool, // List returns a list of images in local storage. The all boolean and filters parameters are optional // ways to alter the image query. -func List(ctx context.Context, options *ListOptions) ([]*entities.ImageSummary, error) { +func List(ctx context.Context, options *ListOptions) ([]*types.ImageSummary, error) { if options == nil { options = new(ListOptions) } - var imageSummary []*entities.ImageSummary + var imageSummary []*types.ImageSummary conn, err := bindings.GetClient(ctx) if err != nil { return nil, err @@ -59,7 +59,7 @@ func List(ctx context.Context, options *ListOptions) ([]*entities.ImageSummary, // Get performs an image inspect. To have the on-disk size of the image calculated, you can // use the optional size parameter. -func GetImage(ctx context.Context, nameOrID string, options *GetOptions) (*entities.ImageInspectReport, error) { +func GetImage(ctx context.Context, nameOrID string, options *GetOptions) (*types.ImageInspectReport, error) { if options == nil { options = new(GetOptions) } @@ -71,7 +71,7 @@ func GetImage(ctx context.Context, nameOrID string, options *GetOptions) (*entit if err != nil { return nil, err } - inspectedData := entities.ImageInspectReport{} + inspectedData := types.ImageInspectReport{} response, err := conn.DoRequest(ctx, nil, http.MethodGet, "/images/%s/json", params, nil, nameOrID) if err != nil { return &inspectedData, err @@ -82,11 +82,11 @@ func GetImage(ctx context.Context, nameOrID string, options *GetOptions) (*entit } // Tree retrieves a "tree" based representation of the given image -func Tree(ctx context.Context, nameOrID string, options *TreeOptions) (*entities.ImageTreeReport, error) { +func Tree(ctx context.Context, nameOrID string, options *TreeOptions) (*types.ImageTreeReport, error) { if options == nil { options = new(TreeOptions) } - var report entities.ImageTreeReport + var report types.ImageTreeReport conn, err := bindings.GetClient(ctx) if err != nil { return nil, err @@ -105,12 +105,12 @@ func Tree(ctx context.Context, nameOrID string, options *TreeOptions) (*entities } // History returns the parent layers of an image. -func History(ctx context.Context, nameOrID string, options *HistoryOptions) ([]*types.HistoryResponse, error) { +func History(ctx context.Context, nameOrID string, options *HistoryOptions) ([]*handlersTypes.HistoryResponse, error) { if options == nil { options = new(HistoryOptions) } _ = options - var history []*types.HistoryResponse + var history []*handlersTypes.HistoryResponse conn, err := bindings.GetClient(ctx) if err != nil { return nil, err @@ -124,8 +124,8 @@ func History(ctx context.Context, nameOrID string, options *HistoryOptions) ([]* return history, response.Process(&history) } -func Load(ctx context.Context, r io.Reader) (*entities.ImageLoadReport, error) { - var report entities.ImageLoadReport +func Load(ctx context.Context, r io.Reader) (*types.ImageLoadReport, error) { + var report types.ImageLoadReport conn, err := bindings.GetClient(ctx) if err != nil { return nil, err @@ -242,11 +242,11 @@ func Untag(ctx context.Context, nameOrID, tag, repo string, options *UntagOption // Import adds the given image to the local image store. This can be done by file and the given reader // or via the url parameter. Additional metadata can be associated with the image by using the changes and // message parameters. The image can also be tagged given a reference. One of url OR r must be provided. -func Import(ctx context.Context, r io.Reader, options *ImportOptions) (*entities.ImageImportReport, error) { +func Import(ctx context.Context, r io.Reader, options *ImportOptions) (*types.ImageImportReport, error) { if options == nil { options = new(ImportOptions) } - var report entities.ImageImportReport + var report types.ImageImportReport if r != nil && options.URL != nil { return nil, errors.New("url and r parameters cannot be used together") } @@ -268,7 +268,7 @@ func Import(ctx context.Context, r io.Reader, options *ImportOptions) (*entities } // Search is the binding for libpod's v2 endpoints for Search images. -func Search(ctx context.Context, term string, options *SearchOptions) ([]entities.ImageSearchReport, error) { +func Search(ctx context.Context, term string, options *SearchOptions) ([]types.ImageSearchReport, error) { if options == nil { options = new(SearchOptions) } @@ -299,7 +299,7 @@ func Search(ctx context.Context, term string, options *SearchOptions) ([]entitie } defer response.Body.Close() - results := []entities.ImageSearchReport{} + results := []types.ImageSearchReport{} if err := response.Process(&results); err != nil { return nil, err } diff --git a/pkg/bindings/images/pull.go b/pkg/bindings/images/pull.go index 43592f6e21..4172e85373 100644 --- a/pkg/bindings/images/pull.go +++ b/pkg/bindings/images/pull.go @@ -10,10 +10,10 @@ import ( "os" "strconv" - "github.com/containers/image/v5/types" + imgTypes "github.com/containers/image/v5/types" "github.com/containers/podman/v4/pkg/auth" "github.com/containers/podman/v4/pkg/bindings" - "github.com/containers/podman/v4/pkg/domain/entities" + "github.com/containers/podman/v4/pkg/domain/entities/types" "github.com/containers/podman/v4/pkg/errorhandling" ) @@ -41,7 +41,7 @@ func Pull(ctx context.Context, rawImage string, options *PullOptions) ([]string, params.Set("tlsVerify", strconv.FormatBool(!options.GetSkipTLSVerify())) } - header, err := auth.MakeXRegistryAuthHeader(&types.SystemContext{AuthFilePath: options.GetAuthfile()}, options.GetUsername(), options.GetPassword()) + header, err := auth.MakeXRegistryAuthHeader(&imgTypes.SystemContext{AuthFilePath: options.GetAuthfile()}, options.GetUsername(), options.GetPassword()) if err != nil { return nil, err } @@ -71,7 +71,7 @@ func Pull(ctx context.Context, rawImage string, options *PullOptions) ([]string, var pullErrors []error LOOP: for { - var report entities.ImagePullReport + var report types.ImagePullReport if err := dec.Decode(&report); err != nil { if errors.Is(err, io.EOF) { break diff --git a/pkg/bindings/images/push.go b/pkg/bindings/images/push.go index ea1d96823e..33ad34dd13 100644 --- a/pkg/bindings/images/push.go +++ b/pkg/bindings/images/push.go @@ -13,7 +13,7 @@ import ( imageTypes "github.com/containers/image/v5/types" "github.com/containers/podman/v4/pkg/auth" "github.com/containers/podman/v4/pkg/bindings" - "github.com/containers/podman/v4/pkg/domain/entities" + "github.com/containers/podman/v4/pkg/domain/entities/types" ) // Push is the binding for libpod's endpoints for push images. Note that @@ -69,7 +69,7 @@ func Push(ctx context.Context, source string, destination string, options *PushO dec := json.NewDecoder(response.Body) LOOP: for { - var report entities.ImagePushStream + var report types.ImagePushStream if err := dec.Decode(&report); err != nil { if errors.Is(err, io.EOF) { break diff --git a/pkg/bindings/images/rm.go b/pkg/bindings/images/rm.go index eb3eef10c4..2d251e6ed7 100644 --- a/pkg/bindings/images/rm.go +++ b/pkg/bindings/images/rm.go @@ -4,19 +4,19 @@ import ( "context" "net/http" - "github.com/containers/podman/v4/pkg/api/handlers/types" + handlersTypes "github.com/containers/podman/v4/pkg/api/handlers/types" "github.com/containers/podman/v4/pkg/bindings" - "github.com/containers/podman/v4/pkg/domain/entities" + "github.com/containers/podman/v4/pkg/domain/entities/types" "github.com/containers/podman/v4/pkg/errorhandling" ) // Remove removes one or more images from the local storage. Use optional force option to remove an // image, even if it's used by containers. -func Remove(ctx context.Context, images []string, options *RemoveOptions) (*entities.ImageRemoveReport, []error) { +func Remove(ctx context.Context, images []string, options *RemoveOptions) (*types.ImageRemoveReport, []error) { if options == nil { options = new(RemoveOptions) } - var report types.LibpodImagesRemoveReport + var report handlersTypes.LibpodImagesRemoveReport conn, err := bindings.GetClient(ctx) if err != nil { return nil, []error{err} diff --git a/pkg/bindings/images/types.go b/pkg/bindings/images/types.go index e5c58df00a..6617108792 100644 --- a/pkg/bindings/images/types.go +++ b/pkg/bindings/images/types.go @@ -3,7 +3,7 @@ package images import ( "io" - buildahDefine "github.com/containers/buildah/define" + "github.com/containers/podman/v4/pkg/domain/entities/types" ) // RemoveOptions are optional options for image removal @@ -226,9 +226,7 @@ type PullOptions struct { } // BuildOptions are optional options for building images -type BuildOptions struct { - buildahDefine.BuildOptions -} +type BuildOptions = types.BuildOptions // ExistsOptions are optional options for checking if an image exists // diff --git a/pkg/domain/entities/images.go b/pkg/domain/entities/images.go index 45cebb55fb..0a4b234068 100644 --- a/pkg/domain/entities/images.go +++ b/pkg/domain/entities/images.go @@ -3,15 +3,13 @@ package entities import ( "io" "net/url" - "time" "github.com/containers/common/pkg/config" "github.com/containers/image/v5/manifest" "github.com/containers/image/v5/signature/signer" "github.com/containers/image/v5/types" encconfig "github.com/containers/ocicrypt/config" - "github.com/containers/podman/v4/pkg/inspect" - "github.com/containers/podman/v4/pkg/trust" + entitiesTypes "github.com/containers/podman/v4/pkg/domain/entities/types" "github.com/docker/docker/api/types/container" "github.com/opencontainers/go-digest" v1 "github.com/opencontainers/image-spec/specs-go/v1" @@ -54,37 +52,7 @@ func (i *Image) Id() string { //nolint:revive,stylecheck } // swagger:model LibpodImageSummary -type ImageSummary struct { - ID string `json:"Id"` - ParentId string //nolint:revive,stylecheck - RepoTags []string - RepoDigests []string - Created int64 - Size int64 - SharedSize int - VirtualSize int64 - Labels map[string]string - Containers int - ReadOnly bool `json:",omitempty"` - Dangling bool `json:",omitempty"` - - // Podman extensions - Names []string `json:",omitempty"` - Digest string `json:",omitempty"` - History []string `json:",omitempty"` -} - -func (i *ImageSummary) Id() string { //nolint:revive,stylecheck - return i.ID -} - -func (i *ImageSummary) IsReadOnly() bool { - return i.ReadOnly -} - -func (i *ImageSummary) IsDangling() bool { - return i.Dangling -} +type ImageSummary = entitiesTypes.ImageSummary // ImageRemoveOptions can be used to alter image removal. type ImageRemoveOptions struct { @@ -102,30 +70,12 @@ type ImageRemoveOptions struct { // ImageRemoveReport is the response for removing one or more image(s) from storage // and images what was untagged vs actually removed. -type ImageRemoveReport struct { - // Deleted images. - Deleted []string `json:",omitempty"` - // Untagged images. Can be longer than Deleted. - Untagged []string `json:",omitempty"` - // ExitCode describes the exit codes as described in the `podman rmi` - // man page. - ExitCode int -} +type ImageRemoveReport = entitiesTypes.ImageRemoveReport type ImageHistoryOptions struct{} -type ImageHistoryLayer struct { - ID string `json:"id"` - Created time.Time `json:"created,omitempty"` - CreatedBy string `json:",omitempty"` - Tags []string `json:"tags,omitempty"` - Size int64 `json:"size"` - Comment string `json:"comment,omitempty"` -} - -type ImageHistoryReport struct { - Layers []ImageHistoryLayer -} +type ImageHistoryLayer = entitiesTypes.ImageHistoryLayer +type ImageHistoryReport = entitiesTypes.ImageHistoryReport // ImagePullOptions are the arguments for pulling images. type ImagePullOptions struct { @@ -166,16 +116,7 @@ type ImagePullOptions struct { } // ImagePullReport is the response from pulling one or more images. -type ImagePullReport struct { - // Stream used to provide output from c/image - Stream string `json:"stream,omitempty"` - // Error contains text of errors from c/image - Error string `json:"error,omitempty"` - // Images contains the ID's of the images pulled - Images []string `json:"images,omitempty"` - // ID contains image id (retained for backwards compatibility) - ID string `json:"id,omitempty"` -} +type ImagePullReport = entitiesTypes.ImagePullReport // ImagePushOptions are the arguments for pushing images. type ImagePushOptions struct { @@ -261,14 +202,7 @@ type ImagePushReport struct { // ImagePushStream is the response from pushing an image. Only used in the // remote API. -type ImagePushStream struct { - // ManifestDigest is the digest of the manifest of the pushed image. - ManifestDigest string `json:"manifestdigest,omitempty"` - // Stream used to provide push progress - Stream string `json:"stream,omitempty"` - // Error contains text of errors from pushing - Error string `json:"error,omitempty"` -} +type ImagePushStream = entitiesTypes.ImagePushStream // ImageSearchOptions are the arguments for searching images. type ImageSearchOptions struct { @@ -296,22 +230,7 @@ type ImageSearchOptions struct { } // ImageSearchReport is the response from searching images. -type ImageSearchReport struct { - // Index is the image index (e.g., "docker.io" or "quay.io") - Index string - // Name is the canonical name of the image (e.g., "docker.io/library/alpine"). - Name string - // Description of the image. - Description string - // Stars is the number of stars of the image. - Stars int - // Official indicates if it's an official image. - Official string - // Automated indicates if the image was created by an automated build. - Automated string - // Tag is the repository tag - Tag string -} +type ImageSearchReport = entitiesTypes.ImageSearchReport // Image List Options type ImageListOptions struct { @@ -329,9 +248,7 @@ type ImageTagOptions struct{} type ImageUntagOptions struct{} // ImageInspectReport is the data when inspecting an image. -type ImageInspectReport struct { - *inspect.ImageData -} +type ImageInspectReport = entitiesTypes.ImageInspectReport type ImageLoadOptions struct { Input string @@ -339,9 +256,7 @@ type ImageLoadOptions struct { SignaturePolicy string } -type ImageLoadReport struct { - Names []string -} +type ImageLoadReport = entitiesTypes.ImageLoadReport type ImageImportOptions struct { Architecture string @@ -356,9 +271,7 @@ type ImageImportOptions struct { SourceIsURL bool } -type ImageImportReport struct { - Id string //nolint:revive,stylecheck -} +type ImageImportReport = entitiesTypes.ImageImportReport // ImageSaveOptions provide options for saving images. type ImageSaveOptions struct { @@ -413,9 +326,7 @@ type ImageTreeOptions struct { } // ImageTreeReport provides results from ImageEngine.Tree() -type ImageTreeReport struct { - Tree string // TODO: Refactor move presentation work out of server -} +type ImageTreeReport = entitiesTypes.ImageTreeReport // ShowTrustOptions are the cli options for showing trust type ShowTrustOptions struct { @@ -426,12 +337,7 @@ type ShowTrustOptions struct { } // ShowTrustReport describes the results of show trust -type ShowTrustReport struct { - Raw []byte - SystemRegistriesDirPath string - JSONOutput []byte - Policies []*trust.Policy -} +type ShowTrustReport = entitiesTypes.ShowTrustReport // SetTrustOptions describes the CLI options for setting trust type SetTrustOptions struct { @@ -466,18 +372,10 @@ type ImageUnmountOptions struct { } // ImageMountReport describes the response from image mount -type ImageMountReport struct { - Id string //nolint:revive,stylecheck - Name string - Repositories []string - Path string -} +type ImageMountReport = entitiesTypes.ImageMountReport // ImageUnmountReport describes the response from umounting an image -type ImageUnmountReport struct { - Err error - Id string //nolint:revive,stylecheck -} +type ImageUnmountReport = entitiesTypes.ImageUnmountReport const ( LocalFarmImageBuilderName = "(local)" @@ -485,10 +383,4 @@ const ( ) // FarmInspectReport describes the response from farm inspect -type FarmInspectReport struct { - NativePlatforms []string - EmulatedPlatforms []string - OS string - Arch string - Variant string -} +type FarmInspectReport = entitiesTypes.FarmInspectReport diff --git a/pkg/domain/entities/types.go b/pkg/domain/entities/types.go index 6a64bfde92..99cd33a9c0 100644 --- a/pkg/domain/entities/types.go +++ b/pkg/domain/entities/types.go @@ -2,9 +2,7 @@ package entities import ( "net" - "os" - buildahDefine "github.com/containers/buildah/define" "github.com/containers/common/libnetwork/types" "github.com/containers/podman/v4/libpod/define" "github.com/containers/podman/v4/libpod/events" @@ -103,33 +101,13 @@ type EventsOptions struct { type ContainerCreateResponse = entitiesTypes.ContainerCreateResponse // BuildOptions describe the options for building container images. -type BuildOptions struct { - buildahDefine.BuildOptions - ContainerFiles []string - FarmBuildOptions - // Files that need to be closed after the build - // so need to pass this to the main build functions - LogFileToClose *os.File - TmpDirToClose string -} +type BuildOptions = entitiesTypes.BuildOptions // BuildReport is the image-build report. -type BuildReport struct { - // ID of the image. - ID string - // Format to save the image in - SaveFormat string -} +type BuildReport = entitiesTypes.BuildReport // FarmBuildOptions describes the options for building container images on farm nodes -type FarmBuildOptions struct { - // Cleanup removes built images from farm nodes on success - Cleanup bool - // Authfile is the path to the file holding registry credentials - Authfile string - // SkipTLSVerify skips tls verification when set to true - SkipTLSVerify bool -} +type FarmBuildOptions = entitiesTypes.FarmBuildOptions type IDOrNameResponse struct { // The Id or Name of an object diff --git a/pkg/domain/entities/types/images.go b/pkg/domain/entities/types/images.go new file mode 100644 index 0000000000..1c012f7007 --- /dev/null +++ b/pkg/domain/entities/types/images.go @@ -0,0 +1,151 @@ +package types + +import ( + "time" + + "github.com/containers/podman/v4/pkg/inspect" + "github.com/containers/podman/v4/pkg/trust" +) + +// swagger:model LibpodImageSummary +type ImageSummary struct { + ID string `json:"Id"` + ParentId string //nolint:revive,stylecheck + RepoTags []string + RepoDigests []string + Created int64 + Size int64 + SharedSize int + VirtualSize int64 + Labels map[string]string + Containers int + ReadOnly bool `json:",omitempty"` + Dangling bool `json:",omitempty"` + + // Podman extensions + Names []string `json:",omitempty"` + Digest string `json:",omitempty"` + History []string `json:",omitempty"` +} + +func (i *ImageSummary) Id() string { //nolint:revive,stylecheck + return i.ID +} + +func (i *ImageSummary) IsReadOnly() bool { + return i.ReadOnly +} + +func (i *ImageSummary) IsDangling() bool { + return i.Dangling +} + +type ImageInspectReport struct { + *inspect.ImageData +} + +type ImageTreeReport struct { + Tree string // TODO: Refactor move presentation work out of server +} + +type ImageLoadReport struct { + Names []string +} + +type ImageImportReport struct { + Id string //nolint:revive,stylecheck +} + +// ImageSearchReport is the response from searching images. +type ImageSearchReport struct { + // Index is the image index (e.g., "docker.io" or "quay.io") + Index string + // Name is the canonical name of the image (e.g., "docker.io/library/alpine"). + Name string + // Description of the image. + Description string + // Stars is the number of stars of the image. + Stars int + // Official indicates if it's an official image. + Official string + // Automated indicates if the image was created by an automated build. + Automated string + // Tag is the repository tag + Tag string +} + +// ShowTrustReport describes the results of show trust +type ShowTrustReport struct { + Raw []byte + SystemRegistriesDirPath string + JSONOutput []byte + Policies []*trust.Policy +} + +// ImageMountReport describes the response from image mount +type ImageMountReport struct { + Id string //nolint:revive,stylecheck + Name string + Repositories []string + Path string +} + +// ImageUnmountReport describes the response from umounting an image +type ImageUnmountReport struct { + Err error + Id string //nolint:revive,stylecheck +} + +// FarmInspectReport describes the response from farm inspect +type FarmInspectReport struct { + NativePlatforms []string + EmulatedPlatforms []string + OS string + Arch string + Variant string +} + +// ImageRemoveReport is the response for removing one or more image(s) from storage +// and images what was untagged vs actually removed. +type ImageRemoveReport struct { + // Deleted images. + Deleted []string `json:",omitempty"` + // Untagged images. Can be longer than Deleted. + Untagged []string `json:",omitempty"` + // ExitCode describes the exit codes as described in the `podman rmi` + // man page. + ExitCode int +} + +type ImageHistoryLayer struct { + ID string `json:"id"` + Created time.Time `json:"created,omitempty"` + CreatedBy string `json:",omitempty"` + Tags []string `json:"tags,omitempty"` + Size int64 `json:"size"` + Comment string `json:"comment,omitempty"` +} + +type ImageHistoryReport struct { + Layers []ImageHistoryLayer +} + +type ImagePullReport struct { + // Stream used to provide output from c/image + Stream string `json:"stream,omitempty"` + // Error contains text of errors from c/image + Error string `json:"error,omitempty"` + // Images contains the ID's of the images pulled + Images []string `json:"images,omitempty"` + // ID contains image id (retained for backwards compatibility) + ID string `json:"id,omitempty"` +} + +type ImagePushStream struct { + // ManifestDigest is the digest of the manifest of the pushed image. + ManifestDigest string `json:"manifestdigest,omitempty"` + // Stream used to provide push progress + Stream string `json:"stream,omitempty"` + // Error contains text of errors from pushing + Error string `json:"error,omitempty"` +} diff --git a/pkg/domain/entities/types/types.go b/pkg/domain/entities/types/types.go index ea0be8ed04..a2f0cf11c5 100644 --- a/pkg/domain/entities/types/types.go +++ b/pkg/domain/entities/types/types.go @@ -1,6 +1,12 @@ // copied from github.com/docker/docker/api/types package types +import ( + "os" + + buildahDefine "github.com/containers/buildah/define" +) + // ComponentVersion describes the version information for a specific component. type ComponentVersion struct { Name string @@ -42,3 +48,32 @@ type ContainerCreateResponse struct { // required: true Warnings []string `json:"Warnings"` } + +// FarmBuildOptions describes the options for building container images on farm nodes +type FarmBuildOptions struct { + // Cleanup removes built images from farm nodes on success + Cleanup bool + // Authfile is the path to the file holding registry credentials + Authfile string + // SkipTLSVerify skips tls verification when set to true + SkipTLSVerify bool +} + +// BuildOptions describe the options for building container images. +type BuildOptions struct { + buildahDefine.BuildOptions + ContainerFiles []string + FarmBuildOptions + // Files that need to be closed after the build + // so need to pass this to the main build functions + LogFileToClose *os.File + TmpDirToClose string +} + +// BuildReport is the image-build report. +type BuildReport struct { + // ID of the image. + ID string + // Format to save the image in + SaveFormat string +}