summaryrefslogtreecommitdiff
path: root/pkg/domain/entities
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/domain/entities')
-rw-r--r--pkg/domain/entities/containers.go60
-rw-r--r--pkg/domain/entities/engine.go8
-rw-r--r--pkg/domain/entities/engine_container.go16
-rw-r--r--pkg/domain/entities/engine_image.go5
-rw-r--r--pkg/domain/entities/images.go75
-rw-r--r--pkg/domain/entities/set.go45
-rw-r--r--pkg/domain/entities/types.go8
-rw-r--r--pkg/domain/entities/volumes.go89
8 files changed, 221 insertions, 85 deletions
diff --git a/pkg/domain/entities/containers.go b/pkg/domain/entities/containers.go
index 0e1208b3b..8b7406ae8 100644
--- a/pkg/domain/entities/containers.go
+++ b/pkg/domain/entities/containers.go
@@ -21,3 +21,63 @@ type WaitReport struct {
type BoolReport struct {
Value bool
}
+
+type PauseUnPauseOptions struct {
+ All bool
+}
+
+type PauseUnpauseReport struct {
+ Err error
+ Id string
+}
+
+type StopOptions struct {
+ All bool
+ CIDFiles []string
+ Ignore bool
+ Latest bool
+ Timeout uint
+}
+
+type StopReport struct {
+ Err error
+ Id string
+}
+
+type KillOptions struct {
+ All bool
+ Latest bool
+ Signal string
+}
+
+type KillReport struct {
+ Err error
+ Id string
+}
+
+type RestartOptions struct {
+ All bool
+ Latest bool
+ Running bool
+ Timeout *uint
+}
+
+type RestartReport struct {
+ Err error
+ Id string
+}
+
+type RmOptions struct {
+ All bool
+ CIDFiles []string
+ Force bool
+ Ignore bool
+ Latest bool
+ Storage bool
+ Volumes bool
+}
+
+type RmReport struct {
+ Err error
+ Id string
+}
diff --git a/pkg/domain/entities/engine.go b/pkg/domain/entities/engine.go
index 08ef1df92..8553f5326 100644
--- a/pkg/domain/entities/engine.go
+++ b/pkg/domain/entities/engine.go
@@ -19,16 +19,12 @@ func (m EngineMode) String() string {
return string(m)
}
-// FIXME: merge EngineOptions and EngineFlags
type EngineOptions struct {
Uri string
Identities []string
FlagSet *pflag.FlagSet
- Flags EngineFlags
EngineMode EngineMode
-}
-type EngineFlags struct {
CGroupManager string
CniConfigDir string
ConmonPath string
@@ -61,9 +57,9 @@ type EngineFlags struct {
IgnoreHosts bool
}
-func NewEngineOptions() (EngineFlags, error) {
+func NewEngineOptions() (EngineOptions, error) {
u, _ := user.Current()
- return EngineFlags{
+ return EngineOptions{
CGroupManager: define.SystemdCgroupsManager,
CniConfigDir: "",
Config: "",
diff --git a/pkg/domain/entities/engine_container.go b/pkg/domain/entities/engine_container.go
index 5820c12c3..2efdbd602 100644
--- a/pkg/domain/entities/engine_container.go
+++ b/pkg/domain/entities/engine_container.go
@@ -5,14 +5,18 @@ import (
)
type ContainerEngine interface {
- ContainerDelete(ctx context.Context, opts ContainerDeleteOptions) (*ContainerDeleteReport, error)
- ContainerPrune(ctx context.Context) (*ContainerPruneReport, error)
ContainerExists(ctx context.Context, nameOrId string) (*BoolReport, error)
+ ContainerKill(ctx context.Context, namesOrIds []string, options KillOptions) ([]*KillReport, error)
+ ContainerPause(ctx context.Context, namesOrIds []string, options PauseUnPauseOptions) ([]*PauseUnpauseReport, error)
+ ContainerRestart(ctx context.Context, namesOrIds []string, options RestartOptions) ([]*RestartReport, error)
+ ContainerRm(ctx context.Context, namesOrIds []string, options RmOptions) ([]*RmReport, error)
+ ContainerUnpause(ctx context.Context, namesOrIds []string, options PauseUnPauseOptions) ([]*PauseUnpauseReport, error)
+ ContainerStop(ctx context.Context, namesOrIds []string, options StopOptions) ([]*StopReport, error)
ContainerWait(ctx context.Context, namesOrIds []string, options WaitOptions) ([]WaitReport, error)
- PodDelete(ctx context.Context, opts PodPruneOptions) (*PodDeleteReport, error)
PodExists(ctx context.Context, nameOrId string) (*BoolReport, error)
- PodPrune(ctx context.Context) (*PodPruneReport, error)
VolumeCreate(ctx context.Context, opts VolumeCreateOptions) (*IdOrNameResponse, error)
- VolumeDelete(ctx context.Context, opts VolumeDeleteOptions) (*VolumeDeleteReport, error)
- VolumePrune(ctx context.Context) (*VolumePruneReport, error)
+ VolumeInspect(ctx context.Context, namesOrIds []string, opts VolumeInspectOptions) ([]*VolumeInspectReport, error)
+ VolumeRm(ctx context.Context, namesOrIds []string, opts VolumeRmOptions) ([]*VolumeRmReport, error)
+ VolumePrune(ctx context.Context, opts VolumePruneOptions) ([]*VolumePruneReport, error)
+ VolumeList(ctx context.Context, opts VolumeListOptions) ([]*VolumeListReport, error)
}
diff --git a/pkg/domain/entities/engine_image.go b/pkg/domain/entities/engine_image.go
index 27676d781..d0c860a04 100644
--- a/pkg/domain/entities/engine_image.go
+++ b/pkg/domain/entities/engine_image.go
@@ -5,8 +5,9 @@ import (
)
type ImageEngine interface {
- Delete(ctx context.Context, nameOrId string, opts ImageDeleteOptions) (*ImageDeleteReport, error)
+ Delete(ctx context.Context, nameOrId []string, opts ImageDeleteOptions) (*ImageDeleteReport, error)
+ Exists(ctx context.Context, nameOrId string) (*BoolReport, error)
History(ctx context.Context, nameOrId string, opts ImageHistoryOptions) (*ImageHistoryReport, error)
- List(ctx context.Context, opts ImageListOptions) (*ImageListReport, error)
+ List(ctx context.Context, opts ImageListOptions) ([]*ImageSummary, error)
Prune(ctx context.Context, opts ImagePruneOptions) (*ImagePruneReport, error)
}
diff --git a/pkg/domain/entities/images.go b/pkg/domain/entities/images.go
index c84ed5351..4a51b3de4 100644
--- a/pkg/domain/entities/images.go
+++ b/pkg/domain/entities/images.go
@@ -48,22 +48,24 @@ func (i *Image) Id() string {
}
type ImageSummary struct {
- Identifier
- ID string `json:"Id"`
- ParentId string `json:",omitempty"`
- RepoTags []string `json:",omitempty"`
- Created int `json:",omitempty"`
- Size int `json:",omitempty"`
- SharedSize int `json:",omitempty"`
- VirtualSize int `json:",omitempty"`
- Labels string `json:",omitempty"`
- Containers int `json:",omitempty"`
- ReadOnly bool `json:",omitempty"`
- Dangling bool `json:",omitempty"`
+ ID string `json:"Id"`
+ ParentId string `json:",omitempty"`
+ RepoTags []string `json:",omitempty"`
+ Created int64 `json:",omitempty"`
+ Size int64 `json:",omitempty"`
+ SharedSize int `json:",omitempty"`
+ VirtualSize int64 `json:",omitempty"`
+ Labels map[string]string `json:",omitempty"`
+ Containers int `json:",omitempty"`
+ ReadOnly bool `json:",omitempty"`
+ Dangling bool `json:",omitempty"`
// Podman extensions
- Digest digest.Digest `json:",omitempty"`
- ConfigDigest digest.Digest `json:",omitempty"`
+ Names []string `json:",omitempty"`
+ Digest string `json:",omitempty"`
+ Digests []string `json:",omitempty"`
+ ConfigDigest string `json:",omitempty"`
+ History []string `json:",omitempty"`
}
func (i *ImageSummary) Id() string {
@@ -78,34 +80,26 @@ func (i *ImageSummary) IsDangling() bool {
return i.Dangling
}
-type ImageOptions struct {
- All bool
- Digests bool
- Filter []string
- Format string
- Noheading bool
- NoTrunc bool
- Quiet bool
- Sort string
- History bool
-}
-
type ImageDeleteOptions struct {
+ All bool
Force bool
}
-// ImageDeleteResponse is the response for removing an image from storage and containers
-// what was untagged vs actually removed
+// ImageDeleteResponse is the response for removing one or more image(s) from storage
+// and containers what was untagged vs actually removed
type ImageDeleteReport struct {
- Untagged []string `json:"untagged"`
- Deleted string `json:"deleted"`
+ Untagged []string `json:",omitempty"`
+ Deleted []string `json:",omitempty"`
+ Errors []error
+ ImageNotFound error
+ ImageInUse error
}
type ImageHistoryOptions struct{}
type ImageHistoryLayer struct {
ID string `json:"Id"`
- Created int64 `json:"Created,omitempty"`
+ Created int64 `json:",omitempty"`
CreatedBy string `json:",omitempty"`
Tags []string `json:",omitempty"`
Size int64 `json:",omitempty"`
@@ -124,21 +118,14 @@ type ImageInspectOptions struct {
}
type ImageListOptions struct {
- All bool `json:"all" schema:"all"`
- Digests bool `json:"digests" schema:"digests"`
- Filter []string `json:",omitempty"`
- Filters url.Values `json:"filters" schema:"filters"`
- Format string `json:",omitempty"`
- History bool `json:",omitempty"`
- Noheading bool `json:",omitempty"`
- NoTrunc bool `json:",omitempty"`
- Quiet bool `json:",omitempty"`
- Sort string `json:",omitempty"`
+ All bool `json:"all" schema:"all"`
+ Filter []string `json:",omitempty"`
+ Filters url.Values `json:"filters" schema:"filters"`
}
-type ImageListReport struct {
- Images []ImageSummary
-}
+// type ImageListReport struct {
+// Images []ImageSummary
+// }
type ImagePruneOptions struct {
All bool
diff --git a/pkg/domain/entities/set.go b/pkg/domain/entities/set.go
new file mode 100644
index 000000000..c8d6cb1a9
--- /dev/null
+++ b/pkg/domain/entities/set.go
@@ -0,0 +1,45 @@
+package entities
+
+import (
+ "strings"
+)
+
+type stringSet struct {
+ m map[string]struct{}
+}
+
+func NewStringSet(elem ...string) *stringSet {
+ s := &stringSet{}
+ s.m = make(map[string]struct{}, len(elem))
+ for _, e := range elem {
+ s.Add(e)
+ }
+ return s
+}
+
+func (s *stringSet) Add(elem string) {
+ s.m[elem] = struct{}{}
+}
+
+func (s *stringSet) Remove(elem string) {
+ delete(s.m, elem)
+}
+
+func (s *stringSet) Contains(elem string) bool {
+ _, ok := s.m[elem]
+ return ok
+}
+
+func (s *stringSet) Elements() []string {
+ keys := make([]string, len(s.m))
+ i := 0
+ for k := range s.m {
+ keys[i] = k
+ i++
+ }
+ return keys
+}
+
+func (s *stringSet) String() string {
+ return strings.Join(s.Elements(), ", ")
+}
diff --git a/pkg/domain/entities/types.go b/pkg/domain/entities/types.go
index 6f947dc4d..e7757a74b 100644
--- a/pkg/domain/entities/types.go
+++ b/pkg/domain/entities/types.go
@@ -13,13 +13,5 @@ type Report struct {
Err map[string]error
}
-type ContainerDeleteOptions struct{}
-type ContainerDeleteReport struct{ Report }
-type ContainerPruneReport struct{ Report }
-
type PodDeleteReport struct{ Report }
type PodPruneOptions struct{}
-type PodPruneReport struct{ Report }
-type VolumeDeleteOptions struct{}
-type VolumeDeleteReport struct{ Report }
-type VolumePruneReport struct{ Report }
diff --git a/pkg/domain/entities/volumes.go b/pkg/domain/entities/volumes.go
index ad12d0d01..23c066083 100644
--- a/pkg/domain/entities/volumes.go
+++ b/pkg/domain/entities/volumes.go
@@ -1,6 +1,8 @@
package entities
-import "time"
+import (
+ "time"
+)
// swagger:model VolumeCreate
type VolumeCreateOptions struct {
@@ -20,22 +22,71 @@ type IdOrNameResponse struct {
}
type VolumeConfigResponse struct {
- // Name of the volume.
- Name string `json:"name"`
- Labels map[string]string `json:"labels"`
- // The volume driver. Empty string or local does not activate a volume
- // driver, all other volumes will.
- Driver string `json:"volumeDriver"`
- // The location the volume is mounted at.
- MountPoint string `json:"mountPoint"`
- // Time the volume was created.
- CreatedTime time.Time `json:"createdAt,omitempty"`
- // Options to pass to the volume driver. For the local driver, this is
- // a list of mount options. For other drivers, they are passed to the
- // volume driver handling the volume.
- Options map[string]string `json:"volumeOptions,omitempty"`
- // UID the volume will be created as.
- UID int `json:"uid"`
- // GID the volume will be created as.
- GID int `json:"gid"`
+ // Name is the name of the volume.
+ Name string `json:"Name"`
+ // Driver is the driver used to create the volume.
+ // This will be properly implemented in a future version.
+ Driver string `json:"Driver"`
+ // Mountpoint is the path on the host where the volume is mounted.
+ Mountpoint string `json:"Mountpoint"`
+ // CreatedAt is the date and time the volume was created at. This is not
+ // stored for older Libpod volumes; if so, it will be omitted.
+ CreatedAt time.Time `json:"CreatedAt,omitempty"`
+ // Status is presently unused and provided only for Docker compatibility.
+ // In the future it will be used to return information on the volume's
+ // current state.
+ Status map[string]string `json:"Status,omitempty"`
+ // Labels includes the volume's configured labels, key:value pairs that
+ // can be passed during volume creation to provide information for third
+ // party tools.
+ Labels map[string]string `json:"Labels"`
+ // Scope is unused and provided solely for Docker compatibility. It is
+ // unconditionally set to "local".
+ Scope string `json:"Scope"`
+ // Options is a set of options that were used when creating the volume.
+ // It is presently not used.
+ Options map[string]string `json:"Options"`
+ // UID is the UID that the volume was created with.
+ UID int `json:"UID,omitempty"`
+ // GID is the GID that the volume was created with.
+ GID int `json:"GID,omitempty"`
+ // Anonymous indicates that the volume was created as an anonymous
+ // volume for a specific container, and will be be removed when any
+ // container using it is removed.
+ Anonymous bool `json:"Anonymous,omitempty"`
+}
+
+type VolumeRmOptions struct {
+ All bool
+ Force bool
+}
+
+type VolumeRmReport struct {
+ Err error
+ Id string
+}
+
+type VolumeInspectOptions struct {
+ All bool
+}
+
+type VolumeInspectReport struct {
+ *VolumeConfigResponse
+}
+
+type VolumePruneOptions struct {
+ Force bool
+}
+
+type VolumePruneReport struct {
+ Err error
+ Id string
+}
+
+type VolumeListOptions struct {
+ Filter map[string][]string
+}
+
+type VolumeListReport struct {
+ VolumeConfigResponse
}