mirror of
https://github.com/containers/podman.git
synced 2025-06-17 23:20:59 +08:00
@ -10,6 +10,7 @@ run:
|
|||||||
- pkg/spec
|
- pkg/spec
|
||||||
- pkg/varlink
|
- pkg/varlink
|
||||||
- pkg/varlinkapi
|
- pkg/varlinkapi
|
||||||
|
- docs/varlink
|
||||||
skip-files:
|
skip-files:
|
||||||
- iopodman.go
|
- iopodman.go
|
||||||
- swagger.go
|
- swagger.go
|
||||||
@ -25,10 +26,6 @@ linters:
|
|||||||
- gosec
|
- gosec
|
||||||
- lll
|
- lll
|
||||||
- maligned
|
- maligned
|
||||||
- misspell
|
|
||||||
- prealloc
|
|
||||||
- unparam
|
|
||||||
- nakedret
|
|
||||||
linters-settings:
|
linters-settings:
|
||||||
errcheck:
|
errcheck:
|
||||||
check-blank: false
|
check-blank: false
|
||||||
|
@ -23,7 +23,7 @@ import (
|
|||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
func getCPULimits(s *specgen.SpecGenerator, c *ContainerCLIOpts, args []string) (*specs.LinuxCPU, error) {
|
func getCPULimits(c *ContainerCLIOpts) *specs.LinuxCPU {
|
||||||
cpu := &specs.LinuxCPU{}
|
cpu := &specs.LinuxCPU{}
|
||||||
hasLimits := false
|
hasLimits := false
|
||||||
|
|
||||||
@ -67,12 +67,12 @@ func getCPULimits(s *specgen.SpecGenerator, c *ContainerCLIOpts, args []string)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !hasLimits {
|
if !hasLimits {
|
||||||
return nil, nil
|
return nil
|
||||||
}
|
}
|
||||||
return cpu, nil
|
return cpu
|
||||||
}
|
}
|
||||||
|
|
||||||
func getIOLimits(s *specgen.SpecGenerator, c *ContainerCLIOpts, args []string) (*specs.LinuxBlockIO, error) {
|
func getIOLimits(s *specgen.SpecGenerator, c *ContainerCLIOpts) (*specs.LinuxBlockIO, error) {
|
||||||
var err error
|
var err error
|
||||||
io := &specs.LinuxBlockIO{}
|
io := &specs.LinuxBlockIO{}
|
||||||
hasLimits := false
|
hasLimits := false
|
||||||
@ -87,7 +87,7 @@ func getIOLimits(s *specgen.SpecGenerator, c *ContainerCLIOpts, args []string) (
|
|||||||
}
|
}
|
||||||
|
|
||||||
if len(c.BlkIOWeightDevice) > 0 {
|
if len(c.BlkIOWeightDevice) > 0 {
|
||||||
if err := parseWeightDevices(c.BlkIOWeightDevice, s); err != nil {
|
if err := parseWeightDevices(s, c.BlkIOWeightDevice); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
hasLimits = true
|
hasLimits = true
|
||||||
@ -127,7 +127,7 @@ func getIOLimits(s *specgen.SpecGenerator, c *ContainerCLIOpts, args []string) (
|
|||||||
return io, nil
|
return io, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func getPidsLimits(s *specgen.SpecGenerator, c *ContainerCLIOpts, args []string) *specs.LinuxPids {
|
func getPidsLimits(c *ContainerCLIOpts) *specs.LinuxPids {
|
||||||
pids := &specs.LinuxPids{}
|
pids := &specs.LinuxPids{}
|
||||||
if c.CGroupsMode == "disabled" && c.PIDsLimit != 0 {
|
if c.CGroupsMode == "disabled" && c.PIDsLimit != 0 {
|
||||||
return nil
|
return nil
|
||||||
@ -146,7 +146,7 @@ func getPidsLimits(s *specgen.SpecGenerator, c *ContainerCLIOpts, args []string)
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func getMemoryLimits(s *specgen.SpecGenerator, c *ContainerCLIOpts, args []string) (*specs.LinuxMemory, error) {
|
func getMemoryLimits(s *specgen.SpecGenerator, c *ContainerCLIOpts) (*specs.LinuxMemory, error) {
|
||||||
var err error
|
var err error
|
||||||
memory := &specs.LinuxMemory{}
|
memory := &specs.LinuxMemory{}
|
||||||
hasLimits := false
|
hasLimits := false
|
||||||
@ -446,19 +446,16 @@ func FillOutSpecGen(s *specgen.SpecGenerator, c *ContainerCLIOpts, args []string
|
|||||||
if s.ResourceLimits == nil {
|
if s.ResourceLimits == nil {
|
||||||
s.ResourceLimits = &specs.LinuxResources{}
|
s.ResourceLimits = &specs.LinuxResources{}
|
||||||
}
|
}
|
||||||
s.ResourceLimits.Memory, err = getMemoryLimits(s, c, args)
|
s.ResourceLimits.Memory, err = getMemoryLimits(s, c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
s.ResourceLimits.BlockIO, err = getIOLimits(s, c, args)
|
s.ResourceLimits.BlockIO, err = getIOLimits(s, c)
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
s.ResourceLimits.Pids = getPidsLimits(s, c, args)
|
|
||||||
s.ResourceLimits.CPU, err = getCPULimits(s, c, args)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
s.ResourceLimits.Pids = getPidsLimits(c)
|
||||||
|
s.ResourceLimits.CPU = getCPULimits(c)
|
||||||
if s.ResourceLimits.CPU == nil && s.ResourceLimits.Pids == nil && s.ResourceLimits.BlockIO == nil && s.ResourceLimits.Memory == nil {
|
if s.ResourceLimits.CPU == nil && s.ResourceLimits.Pids == nil && s.ResourceLimits.BlockIO == nil && s.ResourceLimits.Memory == nil {
|
||||||
s.ResourceLimits = nil
|
s.ResourceLimits = nil
|
||||||
}
|
}
|
||||||
@ -700,7 +697,7 @@ func makeHealthCheckFromCli(inCmd, interval string, retries uint, timeout, start
|
|||||||
return &hc, nil
|
return &hc, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseWeightDevices(weightDevs []string, s *specgen.SpecGenerator) error {
|
func parseWeightDevices(s *specgen.SpecGenerator, weightDevs []string) error {
|
||||||
for _, val := range weightDevs {
|
for _, val := range weightDevs {
|
||||||
split := strings.SplitN(val, ":", 2)
|
split := strings.SplitN(val, ":", 2)
|
||||||
if len(split) != 2 {
|
if len(split) != 2 {
|
||||||
|
@ -71,7 +71,6 @@ func init() {
|
|||||||
func mount(cmd *cobra.Command, args []string) error {
|
func mount(cmd *cobra.Command, args []string) error {
|
||||||
var (
|
var (
|
||||||
errs utils.OutputErrors
|
errs utils.OutputErrors
|
||||||
mrs []mountReporter
|
|
||||||
)
|
)
|
||||||
reports, err := registry.ContainerEngine().ContainerMount(registry.GetContext(), args, mountOpts)
|
reports, err := registry.ContainerEngine().ContainerMount(registry.GetContext(), args, mountOpts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -90,6 +89,7 @@ func mount(cmd *cobra.Command, args []string) error {
|
|||||||
if mountOpts.Format == "json" {
|
if mountOpts.Format == "json" {
|
||||||
return printJSON(reports)
|
return printJSON(reports)
|
||||||
}
|
}
|
||||||
|
mrs := make([]mountReporter, 0, len(reports))
|
||||||
for _, r := range reports {
|
for _, r := range reports {
|
||||||
mrs = append(mrs, mountReporter{r})
|
mrs = append(mrs, mountReporter{r})
|
||||||
}
|
}
|
||||||
@ -110,7 +110,7 @@ func printJSON(reports []*entities.ContainerMountReport) error {
|
|||||||
Names []string
|
Names []string
|
||||||
Mountpoint string `json:"mountpoint"`
|
Mountpoint string `json:"mountpoint"`
|
||||||
}
|
}
|
||||||
var jreports []jreport
|
jreports := make([]jreport, 0, len(reports))
|
||||||
|
|
||||||
for _, r := range reports {
|
for _, r := range reports {
|
||||||
jreports = append(jreports, jreport{
|
jreports = append(jreports, jreport{
|
||||||
|
@ -74,7 +74,7 @@ func listFlagSet(flags *pflag.FlagSet) {
|
|||||||
_ = flags.MarkHidden("latest")
|
_ = flags.MarkHidden("latest")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
func checkFlags(c *cobra.Command, args []string) error {
|
func checkFlags(c *cobra.Command) error {
|
||||||
// latest, and last are mutually exclusive.
|
// latest, and last are mutually exclusive.
|
||||||
if listOpts.Last >= 0 && listOpts.Latest {
|
if listOpts.Last >= 0 && listOpts.Latest {
|
||||||
return errors.Errorf("last and latest are mutually exclusive")
|
return errors.Errorf("last and latest are mutually exclusive")
|
||||||
@ -144,8 +144,7 @@ func getResponses() ([]entities.ListContainer, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func ps(cmd *cobra.Command, args []string) error {
|
func ps(cmd *cobra.Command, args []string) error {
|
||||||
var responses []psReporter
|
if err := checkFlags(cmd); err != nil {
|
||||||
if err := checkFlags(cmd, args); err != nil {
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
for _, f := range filters {
|
for _, f := range filters {
|
||||||
@ -172,6 +171,7 @@ func ps(cmd *cobra.Command, args []string) error {
|
|||||||
return quietOut(listContainers)
|
return quietOut(listContainers)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
responses := make([]psReporter, 0, len(listContainers))
|
||||||
for _, r := range listContainers {
|
for _, r := range listContainers {
|
||||||
responses = append(responses, psReporter{r})
|
responses = append(responses, psReporter{r})
|
||||||
}
|
}
|
||||||
@ -351,7 +351,8 @@ func portsToString(ports []ocicni.PortMapping) string {
|
|||||||
first int32
|
first int32
|
||||||
last int32
|
last int32
|
||||||
}
|
}
|
||||||
var portDisplay []string
|
portDisplay := []string{}
|
||||||
|
|
||||||
if len(ports) == 0 {
|
if len(ports) == 0 {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
@ -134,7 +134,7 @@ func outputStats(reports []*define.ContainerStats) error {
|
|||||||
tm.MoveCursor(1, 1)
|
tm.MoveCursor(1, 1)
|
||||||
tm.Flush()
|
tm.Flush()
|
||||||
}
|
}
|
||||||
var stats []*containerStats
|
stats := make([]*containerStats, 0, len(reports))
|
||||||
for _, r := range reports {
|
for _, r := range reports {
|
||||||
stats = append(stats, &containerStats{r})
|
stats = append(stats, &containerStats{r})
|
||||||
}
|
}
|
||||||
@ -228,7 +228,7 @@ func outputJSON(stats []*containerStats) error {
|
|||||||
BlockIO string `json:"block_io"`
|
BlockIO string `json:"block_io"`
|
||||||
Pids string `json:"pids"`
|
Pids string `json:"pids"`
|
||||||
}
|
}
|
||||||
var jstats []jstat
|
jstats := make([]jstat, 0, len(stats))
|
||||||
for _, j := range stats {
|
for _, j := range stats {
|
||||||
jstats = append(jstats, jstat{
|
jstats = append(jstats, jstat{
|
||||||
Id: j.ID(),
|
Id: j.ID(),
|
||||||
|
@ -41,7 +41,7 @@ func init() {
|
|||||||
flags.BoolVarP(&systemdOptions.New, "new", "", false, "Create a new container instead of starting an existing one")
|
flags.BoolVarP(&systemdOptions.New, "new", "", false, "Create a new container instead of starting an existing one")
|
||||||
flags.StringVar(&systemdOptions.ContainerPrefix, "container-prefix", "container", "Systemd unit name prefix for containers")
|
flags.StringVar(&systemdOptions.ContainerPrefix, "container-prefix", "container", "Systemd unit name prefix for containers")
|
||||||
flags.StringVar(&systemdOptions.PodPrefix, "pod-prefix", "pod", "Systemd unit name prefix for pods")
|
flags.StringVar(&systemdOptions.PodPrefix, "pod-prefix", "pod", "Systemd unit name prefix for pods")
|
||||||
flags.StringVar(&systemdOptions.Separator, "separator", "-", "Systemd unit name seperator between name/id and prefix")
|
flags.StringVar(&systemdOptions.Separator, "separator", "-", "Systemd unit name separator between name/id and prefix")
|
||||||
flags.SetNormalizeFunc(utils.AliasFlags)
|
flags.SetNormalizeFunc(utils.AliasFlags)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,7 +100,7 @@ func history(cmd *cobra.Command, args []string) error {
|
|||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
var hr []historyreporter
|
hr := make([]historyreporter, 0, len(results.Layers))
|
||||||
for _, l := range results.Layers {
|
for _, l := range results.Layers {
|
||||||
hr = append(hr, historyreporter{l})
|
hr = append(hr, historyreporter{l})
|
||||||
}
|
}
|
||||||
|
@ -77,7 +77,7 @@ func newInspector(options entities.InspectOptions) (*inspector, error) {
|
|||||||
// inspect inspects the specified container/image names or IDs.
|
// inspect inspects the specified container/image names or IDs.
|
||||||
func (i *inspector) inspect(namesOrIDs []string) error {
|
func (i *inspector) inspect(namesOrIDs []string) error {
|
||||||
// data - dumping place for inspection results.
|
// data - dumping place for inspection results.
|
||||||
var data []interface{}
|
var data []interface{} //nolint
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
if len(namesOrIDs) == 0 {
|
if len(namesOrIDs) == 0 {
|
||||||
@ -132,7 +132,7 @@ func (i *inspector) inspect(namesOrIDs []string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (i *inspector) inspectAll(ctx context.Context, namesOrIDs []string) ([]interface{}, error) {
|
func (i *inspector) inspectAll(ctx context.Context, namesOrIDs []string) ([]interface{}, error) {
|
||||||
var data []interface{}
|
var data []interface{} //nolint
|
||||||
for _, name := range namesOrIDs {
|
for _, name := range namesOrIDs {
|
||||||
imgData, err := i.imageEngine.Inspect(ctx, []string{name}, i.options)
|
imgData, err := i.imageEngine.Inspect(ctx, []string{name}, i.options)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
@ -56,10 +56,6 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func networkList(cmd *cobra.Command, args []string) error {
|
func networkList(cmd *cobra.Command, args []string) error {
|
||||||
var (
|
|
||||||
nlprs []ListPrintReports
|
|
||||||
)
|
|
||||||
|
|
||||||
// validate the filter pattern.
|
// validate the filter pattern.
|
||||||
if len(networkListOptions.Filter) > 0 {
|
if len(networkListOptions.Filter) > 0 {
|
||||||
tokens := strings.Split(networkListOptions.Filter, "=")
|
tokens := strings.Split(networkListOptions.Filter, "=")
|
||||||
@ -82,6 +78,7 @@ func networkList(cmd *cobra.Command, args []string) error {
|
|||||||
return jsonOut(responses)
|
return jsonOut(responses)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nlprs := make([]ListPrintReports, 0, len(responses))
|
||||||
for _, r := range responses {
|
for _, r := range responses {
|
||||||
nlprs = append(nlprs, ListPrintReports{r})
|
nlprs = append(nlprs, ListPrintReports{r})
|
||||||
}
|
}
|
||||||
|
@ -68,7 +68,6 @@ func pods(cmd *cobra.Command, args []string) error {
|
|||||||
var (
|
var (
|
||||||
w io.Writer = os.Stdout
|
w io.Writer = os.Stdout
|
||||||
row string
|
row string
|
||||||
lpr []ListPodReporter
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if psInput.Quiet && len(psInput.Format) > 0 {
|
if psInput.Quiet && len(psInput.Format) > 0 {
|
||||||
@ -102,6 +101,7 @@ func pods(cmd *cobra.Command, args []string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lpr := make([]ListPodReporter, 0, len(responses))
|
||||||
for _, r := range responses {
|
for _, r := range responses {
|
||||||
lpr = append(lpr, ListPodReporter{r})
|
lpr = append(lpr, ListPodReporter{r})
|
||||||
}
|
}
|
||||||
@ -220,7 +220,7 @@ func (l ListPodReporter) InfraId() string { //nolint
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (l ListPodReporter) ContainerIds() string {
|
func (l ListPodReporter) ContainerIds() string {
|
||||||
var ctrids []string
|
ctrids := make([]string, 0, len(l.Containers))
|
||||||
for _, c := range l.Containers {
|
for _, c := range l.Containers {
|
||||||
id := c.Id
|
id := c.Id
|
||||||
if !noTrunc {
|
if !noTrunc {
|
||||||
@ -232,7 +232,7 @@ func (l ListPodReporter) ContainerIds() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (l ListPodReporter) ContainerNames() string {
|
func (l ListPodReporter) ContainerNames() string {
|
||||||
var ctrNames []string
|
ctrNames := make([]string, 0, len(l.Containers))
|
||||||
for _, c := range l.Containers {
|
for _, c := range l.Containers {
|
||||||
ctrNames = append(ctrNames, c.Names)
|
ctrNames = append(ctrNames, c.Names)
|
||||||
}
|
}
|
||||||
@ -240,7 +240,7 @@ func (l ListPodReporter) ContainerNames() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (l ListPodReporter) ContainerStatuses() string {
|
func (l ListPodReporter) ContainerStatuses() string {
|
||||||
var statuses []string
|
statuses := make([]string, 0, len(l.Containers))
|
||||||
for _, c := range l.Containers {
|
for _, c := range l.Containers {
|
||||||
statuses = append(statuses, c.Status)
|
statuses = append(statuses, c.Status)
|
||||||
}
|
}
|
||||||
|
@ -147,15 +147,13 @@ func printSummary(reports *entities.SystemDfReport, userFormat string) error {
|
|||||||
|
|
||||||
func printVerbose(reports *entities.SystemDfReport) error {
|
func printVerbose(reports *entities.SystemDfReport) error {
|
||||||
var (
|
var (
|
||||||
dfImages []*dfImage
|
w io.Writer = os.Stdout
|
||||||
dfContainers []*dfContainer
|
|
||||||
dfVolumes []*dfVolume
|
|
||||||
w io.Writer = os.Stdout
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Images
|
// Images
|
||||||
fmt.Print("\nImages space usage:\n\n")
|
fmt.Print("\nImages space usage:\n\n")
|
||||||
// convert to dfImage for output
|
// convert to dfImage for output
|
||||||
|
dfImages := make([]*dfImage, 0, len(reports.Images))
|
||||||
for _, d := range reports.Images {
|
for _, d := range reports.Images {
|
||||||
dfImages = append(dfImages, &dfImage{SystemDfImageReport: d})
|
dfImages = append(dfImages, &dfImage{SystemDfImageReport: d})
|
||||||
}
|
}
|
||||||
@ -170,6 +168,7 @@ func printVerbose(reports *entities.SystemDfReport) error {
|
|||||||
fmt.Print("\nContainers space usage:\n\n")
|
fmt.Print("\nContainers space usage:\n\n")
|
||||||
|
|
||||||
// convert to dfContainers for output
|
// convert to dfContainers for output
|
||||||
|
dfContainers := make([]*dfContainer, 0, len(reports.Containers))
|
||||||
for _, d := range reports.Containers {
|
for _, d := range reports.Containers {
|
||||||
dfContainers = append(dfContainers, &dfContainer{SystemDfContainerReport: d})
|
dfContainers = append(dfContainers, &dfContainer{SystemDfContainerReport: d})
|
||||||
}
|
}
|
||||||
@ -183,6 +182,7 @@ func printVerbose(reports *entities.SystemDfReport) error {
|
|||||||
// Volumes
|
// Volumes
|
||||||
fmt.Print("\nLocal Volumes space usage:\n\n")
|
fmt.Print("\nLocal Volumes space usage:\n\n")
|
||||||
|
|
||||||
|
dfVolumes := make([]*dfVolume, 0, len(reports.Volumes))
|
||||||
// convert to dfVolume for output
|
// convert to dfVolume for output
|
||||||
for _, d := range reports.Volumes {
|
for _, d := range reports.Volumes {
|
||||||
dfVolumes = append(dfVolumes, &dfVolume{SystemDfVolumeReport: d})
|
dfVolumes = append(dfVolumes, &dfVolume{SystemDfVolumeReport: d})
|
||||||
|
@ -243,9 +243,7 @@ func (s *BoltState) Refresh() error {
|
|||||||
return errors.Wrapf(err, "error unmarshalling state for container %s", string(id))
|
return errors.Wrapf(err, "error unmarshalling state for container %s", string(id))
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := resetState(state); err != nil {
|
resetState(state)
|
||||||
return errors.Wrapf(err, "error resetting state for container %s", string(id))
|
|
||||||
}
|
|
||||||
|
|
||||||
newStateBytes, err := json.Marshal(state)
|
newStateBytes, err := json.Marshal(state)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -407,10 +407,7 @@ func (s *BoltState) getContainerFromDB(id []byte, ctr *Container, ctrsBkt *bolt.
|
|||||||
ociRuntime, ok := s.runtime.ociRuntimes[runtimeName]
|
ociRuntime, ok := s.runtime.ociRuntimes[runtimeName]
|
||||||
if !ok {
|
if !ok {
|
||||||
// Use a MissingRuntime implementation
|
// Use a MissingRuntime implementation
|
||||||
ociRuntime, err = getMissingRuntime(runtimeName, s.runtime)
|
ociRuntime = getMissingRuntime(runtimeName, s.runtime)
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
ctr.ociRuntime = ociRuntime
|
ctr.ociRuntime = ociRuntime
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ func (c *Container) Init(ctx context.Context) (err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// don't recursively start
|
// don't recursively start
|
||||||
if err := c.checkDependenciesAndHandleError(ctx); err != nil {
|
if err := c.checkDependenciesAndHandleError(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -146,7 +146,7 @@ func (c *Container) RestartWithTimeout(ctx context.Context, timeout uint) (err e
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = c.checkDependenciesAndHandleError(ctx); err != nil {
|
if err = c.checkDependenciesAndHandleError(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@ func (c *Container) getContainerInspectData(size bool, driverData *driver.Data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
namedVolumes, mounts := c.sortUserVolumes(ctrSpec)
|
namedVolumes, mounts := c.sortUserVolumes(ctrSpec)
|
||||||
inspectMounts, err := c.getInspectMounts(ctrSpec, namedVolumes, mounts)
|
inspectMounts, err := c.getInspectMounts(namedVolumes, mounts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -164,10 +164,7 @@ func (c *Container) getContainerInspectData(size bool, driverData *driver.Data)
|
|||||||
}
|
}
|
||||||
data.NetworkSettings = networkConfig
|
data.NetworkSettings = networkConfig
|
||||||
|
|
||||||
inspectConfig, err := c.generateInspectContainerConfig(ctrSpec)
|
inspectConfig := c.generateInspectContainerConfig(ctrSpec)
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
data.Config = inspectConfig
|
data.Config = inspectConfig
|
||||||
|
|
||||||
hostConfig, err := c.generateInspectContainerHostConfig(ctrSpec, namedVolumes, mounts)
|
hostConfig, err := c.generateInspectContainerHostConfig(ctrSpec, namedVolumes, mounts)
|
||||||
@ -195,7 +192,7 @@ func (c *Container) getContainerInspectData(size bool, driverData *driver.Data)
|
|||||||
// Get inspect-formatted mounts list.
|
// Get inspect-formatted mounts list.
|
||||||
// Only includes user-specified mounts. Only includes bind mounts and named
|
// Only includes user-specified mounts. Only includes bind mounts and named
|
||||||
// volumes, not tmpfs volumes.
|
// volumes, not tmpfs volumes.
|
||||||
func (c *Container) getInspectMounts(ctrSpec *spec.Spec, namedVolumes []*ContainerNamedVolume, mounts []spec.Mount) ([]define.InspectMount, error) {
|
func (c *Container) getInspectMounts(namedVolumes []*ContainerNamedVolume, mounts []spec.Mount) ([]define.InspectMount, error) {
|
||||||
inspectMounts := []define.InspectMount{}
|
inspectMounts := []define.InspectMount{}
|
||||||
|
|
||||||
// No mounts, return early
|
// No mounts, return early
|
||||||
@ -278,7 +275,7 @@ func parseMountOptionsForInspect(options []string, mount *define.InspectMount) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Generate the InspectContainerConfig struct for the Config field of Inspect.
|
// Generate the InspectContainerConfig struct for the Config field of Inspect.
|
||||||
func (c *Container) generateInspectContainerConfig(spec *spec.Spec) (*define.InspectContainerConfig, error) {
|
func (c *Container) generateInspectContainerConfig(spec *spec.Spec) *define.InspectContainerConfig {
|
||||||
ctrConfig := new(define.InspectContainerConfig)
|
ctrConfig := new(define.InspectContainerConfig)
|
||||||
|
|
||||||
ctrConfig.Hostname = c.Hostname()
|
ctrConfig.Hostname = c.Hostname()
|
||||||
@ -325,7 +322,7 @@ func (c *Container) generateInspectContainerConfig(spec *spec.Spec) (*define.Ins
|
|||||||
|
|
||||||
ctrConfig.CreateCommand = c.config.CreateCommand
|
ctrConfig.CreateCommand = c.config.CreateCommand
|
||||||
|
|
||||||
return ctrConfig, nil
|
return ctrConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate the InspectContainerHostConfig struct for the HostConfig field of
|
// Generate the InspectContainerHostConfig struct for the HostConfig field of
|
||||||
|
@ -239,7 +239,7 @@ func (c *Container) handleRestartPolicy(ctx context.Context) (restarted bool, er
|
|||||||
logrus.Debugf("Restarting container %s due to restart policy %s", c.ID(), c.config.RestartPolicy)
|
logrus.Debugf("Restarting container %s due to restart policy %s", c.ID(), c.config.RestartPolicy)
|
||||||
|
|
||||||
// Need to check if dependencies are alive.
|
// Need to check if dependencies are alive.
|
||||||
if err = c.checkDependenciesAndHandleError(ctx); err != nil {
|
if err = c.checkDependenciesAndHandleError(); err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -513,7 +513,7 @@ func (c *Container) teardownStorage() error {
|
|||||||
// Reset resets state fields to default values.
|
// Reset resets state fields to default values.
|
||||||
// It is performed before a refresh and clears the state after a reboot.
|
// It is performed before a refresh and clears the state after a reboot.
|
||||||
// It does not save the results - assumes the database will do that for us.
|
// It does not save the results - assumes the database will do that for us.
|
||||||
func resetState(state *ContainerState) error {
|
func resetState(state *ContainerState) {
|
||||||
state.PID = 0
|
state.PID = 0
|
||||||
state.ConmonPID = 0
|
state.ConmonPID = 0
|
||||||
state.Mountpoint = ""
|
state.Mountpoint = ""
|
||||||
@ -527,8 +527,6 @@ func resetState(state *ContainerState) error {
|
|||||||
state.StoppedByUser = false
|
state.StoppedByUser = false
|
||||||
state.RestartPolicyMatch = false
|
state.RestartPolicyMatch = false
|
||||||
state.RestartCount = 0
|
state.RestartCount = 0
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Refresh refreshes the container's state after a restart.
|
// Refresh refreshes the container's state after a restart.
|
||||||
@ -756,7 +754,7 @@ func (c *Container) prepareToStart(ctx context.Context, recursive bool) (err err
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !recursive {
|
if !recursive {
|
||||||
if err := c.checkDependenciesAndHandleError(ctx); err != nil {
|
if err := c.checkDependenciesAndHandleError(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -792,7 +790,7 @@ func (c *Container) prepareToStart(ctx context.Context, recursive bool) (err err
|
|||||||
}
|
}
|
||||||
|
|
||||||
// checks dependencies are running and prints a helpful message
|
// checks dependencies are running and prints a helpful message
|
||||||
func (c *Container) checkDependenciesAndHandleError(ctx context.Context) error {
|
func (c *Container) checkDependenciesAndHandleError() error {
|
||||||
notRunning, err := c.checkDependenciesRunning()
|
notRunning, err := c.checkDependenciesRunning()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrapf(err, "error checking dependencies for container %s", c.ID())
|
return errors.Wrapf(err, "error checking dependencies for container %s", c.ID())
|
||||||
|
@ -1313,7 +1313,7 @@ func (c *Container) generateResolvConf() (string, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var dns []net.IP
|
dns := make([]net.IP, 0, len(c.runtime.config.Containers.DNSServers))
|
||||||
for _, i := range c.runtime.config.Containers.DNSServers {
|
for _, i := range c.runtime.config.Containers.DNSServers {
|
||||||
result := net.ParseIP(i)
|
result := net.ParseIP(i)
|
||||||
if result == nil {
|
if result == nil {
|
||||||
@ -1393,7 +1393,9 @@ func (c *Container) generateHosts(path string) (string, error) {
|
|||||||
// local hosts file. netCtr is the container from which the netNS information is
|
// local hosts file. netCtr is the container from which the netNS information is
|
||||||
// taken.
|
// taken.
|
||||||
// path is the basis of the hosts file, into which netCtr's netNS information will be appended.
|
// path is the basis of the hosts file, into which netCtr's netNS information will be appended.
|
||||||
func (c *Container) appendHosts(path string, netCtr *Container) (string, error) {
|
// FIXME. Path should be used by this function,but I am not sure what is correct; remove //lint
|
||||||
|
// once this is fixed
|
||||||
|
func (c *Container) appendHosts(path string, netCtr *Container) (string, error) { //nolint
|
||||||
return c.appendStringToRundir("hosts", netCtr.getHosts())
|
return c.appendStringToRundir("hosts", netCtr.getHosts())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ type RemoteSocket struct {
|
|||||||
Exists bool `json:"exists,omitempty"`
|
Exists bool `json:"exists,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// SlirpInfo describes the slirp exectuable that
|
// SlirpInfo describes the slirp executable that
|
||||||
// is being being used.
|
// is being being used.
|
||||||
type SlirpInfo struct {
|
type SlirpInfo struct {
|
||||||
Executable string `json:"executable"`
|
Executable string `json:"executable"`
|
||||||
|
@ -85,10 +85,7 @@ func (r *Runtime) Events(options events.ReadOptions) error {
|
|||||||
|
|
||||||
// GetEvents reads the event log and returns events based on input filters
|
// GetEvents reads the event log and returns events based on input filters
|
||||||
func (r *Runtime) GetEvents(filters []string) ([]*events.Event, error) {
|
func (r *Runtime) GetEvents(filters []string) ([]*events.Event, error) {
|
||||||
var (
|
var readErr error
|
||||||
logEvents []*events.Event
|
|
||||||
readErr error
|
|
||||||
)
|
|
||||||
eventChannel := make(chan *events.Event)
|
eventChannel := make(chan *events.Event)
|
||||||
options := events.ReadOptions{
|
options := events.ReadOptions{
|
||||||
EventChannel: eventChannel,
|
EventChannel: eventChannel,
|
||||||
@ -106,6 +103,7 @@ func (r *Runtime) GetEvents(filters []string) ([]*events.Event, error) {
|
|||||||
if readErr != nil {
|
if readErr != nil {
|
||||||
return nil, readErr
|
return nil, readErr
|
||||||
}
|
}
|
||||||
|
logEvents := make([]*events.Event, 0, len(eventChannel))
|
||||||
for e := range eventChannel {
|
for e := range eventChannel {
|
||||||
logEvents = append(logEvents, e)
|
logEvents = append(logEvents, e)
|
||||||
}
|
}
|
||||||
|
@ -81,7 +81,7 @@ func parseFilter(filter string) (string, string, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func generateEventOptions(filters []string, since, until string) ([]EventFilter, error) {
|
func generateEventOptions(filters []string, since, until string) ([]EventFilter, error) {
|
||||||
var options []EventFilter
|
options := make([]EventFilter, 0, len(filters))
|
||||||
for _, filter := range filters {
|
for _, filter := range filters {
|
||||||
key, val, err := parseFilter(filter)
|
key, val, err := parseFilter(filter)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -172,8 +172,6 @@ func (ir *Runtime) New(ctx context.Context, name, signaturePolicyPath, authfile
|
|||||||
// LoadFromArchiveReference creates a new image object for images pulled from a tar archive and the like (podman load)
|
// LoadFromArchiveReference creates a new image object for images pulled from a tar archive and the like (podman load)
|
||||||
// This function is needed because it is possible for a tar archive to have multiple tags for one image
|
// This function is needed because it is possible for a tar archive to have multiple tags for one image
|
||||||
func (ir *Runtime) LoadFromArchiveReference(ctx context.Context, srcRef types.ImageReference, signaturePolicyPath string, writer io.Writer) ([]*Image, error) {
|
func (ir *Runtime) LoadFromArchiveReference(ctx context.Context, srcRef types.ImageReference, signaturePolicyPath string, writer io.Writer) ([]*Image, error) {
|
||||||
var newImages []*Image
|
|
||||||
|
|
||||||
if signaturePolicyPath == "" {
|
if signaturePolicyPath == "" {
|
||||||
signaturePolicyPath = ir.SignaturePolicyPath
|
signaturePolicyPath = ir.SignaturePolicyPath
|
||||||
}
|
}
|
||||||
@ -182,6 +180,7 @@ func (ir *Runtime) LoadFromArchiveReference(ctx context.Context, srcRef types.Im
|
|||||||
return nil, errors.Wrapf(err, "unable to pull %s", transports.ImageName(srcRef))
|
return nil, errors.Wrapf(err, "unable to pull %s", transports.ImageName(srcRef))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
newImages := make([]*Image, 0, len(imageNames))
|
||||||
for _, name := range imageNames {
|
for _, name := range imageNames {
|
||||||
newImage, err := ir.NewFromLocal(name)
|
newImage, err := ir.NewFromLocal(name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -475,11 +474,11 @@ func (ir *Runtime) GetRWImages() ([]*Image, error) {
|
|||||||
|
|
||||||
// getImages retrieves all images present in storage
|
// getImages retrieves all images present in storage
|
||||||
func (ir *Runtime) getImages(rwOnly bool) ([]*Image, error) {
|
func (ir *Runtime) getImages(rwOnly bool) ([]*Image, error) {
|
||||||
var newImages []*Image
|
|
||||||
images, err := ir.store.Images()
|
images, err := ir.store.Images()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
newImages := make([]*Image, 0, len(images))
|
||||||
for _, i := range images {
|
for _, i := range images {
|
||||||
if rwOnly && i.ReadOnly {
|
if rwOnly && i.ReadOnly {
|
||||||
continue
|
continue
|
||||||
|
@ -44,7 +44,7 @@ func cleanup(workdir string, ir *Runtime) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func makeLocalMatrix(b, bg *Image) ([]localImageTest, error) {
|
func makeLocalMatrix(b, bg *Image) []localImageTest {
|
||||||
var l []localImageTest
|
var l []localImageTest
|
||||||
// busybox
|
// busybox
|
||||||
busybox := localImageTest{
|
busybox := localImageTest{
|
||||||
@ -65,7 +65,7 @@ func makeLocalMatrix(b, bg *Image) ([]localImageTest, error) {
|
|||||||
busyboxGlibc.names = bbGlibcNames
|
busyboxGlibc.names = bbGlibcNames
|
||||||
|
|
||||||
l = append(l, busybox, busyboxGlibc)
|
l = append(l, busybox, busyboxGlibc)
|
||||||
return l, nil
|
return l
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,9 +100,7 @@ func TestImage_NewFromLocal(t *testing.T) {
|
|||||||
bbglibc, err := ir.New(context.Background(), "docker.io/library/busybox:glibc", "", "", writer, nil, SigningOptions{}, nil, util.PullImageMissing)
|
bbglibc, err := ir.New(context.Background(), "docker.io/library/busybox:glibc", "", "", writer, nil, SigningOptions{}, nil, util.PullImageMissing)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
||||||
tm, err := makeLocalMatrix(bb, bbglibc)
|
tm := makeLocalMatrix(bb, bbglibc)
|
||||||
assert.NoError(t, err)
|
|
||||||
|
|
||||||
for _, image := range tm {
|
for _, image := range tm {
|
||||||
// tag our images
|
// tag our images
|
||||||
err = image.img.TagImage(image.taggedName)
|
err = image.img.TagImage(image.taggedName)
|
||||||
|
@ -104,10 +104,7 @@ func (ir *Runtime) GetPruneImages(ctx context.Context, all bool, filterFuncs []I
|
|||||||
// PruneImages prunes dangling and optionally all unused images from the local
|
// PruneImages prunes dangling and optionally all unused images from the local
|
||||||
// image store
|
// image store
|
||||||
func (ir *Runtime) PruneImages(ctx context.Context, all bool, filter []string) ([]string, error) {
|
func (ir *Runtime) PruneImages(ctx context.Context, all bool, filter []string) ([]string, error) {
|
||||||
var (
|
filterFuncs := make([]ImageFilter, 0, len(filter))
|
||||||
prunedCids []string
|
|
||||||
filterFuncs []ImageFilter
|
|
||||||
)
|
|
||||||
for _, f := range filter {
|
for _, f := range filter {
|
||||||
filterSplit := strings.SplitN(f, "=", 2)
|
filterSplit := strings.SplitN(f, "=", 2)
|
||||||
if len(filterSplit) < 2 {
|
if len(filterSplit) < 2 {
|
||||||
@ -125,6 +122,7 @@ func (ir *Runtime) PruneImages(ctx context.Context, all bool, filter []string) (
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, "unable to get images to prune")
|
return nil, errors.Wrap(err, "unable to get images to prune")
|
||||||
}
|
}
|
||||||
|
prunedCids := make([]string, 0, len(pruneImages))
|
||||||
for _, p := range pruneImages {
|
for _, p := range pruneImages {
|
||||||
repotags, err := p.RepoTags()
|
repotags, err := p.RepoTags()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -366,7 +366,7 @@ func (ir *Runtime) pullGoalFromPossiblyUnqualifiedName(inputName string) (*pullG
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
var refPairs []pullRefPair
|
refPairs := make([]pullRefPair, 0, len(searchRegistries))
|
||||||
for _, registry := range searchRegistries {
|
for _, registry := range searchRegistries {
|
||||||
ref, err := decomposedImage.referenceWithRegistry(registry)
|
ref, err := decomposedImage.referenceWithRegistry(registry)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -93,8 +93,8 @@ func SearchImages(term string, options SearchOptions) ([]SearchResult, error) {
|
|||||||
searchImageInRegistryHelper := func(index int, registry string) {
|
searchImageInRegistryHelper := func(index int, registry string) {
|
||||||
defer sem.Release(1)
|
defer sem.Release(1)
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
searchOutput, err := searchImageInRegistry(term, registry, options)
|
searchOutput := searchImageInRegistry(term, registry, options)
|
||||||
data[index] = searchOutputData{data: searchOutput, err: err}
|
data[index] = searchOutputData{data: searchOutput}
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
@ -131,7 +131,7 @@ func getRegistries(registry string) ([]string, error) {
|
|||||||
return registries, nil
|
return registries, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func searchImageInRegistry(term string, registry string, options SearchOptions) ([]SearchResult, error) {
|
func searchImageInRegistry(term string, registry string, options SearchOptions) []SearchResult {
|
||||||
// Max number of queries by default is 25
|
// Max number of queries by default is 25
|
||||||
limit := maxQueries
|
limit := maxQueries
|
||||||
if options.Limit > 0 {
|
if options.Limit > 0 {
|
||||||
@ -147,7 +147,7 @@ func searchImageInRegistry(term string, registry string, options SearchOptions)
|
|||||||
results, err := docker.SearchRegistry(context.TODO(), sc, registry, term, limit)
|
results, err := docker.SearchRegistry(context.TODO(), sc, registry, term, limit)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Errorf("error searching registry %q: %v", registry, err)
|
logrus.Errorf("error searching registry %q: %v", registry, err)
|
||||||
return []SearchResult{}, nil
|
return []SearchResult{}
|
||||||
}
|
}
|
||||||
index := registry
|
index := registry
|
||||||
arr := strings.Split(registry, ".")
|
arr := strings.Split(registry, ".")
|
||||||
@ -201,7 +201,7 @@ func searchImageInRegistry(term string, registry string, options SearchOptions)
|
|||||||
}
|
}
|
||||||
paramsArr = append(paramsArr, params)
|
paramsArr = append(paramsArr, params)
|
||||||
}
|
}
|
||||||
return paramsArr, nil
|
return paramsArr
|
||||||
}
|
}
|
||||||
|
|
||||||
// ParseSearchFilter turns the filter into a SearchFilter that can be used for
|
// ParseSearchFilter turns the filter into a SearchFilter that can be used for
|
||||||
|
@ -31,8 +31,8 @@ func (c *Container) GenerateForKube() (*v1.Pod, error) {
|
|||||||
func (p *Pod) GenerateForKube() (*v1.Pod, []v1.ServicePort, error) {
|
func (p *Pod) GenerateForKube() (*v1.Pod, []v1.ServicePort, error) {
|
||||||
// Generate the v1.Pod yaml description
|
// Generate the v1.Pod yaml description
|
||||||
var (
|
var (
|
||||||
servicePorts []v1.ServicePort
|
ports []v1.ContainerPort //nolint
|
||||||
ports []v1.ContainerPort
|
servicePorts []v1.ServicePort //nolint
|
||||||
)
|
)
|
||||||
|
|
||||||
allContainers, err := p.allContainers()
|
allContainers, err := p.allContainers()
|
||||||
@ -99,7 +99,7 @@ func GenerateKubeServiceFromV1Pod(pod *v1.Pod, servicePorts []v1.ServicePort) v1
|
|||||||
// containerPortsToServicePorts takes a slice of containerports and generates a
|
// containerPortsToServicePorts takes a slice of containerports and generates a
|
||||||
// slice of service ports
|
// slice of service ports
|
||||||
func containerPortsToServicePorts(containerPorts []v1.ContainerPort) []v1.ServicePort {
|
func containerPortsToServicePorts(containerPorts []v1.ContainerPort) []v1.ServicePort {
|
||||||
var sps []v1.ServicePort
|
sps := make([]v1.ServicePort, 0, len(containerPorts))
|
||||||
for _, cp := range containerPorts {
|
for _, cp := range containerPorts {
|
||||||
nodePort := 30000 + rand.Intn(32767-30000+1)
|
nodePort := 30000 + rand.Intn(32767-30000+1)
|
||||||
servicePort := v1.ServicePort{
|
servicePort := v1.ServicePort{
|
||||||
@ -116,11 +116,11 @@ func containerPortsToServicePorts(containerPorts []v1.ContainerPort) []v1.Servic
|
|||||||
// containersToServicePorts takes a slice of v1.Containers and generates an
|
// containersToServicePorts takes a slice of v1.Containers and generates an
|
||||||
// inclusive list of serviceports to expose
|
// inclusive list of serviceports to expose
|
||||||
func containersToServicePorts(containers []v1.Container) []v1.ServicePort {
|
func containersToServicePorts(containers []v1.Container) []v1.ServicePort {
|
||||||
var sps []v1.ServicePort
|
|
||||||
// Without the call to rand.Seed, a program will produce the same sequence of pseudo-random numbers
|
// Without the call to rand.Seed, a program will produce the same sequence of pseudo-random numbers
|
||||||
// for each execution. Legal nodeport range is 30000-32767
|
// for each execution. Legal nodeport range is 30000-32767
|
||||||
rand.Seed(time.Now().UnixNano())
|
rand.Seed(time.Now().UnixNano())
|
||||||
|
|
||||||
|
sps := make([]v1.ServicePort, 0, len(containers))
|
||||||
for _, ctr := range containers {
|
for _, ctr := range containers {
|
||||||
sps = append(sps, containerPortsToServicePorts(ctr.Ports)...)
|
sps = append(sps, containerPortsToServicePorts(ctr.Ports)...)
|
||||||
}
|
}
|
||||||
@ -128,11 +128,9 @@ func containersToServicePorts(containers []v1.Container) []v1.ServicePort {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *Pod) podWithContainers(containers []*Container, ports []v1.ContainerPort) (*v1.Pod, error) {
|
func (p *Pod) podWithContainers(containers []*Container, ports []v1.ContainerPort) (*v1.Pod, error) {
|
||||||
var (
|
|
||||||
podContainers []v1.Container
|
|
||||||
)
|
|
||||||
deDupPodVolumes := make(map[string]*v1.Volume)
|
deDupPodVolumes := make(map[string]*v1.Volume)
|
||||||
first := true
|
first := true
|
||||||
|
podContainers := make([]v1.Container, 0, len(containers))
|
||||||
for _, ctr := range containers {
|
for _, ctr := range containers {
|
||||||
if !ctr.IsInfra() {
|
if !ctr.IsInfra() {
|
||||||
ctr, volumes, err := containerToV1Container(ctr)
|
ctr, volumes, err := containerToV1Container(ctr)
|
||||||
@ -201,13 +199,11 @@ func addContainersAndVolumesToPodObject(containers []v1.Container, volumes []v1.
|
|||||||
// simplePodWithV1Container is a function used by inspect when kube yaml needs to be generated
|
// simplePodWithV1Container is a function used by inspect when kube yaml needs to be generated
|
||||||
// for a single container. we "insert" that container description in a pod.
|
// for a single container. we "insert" that container description in a pod.
|
||||||
func simplePodWithV1Container(ctr *Container) (*v1.Pod, error) {
|
func simplePodWithV1Container(ctr *Container) (*v1.Pod, error) {
|
||||||
var containers []v1.Container
|
|
||||||
kubeCtr, kubeVols, err := containerToV1Container(ctr)
|
kubeCtr, kubeVols, err := containerToV1Container(ctr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
containers = append(containers, kubeCtr)
|
return addContainersAndVolumesToPodObject([]v1.Container{kubeCtr}, kubeVols, ctr.Name()), nil
|
||||||
return addContainersAndVolumesToPodObject(containers, kubeVols, ctr.Name()), nil
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -223,11 +219,7 @@ func containerToV1Container(c *Container) (v1.Container, []v1.Volume, error) {
|
|||||||
|
|
||||||
if len(c.config.Spec.Linux.Devices) > 0 {
|
if len(c.config.Spec.Linux.Devices) > 0 {
|
||||||
// TODO Enable when we can support devices and their names
|
// TODO Enable when we can support devices and their names
|
||||||
devices, err := generateKubeVolumeDeviceFromLinuxDevice(c.Spec().Linux.Devices)
|
kubeContainer.VolumeDevices = generateKubeVolumeDeviceFromLinuxDevice(c.Spec().Linux.Devices)
|
||||||
if err != nil {
|
|
||||||
return kubeContainer, kubeVolumes, err
|
|
||||||
}
|
|
||||||
kubeContainer.VolumeDevices = devices
|
|
||||||
return kubeContainer, kubeVolumes, errors.Wrapf(define.ErrNotImplemented, "linux devices")
|
return kubeContainer, kubeVolumes, errors.Wrapf(define.ErrNotImplemented, "linux devices")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -283,7 +275,7 @@ func containerToV1Container(c *Container) (v1.Container, []v1.Volume, error) {
|
|||||||
// ocicniPortMappingToContainerPort takes an ocicni portmapping and converts
|
// ocicniPortMappingToContainerPort takes an ocicni portmapping and converts
|
||||||
// it to a v1.ContainerPort format for kube output
|
// it to a v1.ContainerPort format for kube output
|
||||||
func ocicniPortMappingToContainerPort(portMappings []ocicni.PortMapping) ([]v1.ContainerPort, error) {
|
func ocicniPortMappingToContainerPort(portMappings []ocicni.PortMapping) ([]v1.ContainerPort, error) {
|
||||||
var containerPorts []v1.ContainerPort
|
containerPorts := make([]v1.ContainerPort, 0, len(portMappings))
|
||||||
for _, p := range portMappings {
|
for _, p := range portMappings {
|
||||||
var protocol v1.Protocol
|
var protocol v1.Protocol
|
||||||
switch strings.ToUpper(p.Protocol) {
|
switch strings.ToUpper(p.Protocol) {
|
||||||
@ -308,7 +300,7 @@ func ocicniPortMappingToContainerPort(portMappings []ocicni.PortMapping) ([]v1.C
|
|||||||
|
|
||||||
// libpodEnvVarsToKubeEnvVars converts a key=value string slice to []v1.EnvVar
|
// libpodEnvVarsToKubeEnvVars converts a key=value string slice to []v1.EnvVar
|
||||||
func libpodEnvVarsToKubeEnvVars(envs []string) ([]v1.EnvVar, error) {
|
func libpodEnvVarsToKubeEnvVars(envs []string) ([]v1.EnvVar, error) {
|
||||||
var envVars []v1.EnvVar
|
envVars := make([]v1.EnvVar, 0, len(envs))
|
||||||
for _, e := range envs {
|
for _, e := range envs {
|
||||||
split := strings.SplitN(e, "=", 2)
|
split := strings.SplitN(e, "=", 2)
|
||||||
if len(split) != 2 {
|
if len(split) != 2 {
|
||||||
@ -325,11 +317,10 @@ func libpodEnvVarsToKubeEnvVars(envs []string) ([]v1.EnvVar, error) {
|
|||||||
|
|
||||||
// libpodMountsToKubeVolumeMounts converts the containers mounts to a struct kube understands
|
// libpodMountsToKubeVolumeMounts converts the containers mounts to a struct kube understands
|
||||||
func libpodMountsToKubeVolumeMounts(c *Container) ([]v1.VolumeMount, []v1.Volume, error) {
|
func libpodMountsToKubeVolumeMounts(c *Container) ([]v1.VolumeMount, []v1.Volume, error) {
|
||||||
var vms []v1.VolumeMount
|
|
||||||
var vos []v1.Volume
|
|
||||||
|
|
||||||
// TjDO when named volumes are supported in play kube, also parse named volumes here
|
// TjDO when named volumes are supported in play kube, also parse named volumes here
|
||||||
_, mounts := c.sortUserVolumes(c.config.Spec)
|
_, mounts := c.sortUserVolumes(c.config.Spec)
|
||||||
|
vms := make([]v1.VolumeMount, 0, len(mounts))
|
||||||
|
vos := make([]v1.Volume, 0, len(mounts))
|
||||||
for _, m := range mounts {
|
for _, m := range mounts {
|
||||||
vm, vo, err := generateKubeVolumeMount(m)
|
vm, vo, err := generateKubeVolumeMount(m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -404,8 +395,8 @@ func convertVolumePathToName(hostSourcePath string) (string, error) {
|
|||||||
|
|
||||||
func determineCapAddDropFromCapabilities(defaultCaps, containerCaps []string) *v1.Capabilities {
|
func determineCapAddDropFromCapabilities(defaultCaps, containerCaps []string) *v1.Capabilities {
|
||||||
var (
|
var (
|
||||||
drop []v1.Capability
|
drop = []v1.Capability{}
|
||||||
add []v1.Capability
|
add = []v1.Capability{}
|
||||||
)
|
)
|
||||||
dedupDrop := make(map[string]bool)
|
dedupDrop := make(map[string]bool)
|
||||||
dedupAdd := make(map[string]bool)
|
dedupAdd := make(map[string]bool)
|
||||||
@ -518,8 +509,8 @@ func generateKubeSecurityContext(c *Container) (*v1.SecurityContext, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// generateKubeVolumeDeviceFromLinuxDevice takes a list of devices and makes a VolumeDevice struct for kube
|
// generateKubeVolumeDeviceFromLinuxDevice takes a list of devices and makes a VolumeDevice struct for kube
|
||||||
func generateKubeVolumeDeviceFromLinuxDevice(devices []specs.LinuxDevice) ([]v1.VolumeDevice, error) {
|
func generateKubeVolumeDeviceFromLinuxDevice(devices []specs.LinuxDevice) []v1.VolumeDevice {
|
||||||
var volumeDevices []v1.VolumeDevice
|
volumeDevices := make([]v1.VolumeDevice, 0, len(devices))
|
||||||
for _, d := range devices {
|
for _, d := range devices {
|
||||||
vd := v1.VolumeDevice{
|
vd := v1.VolumeDevice{
|
||||||
// TBD How are we going to sync up these names
|
// TBD How are we going to sync up these names
|
||||||
@ -528,7 +519,7 @@ func generateKubeVolumeDeviceFromLinuxDevice(devices []specs.LinuxDevice) ([]v1.
|
|||||||
}
|
}
|
||||||
volumeDevices = append(volumeDevices, vd)
|
volumeDevices = append(volumeDevices, vd)
|
||||||
}
|
}
|
||||||
return volumeDevices, nil
|
return volumeDevices
|
||||||
}
|
}
|
||||||
|
|
||||||
func removeUnderscores(s string) string {
|
func removeUnderscores(s string) string {
|
||||||
|
@ -32,7 +32,7 @@ type MissingRuntime struct {
|
|||||||
|
|
||||||
// Get a new MissingRuntime for the given name.
|
// Get a new MissingRuntime for the given name.
|
||||||
// Requires a libpod Runtime so we can make a sane path for the exits dir.
|
// Requires a libpod Runtime so we can make a sane path for the exits dir.
|
||||||
func getMissingRuntime(name string, r *Runtime) (OCIRuntime, error) {
|
func getMissingRuntime(name string, r *Runtime) OCIRuntime {
|
||||||
missingRuntimesLock.Lock()
|
missingRuntimesLock.Lock()
|
||||||
defer missingRuntimesLock.Unlock()
|
defer missingRuntimesLock.Unlock()
|
||||||
|
|
||||||
@ -42,7 +42,7 @@ func getMissingRuntime(name string, r *Runtime) (OCIRuntime, error) {
|
|||||||
|
|
||||||
runtime, ok := missingRuntimes[name]
|
runtime, ok := missingRuntimes[name]
|
||||||
if ok {
|
if ok {
|
||||||
return runtime, nil
|
return runtime
|
||||||
}
|
}
|
||||||
|
|
||||||
// Once for each missing runtime, we want to error.
|
// Once for each missing runtime, we want to error.
|
||||||
@ -54,7 +54,7 @@ func getMissingRuntime(name string, r *Runtime) (OCIRuntime, error) {
|
|||||||
|
|
||||||
missingRuntimes[name] = newRuntime
|
missingRuntimes[name] = newRuntime
|
||||||
|
|
||||||
return newRuntime, nil
|
return newRuntime
|
||||||
}
|
}
|
||||||
|
|
||||||
// Name is the name of the missing runtime
|
// Name is the name of the missing runtime
|
||||||
|
@ -432,10 +432,6 @@ func containerStatusFromContainers(allCtrs []*Container) (map[string]define.Cont
|
|||||||
|
|
||||||
// Inspect returns a PodInspect struct to describe the pod
|
// Inspect returns a PodInspect struct to describe the pod
|
||||||
func (p *Pod) Inspect() (*define.InspectPodData, error) {
|
func (p *Pod) Inspect() (*define.InspectPodData, error) {
|
||||||
var (
|
|
||||||
ctrs []define.InspectPodContainerInfo
|
|
||||||
)
|
|
||||||
|
|
||||||
p.lock.Lock()
|
p.lock.Lock()
|
||||||
defer p.lock.Unlock()
|
defer p.lock.Unlock()
|
||||||
if err := p.updatePod(); err != nil {
|
if err := p.updatePod(); err != nil {
|
||||||
@ -446,6 +442,7 @@ func (p *Pod) Inspect() (*define.InspectPodData, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
ctrs := make([]define.InspectPodContainerInfo, 0, len(containers))
|
||||||
ctrStatuses := make(map[string]define.ContainerStatus, len(containers))
|
ctrStatuses := make(map[string]define.ContainerStatus, len(containers))
|
||||||
for _, c := range containers {
|
for _, c := range containers {
|
||||||
containerStatus := "unknown"
|
containerStatus := "unknown"
|
||||||
|
@ -13,7 +13,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// Creates a new, empty pod
|
// Creates a new, empty pod
|
||||||
func newPod(runtime *Runtime) (*Pod, error) {
|
func newPod(runtime *Runtime) *Pod {
|
||||||
pod := new(Pod)
|
pod := new(Pod)
|
||||||
pod.config = new(PodConfig)
|
pod.config = new(PodConfig)
|
||||||
pod.config.ID = stringid.GenerateNonCryptoID()
|
pod.config.ID = stringid.GenerateNonCryptoID()
|
||||||
@ -23,7 +23,7 @@ func newPod(runtime *Runtime) (*Pod, error) {
|
|||||||
pod.state = new(podState)
|
pod.state = new(podState)
|
||||||
pod.runtime = runtime
|
pod.runtime = runtime
|
||||||
|
|
||||||
return pod, nil
|
return pod
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update pod state from database
|
// Update pod state from database
|
||||||
|
@ -286,9 +286,7 @@ func makeRuntime(ctx context.Context, runtime *Runtime) (err error) {
|
|||||||
return errors.Wrapf(err, "error retrieving runtime configuration from database")
|
return errors.Wrapf(err, "error retrieving runtime configuration from database")
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := runtime.mergeDBConfig(dbConfig); err != nil {
|
runtime.mergeDBConfig(dbConfig)
|
||||||
return errors.Wrapf(err, "error merging database config into runtime config")
|
|
||||||
}
|
|
||||||
|
|
||||||
logrus.Debugf("Using graph driver %s", runtime.storageConfig.GraphDriverName)
|
logrus.Debugf("Using graph driver %s", runtime.storageConfig.GraphDriverName)
|
||||||
logrus.Debugf("Using graph root %s", runtime.storageConfig.GraphRoot)
|
logrus.Debugf("Using graph root %s", runtime.storageConfig.GraphRoot)
|
||||||
@ -696,11 +694,7 @@ func (r *Runtime) configureStore() error {
|
|||||||
|
|
||||||
// Set up a storage service for creating container root filesystems from
|
// Set up a storage service for creating container root filesystems from
|
||||||
// images
|
// images
|
||||||
storageService, err := getStorageService(r.store)
|
r.storageService = getStorageService(r.store)
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
r.storageService = storageService
|
|
||||||
|
|
||||||
ir := image.NewImageRuntimeFromStore(r.store)
|
ir := image.NewImageRuntimeFromStore(r.store)
|
||||||
ir.SignaturePolicyPath = r.config.Engine.SignaturePolicyPath
|
ir.SignaturePolicyPath = r.config.Engine.SignaturePolicyPath
|
||||||
@ -751,7 +745,7 @@ type DBConfig struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// mergeDBConfig merges the configuration from the database.
|
// mergeDBConfig merges the configuration from the database.
|
||||||
func (r *Runtime) mergeDBConfig(dbConfig *DBConfig) error {
|
func (r *Runtime) mergeDBConfig(dbConfig *DBConfig) {
|
||||||
|
|
||||||
c := &r.config.Engine
|
c := &r.config.Engine
|
||||||
if !r.storageSet.RunRootSet && dbConfig.StorageTmp != "" {
|
if !r.storageSet.RunRootSet && dbConfig.StorageTmp != "" {
|
||||||
@ -802,7 +796,6 @@ func (r *Runtime) mergeDBConfig(dbConfig *DBConfig) error {
|
|||||||
}
|
}
|
||||||
c.VolumePath = dbConfig.VolumePath
|
c.VolumePath = dbConfig.VolumePath
|
||||||
}
|
}
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Runtime) EnableLabeling() bool {
|
func (r *Runtime) EnableLabeling() bool {
|
||||||
|
@ -813,7 +813,7 @@ func (r *Runtime) GetRunningContainers() ([]*Container, error) {
|
|||||||
// GetContainersByList is a helper function for GetContainers
|
// GetContainersByList is a helper function for GetContainers
|
||||||
// which takes a []string of container IDs or names
|
// which takes a []string of container IDs or names
|
||||||
func (r *Runtime) GetContainersByList(containers []string) ([]*Container, error) {
|
func (r *Runtime) GetContainersByList(containers []string) ([]*Container, error) {
|
||||||
var ctrs []*Container
|
ctrs := make([]*Container, 0, len(containers))
|
||||||
for _, inputContainer := range containers {
|
for _, inputContainer := range containers {
|
||||||
ctr, err := r.LookupContainer(inputContainer)
|
ctr, err := r.LookupContainer(inputContainer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -28,10 +28,7 @@ func (r *Runtime) NewPod(ctx context.Context, options ...PodCreateOption) (_ *Po
|
|||||||
return nil, define.ErrRuntimeStopped
|
return nil, define.ErrRuntimeStopped
|
||||||
}
|
}
|
||||||
|
|
||||||
pod, err := newPod(r)
|
pod := newPod(r)
|
||||||
if err != nil {
|
|
||||||
return nil, errors.Wrapf(err, "error creating pod")
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set default namespace to runtime's namespace
|
// Set default namespace to runtime's namespace
|
||||||
// Do so before options run so they can override it
|
// Do so before options run so they can override it
|
||||||
|
@ -29,11 +29,7 @@ func (r *Runtime) NewVolume(ctx context.Context, options ...VolumeCreateOption)
|
|||||||
|
|
||||||
// newVolume creates a new empty volume
|
// newVolume creates a new empty volume
|
||||||
func (r *Runtime) newVolume(ctx context.Context, options ...VolumeCreateOption) (_ *Volume, deferredErr error) {
|
func (r *Runtime) newVolume(ctx context.Context, options ...VolumeCreateOption) (_ *Volume, deferredErr error) {
|
||||||
volume, err := newVolume(r)
|
volume := newVolume(r)
|
||||||
if err != nil {
|
|
||||||
return nil, errors.Wrapf(err, "error creating volume")
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, option := range options {
|
for _, option := range options {
|
||||||
if err := option(volume); err != nil {
|
if err := option(volume); err != nil {
|
||||||
return nil, errors.Wrapf(err, "error running volume create option")
|
return nil, errors.Wrapf(err, "error running volume create option")
|
||||||
|
@ -21,8 +21,8 @@ type storageService struct {
|
|||||||
|
|
||||||
// getStorageService returns a storageService which can create container root
|
// getStorageService returns a storageService which can create container root
|
||||||
// filesystems from images
|
// filesystems from images
|
||||||
func getStorageService(store storage.Store) (*storageService, error) {
|
func getStorageService(store storage.Store) *storageService {
|
||||||
return &storageService{store: store}, nil
|
return &storageService{store: store}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ContainerInfo wraps a subset of information about a container: the locations
|
// ContainerInfo wraps a subset of information about a container: the locations
|
||||||
|
@ -9,7 +9,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// Creates a new volume
|
// Creates a new volume
|
||||||
func newVolume(runtime *Runtime) (*Volume, error) {
|
func newVolume(runtime *Runtime) *Volume {
|
||||||
volume := new(Volume)
|
volume := new(Volume)
|
||||||
volume.config = new(VolumeConfig)
|
volume.config = new(VolumeConfig)
|
||||||
volume.state = new(VolumeState)
|
volume.state = new(VolumeState)
|
||||||
@ -17,8 +17,7 @@ func newVolume(runtime *Runtime) (*Volume, error) {
|
|||||||
volume.config.Labels = make(map[string]string)
|
volume.config.Labels = make(map[string]string)
|
||||||
volume.config.Options = make(map[string]string)
|
volume.config.Options = make(map[string]string)
|
||||||
volume.state.NeedsCopyUp = true
|
volume.state.NeedsCopyUp = true
|
||||||
|
return volume
|
||||||
return volume, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// teardownStorage deletes the volume from volumePath
|
// teardownStorage deletes the volume from volumePath
|
||||||
|
@ -62,10 +62,8 @@ func CreateContainer(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
func makeCreateConfig(containerConfig *config.Config, input handlers.CreateContainerConfig, newImage *image2.Image) (createconfig.CreateConfig, error) {
|
func makeCreateConfig(containerConfig *config.Config, input handlers.CreateContainerConfig, newImage *image2.Image) (createconfig.CreateConfig, error) {
|
||||||
var (
|
var (
|
||||||
err error
|
err error
|
||||||
init bool
|
init bool
|
||||||
tmpfs []string
|
|
||||||
volumes []string
|
|
||||||
)
|
)
|
||||||
env := make(map[string]string)
|
env := make(map[string]string)
|
||||||
stopSignal := unix.SIGTERM
|
stopSignal := unix.SIGTERM
|
||||||
@ -137,6 +135,7 @@ func makeCreateConfig(containerConfig *config.Config, input handlers.CreateConta
|
|||||||
User: input.User,
|
User: input.User,
|
||||||
}
|
}
|
||||||
pidConfig := createconfig.PidConfig{PidMode: namespaces.PidMode(input.HostConfig.PidMode)}
|
pidConfig := createconfig.PidConfig{PidMode: namespaces.PidMode(input.HostConfig.PidMode)}
|
||||||
|
volumes := make([]string, 0, len(input.Volumes))
|
||||||
for k := range input.Volumes {
|
for k := range input.Volumes {
|
||||||
volumes = append(volumes, k)
|
volumes = append(volumes, k)
|
||||||
}
|
}
|
||||||
@ -158,6 +157,7 @@ func makeCreateConfig(containerConfig *config.Config, input handlers.CreateConta
|
|||||||
}
|
}
|
||||||
|
|
||||||
// format the tmpfs mounts into a []string from map
|
// format the tmpfs mounts into a []string from map
|
||||||
|
tmpfs := make([]string, 0, len(input.HostConfig.Tmpfs))
|
||||||
for k, v := range input.HostConfig.Tmpfs {
|
for k, v := range input.HostConfig.Tmpfs {
|
||||||
tmpfs = append(tmpfs, fmt.Sprintf("%s:%s", k, v))
|
tmpfs = append(tmpfs, fmt.Sprintf("%s:%s", k, v))
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,6 @@ import (
|
|||||||
func HistoryImage(w http.ResponseWriter, r *http.Request) {
|
func HistoryImage(w http.ResponseWriter, r *http.Request) {
|
||||||
runtime := r.Context().Value("runtime").(*libpod.Runtime)
|
runtime := r.Context().Value("runtime").(*libpod.Runtime)
|
||||||
name := utils.GetName(r)
|
name := utils.GetName(r)
|
||||||
var allHistory []handlers.HistoryResponse
|
|
||||||
|
|
||||||
newImage, err := runtime.ImageRuntime().NewFromLocal(name)
|
newImage, err := runtime.ImageRuntime().NewFromLocal(name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -25,6 +24,7 @@ func HistoryImage(w http.ResponseWriter, r *http.Request) {
|
|||||||
utils.InternalServerError(w, err)
|
utils.InternalServerError(w, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
allHistory := make([]handlers.HistoryResponse, 0, len(history))
|
||||||
for _, h := range history {
|
for _, h := range history {
|
||||||
l := handlers.HistoryResponse{
|
l := handlers.HistoryResponse{
|
||||||
ID: h.ID,
|
ID: h.ID,
|
||||||
|
@ -129,7 +129,7 @@ func GetInfo(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func getGraphStatus(storeInfo map[string]string) [][2]string {
|
func getGraphStatus(storeInfo map[string]string) [][2]string {
|
||||||
var graphStatus [][2]string
|
graphStatus := make([][2]string, 0, len(storeInfo))
|
||||||
for k, v := range storeInfo {
|
for k, v := range storeInfo {
|
||||||
graphStatus = append(graphStatus, [2]string{k, v})
|
graphStatus = append(graphStatus, [2]string{k, v})
|
||||||
}
|
}
|
||||||
|
@ -162,9 +162,6 @@ func findPluginByName(plugins []*libcni.NetworkConfig, pluginType string) ([]byt
|
|||||||
}
|
}
|
||||||
|
|
||||||
func ListNetworks(w http.ResponseWriter, r *http.Request) {
|
func ListNetworks(w http.ResponseWriter, r *http.Request) {
|
||||||
var (
|
|
||||||
reports []*types.NetworkResource
|
|
||||||
)
|
|
||||||
runtime := r.Context().Value("runtime").(*libpod.Runtime)
|
runtime := r.Context().Value("runtime").(*libpod.Runtime)
|
||||||
decoder := r.Context().Value("decoder").(*schema.Decoder)
|
decoder := r.Context().Value("decoder").(*schema.Decoder)
|
||||||
query := struct {
|
query := struct {
|
||||||
@ -191,6 +188,7 @@ func ListNetworks(w http.ResponseWriter, r *http.Request) {
|
|||||||
utils.InternalServerError(w, err)
|
utils.InternalServerError(w, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
reports := make([]*types.NetworkResource, 0, len(netNames))
|
||||||
for _, name := range netNames {
|
for _, name := range netNames {
|
||||||
report, err := getNetworkResourceByName(name, runtime)
|
report, err := getNetworkResourceByName(name, runtime)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -215,7 +213,7 @@ func CreateNetwork(w http.ResponseWriter, r *http.Request) {
|
|||||||
if len(networkCreate.Name) > 0 {
|
if len(networkCreate.Name) > 0 {
|
||||||
name = networkCreate.Name
|
name = networkCreate.Name
|
||||||
}
|
}
|
||||||
// At present I think we should just suport the bridge driver
|
// At present I think we should just support the bridge driver
|
||||||
// and allow demand to make us consider more
|
// and allow demand to make us consider more
|
||||||
if networkCreate.Driver != network.DefaultNetworkDriver {
|
if networkCreate.Driver != network.DefaultNetworkDriver {
|
||||||
utils.InternalServerError(w, errors.New("network create only supports the bridge driver"))
|
utils.InternalServerError(w, errors.New("network create only supports the bridge driver"))
|
||||||
|
@ -89,7 +89,6 @@ func PodStop(w http.ResponseWriter, r *http.Request) {
|
|||||||
runtime = r.Context().Value("runtime").(*libpod.Runtime)
|
runtime = r.Context().Value("runtime").(*libpod.Runtime)
|
||||||
decoder = r.Context().Value("decoder").(*schema.Decoder)
|
decoder = r.Context().Value("decoder").(*schema.Decoder)
|
||||||
responses map[string]error
|
responses map[string]error
|
||||||
errs []error
|
|
||||||
)
|
)
|
||||||
query := struct {
|
query := struct {
|
||||||
Timeout int `schema:"t"`
|
Timeout int `schema:"t"`
|
||||||
@ -128,6 +127,7 @@ func PodStop(w http.ResponseWriter, r *http.Request) {
|
|||||||
utils.Error(w, "Something went wrong", http.StatusInternalServerError, err)
|
utils.Error(w, "Something went wrong", http.StatusInternalServerError, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
var errs []error //nolint
|
||||||
for _, err := range responses {
|
for _, err := range responses {
|
||||||
errs = append(errs, err)
|
errs = append(errs, err)
|
||||||
}
|
}
|
||||||
@ -139,9 +139,7 @@ func PodStop(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func PodStart(w http.ResponseWriter, r *http.Request) {
|
func PodStart(w http.ResponseWriter, r *http.Request) {
|
||||||
var (
|
var errs []error //nolint
|
||||||
errs []error
|
|
||||||
)
|
|
||||||
runtime := r.Context().Value("runtime").(*libpod.Runtime)
|
runtime := r.Context().Value("runtime").(*libpod.Runtime)
|
||||||
name := utils.GetName(r)
|
name := utils.GetName(r)
|
||||||
pod, err := runtime.LookupPod(name)
|
pod, err := runtime.LookupPod(name)
|
||||||
@ -206,9 +204,7 @@ func PodDelete(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func PodRestart(w http.ResponseWriter, r *http.Request) {
|
func PodRestart(w http.ResponseWriter, r *http.Request) {
|
||||||
var (
|
var errs []error //nolint
|
||||||
errs []error
|
|
||||||
)
|
|
||||||
runtime := r.Context().Value("runtime").(*libpod.Runtime)
|
runtime := r.Context().Value("runtime").(*libpod.Runtime)
|
||||||
name := utils.GetName(r)
|
name := utils.GetName(r)
|
||||||
pod, err := runtime.LookupPod(name)
|
pod, err := runtime.LookupPod(name)
|
||||||
@ -243,12 +239,12 @@ func PodPrune(w http.ResponseWriter, r *http.Request) {
|
|||||||
func PodPruneHelper(w http.ResponseWriter, r *http.Request) ([]*entities.PodPruneReport, error) {
|
func PodPruneHelper(w http.ResponseWriter, r *http.Request) ([]*entities.PodPruneReport, error) {
|
||||||
var (
|
var (
|
||||||
runtime = r.Context().Value("runtime").(*libpod.Runtime)
|
runtime = r.Context().Value("runtime").(*libpod.Runtime)
|
||||||
reports []*entities.PodPruneReport
|
|
||||||
)
|
)
|
||||||
responses, err := runtime.PrunePods(r.Context())
|
responses, err := runtime.PrunePods(r.Context())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
reports := make([]*entities.PodPruneReport, 0, len(responses))
|
||||||
for k, v := range responses {
|
for k, v := range responses {
|
||||||
reports = append(reports, &entities.PodPruneReport{
|
reports = append(reports, &entities.PodPruneReport{
|
||||||
Err: v,
|
Err: v,
|
||||||
@ -259,9 +255,7 @@ func PodPruneHelper(w http.ResponseWriter, r *http.Request) ([]*entities.PodPrun
|
|||||||
}
|
}
|
||||||
|
|
||||||
func PodPause(w http.ResponseWriter, r *http.Request) {
|
func PodPause(w http.ResponseWriter, r *http.Request) {
|
||||||
var (
|
var errs []error //nolint
|
||||||
errs []error
|
|
||||||
)
|
|
||||||
runtime := r.Context().Value("runtime").(*libpod.Runtime)
|
runtime := r.Context().Value("runtime").(*libpod.Runtime)
|
||||||
name := utils.GetName(r)
|
name := utils.GetName(r)
|
||||||
pod, err := runtime.LookupPod(name)
|
pod, err := runtime.LookupPod(name)
|
||||||
@ -285,9 +279,7 @@ func PodPause(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func PodUnpause(w http.ResponseWriter, r *http.Request) {
|
func PodUnpause(w http.ResponseWriter, r *http.Request) {
|
||||||
var (
|
var errs []error //nolint
|
||||||
errs []error
|
|
||||||
)
|
|
||||||
runtime := r.Context().Value("runtime").(*libpod.Runtime)
|
runtime := r.Context().Value("runtime").(*libpod.Runtime)
|
||||||
name := utils.GetName(r)
|
name := utils.GetName(r)
|
||||||
pod, err := runtime.LookupPod(name)
|
pod, err := runtime.LookupPod(name)
|
||||||
@ -357,7 +349,7 @@ func PodKill(w http.ResponseWriter, r *http.Request) {
|
|||||||
runtime = r.Context().Value("runtime").(*libpod.Runtime)
|
runtime = r.Context().Value("runtime").(*libpod.Runtime)
|
||||||
decoder = r.Context().Value("decoder").(*schema.Decoder)
|
decoder = r.Context().Value("decoder").(*schema.Decoder)
|
||||||
signal = "SIGKILL"
|
signal = "SIGKILL"
|
||||||
errs []error
|
errs []error //nolint
|
||||||
)
|
)
|
||||||
query := struct {
|
query := struct {
|
||||||
Signal string `schema:"signal"`
|
Signal string `schema:"signal"`
|
||||||
|
@ -61,7 +61,7 @@ func SystemPrune(w http.ResponseWriter, r *http.Request) {
|
|||||||
systemPruneReport.ImagePruneReport = &report
|
systemPruneReport.ImagePruneReport = &report
|
||||||
|
|
||||||
if query.Volumes {
|
if query.Volumes {
|
||||||
volumePruneReport, err := pruneVolumesHelper(w, r)
|
volumePruneReport, err := pruneVolumesHelper(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
utils.InternalServerError(w, err)
|
utils.InternalServerError(w, err)
|
||||||
return
|
return
|
||||||
|
@ -102,9 +102,8 @@ func InspectVolume(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
func ListVolumes(w http.ResponseWriter, r *http.Request) {
|
func ListVolumes(w http.ResponseWriter, r *http.Request) {
|
||||||
var (
|
var (
|
||||||
decoder = r.Context().Value("decoder").(*schema.Decoder)
|
decoder = r.Context().Value("decoder").(*schema.Decoder)
|
||||||
runtime = r.Context().Value("runtime").(*libpod.Runtime)
|
runtime = r.Context().Value("runtime").(*libpod.Runtime)
|
||||||
volumeConfigs []*entities.VolumeListReport
|
|
||||||
)
|
)
|
||||||
query := struct {
|
query := struct {
|
||||||
Filters map[string][]string `schema:"filters"`
|
Filters map[string][]string `schema:"filters"`
|
||||||
@ -129,6 +128,7 @@ func ListVolumes(w http.ResponseWriter, r *http.Request) {
|
|||||||
utils.InternalServerError(w, err)
|
utils.InternalServerError(w, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
volumeConfigs := make([]*entities.VolumeListReport, 0, len(vols))
|
||||||
for _, v := range vols {
|
for _, v := range vols {
|
||||||
config := entities.VolumeConfigResponse{
|
config := entities.VolumeConfigResponse{
|
||||||
Name: v.Name(),
|
Name: v.Name(),
|
||||||
@ -147,7 +147,7 @@ func ListVolumes(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func PruneVolumes(w http.ResponseWriter, r *http.Request) {
|
func PruneVolumes(w http.ResponseWriter, r *http.Request) {
|
||||||
reports, err := pruneVolumesHelper(w, r)
|
reports, err := pruneVolumesHelper(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
utils.InternalServerError(w, err)
|
utils.InternalServerError(w, err)
|
||||||
return
|
return
|
||||||
@ -155,15 +155,15 @@ func PruneVolumes(w http.ResponseWriter, r *http.Request) {
|
|||||||
utils.WriteResponse(w, http.StatusOK, reports)
|
utils.WriteResponse(w, http.StatusOK, reports)
|
||||||
}
|
}
|
||||||
|
|
||||||
func pruneVolumesHelper(w http.ResponseWriter, r *http.Request) ([]*entities.VolumePruneReport, error) {
|
func pruneVolumesHelper(r *http.Request) ([]*entities.VolumePruneReport, error) {
|
||||||
var (
|
var (
|
||||||
runtime = r.Context().Value("runtime").(*libpod.Runtime)
|
runtime = r.Context().Value("runtime").(*libpod.Runtime)
|
||||||
reports []*entities.VolumePruneReport
|
|
||||||
)
|
)
|
||||||
pruned, err := runtime.PruneVolumes(r.Context())
|
pruned, err := runtime.PruneVolumes(r.Context())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
reports := make([]*entities.VolumePruneReport, 0, len(pruned))
|
||||||
for k, v := range pruned {
|
for k, v := range pruned {
|
||||||
reports = append(reports, &entities.VolumePruneReport{
|
reports = append(reports, &entities.VolumePruneReport{
|
||||||
Err: v,
|
Err: v,
|
||||||
|
@ -93,7 +93,7 @@ func GetImages(w http.ResponseWriter, r *http.Request) ([]*image.Image, error) {
|
|||||||
if query.All {
|
if query.All {
|
||||||
return images, nil
|
return images, nil
|
||||||
}
|
}
|
||||||
var returnImages []*image.Image
|
returnImages := []*image.Image{}
|
||||||
for _, img := range images {
|
for _, img := range images {
|
||||||
if len(img.Names()) == 0 {
|
if len(img.Names()) == 0 {
|
||||||
parent, err := img.IsParent(r.Context())
|
parent, err := img.IsParent(r.Context())
|
||||||
|
@ -11,7 +11,6 @@ import (
|
|||||||
|
|
||||||
func GetPods(w http.ResponseWriter, r *http.Request) ([]*entities.ListPodsReport, error) {
|
func GetPods(w http.ResponseWriter, r *http.Request) ([]*entities.ListPodsReport, error) {
|
||||||
var (
|
var (
|
||||||
lps []*entities.ListPodsReport
|
|
||||||
pods []*libpod.Pod
|
pods []*libpod.Pod
|
||||||
filters []libpod.PodFilter
|
filters []libpod.PodFilter
|
||||||
)
|
)
|
||||||
@ -45,6 +44,11 @@ func GetPods(w http.ResponseWriter, r *http.Request) ([]*entities.ListPodsReport
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(pods) == 0 {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
lps := make([]*entities.ListPodsReport, 0, len(pods))
|
||||||
for _, pod := range pods {
|
for _, pod := range pods {
|
||||||
status, err := pod.GetPodStatus()
|
status, err := pod.GetPodStatus()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -115,12 +115,12 @@ func NewConnectionWithIdentity(ctx context.Context, uri string, passPhrase strin
|
|||||||
_url.Path = JoinURL(_url.Host, _url.Path)
|
_url.Path = JoinURL(_url.Host, _url.Path)
|
||||||
_url.Host = ""
|
_url.Host = ""
|
||||||
}
|
}
|
||||||
connection, err = unixClient(_url)
|
connection = unixClient(_url)
|
||||||
case "tcp":
|
case "tcp":
|
||||||
if !strings.HasPrefix(uri, "tcp://") {
|
if !strings.HasPrefix(uri, "tcp://") {
|
||||||
return nil, errors.New("tcp URIs should begin with tcp://")
|
return nil, errors.New("tcp URIs should begin with tcp://")
|
||||||
}
|
}
|
||||||
connection, err = tcpClient(_url)
|
connection = tcpClient(_url)
|
||||||
default:
|
default:
|
||||||
return nil, errors.Errorf("'%s' is not a supported schema", _url.Scheme)
|
return nil, errors.Errorf("'%s' is not a supported schema", _url.Scheme)
|
||||||
}
|
}
|
||||||
@ -135,7 +135,7 @@ func NewConnectionWithIdentity(ctx context.Context, uri string, passPhrase strin
|
|||||||
return ctx, nil
|
return ctx, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func tcpClient(_url *url.URL) (Connection, error) {
|
func tcpClient(_url *url.URL) Connection {
|
||||||
connection := Connection{
|
connection := Connection{
|
||||||
URI: _url,
|
URI: _url,
|
||||||
}
|
}
|
||||||
@ -147,7 +147,7 @@ func tcpClient(_url *url.URL) (Connection, error) {
|
|||||||
DisableCompression: true,
|
DisableCompression: true,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
return connection, nil
|
return connection
|
||||||
}
|
}
|
||||||
|
|
||||||
// pingNewConnection pings to make sure the RESTFUL service is up
|
// pingNewConnection pings to make sure the RESTFUL service is up
|
||||||
@ -186,8 +186,7 @@ func pingNewConnection(ctx context.Context) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func sshClient(_url *url.URL, secure bool, passPhrase string, identities ...string) (Connection, error) {
|
func sshClient(_url *url.URL, secure bool, passPhrase string, identities ...string) (Connection, error) {
|
||||||
var authMethods []ssh.AuthMethod
|
authMethods := []ssh.AuthMethod{}
|
||||||
|
|
||||||
for _, i := range identities {
|
for _, i := range identities {
|
||||||
auth, err := publicKey(i, []byte(passPhrase))
|
auth, err := publicKey(i, []byte(passPhrase))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -256,7 +255,7 @@ func sshClient(_url *url.URL, secure bool, passPhrase string, identities ...stri
|
|||||||
return connection, nil
|
return connection, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func unixClient(_url *url.URL) (Connection, error) {
|
func unixClient(_url *url.URL) Connection {
|
||||||
connection := Connection{URI: _url}
|
connection := Connection{URI: _url}
|
||||||
connection.Client = &http.Client{
|
connection.Client = &http.Client{
|
||||||
Transport: &http.Transport{
|
Transport: &http.Transport{
|
||||||
@ -266,7 +265,7 @@ func unixClient(_url *url.URL) (Connection, error) {
|
|||||||
DisableCompression: true,
|
DisableCompression: true,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
return connection, nil
|
return connection
|
||||||
}
|
}
|
||||||
|
|
||||||
// DoRequest assembles the http request and returns the response
|
// DoRequest assembles the http request and returns the response
|
||||||
|
@ -42,7 +42,7 @@ func Checkpoint(ctx context.Context, nameOrID string, keep, leaveRunning, tcpEst
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Restore restores a checkpointed container to running. The container is identified by the nameOrID option. All
|
// Restore restores a checkpointed container to running. The container is identified by the nameOrID option. All
|
||||||
// additional options are optional and allow finer control of the restore processs.
|
// additional options are optional and allow finer control of the restore process.
|
||||||
func Restore(ctx context.Context, nameOrID string, keep, tcpEstablished, ignoreRootFS, ignoreStaticIP, ignoreStaticMAC *bool, name, importArchive *string) (*entities.RestoreReport, error) {
|
func Restore(ctx context.Context, nameOrID string, keep, tcpEstablished, ignoreRootFS, ignoreStaticIP, ignoreStaticMAC *bool, name, importArchive *string) (*entities.RestoreReport, error) {
|
||||||
var report entities.RestoreReport
|
var report entities.RestoreReport
|
||||||
conn, err := bindings.GetClient(ctx)
|
conn, err := bindings.GetClient(ctx)
|
||||||
|
@ -12,7 +12,7 @@ type LogOptions struct {
|
|||||||
Until *string
|
Until *string
|
||||||
}
|
}
|
||||||
|
|
||||||
// CommitOptions describe details about the resulting commited
|
// CommitOptions describe details about the resulting committed
|
||||||
// image as defined by repo and tag. None of these options
|
// image as defined by repo and tag. None of these options
|
||||||
// are required.
|
// are required.
|
||||||
type CommitOptions struct {
|
type CommitOptions struct {
|
||||||
|
@ -394,7 +394,7 @@ func Pull(ctx context.Context, rawImage string, options entities.ImagePullOption
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Push is the binding for libpod's v2 endpoints for push images. Note that
|
// Push is the binding for libpod's v2 endpoints for push images. Note that
|
||||||
// `source` must be a refering to an image in the remote's container storage.
|
// `source` must be a referring to an image in the remote's container storage.
|
||||||
// The destination must be a reference to a registry (i.e., of docker transport
|
// The destination must be a reference to a registry (i.e., of docker transport
|
||||||
// or be normalized to one). Other transports are rejected as they do not make
|
// or be normalized to one). Other transports are rejected as they do not make
|
||||||
// sense in a remote context.
|
// sense in a remote context.
|
||||||
|
@ -133,7 +133,7 @@ func getAvailableControllers(exclude map[string]controllerHandler, cgroup2 bool)
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrapf(err, "read directory %s", cgroupRoot)
|
return nil, errors.Wrapf(err, "read directory %s", cgroupRoot)
|
||||||
}
|
}
|
||||||
var controllers []controller
|
controllers := []controller{}
|
||||||
for _, i := range infos {
|
for _, i := range infos {
|
||||||
name := i.Name()
|
name := i.Name()
|
||||||
if _, found := exclude[name]; found {
|
if _, found := exclude[name]; found {
|
||||||
@ -505,7 +505,7 @@ func (c *CgroupControl) AddPid(pid int) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var names []string
|
names := make([]string, 0, len(handlers))
|
||||||
for n := range handlers {
|
for n := range handlers {
|
||||||
names = append(names, n)
|
names = append(names, n)
|
||||||
}
|
}
|
||||||
|
@ -29,13 +29,12 @@ func readAcct(ctr *CgroupControl, name string) (uint64, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func readAcctList(ctr *CgroupControl, name string) ([]uint64, error) {
|
func readAcctList(ctr *CgroupControl, name string) ([]uint64, error) {
|
||||||
var r []uint64
|
|
||||||
|
|
||||||
p := filepath.Join(ctr.getCgroupv1Path(CPUAcct), name)
|
p := filepath.Join(ctr.getCgroupv1Path(CPUAcct), name)
|
||||||
data, err := ioutil.ReadFile(p)
|
data, err := ioutil.ReadFile(p)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrapf(err, "reading %s", p)
|
return nil, errors.Wrapf(err, "reading %s", p)
|
||||||
}
|
}
|
||||||
|
r := []uint64{}
|
||||||
for _, s := range strings.Split(string(data), " ") {
|
for _, s := range strings.Split(string(data), " ") {
|
||||||
s = cleanString(s)
|
s = cleanString(s)
|
||||||
if s == "" {
|
if s == "" {
|
||||||
|
@ -18,7 +18,7 @@ type GenerateSystemdOptions struct {
|
|||||||
ContainerPrefix string
|
ContainerPrefix string
|
||||||
// PodPrefix - systemd unit name prefix for pods
|
// PodPrefix - systemd unit name prefix for pods
|
||||||
PodPrefix string
|
PodPrefix string
|
||||||
// Separator - systemd unit name seperator between name/id and prefix
|
// Separator - systemd unit name separator between name/id and prefix
|
||||||
Separator string
|
Separator string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,13 +84,11 @@ func (ic *ContainerEngine) ContainerExists(ctx context.Context, nameOrID string)
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ic *ContainerEngine) ContainerWait(ctx context.Context, namesOrIds []string, options entities.WaitOptions) ([]entities.WaitReport, error) {
|
func (ic *ContainerEngine) ContainerWait(ctx context.Context, namesOrIds []string, options entities.WaitOptions) ([]entities.WaitReport, error) {
|
||||||
var (
|
|
||||||
responses []entities.WaitReport
|
|
||||||
)
|
|
||||||
ctrs, err := getContainersByContext(false, options.Latest, namesOrIds, ic.Libpod)
|
ctrs, err := getContainersByContext(false, options.Latest, namesOrIds, ic.Libpod)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
responses := make([]entities.WaitReport, 0, len(ctrs))
|
||||||
for _, c := range ctrs {
|
for _, c := range ctrs {
|
||||||
response := entities.WaitReport{Id: c.ID()}
|
response := entities.WaitReport{Id: c.ID()}
|
||||||
exitCode, err := c.WaitForConditionWithInterval(options.Interval, options.Condition)
|
exitCode, err := c.WaitForConditionWithInterval(options.Interval, options.Condition)
|
||||||
@ -106,10 +104,9 @@ func (ic *ContainerEngine) ContainerWait(ctx context.Context, namesOrIds []strin
|
|||||||
|
|
||||||
func (ic *ContainerEngine) ContainerPause(ctx context.Context, namesOrIds []string, options entities.PauseUnPauseOptions) ([]*entities.PauseUnpauseReport, error) {
|
func (ic *ContainerEngine) ContainerPause(ctx context.Context, namesOrIds []string, options entities.PauseUnPauseOptions) ([]*entities.PauseUnpauseReport, error) {
|
||||||
var (
|
var (
|
||||||
ctrs []*libpod.Container
|
err error
|
||||||
err error
|
|
||||||
report []*entities.PauseUnpauseReport
|
|
||||||
)
|
)
|
||||||
|
ctrs := []*libpod.Container{} //nolint
|
||||||
if options.All {
|
if options.All {
|
||||||
ctrs, err = ic.Libpod.GetAllContainers()
|
ctrs, err = ic.Libpod.GetAllContainers()
|
||||||
} else {
|
} else {
|
||||||
@ -118,6 +115,7 @@ func (ic *ContainerEngine) ContainerPause(ctx context.Context, namesOrIds []stri
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
report := make([]*entities.PauseUnpauseReport, 0, len(ctrs))
|
||||||
for _, c := range ctrs {
|
for _, c := range ctrs {
|
||||||
err := c.Pause()
|
err := c.Pause()
|
||||||
report = append(report, &entities.PauseUnpauseReport{Id: c.ID(), Err: err})
|
report = append(report, &entities.PauseUnpauseReport{Id: c.ID(), Err: err})
|
||||||
@ -127,10 +125,9 @@ func (ic *ContainerEngine) ContainerPause(ctx context.Context, namesOrIds []stri
|
|||||||
|
|
||||||
func (ic *ContainerEngine) ContainerUnpause(ctx context.Context, namesOrIds []string, options entities.PauseUnPauseOptions) ([]*entities.PauseUnpauseReport, error) {
|
func (ic *ContainerEngine) ContainerUnpause(ctx context.Context, namesOrIds []string, options entities.PauseUnPauseOptions) ([]*entities.PauseUnpauseReport, error) {
|
||||||
var (
|
var (
|
||||||
ctrs []*libpod.Container
|
err error
|
||||||
err error
|
|
||||||
report []*entities.PauseUnpauseReport
|
|
||||||
)
|
)
|
||||||
|
ctrs := []*libpod.Container{} //nolint
|
||||||
if options.All {
|
if options.All {
|
||||||
ctrs, err = ic.Libpod.GetAllContainers()
|
ctrs, err = ic.Libpod.GetAllContainers()
|
||||||
} else {
|
} else {
|
||||||
@ -139,6 +136,7 @@ func (ic *ContainerEngine) ContainerUnpause(ctx context.Context, namesOrIds []st
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
report := make([]*entities.PauseUnpauseReport, 0, len(ctrs))
|
||||||
for _, c := range ctrs {
|
for _, c := range ctrs {
|
||||||
err := c.Unpause()
|
err := c.Unpause()
|
||||||
report = append(report, &entities.PauseUnpauseReport{Id: c.ID(), Err: err})
|
report = append(report, &entities.PauseUnpauseReport{Id: c.ID(), Err: err})
|
||||||
@ -146,9 +144,6 @@ func (ic *ContainerEngine) ContainerUnpause(ctx context.Context, namesOrIds []st
|
|||||||
return report, nil
|
return report, nil
|
||||||
}
|
}
|
||||||
func (ic *ContainerEngine) ContainerStop(ctx context.Context, namesOrIds []string, options entities.StopOptions) ([]*entities.StopReport, error) {
|
func (ic *ContainerEngine) ContainerStop(ctx context.Context, namesOrIds []string, options entities.StopOptions) ([]*entities.StopReport, error) {
|
||||||
var (
|
|
||||||
reports []*entities.StopReport
|
|
||||||
)
|
|
||||||
names := namesOrIds
|
names := namesOrIds
|
||||||
for _, cidFile := range options.CIDFiles {
|
for _, cidFile := range options.CIDFiles {
|
||||||
content, err := ioutil.ReadFile(cidFile)
|
content, err := ioutil.ReadFile(cidFile)
|
||||||
@ -184,6 +179,7 @@ func (ic *ContainerEngine) ContainerStop(ctx context.Context, namesOrIds []strin
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
reports := make([]*entities.StopReport, 0, len(errMap))
|
||||||
for ctr, err := range errMap {
|
for ctr, err := range errMap {
|
||||||
report := new(entities.StopReport)
|
report := new(entities.StopReport)
|
||||||
report.Id = ctr.ID()
|
report.Id = ctr.ID()
|
||||||
@ -204,10 +200,10 @@ func (ic *ContainerEngine) ContainerPrune(ctx context.Context, options entities.
|
|||||||
filterFuncs = append(filterFuncs, generatedFunc)
|
filterFuncs = append(filterFuncs, generatedFunc)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ic.pruneContainersHelper(ctx, filterFuncs)
|
return ic.pruneContainersHelper(filterFuncs)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ic *ContainerEngine) pruneContainersHelper(ctx context.Context, filterFuncs []libpod.ContainerFilter) (*entities.ContainerPruneReport, error) {
|
func (ic *ContainerEngine) pruneContainersHelper(filterFuncs []libpod.ContainerFilter) (*entities.ContainerPruneReport, error) {
|
||||||
prunedContainers, pruneErrors, err := ic.Libpod.PruneContainers(filterFuncs)
|
prunedContainers, pruneErrors, err := ic.Libpod.PruneContainers(filterFuncs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -220,9 +216,6 @@ func (ic *ContainerEngine) pruneContainersHelper(ctx context.Context, filterFunc
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ic *ContainerEngine) ContainerKill(ctx context.Context, namesOrIds []string, options entities.KillOptions) ([]*entities.KillReport, error) {
|
func (ic *ContainerEngine) ContainerKill(ctx context.Context, namesOrIds []string, options entities.KillOptions) ([]*entities.KillReport, error) {
|
||||||
var (
|
|
||||||
reports []*entities.KillReport
|
|
||||||
)
|
|
||||||
sig, err := signal.ParseSignalNameOrNumber(options.Signal)
|
sig, err := signal.ParseSignalNameOrNumber(options.Signal)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -231,6 +224,7 @@ func (ic *ContainerEngine) ContainerKill(ctx context.Context, namesOrIds []strin
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
reports := make([]*entities.KillReport, 0, len(ctrs))
|
||||||
for _, con := range ctrs {
|
for _, con := range ctrs {
|
||||||
reports = append(reports, &entities.KillReport{
|
reports = append(reports, &entities.KillReport{
|
||||||
Id: con.ID(),
|
Id: con.ID(),
|
||||||
@ -241,9 +235,8 @@ func (ic *ContainerEngine) ContainerKill(ctx context.Context, namesOrIds []strin
|
|||||||
}
|
}
|
||||||
func (ic *ContainerEngine) ContainerRestart(ctx context.Context, namesOrIds []string, options entities.RestartOptions) ([]*entities.RestartReport, error) {
|
func (ic *ContainerEngine) ContainerRestart(ctx context.Context, namesOrIds []string, options entities.RestartOptions) ([]*entities.RestartReport, error) {
|
||||||
var (
|
var (
|
||||||
ctrs []*libpod.Container
|
ctrs []*libpod.Container
|
||||||
err error
|
err error
|
||||||
reports []*entities.RestartReport
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if options.Running {
|
if options.Running {
|
||||||
@ -258,6 +251,7 @@ func (ic *ContainerEngine) ContainerRestart(ctx context.Context, namesOrIds []st
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
reports := make([]*entities.RestartReport, 0, len(ctrs))
|
||||||
for _, con := range ctrs {
|
for _, con := range ctrs {
|
||||||
timeout := con.StopTimeout()
|
timeout := con.StopTimeout()
|
||||||
if options.Timeout != nil {
|
if options.Timeout != nil {
|
||||||
@ -272,9 +266,7 @@ func (ic *ContainerEngine) ContainerRestart(ctx context.Context, namesOrIds []st
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ic *ContainerEngine) ContainerRm(ctx context.Context, namesOrIds []string, options entities.RmOptions) ([]*entities.RmReport, error) {
|
func (ic *ContainerEngine) ContainerRm(ctx context.Context, namesOrIds []string, options entities.RmOptions) ([]*entities.RmReport, error) {
|
||||||
var (
|
reports := []*entities.RmReport{}
|
||||||
reports []*entities.RmReport
|
|
||||||
)
|
|
||||||
if options.Storage {
|
if options.Storage {
|
||||||
for _, ctr := range namesOrIds {
|
for _, ctr := range namesOrIds {
|
||||||
report := entities.RmReport{Id: ctr}
|
report := entities.RmReport{Id: ctr}
|
||||||
@ -347,11 +339,11 @@ func (ic *ContainerEngine) ContainerRm(ctx context.Context, namesOrIds []string,
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ic *ContainerEngine) ContainerInspect(ctx context.Context, namesOrIds []string, options entities.InspectOptions) ([]*entities.ContainerInspectReport, error) {
|
func (ic *ContainerEngine) ContainerInspect(ctx context.Context, namesOrIds []string, options entities.InspectOptions) ([]*entities.ContainerInspectReport, error) {
|
||||||
var reports []*entities.ContainerInspectReport
|
|
||||||
ctrs, err := getContainersByContext(false, options.Latest, namesOrIds, ic.Libpod)
|
ctrs, err := getContainersByContext(false, options.Latest, namesOrIds, ic.Libpod)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
reports := make([]*entities.ContainerInspectReport, 0, len(ctrs))
|
||||||
for _, c := range ctrs {
|
for _, c := range ctrs {
|
||||||
data, err := c.Inspect(options.Size)
|
data, err := c.Inspect(options.Size)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -439,9 +431,8 @@ func (ic *ContainerEngine) ContainerExport(ctx context.Context, nameOrID string,
|
|||||||
|
|
||||||
func (ic *ContainerEngine) ContainerCheckpoint(ctx context.Context, namesOrIds []string, options entities.CheckpointOptions) ([]*entities.CheckpointReport, error) {
|
func (ic *ContainerEngine) ContainerCheckpoint(ctx context.Context, namesOrIds []string, options entities.CheckpointOptions) ([]*entities.CheckpointReport, error) {
|
||||||
var (
|
var (
|
||||||
err error
|
err error
|
||||||
cons []*libpod.Container
|
cons []*libpod.Container
|
||||||
reports []*entities.CheckpointReport
|
|
||||||
)
|
)
|
||||||
checkOpts := libpod.ContainerCheckpointOptions{
|
checkOpts := libpod.ContainerCheckpointOptions{
|
||||||
Keep: options.Keep,
|
Keep: options.Keep,
|
||||||
@ -463,6 +454,7 @@ func (ic *ContainerEngine) ContainerCheckpoint(ctx context.Context, namesOrIds [
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
reports := make([]*entities.CheckpointReport, 0, len(cons))
|
||||||
for _, con := range cons {
|
for _, con := range cons {
|
||||||
err = con.Checkpoint(ctx, checkOpts)
|
err = con.Checkpoint(ctx, checkOpts)
|
||||||
reports = append(reports, &entities.CheckpointReport{
|
reports = append(reports, &entities.CheckpointReport{
|
||||||
@ -475,10 +467,8 @@ func (ic *ContainerEngine) ContainerCheckpoint(ctx context.Context, namesOrIds [
|
|||||||
|
|
||||||
func (ic *ContainerEngine) ContainerRestore(ctx context.Context, namesOrIds []string, options entities.RestoreOptions) ([]*entities.RestoreReport, error) {
|
func (ic *ContainerEngine) ContainerRestore(ctx context.Context, namesOrIds []string, options entities.RestoreOptions) ([]*entities.RestoreReport, error) {
|
||||||
var (
|
var (
|
||||||
cons []*libpod.Container
|
cons []*libpod.Container
|
||||||
err error
|
err error
|
||||||
filterFuncs []libpod.ContainerFilter
|
|
||||||
reports []*entities.RestoreReport
|
|
||||||
)
|
)
|
||||||
|
|
||||||
restoreOptions := libpod.ContainerCheckpointOptions{
|
restoreOptions := libpod.ContainerCheckpointOptions{
|
||||||
@ -491,10 +481,12 @@ func (ic *ContainerEngine) ContainerRestore(ctx context.Context, namesOrIds []st
|
|||||||
IgnoreStaticMAC: options.IgnoreStaticMAC,
|
IgnoreStaticMAC: options.IgnoreStaticMAC,
|
||||||
}
|
}
|
||||||
|
|
||||||
filterFuncs = append(filterFuncs, func(c *libpod.Container) bool {
|
filterFuncs := []libpod.ContainerFilter{
|
||||||
state, _ := c.State()
|
func(c *libpod.Container) bool {
|
||||||
return state == define.ContainerStateExited
|
state, _ := c.State()
|
||||||
})
|
return state == define.ContainerStateExited
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
switch {
|
switch {
|
||||||
case options.Import != "":
|
case options.Import != "":
|
||||||
@ -507,6 +499,7 @@ func (ic *ContainerEngine) ContainerRestore(ctx context.Context, namesOrIds []st
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
reports := make([]*entities.RestoreReport, 0, len(cons))
|
||||||
for _, con := range cons {
|
for _, con := range cons {
|
||||||
err := con.Restore(ctx, restoreOptions)
|
err := con.Restore(ctx, restoreOptions)
|
||||||
reports = append(reports, &entities.RestoreReport{
|
reports = append(reports, &entities.RestoreReport{
|
||||||
@ -565,34 +558,34 @@ func makeExecConfig(options entities.ExecOptions) *libpod.ExecConfig {
|
|||||||
return execConfig
|
return execConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkExecPreserveFDs(options entities.ExecOptions) (int, error) {
|
func checkExecPreserveFDs(options entities.ExecOptions) error {
|
||||||
ec := define.ExecErrorCodeGeneric
|
|
||||||
if options.PreserveFDs > 0 {
|
if options.PreserveFDs > 0 {
|
||||||
entries, err := ioutil.ReadDir("/proc/self/fd")
|
entries, err := ioutil.ReadDir("/proc/self/fd")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ec, errors.Wrapf(err, "unable to read /proc/self/fd")
|
return errors.Wrapf(err, "unable to read /proc/self/fd")
|
||||||
}
|
}
|
||||||
|
|
||||||
m := make(map[int]bool)
|
m := make(map[int]bool)
|
||||||
for _, e := range entries {
|
for _, e := range entries {
|
||||||
i, err := strconv.Atoi(e.Name())
|
i, err := strconv.Atoi(e.Name())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ec, errors.Wrapf(err, "cannot parse %s in /proc/self/fd", e.Name())
|
return errors.Wrapf(err, "cannot parse %s in /proc/self/fd", e.Name())
|
||||||
}
|
}
|
||||||
m[i] = true
|
m[i] = true
|
||||||
}
|
}
|
||||||
|
|
||||||
for i := 3; i < 3+int(options.PreserveFDs); i++ {
|
for i := 3; i < 3+int(options.PreserveFDs); i++ {
|
||||||
if _, found := m[i]; !found {
|
if _, found := m[i]; !found {
|
||||||
return ec, errors.New("invalid --preserve-fds=N specified. Not enough FDs available")
|
return errors.New("invalid --preserve-fds=N specified. Not enough FDs available")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ec, nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ic *ContainerEngine) ContainerExec(ctx context.Context, nameOrID string, options entities.ExecOptions, streams define.AttachStreams) (int, error) {
|
func (ic *ContainerEngine) ContainerExec(ctx context.Context, nameOrID string, options entities.ExecOptions, streams define.AttachStreams) (int, error) {
|
||||||
ec, err := checkExecPreserveFDs(options)
|
ec := define.ExecErrorCodeGeneric
|
||||||
|
err := checkExecPreserveFDs(options)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ec, err
|
return ec, err
|
||||||
}
|
}
|
||||||
@ -609,7 +602,7 @@ func (ic *ContainerEngine) ContainerExec(ctx context.Context, nameOrID string, o
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ic *ContainerEngine) ContainerExecDetached(ctx context.Context, nameOrID string, options entities.ExecOptions) (string, error) {
|
func (ic *ContainerEngine) ContainerExecDetached(ctx context.Context, nameOrID string, options entities.ExecOptions) (string, error) {
|
||||||
_, err := checkExecPreserveFDs(options)
|
err := checkExecPreserveFDs(options)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
@ -648,7 +641,7 @@ func (ic *ContainerEngine) ContainerExecDetached(ctx context.Context, nameOrID s
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ic *ContainerEngine) ContainerStart(ctx context.Context, namesOrIds []string, options entities.ContainerStartOptions) ([]*entities.ContainerStartReport, error) {
|
func (ic *ContainerEngine) ContainerStart(ctx context.Context, namesOrIds []string, options entities.ContainerStartOptions) ([]*entities.ContainerStartReport, error) {
|
||||||
var reports []*entities.ContainerStartReport
|
reports := []*entities.ContainerStartReport{}
|
||||||
var exitCode = define.ExecErrorCodeGeneric
|
var exitCode = define.ExecErrorCodeGeneric
|
||||||
ctrs, rawInputs, err := getContainersAndInputByContext(false, options.Latest, namesOrIds, ic.Libpod)
|
ctrs, rawInputs, err := getContainersAndInputByContext(false, options.Latest, namesOrIds, ic.Libpod)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -907,7 +900,7 @@ func (ic *ContainerEngine) ContainerLogs(ctx context.Context, containers []strin
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ic *ContainerEngine) ContainerCleanup(ctx context.Context, namesOrIds []string, options entities.ContainerCleanupOptions) ([]*entities.ContainerCleanupReport, error) {
|
func (ic *ContainerEngine) ContainerCleanup(ctx context.Context, namesOrIds []string, options entities.ContainerCleanupOptions) ([]*entities.ContainerCleanupReport, error) {
|
||||||
var reports []*entities.ContainerCleanupReport
|
reports := []*entities.ContainerCleanupReport{}
|
||||||
ctrs, err := getContainersByContext(options.All, options.Latest, namesOrIds, ic.Libpod)
|
ctrs, err := getContainersByContext(options.All, options.Latest, namesOrIds, ic.Libpod)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -958,11 +951,11 @@ func (ic *ContainerEngine) ContainerCleanup(ctx context.Context, namesOrIds []st
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ic *ContainerEngine) ContainerInit(ctx context.Context, namesOrIds []string, options entities.ContainerInitOptions) ([]*entities.ContainerInitReport, error) {
|
func (ic *ContainerEngine) ContainerInit(ctx context.Context, namesOrIds []string, options entities.ContainerInitOptions) ([]*entities.ContainerInitReport, error) {
|
||||||
var reports []*entities.ContainerInitReport
|
|
||||||
ctrs, err := getContainersByContext(options.All, options.Latest, namesOrIds, ic.Libpod)
|
ctrs, err := getContainersByContext(options.All, options.Latest, namesOrIds, ic.Libpod)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
reports := make([]*entities.ContainerInitReport, 0, len(ctrs))
|
||||||
for _, ctr := range ctrs {
|
for _, ctr := range ctrs {
|
||||||
report := entities.ContainerInitReport{Id: ctr.ID()}
|
report := entities.ContainerInitReport{Id: ctr.ID()}
|
||||||
err := ctr.Init(ctx)
|
err := ctr.Init(ctx)
|
||||||
@ -993,11 +986,11 @@ func (ic *ContainerEngine) ContainerMount(ctx context.Context, nameOrIDs []strin
|
|||||||
os.Exit(ret)
|
os.Exit(ret)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var reports []*entities.ContainerMountReport
|
|
||||||
ctrs, err := getContainersByContext(options.All, options.Latest, nameOrIDs, ic.Libpod)
|
ctrs, err := getContainersByContext(options.All, options.Latest, nameOrIDs, ic.Libpod)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
reports := make([]*entities.ContainerMountReport, 0, len(ctrs))
|
||||||
for _, ctr := range ctrs {
|
for _, ctr := range ctrs {
|
||||||
report := entities.ContainerMountReport{Id: ctr.ID()}
|
report := entities.ContainerMountReport{Id: ctr.ID()}
|
||||||
report.Path, report.Err = ctr.Mount()
|
report.Path, report.Err = ctr.Mount()
|
||||||
@ -1030,11 +1023,11 @@ func (ic *ContainerEngine) ContainerMount(ctx context.Context, nameOrIDs []strin
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ic *ContainerEngine) ContainerUnmount(ctx context.Context, nameOrIDs []string, options entities.ContainerUnmountOptions) ([]*entities.ContainerUnmountReport, error) {
|
func (ic *ContainerEngine) ContainerUnmount(ctx context.Context, nameOrIDs []string, options entities.ContainerUnmountOptions) ([]*entities.ContainerUnmountReport, error) {
|
||||||
var reports []*entities.ContainerUnmountReport
|
|
||||||
ctrs, err := getContainersByContext(options.All, options.Latest, nameOrIDs, ic.Libpod)
|
ctrs, err := getContainersByContext(options.All, options.Latest, nameOrIDs, ic.Libpod)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
reports := []*entities.ContainerUnmountReport{}
|
||||||
for _, ctr := range ctrs {
|
for _, ctr := range ctrs {
|
||||||
state, err := ctr.State()
|
state, err := ctr.State()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -1065,11 +1058,11 @@ func (ic *ContainerEngine) Config(_ context.Context) (*config.Config, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ic *ContainerEngine) ContainerPort(ctx context.Context, nameOrID string, options entities.ContainerPortOptions) ([]*entities.ContainerPortReport, error) {
|
func (ic *ContainerEngine) ContainerPort(ctx context.Context, nameOrID string, options entities.ContainerPortOptions) ([]*entities.ContainerPortReport, error) {
|
||||||
var reports []*entities.ContainerPortReport
|
|
||||||
ctrs, err := getContainersByContext(options.All, options.Latest, []string{nameOrID}, ic.Libpod)
|
ctrs, err := getContainersByContext(options.All, options.Latest, []string{nameOrID}, ic.Libpod)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
reports := []*entities.ContainerPortReport{}
|
||||||
for _, con := range ctrs {
|
for _, con := range ctrs {
|
||||||
state, err := con.State()
|
state, err := con.State()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -116,7 +116,7 @@ func generateRunlabelCommand(runlabel string, img *image.Image, args []string, o
|
|||||||
err error
|
err error
|
||||||
name, imageName string
|
name, imageName string
|
||||||
globalOpts string
|
globalOpts string
|
||||||
cmd, env []string
|
cmd []string
|
||||||
)
|
)
|
||||||
|
|
||||||
// TODO: How do we get global opts as done in v1?
|
// TODO: How do we get global opts as done in v1?
|
||||||
@ -149,7 +149,7 @@ func generateRunlabelCommand(runlabel string, img *image.Image, args []string, o
|
|||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
env = generateRunEnvironment(name, imageName, options)
|
env := generateRunEnvironment(options)
|
||||||
env = append(env, "PODMAN_RUNLABEL_NESTED=1")
|
env = append(env, "PODMAN_RUNLABEL_NESTED=1")
|
||||||
envmap, err := envLib.ParseSlice(env)
|
envmap, err := envLib.ParseSlice(env)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -185,9 +185,6 @@ func generateRunlabelCommand(runlabel string, img *image.Image, args []string, o
|
|||||||
|
|
||||||
// generateCommand takes a label (string) and converts it to an executable command
|
// generateCommand takes a label (string) and converts it to an executable command
|
||||||
func generateCommand(command, imageName, name, globalOpts string) ([]string, error) {
|
func generateCommand(command, imageName, name, globalOpts string) ([]string, error) {
|
||||||
var (
|
|
||||||
newCommand []string
|
|
||||||
)
|
|
||||||
if name == "" {
|
if name == "" {
|
||||||
name = imageName
|
name = imageName
|
||||||
}
|
}
|
||||||
@ -201,8 +198,7 @@ func generateCommand(command, imageName, name, globalOpts string) ([]string, err
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
newCommand = append(newCommand, prog)
|
newCommand := []string{prog}
|
||||||
|
|
||||||
for _, arg := range cmd[1:] {
|
for _, arg := range cmd[1:] {
|
||||||
var newArg string
|
var newArg string
|
||||||
switch arg {
|
switch arg {
|
||||||
@ -234,7 +230,7 @@ func generateCommand(command, imageName, name, globalOpts string) ([]string, err
|
|||||||
|
|
||||||
// GenerateRunEnvironment merges the current environment variables with optional
|
// GenerateRunEnvironment merges the current environment variables with optional
|
||||||
// environment variables provided by the user
|
// environment variables provided by the user
|
||||||
func generateRunEnvironment(name, imageName string, options entities.ContainerRunlabelOptions) []string {
|
func generateRunEnvironment(options entities.ContainerRunlabelOptions) []string {
|
||||||
newEnv := os.Environ()
|
newEnv := os.Environ()
|
||||||
if options.Optional1 != "" {
|
if options.Optional1 != "" {
|
||||||
newEnv = append(newEnv, fmt.Sprintf("OPT1=%s", options.Optional1))
|
newEnv = append(newEnv, fmt.Sprintf("OPT1=%s", options.Optional1))
|
||||||
|
@ -92,7 +92,7 @@ func (ic *ContainerEngine) ContainerCp(ctx context.Context, source, dest string,
|
|||||||
|
|
||||||
if isFromHostToCtr {
|
if isFromHostToCtr {
|
||||||
if isVol, volDestName, volName := isVolumeDestName(destPath, ctr); isVol { //nolint(gocritic)
|
if isVol, volDestName, volName := isVolumeDestName(destPath, ctr); isVol { //nolint(gocritic)
|
||||||
path, err := pathWithVolumeMount(ctr, ic.Libpod, volDestName, volName, destPath)
|
path, err := pathWithVolumeMount(ic.Libpod, volDestName, volName, destPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrapf(err, "error getting destination path from volume %s", volDestName)
|
return nil, errors.Wrapf(err, "error getting destination path from volume %s", volDestName)
|
||||||
}
|
}
|
||||||
@ -126,7 +126,7 @@ func (ic *ContainerEngine) ContainerCp(ctx context.Context, source, dest string,
|
|||||||
} else {
|
} else {
|
||||||
destOwner = idtools.IDPair{UID: os.Getuid(), GID: os.Getgid()}
|
destOwner = idtools.IDPair{UID: os.Getuid(), GID: os.Getgid()}
|
||||||
if isVol, volDestName, volName := isVolumeDestName(srcPath, ctr); isVol { //nolint(gocritic)
|
if isVol, volDestName, volName := isVolumeDestName(srcPath, ctr); isVol { //nolint(gocritic)
|
||||||
path, err := pathWithVolumeMount(ctr, ic.Libpod, volDestName, volName, srcPath)
|
path, err := pathWithVolumeMount(ic.Libpod, volDestName, volName, srcPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrapf(err, "error getting source path from volume %s", volDestName)
|
return nil, errors.Wrapf(err, "error getting source path from volume %s", volDestName)
|
||||||
}
|
}
|
||||||
@ -384,7 +384,7 @@ func isVolumeDestName(path string, ctr *libpod.Container) (bool, string, string)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// if SRCPATH or DESTPATH is from volume mount's destination -v or --mount type=volume, generates the path with volume mount point
|
// if SRCPATH or DESTPATH is from volume mount's destination -v or --mount type=volume, generates the path with volume mount point
|
||||||
func pathWithVolumeMount(ctr *libpod.Container, runtime *libpod.Runtime, volDestName, volName, path string) (string, error) {
|
func pathWithVolumeMount(runtime *libpod.Runtime, volDestName, volName, path string) (string, error) {
|
||||||
destVolume, err := runtime.GetVolume(volName)
|
destVolume, err := runtime.GetVolume(volName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", errors.Wrapf(err, "error getting volume destination %s", volName)
|
return "", errors.Wrapf(err, "error getting volume destination %s", volName)
|
||||||
|
@ -167,7 +167,7 @@ func (ir *ImageEngine) Pull(ctx context.Context, rawImage string, options entiti
|
|||||||
return nil, errors.Wrapf(err, "error getting repository tags")
|
return nil, errors.Wrapf(err, "error getting repository tags")
|
||||||
}
|
}
|
||||||
|
|
||||||
var foundIDs []string
|
foundIDs := []string{}
|
||||||
for _, tag := range tags {
|
for _, tag := range tags {
|
||||||
name := rawImage + ":" + tag
|
name := rawImage + ":" + tag
|
||||||
newImage, err := ir.Libpod.ImageRuntime().New(ctx, name, options.SignaturePolicy, options.Authfile, writer, &dockerRegistryOptions, image.SigningOptions{}, nil, util.PullImageAlways)
|
newImage, err := ir.Libpod.ImageRuntime().New(ctx, name, options.SignaturePolicy, options.Authfile, writer, &dockerRegistryOptions, image.SigningOptions{}, nil, util.PullImageAlways)
|
||||||
@ -443,7 +443,7 @@ func removeErrorsToExitCode(rmErrors []error) int {
|
|||||||
// container.
|
// container.
|
||||||
inUseErrors bool
|
inUseErrors bool
|
||||||
// otherErrors indicates that at least one error other than the two
|
// otherErrors indicates that at least one error other than the two
|
||||||
// above occured.
|
// above occurred.
|
||||||
otherErrors bool
|
otherErrors bool
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -549,8 +549,7 @@ func (ir *ImageEngine) Remove(ctx context.Context, images []string, opts entitie
|
|||||||
rmErrors = append(rmErrors, err)
|
rmErrors = append(rmErrors, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return //nolint
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Shutdown Libpod engine
|
// Shutdown Libpod engine
|
||||||
|
@ -8,17 +8,12 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func (ir *ImageEngine) List(ctx context.Context, opts entities.ImageListOptions) ([]*entities.ImageSummary, error) {
|
func (ir *ImageEngine) List(ctx context.Context, opts entities.ImageListOptions) ([]*entities.ImageSummary, error) {
|
||||||
var (
|
images, err := ir.Libpod.ImageRuntime().GetImagesWithFilters(opts.Filter)
|
||||||
images []*libpodImage.Image
|
|
||||||
err error
|
|
||||||
)
|
|
||||||
|
|
||||||
images, err = ir.Libpod.ImageRuntime().GetImagesWithFilters(opts.Filter)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
var summaries []*entities.ImageSummary
|
summaries := []*entities.ImageSummary{}
|
||||||
for _, img := range images {
|
for _, img := range images {
|
||||||
var repoTags []string
|
var repoTags []string
|
||||||
if opts.All {
|
if opts.All {
|
||||||
|
@ -153,7 +153,7 @@ func (ir *ImageEngine) ManifestRemove(ctx context.Context, names []string) (stri
|
|||||||
}
|
}
|
||||||
listImage, err := ir.Libpod.ImageRuntime().NewFromLocal(names[0])
|
listImage, err := ir.Libpod.ImageRuntime().NewFromLocal(names[0])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", errors.Wrapf(err, "error retriving local image from image name %s", names[0])
|
return "", errors.Wrapf(err, "error retrieving local image from image name %s", names[0])
|
||||||
}
|
}
|
||||||
updatedListID, err := listImage.RemoveManifest(instanceDigest)
|
updatedListID, err := listImage.RemoveManifest(instanceDigest)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
@ -166,7 +166,7 @@ func (ir *ImageEngine) ManifestRemove(ctx context.Context, names []string) (stri
|
|||||||
func (ir *ImageEngine) ManifestPush(ctx context.Context, names []string, opts entities.ManifestPushOptions) error {
|
func (ir *ImageEngine) ManifestPush(ctx context.Context, names []string, opts entities.ManifestPushOptions) error {
|
||||||
listImage, err := ir.Libpod.ImageRuntime().NewFromLocal(names[0])
|
listImage, err := ir.Libpod.ImageRuntime().NewFromLocal(names[0])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrapf(err, "error retriving local image from image name %s", names[0])
|
return errors.Wrapf(err, "error retrieving local image from image name %s", names[0])
|
||||||
}
|
}
|
||||||
dest, err := alltransports.ParseImageName(names[1])
|
dest, err := alltransports.ParseImageName(names[1])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -48,15 +48,12 @@ func (ic *ContainerEngine) NetworkList(ctx context.Context, options entities.Net
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ic *ContainerEngine) NetworkInspect(ctx context.Context, namesOrIds []string, options entities.NetworkInspectOptions) ([]entities.NetworkInspectReport, error) {
|
func (ic *ContainerEngine) NetworkInspect(ctx context.Context, namesOrIds []string, options entities.NetworkInspectOptions) ([]entities.NetworkInspectReport, error) {
|
||||||
var (
|
|
||||||
rawCNINetworks []entities.NetworkInspectReport
|
|
||||||
)
|
|
||||||
|
|
||||||
config, err := ic.Libpod.GetConfig()
|
config, err := ic.Libpod.GetConfig()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rawCNINetworks := make([]entities.NetworkInspectReport, 0, len(namesOrIds))
|
||||||
for _, name := range namesOrIds {
|
for _, name := range namesOrIds {
|
||||||
rawList, err := network.InspectNetwork(config, name)
|
rawList, err := network.InspectNetwork(config, name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -68,7 +65,7 @@ func (ic *ContainerEngine) NetworkInspect(ctx context.Context, namesOrIds []stri
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ic *ContainerEngine) NetworkRm(ctx context.Context, namesOrIds []string, options entities.NetworkRmOptions) ([]*entities.NetworkRmReport, error) {
|
func (ic *ContainerEngine) NetworkRm(ctx context.Context, namesOrIds []string, options entities.NetworkRmOptions) ([]*entities.NetworkRmReport, error) {
|
||||||
var reports []*entities.NetworkRmReport
|
reports := []*entities.NetworkRmReport{}
|
||||||
|
|
||||||
config, err := ic.Libpod.GetConfig()
|
config, err := ic.Libpod.GetConfig()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -109,9 +109,7 @@ func (ic *ContainerEngine) playKubeDeployment(ctx context.Context, deploymentYAM
|
|||||||
|
|
||||||
func (ic *ContainerEngine) playKubePod(ctx context.Context, podName string, podYAML *v1.PodTemplateSpec, options entities.PlayKubeOptions) (*entities.PlayKubeReport, error) {
|
func (ic *ContainerEngine) playKubePod(ctx context.Context, podName string, podYAML *v1.PodTemplateSpec, options entities.PlayKubeOptions) (*entities.PlayKubeReport, error) {
|
||||||
var (
|
var (
|
||||||
containers []*libpod.Container
|
|
||||||
pod *libpod.Pod
|
pod *libpod.Pod
|
||||||
podOptions []libpod.PodCreateOption
|
|
||||||
registryCreds *types.DockerAuthConfig
|
registryCreds *types.DockerAuthConfig
|
||||||
writer io.Writer
|
writer io.Writer
|
||||||
playKubePod entities.PlayKubePod
|
playKubePod entities.PlayKubePod
|
||||||
@ -130,8 +128,10 @@ func (ic *ContainerEngine) playKubePod(ctx context.Context, podName string, podY
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
podOptions = append(podOptions, libpod.WithInfraContainer())
|
podOptions := []libpod.PodCreateOption{
|
||||||
podOptions = append(podOptions, libpod.WithPodName(podName))
|
libpod.WithInfraContainer(),
|
||||||
|
libpod.WithPodName(podName),
|
||||||
|
}
|
||||||
// TODO for now we just used the default kernel namespaces; we need to add/subtract this from yaml
|
// TODO for now we just used the default kernel namespaces; we need to add/subtract this from yaml
|
||||||
|
|
||||||
hostname := podYAML.Spec.Hostname
|
hostname := podYAML.Spec.Hostname
|
||||||
@ -271,6 +271,7 @@ func (ic *ContainerEngine) playKubePod(ctx context.Context, podName string, podY
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
containers := make([]*libpod.Container, 0, len(podYAML.Spec.Containers))
|
||||||
for _, container := range podYAML.Spec.Containers {
|
for _, container := range podYAML.Spec.Containers {
|
||||||
pullPolicy := util.PullImageMissing
|
pullPolicy := util.PullImageMissing
|
||||||
if len(container.ImagePullPolicy) > 0 {
|
if len(container.ImagePullPolicy) > 0 {
|
||||||
@ -293,7 +294,7 @@ func (ic *ContainerEngine) playKubePod(ctx context.Context, podName string, podY
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
conf, err := kubeContainerToCreateConfig(ctx, container, ic.Libpod, newImage, namespaces, volumes, pod.ID(), podName, podInfraID, seccompPaths)
|
conf, err := kubeContainerToCreateConfig(ctx, container, newImage, namespaces, volumes, pod.ID(), podName, podInfraID, seccompPaths)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -407,7 +408,7 @@ func setupSecurityContext(securityConfig *createconfig.SecurityConfig, userConfi
|
|||||||
}
|
}
|
||||||
|
|
||||||
// kubeContainerToCreateConfig takes a v1.Container and returns a createconfig describing a container
|
// kubeContainerToCreateConfig takes a v1.Container and returns a createconfig describing a container
|
||||||
func kubeContainerToCreateConfig(ctx context.Context, containerYAML v1.Container, runtime *libpod.Runtime, newImage *image.Image, namespaces map[string]string, volumes map[string]string, podID, podName, infraID string, seccompPaths *kubeSeccompPaths) (*createconfig.CreateConfig, error) {
|
func kubeContainerToCreateConfig(ctx context.Context, containerYAML v1.Container, newImage *image.Image, namespaces map[string]string, volumes map[string]string, podID, podName, infraID string, seccompPaths *kubeSeccompPaths) (*createconfig.CreateConfig, error) {
|
||||||
var (
|
var (
|
||||||
containerConfig createconfig.CreateConfig
|
containerConfig createconfig.CreateConfig
|
||||||
pidConfig createconfig.PidConfig
|
pidConfig createconfig.PidConfig
|
||||||
|
@ -54,9 +54,7 @@ func (ic *ContainerEngine) PodExists(ctx context.Context, nameOrID string) (*ent
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ic *ContainerEngine) PodKill(ctx context.Context, namesOrIds []string, options entities.PodKillOptions) ([]*entities.PodKillReport, error) {
|
func (ic *ContainerEngine) PodKill(ctx context.Context, namesOrIds []string, options entities.PodKillOptions) ([]*entities.PodKillReport, error) {
|
||||||
var (
|
reports := []*entities.PodKillReport{}
|
||||||
reports []*entities.PodKillReport
|
|
||||||
)
|
|
||||||
sig, err := signal.ParseSignalNameOrNumber(options.Signal)
|
sig, err := signal.ParseSignalNameOrNumber(options.Signal)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -87,9 +85,7 @@ func (ic *ContainerEngine) PodKill(ctx context.Context, namesOrIds []string, opt
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ic *ContainerEngine) PodPause(ctx context.Context, namesOrIds []string, options entities.PodPauseOptions) ([]*entities.PodPauseReport, error) {
|
func (ic *ContainerEngine) PodPause(ctx context.Context, namesOrIds []string, options entities.PodPauseOptions) ([]*entities.PodPauseReport, error) {
|
||||||
var (
|
reports := []*entities.PodPauseReport{}
|
||||||
reports []*entities.PodPauseReport
|
|
||||||
)
|
|
||||||
pods, err := getPodsByContext(options.All, options.Latest, namesOrIds, ic.Libpod)
|
pods, err := getPodsByContext(options.All, options.Latest, namesOrIds, ic.Libpod)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -114,9 +110,7 @@ func (ic *ContainerEngine) PodPause(ctx context.Context, namesOrIds []string, op
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ic *ContainerEngine) PodUnpause(ctx context.Context, namesOrIds []string, options entities.PodunpauseOptions) ([]*entities.PodUnpauseReport, error) {
|
func (ic *ContainerEngine) PodUnpause(ctx context.Context, namesOrIds []string, options entities.PodunpauseOptions) ([]*entities.PodUnpauseReport, error) {
|
||||||
var (
|
reports := []*entities.PodUnpauseReport{}
|
||||||
reports []*entities.PodUnpauseReport
|
|
||||||
)
|
|
||||||
pods, err := getPodsByContext(options.All, options.Latest, namesOrIds, ic.Libpod)
|
pods, err := getPodsByContext(options.All, options.Latest, namesOrIds, ic.Libpod)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -141,10 +135,7 @@ func (ic *ContainerEngine) PodUnpause(ctx context.Context, namesOrIds []string,
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ic *ContainerEngine) PodStop(ctx context.Context, namesOrIds []string, options entities.PodStopOptions) ([]*entities.PodStopReport, error) {
|
func (ic *ContainerEngine) PodStop(ctx context.Context, namesOrIds []string, options entities.PodStopOptions) ([]*entities.PodStopReport, error) {
|
||||||
var (
|
reports := []*entities.PodStopReport{}
|
||||||
reports []*entities.PodStopReport
|
|
||||||
)
|
|
||||||
|
|
||||||
pods, err := getPodsByContext(options.All, options.Latest, namesOrIds, ic.Libpod)
|
pods, err := getPodsByContext(options.All, options.Latest, namesOrIds, ic.Libpod)
|
||||||
if err != nil && !(options.Ignore && errors.Cause(err) == define.ErrNoSuchPod) {
|
if err != nil && !(options.Ignore && errors.Cause(err) == define.ErrNoSuchPod) {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -169,9 +160,7 @@ func (ic *ContainerEngine) PodStop(ctx context.Context, namesOrIds []string, opt
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ic *ContainerEngine) PodRestart(ctx context.Context, namesOrIds []string, options entities.PodRestartOptions) ([]*entities.PodRestartReport, error) {
|
func (ic *ContainerEngine) PodRestart(ctx context.Context, namesOrIds []string, options entities.PodRestartOptions) ([]*entities.PodRestartReport, error) {
|
||||||
var (
|
reports := []*entities.PodRestartReport{}
|
||||||
reports []*entities.PodRestartReport
|
|
||||||
)
|
|
||||||
pods, err := getPodsByContext(options.All, options.Latest, namesOrIds, ic.Libpod)
|
pods, err := getPodsByContext(options.All, options.Latest, namesOrIds, ic.Libpod)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -197,10 +186,7 @@ func (ic *ContainerEngine) PodRestart(ctx context.Context, namesOrIds []string,
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ic *ContainerEngine) PodStart(ctx context.Context, namesOrIds []string, options entities.PodStartOptions) ([]*entities.PodStartReport, error) {
|
func (ic *ContainerEngine) PodStart(ctx context.Context, namesOrIds []string, options entities.PodStartOptions) ([]*entities.PodStartReport, error) {
|
||||||
var (
|
reports := []*entities.PodStartReport{}
|
||||||
reports []*entities.PodStartReport
|
|
||||||
)
|
|
||||||
|
|
||||||
pods, err := getPodsByContext(options.All, options.Latest, namesOrIds, ic.Libpod)
|
pods, err := getPodsByContext(options.All, options.Latest, namesOrIds, ic.Libpod)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -227,14 +213,11 @@ func (ic *ContainerEngine) PodStart(ctx context.Context, namesOrIds []string, op
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ic *ContainerEngine) PodRm(ctx context.Context, namesOrIds []string, options entities.PodRmOptions) ([]*entities.PodRmReport, error) {
|
func (ic *ContainerEngine) PodRm(ctx context.Context, namesOrIds []string, options entities.PodRmOptions) ([]*entities.PodRmReport, error) {
|
||||||
var (
|
|
||||||
reports []*entities.PodRmReport
|
|
||||||
)
|
|
||||||
|
|
||||||
pods, err := getPodsByContext(options.All, options.Latest, namesOrIds, ic.Libpod)
|
pods, err := getPodsByContext(options.All, options.Latest, namesOrIds, ic.Libpod)
|
||||||
if err != nil && !(options.Ignore && errors.Cause(err) == define.ErrNoSuchPod) {
|
if err != nil && !(options.Ignore && errors.Cause(err) == define.ErrNoSuchPod) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
reports := make([]*entities.PodRmReport, 0, len(pods))
|
||||||
for _, p := range pods {
|
for _, p := range pods {
|
||||||
report := entities.PodRmReport{Id: p.ID()}
|
report := entities.PodRmReport{Id: p.ID()}
|
||||||
err := ic.Libpod.RemovePod(ctx, p, true, options.Force)
|
err := ic.Libpod.RemovePod(ctx, p, true, options.Force)
|
||||||
@ -251,13 +234,11 @@ func (ic *ContainerEngine) PodPrune(ctx context.Context, options entities.PodPru
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ic *ContainerEngine) prunePodHelper(ctx context.Context) ([]*entities.PodPruneReport, error) {
|
func (ic *ContainerEngine) prunePodHelper(ctx context.Context) ([]*entities.PodPruneReport, error) {
|
||||||
var (
|
|
||||||
reports []*entities.PodPruneReport
|
|
||||||
)
|
|
||||||
response, err := ic.Libpod.PrunePods(ctx)
|
response, err := ic.Libpod.PrunePods(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
reports := make([]*entities.PodPruneReport, 0, len(response))
|
||||||
for k, v := range response {
|
for k, v := range response {
|
||||||
reports = append(reports, &entities.PodPruneReport{
|
reports = append(reports, &entities.PodPruneReport{
|
||||||
Err: v,
|
Err: v,
|
||||||
@ -302,9 +283,8 @@ func (ic *ContainerEngine) PodTop(ctx context.Context, options entities.PodTopOp
|
|||||||
func (ic *ContainerEngine) PodPs(ctx context.Context, options entities.PodPSOptions) ([]*entities.ListPodsReport, error) {
|
func (ic *ContainerEngine) PodPs(ctx context.Context, options entities.PodPSOptions) ([]*entities.ListPodsReport, error) {
|
||||||
var (
|
var (
|
||||||
err error
|
err error
|
||||||
filters []libpod.PodFilter
|
filters = []libpod.PodFilter{}
|
||||||
pds []*libpod.Pod
|
pds = []*libpod.Pod{}
|
||||||
reports []*entities.ListPodsReport
|
|
||||||
)
|
)
|
||||||
|
|
||||||
for k, v := range options.Filters {
|
for k, v := range options.Filters {
|
||||||
@ -330,6 +310,7 @@ func (ic *ContainerEngine) PodPs(ctx context.Context, options entities.PodPSOpti
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
reports := make([]*entities.ListPodsReport, 0, len(pds))
|
||||||
for _, p := range pds {
|
for _, p := range pds {
|
||||||
var lpcs []*entities.ListPodContainer
|
var lpcs []*entities.ListPodContainer
|
||||||
status, err := p.GetPodStatus()
|
status, err := p.GetPodStatus()
|
||||||
|
@ -172,7 +172,7 @@ func checkInput() error { // nolint:deadcode,unused
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// SystemPrune removes unsed data from the system. Pruning pods, containers, volumes and images.
|
// SystemPrune removes unused data from the system. Pruning pods, containers, volumes and images.
|
||||||
func (ic *ContainerEngine) SystemPrune(ctx context.Context, options entities.SystemPruneOptions) (*entities.SystemPruneReport, error) {
|
func (ic *ContainerEngine) SystemPrune(ctx context.Context, options entities.SystemPruneOptions) (*entities.SystemPruneReport, error) {
|
||||||
var systemPruneReport = new(entities.SystemPruneReport)
|
var systemPruneReport = new(entities.SystemPruneReport)
|
||||||
podPruneReport, err := ic.prunePodHelper(ctx)
|
podPruneReport, err := ic.prunePodHelper(ctx)
|
||||||
@ -181,7 +181,7 @@ func (ic *ContainerEngine) SystemPrune(ctx context.Context, options entities.Sys
|
|||||||
}
|
}
|
||||||
systemPruneReport.PodPruneReport = podPruneReport
|
systemPruneReport.PodPruneReport = podPruneReport
|
||||||
|
|
||||||
containerPruneReport, err := ic.pruneContainersHelper(ctx, nil)
|
containerPruneReport, err := ic.pruneContainersHelper(nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -212,10 +212,7 @@ func (ic *ContainerEngine) SystemPrune(ctx context.Context, options entities.Sys
|
|||||||
|
|
||||||
func (ic *ContainerEngine) SystemDf(ctx context.Context, options entities.SystemDfOptions) (*entities.SystemDfReport, error) {
|
func (ic *ContainerEngine) SystemDf(ctx context.Context, options entities.SystemDfOptions) (*entities.SystemDfReport, error) {
|
||||||
var (
|
var (
|
||||||
dfImages []*entities.SystemDfImageReport
|
dfImages = []*entities.SystemDfImageReport{}
|
||||||
dfContainers []*entities.SystemDfContainerReport
|
|
||||||
dfVolumes []*entities.SystemDfVolumeReport
|
|
||||||
runningContainers []string
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Get Images and iterate them
|
// Get Images and iterate them
|
||||||
@ -282,6 +279,7 @@ func (ic *ContainerEngine) SystemDf(ctx context.Context, options entities.System
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
dfContainers := make([]*entities.SystemDfContainerReport, 0, len(cons))
|
||||||
for _, c := range cons {
|
for _, c := range cons {
|
||||||
iid, _ := c.Image()
|
iid, _ := c.Image()
|
||||||
conSize, err := c.RootFsSize()
|
conSize, err := c.RootFsSize()
|
||||||
@ -320,10 +318,12 @@ func (ic *ContainerEngine) SystemDf(ctx context.Context, options entities.System
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
runningContainers := make([]string, 0, len(running))
|
||||||
for _, c := range running {
|
for _, c := range running {
|
||||||
runningContainers = append(runningContainers, c.ID())
|
runningContainers = append(runningContainers, c.ID())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dfVolumes := make([]*entities.SystemDfVolumeReport, 0, len(vols))
|
||||||
for _, v := range vols {
|
for _, v := range vols {
|
||||||
var consInUse int
|
var consInUse int
|
||||||
volSize, err := sizeOfPath(v.MountPoint())
|
volSize, err := sizeOfPath(v.MountPoint())
|
||||||
|
@ -40,9 +40,10 @@ func (ic *ContainerEngine) VolumeCreate(ctx context.Context, opts entities.Volum
|
|||||||
func (ic *ContainerEngine) VolumeRm(ctx context.Context, namesOrIds []string, opts entities.VolumeRmOptions) ([]*entities.VolumeRmReport, error) {
|
func (ic *ContainerEngine) VolumeRm(ctx context.Context, namesOrIds []string, opts entities.VolumeRmOptions) ([]*entities.VolumeRmReport, error) {
|
||||||
var (
|
var (
|
||||||
err error
|
err error
|
||||||
reports []*entities.VolumeRmReport
|
|
||||||
vols []*libpod.Volume
|
vols []*libpod.Volume
|
||||||
|
reports = []*entities.VolumeRmReport{}
|
||||||
)
|
)
|
||||||
|
|
||||||
if opts.All {
|
if opts.All {
|
||||||
vols, err = ic.Libpod.Volumes()
|
vols, err = ic.Libpod.Volumes()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -72,9 +73,8 @@ func (ic *ContainerEngine) VolumeRm(ctx context.Context, namesOrIds []string, op
|
|||||||
|
|
||||||
func (ic *ContainerEngine) VolumeInspect(ctx context.Context, namesOrIds []string, opts entities.VolumeInspectOptions) ([]*entities.VolumeInspectReport, error) {
|
func (ic *ContainerEngine) VolumeInspect(ctx context.Context, namesOrIds []string, opts entities.VolumeInspectOptions) ([]*entities.VolumeInspectReport, error) {
|
||||||
var (
|
var (
|
||||||
err error
|
err error
|
||||||
reports []*entities.VolumeInspectReport
|
vols []*libpod.Volume
|
||||||
vols []*libpod.Volume
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Note: as with previous implementation, a single failure here
|
// Note: as with previous implementation, a single failure here
|
||||||
@ -93,6 +93,7 @@ func (ic *ContainerEngine) VolumeInspect(ctx context.Context, namesOrIds []strin
|
|||||||
vols = append(vols, vol)
|
vols = append(vols, vol)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
reports := make([]*entities.VolumeInspectReport, 0, len(vols))
|
||||||
for _, v := range vols {
|
for _, v := range vols {
|
||||||
config := entities.VolumeConfigResponse{
|
config := entities.VolumeConfigResponse{
|
||||||
Name: v.Name(),
|
Name: v.Name(),
|
||||||
@ -115,13 +116,11 @@ func (ic *ContainerEngine) VolumePrune(ctx context.Context, opts entities.Volume
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ic *ContainerEngine) pruneVolumesHelper(ctx context.Context) ([]*entities.VolumePruneReport, error) {
|
func (ic *ContainerEngine) pruneVolumesHelper(ctx context.Context) ([]*entities.VolumePruneReport, error) {
|
||||||
var (
|
|
||||||
reports []*entities.VolumePruneReport
|
|
||||||
)
|
|
||||||
pruned, err := ic.Libpod.PruneVolumes(ctx)
|
pruned, err := ic.Libpod.PruneVolumes(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
reports := make([]*entities.VolumePruneReport, 0, len(pruned))
|
||||||
for k, v := range pruned {
|
for k, v := range pruned {
|
||||||
reports = append(reports, &entities.VolumePruneReport{
|
reports = append(reports, &entities.VolumePruneReport{
|
||||||
Err: v,
|
Err: v,
|
||||||
@ -132,9 +131,6 @@ func (ic *ContainerEngine) pruneVolumesHelper(ctx context.Context) ([]*entities.
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ic *ContainerEngine) VolumeList(ctx context.Context, opts entities.VolumeListOptions) ([]*entities.VolumeListReport, error) {
|
func (ic *ContainerEngine) VolumeList(ctx context.Context, opts entities.VolumeListOptions) ([]*entities.VolumeListReport, error) {
|
||||||
var (
|
|
||||||
reports []*entities.VolumeListReport
|
|
||||||
)
|
|
||||||
volumeFilters, err := filters.GenerateVolumeFilters(opts.Filter)
|
volumeFilters, err := filters.GenerateVolumeFilters(opts.Filter)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -143,6 +139,7 @@ func (ic *ContainerEngine) VolumeList(ctx context.Context, opts entities.VolumeL
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
reports := make([]*entities.VolumeListReport, 0, len(vols))
|
||||||
for _, v := range vols {
|
for _, v := range vols {
|
||||||
config := entities.VolumeConfigResponse{
|
config := entities.VolumeConfigResponse{
|
||||||
Name: v.Name(),
|
Name: v.Name(),
|
||||||
|
@ -32,13 +32,11 @@ func (ic *ContainerEngine) ContainerExists(ctx context.Context, nameOrID string)
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ic *ContainerEngine) ContainerWait(ctx context.Context, namesOrIds []string, options entities.WaitOptions) ([]entities.WaitReport, error) {
|
func (ic *ContainerEngine) ContainerWait(ctx context.Context, namesOrIds []string, options entities.WaitOptions) ([]entities.WaitReport, error) {
|
||||||
var (
|
|
||||||
responses []entities.WaitReport
|
|
||||||
)
|
|
||||||
cons, err := getContainersByContext(ic.ClientCxt, false, namesOrIds)
|
cons, err := getContainersByContext(ic.ClientCxt, false, namesOrIds)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
responses := make([]entities.WaitReport, 0, len(cons))
|
||||||
for _, c := range cons {
|
for _, c := range cons {
|
||||||
response := entities.WaitReport{Id: c.ID}
|
response := entities.WaitReport{Id: c.ID}
|
||||||
exitCode, err := containers.Wait(ic.ClientCxt, c.ID, &options.Condition)
|
exitCode, err := containers.Wait(ic.ClientCxt, c.ID, &options.Condition)
|
||||||
@ -53,13 +51,11 @@ func (ic *ContainerEngine) ContainerWait(ctx context.Context, namesOrIds []strin
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ic *ContainerEngine) ContainerPause(ctx context.Context, namesOrIds []string, options entities.PauseUnPauseOptions) ([]*entities.PauseUnpauseReport, error) {
|
func (ic *ContainerEngine) ContainerPause(ctx context.Context, namesOrIds []string, options entities.PauseUnPauseOptions) ([]*entities.PauseUnpauseReport, error) {
|
||||||
var (
|
|
||||||
reports []*entities.PauseUnpauseReport
|
|
||||||
)
|
|
||||||
ctrs, err := getContainersByContext(ic.ClientCxt, options.All, namesOrIds)
|
ctrs, err := getContainersByContext(ic.ClientCxt, options.All, namesOrIds)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
reports := make([]*entities.PauseUnpauseReport, 0, len(ctrs))
|
||||||
for _, c := range ctrs {
|
for _, c := range ctrs {
|
||||||
err := containers.Pause(ic.ClientCxt, c.ID)
|
err := containers.Pause(ic.ClientCxt, c.ID)
|
||||||
reports = append(reports, &entities.PauseUnpauseReport{Id: c.ID, Err: err})
|
reports = append(reports, &entities.PauseUnpauseReport{Id: c.ID, Err: err})
|
||||||
@ -68,13 +64,11 @@ func (ic *ContainerEngine) ContainerPause(ctx context.Context, namesOrIds []stri
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ic *ContainerEngine) ContainerUnpause(ctx context.Context, namesOrIds []string, options entities.PauseUnPauseOptions) ([]*entities.PauseUnpauseReport, error) {
|
func (ic *ContainerEngine) ContainerUnpause(ctx context.Context, namesOrIds []string, options entities.PauseUnPauseOptions) ([]*entities.PauseUnpauseReport, error) {
|
||||||
var (
|
|
||||||
reports []*entities.PauseUnpauseReport
|
|
||||||
)
|
|
||||||
ctrs, err := getContainersByContext(ic.ClientCxt, options.All, namesOrIds)
|
ctrs, err := getContainersByContext(ic.ClientCxt, options.All, namesOrIds)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
reports := make([]*entities.PauseUnpauseReport, 0, len(ctrs))
|
||||||
for _, c := range ctrs {
|
for _, c := range ctrs {
|
||||||
err := containers.Unpause(ic.ClientCxt, c.ID)
|
err := containers.Unpause(ic.ClientCxt, c.ID)
|
||||||
reports = append(reports, &entities.PauseUnpauseReport{Id: c.ID, Err: err})
|
reports = append(reports, &entities.PauseUnpauseReport{Id: c.ID, Err: err})
|
||||||
@ -83,9 +77,7 @@ func (ic *ContainerEngine) ContainerUnpause(ctx context.Context, namesOrIds []st
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ic *ContainerEngine) ContainerStop(ctx context.Context, namesOrIds []string, options entities.StopOptions) ([]*entities.StopReport, error) {
|
func (ic *ContainerEngine) ContainerStop(ctx context.Context, namesOrIds []string, options entities.StopOptions) ([]*entities.StopReport, error) {
|
||||||
var (
|
reports := []*entities.StopReport{}
|
||||||
reports []*entities.StopReport
|
|
||||||
)
|
|
||||||
for _, cidFile := range options.CIDFiles {
|
for _, cidFile := range options.CIDFiles {
|
||||||
content, err := ioutil.ReadFile(cidFile)
|
content, err := ioutil.ReadFile(cidFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -125,13 +117,11 @@ func (ic *ContainerEngine) ContainerStop(ctx context.Context, namesOrIds []strin
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ic *ContainerEngine) ContainerKill(ctx context.Context, namesOrIds []string, options entities.KillOptions) ([]*entities.KillReport, error) {
|
func (ic *ContainerEngine) ContainerKill(ctx context.Context, namesOrIds []string, options entities.KillOptions) ([]*entities.KillReport, error) {
|
||||||
var (
|
|
||||||
reports []*entities.KillReport
|
|
||||||
)
|
|
||||||
ctrs, err := getContainersByContext(ic.ClientCxt, options.All, namesOrIds)
|
ctrs, err := getContainersByContext(ic.ClientCxt, options.All, namesOrIds)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
reports := make([]*entities.KillReport, 0, len(ctrs))
|
||||||
for _, c := range ctrs {
|
for _, c := range ctrs {
|
||||||
reports = append(reports, &entities.KillReport{
|
reports = append(reports, &entities.KillReport{
|
||||||
Id: c.ID,
|
Id: c.ID,
|
||||||
@ -143,7 +133,7 @@ func (ic *ContainerEngine) ContainerKill(ctx context.Context, namesOrIds []strin
|
|||||||
|
|
||||||
func (ic *ContainerEngine) ContainerRestart(ctx context.Context, namesOrIds []string, options entities.RestartOptions) ([]*entities.RestartReport, error) {
|
func (ic *ContainerEngine) ContainerRestart(ctx context.Context, namesOrIds []string, options entities.RestartOptions) ([]*entities.RestartReport, error) {
|
||||||
var (
|
var (
|
||||||
reports []*entities.RestartReport
|
reports = []*entities.RestartReport{}
|
||||||
timeout *int
|
timeout *int
|
||||||
)
|
)
|
||||||
if options.Timeout != nil {
|
if options.Timeout != nil {
|
||||||
@ -168,9 +158,6 @@ func (ic *ContainerEngine) ContainerRestart(ctx context.Context, namesOrIds []st
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ic *ContainerEngine) ContainerRm(ctx context.Context, namesOrIds []string, options entities.RmOptions) ([]*entities.RmReport, error) {
|
func (ic *ContainerEngine) ContainerRm(ctx context.Context, namesOrIds []string, options entities.RmOptions) ([]*entities.RmReport, error) {
|
||||||
var (
|
|
||||||
reports []*entities.RmReport
|
|
||||||
)
|
|
||||||
for _, cidFile := range options.CIDFiles {
|
for _, cidFile := range options.CIDFiles {
|
||||||
content, err := ioutil.ReadFile(cidFile)
|
content, err := ioutil.ReadFile(cidFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -184,6 +171,7 @@ func (ic *ContainerEngine) ContainerRm(ctx context.Context, namesOrIds []string,
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
// TODO there is no endpoint for container eviction. Need to discuss
|
// TODO there is no endpoint for container eviction. Need to discuss
|
||||||
|
reports := make([]*entities.RmReport, 0, len(ctrs))
|
||||||
for _, c := range ctrs {
|
for _, c := range ctrs {
|
||||||
reports = append(reports, &entities.RmReport{
|
reports = append(reports, &entities.RmReport{
|
||||||
Id: c.ID,
|
Id: c.ID,
|
||||||
@ -198,13 +186,11 @@ func (ic *ContainerEngine) ContainerPrune(ctx context.Context, options entities.
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ic *ContainerEngine) ContainerInspect(ctx context.Context, namesOrIds []string, options entities.InspectOptions) ([]*entities.ContainerInspectReport, error) {
|
func (ic *ContainerEngine) ContainerInspect(ctx context.Context, namesOrIds []string, options entities.InspectOptions) ([]*entities.ContainerInspectReport, error) {
|
||||||
var (
|
|
||||||
reports []*entities.ContainerInspectReport
|
|
||||||
)
|
|
||||||
ctrs, err := getContainersByContext(ic.ClientCxt, false, namesOrIds)
|
ctrs, err := getContainersByContext(ic.ClientCxt, false, namesOrIds)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
reports := make([]*entities.ContainerInspectReport, 0, len(ctrs))
|
||||||
for _, con := range ctrs {
|
for _, con := range ctrs {
|
||||||
data, err := containers.Inspect(ic.ClientCxt, con.ID, &options.Size)
|
data, err := containers.Inspect(ic.ClientCxt, con.ID, &options.Size)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -282,9 +268,8 @@ func (ic *ContainerEngine) ContainerExport(ctx context.Context, nameOrID string,
|
|||||||
|
|
||||||
func (ic *ContainerEngine) ContainerCheckpoint(ctx context.Context, namesOrIds []string, options entities.CheckpointOptions) ([]*entities.CheckpointReport, error) {
|
func (ic *ContainerEngine) ContainerCheckpoint(ctx context.Context, namesOrIds []string, options entities.CheckpointOptions) ([]*entities.CheckpointReport, error) {
|
||||||
var (
|
var (
|
||||||
reports []*entities.CheckpointReport
|
err error
|
||||||
err error
|
ctrs = []entities.ListContainer{}
|
||||||
ctrs []entities.ListContainer
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if options.All {
|
if options.All {
|
||||||
@ -305,6 +290,7 @@ func (ic *ContainerEngine) ContainerCheckpoint(ctx context.Context, namesOrIds [
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
reports := make([]*entities.CheckpointReport, 0, len(ctrs))
|
||||||
for _, c := range ctrs {
|
for _, c := range ctrs {
|
||||||
report, err := containers.Checkpoint(ic.ClientCxt, c.ID, &options.Keep, &options.LeaveRunning, &options.TCPEstablished, &options.IgnoreRootFS, &options.Export)
|
report, err := containers.Checkpoint(ic.ClientCxt, c.ID, &options.Keep, &options.LeaveRunning, &options.TCPEstablished, &options.IgnoreRootFS, &options.Export)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -317,9 +303,8 @@ func (ic *ContainerEngine) ContainerCheckpoint(ctx context.Context, namesOrIds [
|
|||||||
|
|
||||||
func (ic *ContainerEngine) ContainerRestore(ctx context.Context, namesOrIds []string, options entities.RestoreOptions) ([]*entities.RestoreReport, error) {
|
func (ic *ContainerEngine) ContainerRestore(ctx context.Context, namesOrIds []string, options entities.RestoreOptions) ([]*entities.RestoreReport, error) {
|
||||||
var (
|
var (
|
||||||
reports []*entities.RestoreReport
|
err error
|
||||||
err error
|
ctrs = []entities.ListContainer{}
|
||||||
ctrs []entities.ListContainer
|
|
||||||
)
|
)
|
||||||
if options.All {
|
if options.All {
|
||||||
allCtrs, err := getContainersByContext(ic.ClientCxt, true, []string{})
|
allCtrs, err := getContainersByContext(ic.ClientCxt, true, []string{})
|
||||||
@ -339,6 +324,7 @@ func (ic *ContainerEngine) ContainerRestore(ctx context.Context, namesOrIds []st
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
reports := make([]*entities.RestoreReport, 0, len(ctrs))
|
||||||
for _, c := range ctrs {
|
for _, c := range ctrs {
|
||||||
report, err := containers.Restore(ic.ClientCxt, c.ID, &options.Keep, &options.TCPEstablished, &options.IgnoreRootFS, &options.IgnoreStaticIP, &options.IgnoreStaticMAC, &options.Name, &options.Import)
|
report, err := containers.Restore(ic.ClientCxt, c.ID, &options.Keep, &options.TCPEstablished, &options.IgnoreRootFS, &options.IgnoreStaticIP, &options.IgnoreStaticMAC, &options.Name, &options.Import)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -467,7 +453,7 @@ func startAndAttach(ic *ContainerEngine, name string, detachKeys *string, input,
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ic *ContainerEngine) ContainerStart(ctx context.Context, namesOrIds []string, options entities.ContainerStartOptions) ([]*entities.ContainerStartReport, error) {
|
func (ic *ContainerEngine) ContainerStart(ctx context.Context, namesOrIds []string, options entities.ContainerStartOptions) ([]*entities.ContainerStartReport, error) {
|
||||||
var reports []*entities.ContainerStartReport
|
reports := []*entities.ContainerStartReport{}
|
||||||
for _, name := range namesOrIds {
|
for _, name := range namesOrIds {
|
||||||
report := entities.ContainerStartReport{
|
report := entities.ContainerStartReport{
|
||||||
Id: name,
|
Id: name,
|
||||||
@ -535,11 +521,11 @@ func (ic *ContainerEngine) ContainerCleanup(ctx context.Context, namesOrIds []st
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ic *ContainerEngine) ContainerInit(ctx context.Context, namesOrIds []string, options entities.ContainerInitOptions) ([]*entities.ContainerInitReport, error) {
|
func (ic *ContainerEngine) ContainerInit(ctx context.Context, namesOrIds []string, options entities.ContainerInitOptions) ([]*entities.ContainerInitReport, error) {
|
||||||
var reports []*entities.ContainerInitReport
|
|
||||||
ctrs, err := getContainersByContext(ic.ClientCxt, options.All, namesOrIds)
|
ctrs, err := getContainersByContext(ic.ClientCxt, options.All, namesOrIds)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
reports := make([]*entities.ContainerInitReport, 0, len(ctrs))
|
||||||
for _, ctr := range ctrs {
|
for _, ctr := range ctrs {
|
||||||
err := containers.ContainerInit(ic.ClientCxt, ctr.ID)
|
err := containers.ContainerInit(ic.ClientCxt, ctr.ID)
|
||||||
// When using all, it is NOT considered an error if a container
|
// When using all, it is NOT considered an error if a container
|
||||||
@ -569,8 +555,8 @@ func (ic *ContainerEngine) Config(_ context.Context) (*config.Config, error) {
|
|||||||
|
|
||||||
func (ic *ContainerEngine) ContainerPort(ctx context.Context, nameOrID string, options entities.ContainerPortOptions) ([]*entities.ContainerPortReport, error) {
|
func (ic *ContainerEngine) ContainerPort(ctx context.Context, nameOrID string, options entities.ContainerPortOptions) ([]*entities.ContainerPortReport, error) {
|
||||||
var (
|
var (
|
||||||
reports []*entities.ContainerPortReport
|
reports = []*entities.ContainerPortReport{}
|
||||||
namesOrIds []string
|
namesOrIds = []string{}
|
||||||
)
|
)
|
||||||
if len(nameOrID) > 0 {
|
if len(nameOrID) > 0 {
|
||||||
namesOrIds = append(namesOrIds, nameOrID)
|
namesOrIds = append(namesOrIds, nameOrID)
|
||||||
|
@ -39,7 +39,7 @@ func (ir *ImageEngine) List(ctx context.Context, opts entities.ImageListOptions)
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
is := make([]*entities.ImageSummary, len(images))
|
is := make([]*entities.ImageSummary, 0, len(images))
|
||||||
for i, img := range images {
|
for i, img := range images {
|
||||||
hold := entities.ImageSummary{}
|
hold := entities.ImageSummary{}
|
||||||
if err := utils.DeepCopy(&hold, img); err != nil {
|
if err := utils.DeepCopy(&hold, img); err != nil {
|
||||||
|
@ -12,7 +12,7 @@ func (ic *ContainerEngine) NetworkList(ctx context.Context, options entities.Net
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ic *ContainerEngine) NetworkInspect(ctx context.Context, namesOrIds []string, options entities.NetworkInspectOptions) ([]entities.NetworkInspectReport, error) {
|
func (ic *ContainerEngine) NetworkInspect(ctx context.Context, namesOrIds []string, options entities.NetworkInspectOptions) ([]entities.NetworkInspectReport, error) {
|
||||||
var reports []entities.NetworkInspectReport
|
reports := make([]entities.NetworkInspectReport, 0, len(namesOrIds))
|
||||||
for _, name := range namesOrIds {
|
for _, name := range namesOrIds {
|
||||||
report, err := network.Inspect(ic.ClientCxt, name)
|
report, err := network.Inspect(ic.ClientCxt, name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -24,7 +24,7 @@ func (ic *ContainerEngine) NetworkInspect(ctx context.Context, namesOrIds []stri
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ic *ContainerEngine) NetworkRm(ctx context.Context, namesOrIds []string, options entities.NetworkRmOptions) ([]*entities.NetworkRmReport, error) {
|
func (ic *ContainerEngine) NetworkRm(ctx context.Context, namesOrIds []string, options entities.NetworkRmOptions) ([]*entities.NetworkRmReport, error) {
|
||||||
var reports []*entities.NetworkRmReport
|
reports := make([]*entities.NetworkRmReport, 0, len(namesOrIds))
|
||||||
for _, name := range namesOrIds {
|
for _, name := range namesOrIds {
|
||||||
report, err := network.Remove(ic.ClientCxt, name, &options.Force)
|
report, err := network.Remove(ic.ClientCxt, name, &options.Force)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -17,10 +17,6 @@ func (ic *ContainerEngine) PodExists(ctx context.Context, nameOrID string) (*ent
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ic *ContainerEngine) PodKill(ctx context.Context, namesOrIds []string, options entities.PodKillOptions) ([]*entities.PodKillReport, error) {
|
func (ic *ContainerEngine) PodKill(ctx context.Context, namesOrIds []string, options entities.PodKillOptions) ([]*entities.PodKillReport, error) {
|
||||||
var (
|
|
||||||
reports []*entities.PodKillReport
|
|
||||||
)
|
|
||||||
|
|
||||||
_, err := util.ParseSignal(options.Signal)
|
_, err := util.ParseSignal(options.Signal)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -30,6 +26,7 @@ func (ic *ContainerEngine) PodKill(ctx context.Context, namesOrIds []string, opt
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
reports := make([]*entities.PodKillReport, 0, len(foundPods))
|
||||||
for _, p := range foundPods {
|
for _, p := range foundPods {
|
||||||
response, err := pods.Kill(ic.ClientCxt, p.Id, &options.Signal)
|
response, err := pods.Kill(ic.ClientCxt, p.Id, &options.Signal)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -46,13 +43,11 @@ func (ic *ContainerEngine) PodKill(ctx context.Context, namesOrIds []string, opt
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ic *ContainerEngine) PodPause(ctx context.Context, namesOrIds []string, options entities.PodPauseOptions) ([]*entities.PodPauseReport, error) {
|
func (ic *ContainerEngine) PodPause(ctx context.Context, namesOrIds []string, options entities.PodPauseOptions) ([]*entities.PodPauseReport, error) {
|
||||||
var (
|
|
||||||
reports []*entities.PodPauseReport
|
|
||||||
)
|
|
||||||
foundPods, err := getPodsByContext(ic.ClientCxt, options.All, namesOrIds)
|
foundPods, err := getPodsByContext(ic.ClientCxt, options.All, namesOrIds)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
reports := make([]*entities.PodPauseReport, 0, len(foundPods))
|
||||||
for _, p := range foundPods {
|
for _, p := range foundPods {
|
||||||
response, err := pods.Pause(ic.ClientCxt, p.Id)
|
response, err := pods.Pause(ic.ClientCxt, p.Id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -69,13 +64,11 @@ func (ic *ContainerEngine) PodPause(ctx context.Context, namesOrIds []string, op
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ic *ContainerEngine) PodUnpause(ctx context.Context, namesOrIds []string, options entities.PodunpauseOptions) ([]*entities.PodUnpauseReport, error) {
|
func (ic *ContainerEngine) PodUnpause(ctx context.Context, namesOrIds []string, options entities.PodunpauseOptions) ([]*entities.PodUnpauseReport, error) {
|
||||||
var (
|
|
||||||
reports []*entities.PodUnpauseReport
|
|
||||||
)
|
|
||||||
foundPods, err := getPodsByContext(ic.ClientCxt, options.All, namesOrIds)
|
foundPods, err := getPodsByContext(ic.ClientCxt, options.All, namesOrIds)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
reports := make([]*entities.PodUnpauseReport, 0, len(foundPods))
|
||||||
for _, p := range foundPods {
|
for _, p := range foundPods {
|
||||||
response, err := pods.Unpause(ic.ClientCxt, p.Id)
|
response, err := pods.Unpause(ic.ClientCxt, p.Id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -92,10 +85,7 @@ func (ic *ContainerEngine) PodUnpause(ctx context.Context, namesOrIds []string,
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ic *ContainerEngine) PodStop(ctx context.Context, namesOrIds []string, options entities.PodStopOptions) ([]*entities.PodStopReport, error) {
|
func (ic *ContainerEngine) PodStop(ctx context.Context, namesOrIds []string, options entities.PodStopOptions) ([]*entities.PodStopReport, error) {
|
||||||
var (
|
timeout := -1
|
||||||
reports []*entities.PodStopReport
|
|
||||||
timeout = -1
|
|
||||||
)
|
|
||||||
foundPods, err := getPodsByContext(ic.ClientCxt, options.All, namesOrIds)
|
foundPods, err := getPodsByContext(ic.ClientCxt, options.All, namesOrIds)
|
||||||
if err != nil && !(options.Ignore && errors.Cause(err) == define.ErrNoSuchPod) {
|
if err != nil && !(options.Ignore && errors.Cause(err) == define.ErrNoSuchPod) {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -103,6 +93,7 @@ func (ic *ContainerEngine) PodStop(ctx context.Context, namesOrIds []string, opt
|
|||||||
if options.Timeout != -1 {
|
if options.Timeout != -1 {
|
||||||
timeout = options.Timeout
|
timeout = options.Timeout
|
||||||
}
|
}
|
||||||
|
reports := make([]*entities.PodStopReport, 0, len(foundPods))
|
||||||
for _, p := range foundPods {
|
for _, p := range foundPods {
|
||||||
response, err := pods.Stop(ic.ClientCxt, p.Id, &timeout)
|
response, err := pods.Stop(ic.ClientCxt, p.Id, &timeout)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -119,11 +110,11 @@ func (ic *ContainerEngine) PodStop(ctx context.Context, namesOrIds []string, opt
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ic *ContainerEngine) PodRestart(ctx context.Context, namesOrIds []string, options entities.PodRestartOptions) ([]*entities.PodRestartReport, error) {
|
func (ic *ContainerEngine) PodRestart(ctx context.Context, namesOrIds []string, options entities.PodRestartOptions) ([]*entities.PodRestartReport, error) {
|
||||||
var reports []*entities.PodRestartReport
|
|
||||||
foundPods, err := getPodsByContext(ic.ClientCxt, options.All, namesOrIds)
|
foundPods, err := getPodsByContext(ic.ClientCxt, options.All, namesOrIds)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
reports := make([]*entities.PodRestartReport, 0, len(foundPods))
|
||||||
for _, p := range foundPods {
|
for _, p := range foundPods {
|
||||||
response, err := pods.Restart(ic.ClientCxt, p.Id)
|
response, err := pods.Restart(ic.ClientCxt, p.Id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -140,11 +131,11 @@ func (ic *ContainerEngine) PodRestart(ctx context.Context, namesOrIds []string,
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ic *ContainerEngine) PodStart(ctx context.Context, namesOrIds []string, options entities.PodStartOptions) ([]*entities.PodStartReport, error) {
|
func (ic *ContainerEngine) PodStart(ctx context.Context, namesOrIds []string, options entities.PodStartOptions) ([]*entities.PodStartReport, error) {
|
||||||
var reports []*entities.PodStartReport
|
|
||||||
foundPods, err := getPodsByContext(ic.ClientCxt, options.All, namesOrIds)
|
foundPods, err := getPodsByContext(ic.ClientCxt, options.All, namesOrIds)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
reports := make([]*entities.PodStartReport, 0, len(foundPods))
|
||||||
for _, p := range foundPods {
|
for _, p := range foundPods {
|
||||||
response, err := pods.Start(ic.ClientCxt, p.Id)
|
response, err := pods.Start(ic.ClientCxt, p.Id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -161,11 +152,11 @@ func (ic *ContainerEngine) PodStart(ctx context.Context, namesOrIds []string, op
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ic *ContainerEngine) PodRm(ctx context.Context, namesOrIds []string, options entities.PodRmOptions) ([]*entities.PodRmReport, error) {
|
func (ic *ContainerEngine) PodRm(ctx context.Context, namesOrIds []string, options entities.PodRmOptions) ([]*entities.PodRmReport, error) {
|
||||||
var reports []*entities.PodRmReport
|
|
||||||
foundPods, err := getPodsByContext(ic.ClientCxt, options.All, namesOrIds)
|
foundPods, err := getPodsByContext(ic.ClientCxt, options.All, namesOrIds)
|
||||||
if err != nil && !(options.Ignore && errors.Cause(err) == define.ErrNoSuchPod) {
|
if err != nil && !(options.Ignore && errors.Cause(err) == define.ErrNoSuchPod) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
reports := make([]*entities.PodRmReport, 0, len(foundPods))
|
||||||
for _, p := range foundPods {
|
for _, p := range foundPods {
|
||||||
response, err := pods.Remove(ic.ClientCxt, p.Id, &options.Force)
|
response, err := pods.Remove(ic.ClientCxt, p.Id, &options.Force)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -16,10 +16,6 @@ func (ic *ContainerEngine) VolumeCreate(ctx context.Context, opts entities.Volum
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ic *ContainerEngine) VolumeRm(ctx context.Context, namesOrIds []string, opts entities.VolumeRmOptions) ([]*entities.VolumeRmReport, error) {
|
func (ic *ContainerEngine) VolumeRm(ctx context.Context, namesOrIds []string, opts entities.VolumeRmOptions) ([]*entities.VolumeRmReport, error) {
|
||||||
var (
|
|
||||||
reports []*entities.VolumeRmReport
|
|
||||||
)
|
|
||||||
|
|
||||||
if opts.All {
|
if opts.All {
|
||||||
vols, err := volumes.List(ic.ClientCxt, nil)
|
vols, err := volumes.List(ic.ClientCxt, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -29,6 +25,7 @@ func (ic *ContainerEngine) VolumeRm(ctx context.Context, namesOrIds []string, op
|
|||||||
namesOrIds = append(namesOrIds, v.Name)
|
namesOrIds = append(namesOrIds, v.Name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
reports := make([]*entities.VolumeRmReport, 0, len(namesOrIds))
|
||||||
for _, id := range namesOrIds {
|
for _, id := range namesOrIds {
|
||||||
reports = append(reports, &entities.VolumeRmReport{
|
reports = append(reports, &entities.VolumeRmReport{
|
||||||
Err: volumes.Remove(ic.ClientCxt, id, &opts.Force),
|
Err: volumes.Remove(ic.ClientCxt, id, &opts.Force),
|
||||||
@ -39,9 +36,6 @@ func (ic *ContainerEngine) VolumeRm(ctx context.Context, namesOrIds []string, op
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ic *ContainerEngine) VolumeInspect(ctx context.Context, namesOrIds []string, opts entities.VolumeInspectOptions) ([]*entities.VolumeInspectReport, error) {
|
func (ic *ContainerEngine) VolumeInspect(ctx context.Context, namesOrIds []string, opts entities.VolumeInspectOptions) ([]*entities.VolumeInspectReport, error) {
|
||||||
var (
|
|
||||||
reports []*entities.VolumeInspectReport
|
|
||||||
)
|
|
||||||
if opts.All {
|
if opts.All {
|
||||||
vols, err := volumes.List(ic.ClientCxt, nil)
|
vols, err := volumes.List(ic.ClientCxt, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -51,6 +45,7 @@ func (ic *ContainerEngine) VolumeInspect(ctx context.Context, namesOrIds []strin
|
|||||||
namesOrIds = append(namesOrIds, v.Name)
|
namesOrIds = append(namesOrIds, v.Name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
reports := make([]*entities.VolumeInspectReport, 0, len(namesOrIds))
|
||||||
for _, id := range namesOrIds {
|
for _, id := range namesOrIds {
|
||||||
data, err := volumes.Inspect(ic.ClientCxt, id)
|
data, err := volumes.Inspect(ic.ClientCxt, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -12,21 +12,11 @@ import (
|
|||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
func pointerInt(value int) *int {
|
|
||||||
return &value
|
|
||||||
}
|
|
||||||
|
|
||||||
func pointerUInt32(value uint32) *uint32 {
|
|
||||||
return &value
|
|
||||||
}
|
|
||||||
|
|
||||||
func pointerFileMode(value os.FileMode) *os.FileMode {
|
|
||||||
return &value
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestRuntimeConfigFilter(t *testing.T) {
|
func TestRuntimeConfigFilter(t *testing.T) {
|
||||||
unexpectedEndOfJSONInput := json.Unmarshal([]byte("{\n"), nil) //nolint
|
unexpectedEndOfJSONInput := json.Unmarshal([]byte("{\n"), nil) //nolint
|
||||||
|
fileMode := os.FileMode(0600)
|
||||||
|
rootUint32 := uint32(0)
|
||||||
|
binUser := int(1)
|
||||||
for _, tt := range []struct {
|
for _, tt := range []struct {
|
||||||
name string
|
name string
|
||||||
contextTimeout time.Duration
|
contextTimeout time.Duration
|
||||||
@ -77,9 +67,9 @@ func TestRuntimeConfigFilter(t *testing.T) {
|
|||||||
Type: "c",
|
Type: "c",
|
||||||
Major: 10,
|
Major: 10,
|
||||||
Minor: 229,
|
Minor: 229,
|
||||||
FileMode: pointerFileMode(0600),
|
FileMode: &fileMode,
|
||||||
UID: pointerUInt32(0),
|
UID: &rootUint32,
|
||||||
GID: pointerUInt32(0),
|
GID: &rootUint32,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -96,18 +86,18 @@ func TestRuntimeConfigFilter(t *testing.T) {
|
|||||||
Type: "c",
|
Type: "c",
|
||||||
Major: 10,
|
Major: 10,
|
||||||
Minor: 229,
|
Minor: 229,
|
||||||
FileMode: pointerFileMode(0600),
|
FileMode: &fileMode,
|
||||||
UID: pointerUInt32(0),
|
UID: &rootUint32,
|
||||||
GID: pointerUInt32(0),
|
GID: &rootUint32,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Path: "/dev/sda",
|
Path: "/dev/sda",
|
||||||
Type: "b",
|
Type: "b",
|
||||||
Major: 8,
|
Major: 8,
|
||||||
Minor: 0,
|
Minor: 0,
|
||||||
FileMode: pointerFileMode(0600),
|
FileMode: &fileMode,
|
||||||
UID: pointerUInt32(0),
|
UID: &rootUint32,
|
||||||
GID: pointerUInt32(0),
|
GID: &rootUint32,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -137,9 +127,9 @@ func TestRuntimeConfigFilter(t *testing.T) {
|
|||||||
Type: "c",
|
Type: "c",
|
||||||
Major: 10,
|
Major: 10,
|
||||||
Minor: 229,
|
Minor: 229,
|
||||||
FileMode: pointerFileMode(0600),
|
FileMode: &fileMode,
|
||||||
UID: pointerUInt32(0),
|
UID: &rootUint32,
|
||||||
GID: pointerUInt32(0),
|
GID: &rootUint32,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -156,18 +146,18 @@ func TestRuntimeConfigFilter(t *testing.T) {
|
|||||||
Type: "c",
|
Type: "c",
|
||||||
Major: 10,
|
Major: 10,
|
||||||
Minor: 229,
|
Minor: 229,
|
||||||
FileMode: pointerFileMode(0600),
|
FileMode: &fileMode,
|
||||||
UID: pointerUInt32(0),
|
UID: &rootUint32,
|
||||||
GID: pointerUInt32(0),
|
GID: &rootUint32,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Path: "/dev/sdb",
|
Path: "/dev/sdb",
|
||||||
Type: "b",
|
Type: "b",
|
||||||
Major: 8,
|
Major: 8,
|
||||||
Minor: 0,
|
Minor: 0,
|
||||||
FileMode: pointerFileMode(0600),
|
FileMode: &fileMode,
|
||||||
UID: pointerUInt32(0),
|
UID: &rootUint32,
|
||||||
GID: pointerUInt32(0),
|
GID: &rootUint32,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -203,7 +193,7 @@ func TestRuntimeConfigFilter(t *testing.T) {
|
|||||||
{
|
{
|
||||||
Path: path,
|
Path: path,
|
||||||
Args: []string{"sh", "-c", "sleep 2"},
|
Args: []string{"sh", "-c", "sleep 2"},
|
||||||
Timeout: pointerInt(1),
|
Timeout: &binUser,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
input: &spec.Spec{
|
input: &spec.Spec{
|
||||||
|
@ -79,7 +79,6 @@ func GetContainerGroups(groups []string, containerMount string, override *Overri
|
|||||||
var (
|
var (
|
||||||
groupDest string
|
groupDest string
|
||||||
err error
|
err error
|
||||||
uintgids []uint32
|
|
||||||
)
|
)
|
||||||
|
|
||||||
groupPath := etcgroup
|
groupPath := etcgroup
|
||||||
@ -96,6 +95,7 @@ func GetContainerGroups(groups []string, containerMount string, override *Overri
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
uintgids := make([]uint32, 0, len(gids))
|
||||||
// For libpod, we want []uint32s
|
// For libpod, we want []uint32s
|
||||||
for _, gid := range gids {
|
for _, gid := range gids {
|
||||||
uintgids = append(uintgids, uint32(gid))
|
uintgids = append(uintgids, uint32(gid))
|
||||||
|
@ -22,13 +22,13 @@ func GetCNIConfDir(config *config.Config) string {
|
|||||||
|
|
||||||
// LoadCNIConfsFromDir loads all the CNI configurations from a dir
|
// LoadCNIConfsFromDir loads all the CNI configurations from a dir
|
||||||
func LoadCNIConfsFromDir(dir string) ([]*libcni.NetworkConfigList, error) {
|
func LoadCNIConfsFromDir(dir string) ([]*libcni.NetworkConfigList, error) {
|
||||||
var configs []*libcni.NetworkConfigList
|
|
||||||
files, err := libcni.ConfFiles(dir, []string{".conflist"})
|
files, err := libcni.ConfFiles(dir, []string{".conflist"})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
sort.Strings(files)
|
sort.Strings(files)
|
||||||
|
|
||||||
|
configs := make([]*libcni.NetworkConfigList, 0, len(files))
|
||||||
for _, confFile := range files {
|
for _, confFile := range files {
|
||||||
conf, err := libcni.ConfListFromFile(confFile)
|
conf, err := libcni.ConfListFromFile(confFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -72,7 +72,7 @@ func ReadRawCNIConfByName(config *config.Config, name string) ([]byte, error) {
|
|||||||
// GetCNIPlugins returns a list of plugins that a given network
|
// GetCNIPlugins returns a list of plugins that a given network
|
||||||
// has in the form of a string
|
// has in the form of a string
|
||||||
func GetCNIPlugins(list *libcni.NetworkConfigList) string {
|
func GetCNIPlugins(list *libcni.NetworkConfigList) string {
|
||||||
var plugins []string
|
plugins := make([]string, 0, len(list.Plugins))
|
||||||
for _, plug := range list.Plugins {
|
for _, plug := range list.Plugins {
|
||||||
plugins = append(plugins, plug.Network.Type)
|
plugins = append(plugins, plug.Network.Type)
|
||||||
}
|
}
|
||||||
@ -106,12 +106,11 @@ func GetNetworksFromFilesystem(config *config.Config) ([]*allocator.Net, error)
|
|||||||
// GetNetworkNamesFromFileSystem gets all the names from the cni network
|
// GetNetworkNamesFromFileSystem gets all the names from the cni network
|
||||||
// configuration files
|
// configuration files
|
||||||
func GetNetworkNamesFromFileSystem(config *config.Config) ([]string, error) {
|
func GetNetworkNamesFromFileSystem(config *config.Config) ([]string, error) {
|
||||||
var networkNames []string
|
|
||||||
|
|
||||||
networks, err := LoadCNIConfsFromDir(GetCNIConfDir(config))
|
networks, err := LoadCNIConfsFromDir(GetCNIConfDir(config))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
networkNames := []string{}
|
||||||
for _, n := range networks {
|
for _, n := range networks {
|
||||||
networkNames = append(networkNames, n.Name)
|
networkNames = append(networkNames, n.Name)
|
||||||
}
|
}
|
||||||
@ -144,12 +143,12 @@ func GetInterfaceNameFromConfig(path string) (string, error) {
|
|||||||
// GetBridgeNamesFromFileSystem is a convenience function to get all the bridge
|
// GetBridgeNamesFromFileSystem is a convenience function to get all the bridge
|
||||||
// names from the configured networks
|
// names from the configured networks
|
||||||
func GetBridgeNamesFromFileSystem(config *config.Config) ([]string, error) {
|
func GetBridgeNamesFromFileSystem(config *config.Config) ([]string, error) {
|
||||||
var bridgeNames []string
|
|
||||||
|
|
||||||
networks, err := LoadCNIConfsFromDir(GetCNIConfDir(config))
|
networks, err := LoadCNIConfsFromDir(GetCNIConfDir(config))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bridgeNames := []string{}
|
||||||
for _, n := range networks {
|
for _, n := range networks {
|
||||||
var name string
|
var name string
|
||||||
// iterate network conflists
|
// iterate network conflists
|
||||||
|
@ -30,11 +30,11 @@ func IsSupportedDriver(driver string) error {
|
|||||||
// GetLiveNetworks returns a slice of networks representing what the system
|
// GetLiveNetworks returns a slice of networks representing what the system
|
||||||
// has defined as network interfaces
|
// has defined as network interfaces
|
||||||
func GetLiveNetworks() ([]*net.IPNet, error) {
|
func GetLiveNetworks() ([]*net.IPNet, error) {
|
||||||
var nets []*net.IPNet
|
|
||||||
addrs, err := net.InterfaceAddrs()
|
addrs, err := net.InterfaceAddrs()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
nets := make([]*net.IPNet, 0, len(addrs))
|
||||||
for _, address := range addrs {
|
for _, address := range addrs {
|
||||||
_, n, err := net.ParseCIDR(address.String())
|
_, n, err := net.ParseCIDR(address.String())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -47,11 +47,11 @@ func GetLiveNetworks() ([]*net.IPNet, error) {
|
|||||||
|
|
||||||
// GetLiveNetworkNames returns a list of network interfaces on the system
|
// GetLiveNetworkNames returns a list of network interfaces on the system
|
||||||
func GetLiveNetworkNames() ([]string, error) {
|
func GetLiveNetworkNames() ([]string, error) {
|
||||||
var interfaceNames []string
|
|
||||||
liveInterfaces, err := net.Interfaces()
|
liveInterfaces, err := net.Interfaces()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
interfaceNames := make([]string, 0, len(liveInterfaces))
|
||||||
for _, i := range liveInterfaces {
|
for _, i := range liveInterfaces {
|
||||||
interfaceNames = append(interfaceNames, i.Name)
|
interfaceNames = append(interfaceNames, i.Name)
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ import (
|
|||||||
func GetContainerLists(runtime *libpod.Runtime, options entities.ContainerListOptions) ([]entities.ListContainer, error) {
|
func GetContainerLists(runtime *libpod.Runtime, options entities.ContainerListOptions) ([]entities.ListContainer, error) {
|
||||||
var (
|
var (
|
||||||
filterFuncs []libpod.ContainerFilter
|
filterFuncs []libpod.ContainerFilter
|
||||||
pss []entities.ListContainer
|
pss = []entities.ListContainer{}
|
||||||
)
|
)
|
||||||
all := options.All || options.Last > 0
|
all := options.All || options.Last > 0
|
||||||
if len(options.Filters) > 0 {
|
if len(options.Filters) > 0 {
|
||||||
|
@ -93,7 +93,7 @@ var signalMap = map[string]syscall.Signal{
|
|||||||
|
|
||||||
// CatchAll catches all signals and relays them to the specified channel.
|
// CatchAll catches all signals and relays them to the specified channel.
|
||||||
func CatchAll(sigc chan os.Signal) {
|
func CatchAll(sigc chan os.Signal) {
|
||||||
var handledSigs []os.Signal
|
handledSigs := make([]os.Signal, 0, len(signalMap))
|
||||||
for _, s := range signalMap {
|
for _, s := range signalMap {
|
||||||
handledSigs = append(handledSigs, s)
|
handledSigs = append(handledSigs, s)
|
||||||
}
|
}
|
||||||
|
@ -28,8 +28,7 @@ func ProcessOptions(options []string, isTmpfs bool, sourcePath string) ([]string
|
|||||||
foundWrite, foundSize, foundProp, foundMode, foundExec, foundSuid, foundDev, foundCopyUp, foundBind, foundZ bool
|
foundWrite, foundSize, foundProp, foundMode, foundExec, foundSuid, foundDev, foundCopyUp, foundBind, foundZ bool
|
||||||
)
|
)
|
||||||
|
|
||||||
var newOptions []string
|
newOptions := make([]string, 0, len(options))
|
||||||
|
|
||||||
for _, opt := range options {
|
for _, opt := range options {
|
||||||
// Some options have parameters - size, mode
|
// Some options have parameters - size, mode
|
||||||
splitOpt := strings.SplitN(opt, "=", 2)
|
splitOpt := strings.SplitN(opt, "=", 2)
|
||||||
|
Reference in New Issue
Block a user