mirror of
https://github.com/containers/podman.git
synced 2025-07-18 01:57:24 +08:00
bindings: manifests uses entities/types
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
pkg
@ -17,8 +17,9 @@ import (
|
||||
"github.com/containers/podman/v4/pkg/auth"
|
||||
"github.com/containers/podman/v4/pkg/bindings"
|
||||
"github.com/containers/podman/v4/pkg/bindings/images"
|
||||
"github.com/containers/podman/v4/pkg/domain/entities"
|
||||
entitiesTypes "github.com/containers/podman/v4/pkg/domain/entities/types"
|
||||
"github.com/containers/podman/v4/pkg/errorhandling"
|
||||
dockerAPI "github.com/docker/docker/api/types"
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
)
|
||||
|
||||
@ -27,7 +28,7 @@ import (
|
||||
// of a list if the name provided is a manifest list. The ID of the new manifest list
|
||||
// is returned as a string.
|
||||
func Create(ctx context.Context, name string, images []string, options *CreateOptions) (string, error) {
|
||||
var idr entities.IDResponse
|
||||
var idr dockerAPI.IDResponse
|
||||
if options == nil {
|
||||
options = new(CreateOptions)
|
||||
}
|
||||
@ -179,8 +180,8 @@ func Remove(ctx context.Context, name, digest string, _ *RemoveOptions) (string,
|
||||
}
|
||||
|
||||
// Delete removes specified manifest from local storage.
|
||||
func Delete(ctx context.Context, name string) (*entities.ManifestRemoveReport, error) {
|
||||
var report entities.ManifestRemoveReport
|
||||
func Delete(ctx context.Context, name string) (*entitiesTypes.ManifestRemoveReport, error) {
|
||||
var report entitiesTypes.ManifestRemoveReport
|
||||
conn, err := bindings.GetClient(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -250,7 +251,7 @@ func Push(ctx context.Context, name, destination string, options *images.PushOpt
|
||||
|
||||
dec := json.NewDecoder(response.Body)
|
||||
for {
|
||||
var report entities.ManifestPushReport
|
||||
var report entitiesTypes.ManifestPushReport
|
||||
if err := dec.Decode(&report); err != nil {
|
||||
return "", err
|
||||
}
|
||||
@ -320,7 +321,7 @@ func Modify(ctx context.Context, name string, images []string, options *ModifyOp
|
||||
}
|
||||
|
||||
if response.IsSuccess() || response.IsRedirection() {
|
||||
var report entities.ManifestModifyReport
|
||||
var report entitiesTypes.ManifestModifyReport
|
||||
if err = jsoniter.Unmarshal(data, &report); err != nil {
|
||||
return "", fmt.Errorf("unable to decode API response: %w", err)
|
||||
}
|
||||
|
@ -1,6 +1,9 @@
|
||||
package entities
|
||||
|
||||
import "github.com/containers/image/v5/types"
|
||||
import (
|
||||
"github.com/containers/image/v5/types"
|
||||
entitiesTypes "github.com/containers/podman/v4/pkg/domain/entities/types"
|
||||
)
|
||||
|
||||
// ManifestCreateOptions provides model for creating manifest
|
||||
type ManifestCreateOptions struct {
|
||||
@ -79,14 +82,7 @@ type ManifestModifyOptions struct {
|
||||
// ManifestPushReport provides the model for the pushed manifest
|
||||
//
|
||||
// swagger:model
|
||||
type ManifestPushReport struct {
|
||||
// ID of the pushed manifest
|
||||
ID string `json:"Id"`
|
||||
// Stream used to provide push progress
|
||||
Stream string `json:"stream,omitempty"`
|
||||
// Error contains text of errors from pushing
|
||||
Error string `json:"error,omitempty"`
|
||||
}
|
||||
type ManifestPushReport = entitiesTypes.ManifestPushReport
|
||||
|
||||
// ManifestRemoveOptions provides the model for removing digests from a manifest
|
||||
//
|
||||
@ -97,26 +93,9 @@ type ManifestRemoveOptions struct {
|
||||
// ManifestRemoveReport provides the model for the removed manifest
|
||||
//
|
||||
// swagger:model
|
||||
type ManifestRemoveReport struct {
|
||||
// Deleted manifest list.
|
||||
Deleted []string `json:",omitempty"`
|
||||
// Untagged images. Can be longer than Deleted.
|
||||
Untagged []string `json:",omitempty"`
|
||||
// Errors associated with operation
|
||||
Errors []string `json:",omitempty"`
|
||||
// ExitCode describes the exit codes as described in the `podman rmi`
|
||||
// man page.
|
||||
ExitCode int
|
||||
}
|
||||
type ManifestRemoveReport = entitiesTypes.ManifestRemoveReport
|
||||
|
||||
// ManifestModifyReport provides the model for removed digests and changed manifest
|
||||
//
|
||||
// swagger:model
|
||||
type ManifestModifyReport struct {
|
||||
// Manifest List ID
|
||||
ID string `json:"Id"`
|
||||
// Images to removed from manifest list, otherwise not provided.
|
||||
Images []string `json:"images,omitempty" schema:"images"`
|
||||
// Errors associated with operation
|
||||
Errors []error `json:"errors,omitempty"`
|
||||
}
|
||||
type ManifestModifyReport = entitiesTypes.ManifestModifyReport
|
||||
|
34
pkg/domain/entities/types/manifest.go
Normal file
34
pkg/domain/entities/types/manifest.go
Normal file
@ -0,0 +1,34 @@
|
||||
package types
|
||||
|
||||
// swagger:model
|
||||
type ManifestPushReport struct {
|
||||
// ID of the pushed manifest
|
||||
ID string `json:"Id"`
|
||||
// Stream used to provide push progress
|
||||
Stream string `json:"stream,omitempty"`
|
||||
// Error contains text of errors from pushing
|
||||
Error string `json:"error,omitempty"`
|
||||
}
|
||||
|
||||
// swagger:model
|
||||
type ManifestModifyReport struct {
|
||||
// Manifest List ID
|
||||
ID string `json:"Id"`
|
||||
// Images to removed from manifest list, otherwise not provided.
|
||||
Images []string `json:"images,omitempty" schema:"images"`
|
||||
// Errors associated with operation
|
||||
Errors []error `json:"errors,omitempty"`
|
||||
}
|
||||
|
||||
// swagger:model
|
||||
type ManifestRemoveReport struct {
|
||||
// Deleted manifest list.
|
||||
Deleted []string `json:",omitempty"`
|
||||
// Untagged images. Can be longer than Deleted.
|
||||
Untagged []string `json:",omitempty"`
|
||||
// Errors associated with operation
|
||||
Errors []string `json:",omitempty"`
|
||||
// ExitCode describes the exit codes as described in the `podman rmi`
|
||||
// man page.
|
||||
ExitCode int
|
||||
}
|
Reference in New Issue
Block a user