remove libpod from main

the compilation demands of having libpod in main is a burden for the
remote client compilations.  to combat this, we should move the use of
libpod structs, vars, constants, and functions into the adapter code
where it will only be compiled by the local client.

this should result in cleaner code organization and smaller binaries. it
should also help if we ever need to compile the remote client on
non-Linux operating systems natively (not cross-compiled).

Signed-off-by: baude <bbaude@redhat.com>
This commit is contained in:
baude
2019-06-24 15:48:34 -05:00
parent a1a4a75abe
commit dd81a44ccf
72 changed files with 822 additions and 746 deletions

View File

@ -3,6 +3,7 @@ package libpod
import (
"context"
"github.com/containers/libpod/libpod/define"
"github.com/containers/libpod/libpod/events"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
@ -27,7 +28,7 @@ func (p *Pod) Start(ctx context.Context) (map[string]error, error) {
defer p.lock.Unlock()
if !p.valid {
return nil, ErrPodRemoved
return nil, define.ErrPodRemoved
}
allCtrs, err := p.runtime.state.PodContainers(p)
@ -47,7 +48,7 @@ func (p *Pod) Start(ctx context.Context) (map[string]error, error) {
// If there are no containers without dependencies, we can't start
// Error out
if len(graph.noDepNodes) == 0 {
return nil, errors.Wrapf(ErrNoSuchCtr, "no containers in pod %s have no dependencies, cannot start pod", p.ID())
return nil, errors.Wrapf(define.ErrNoSuchCtr, "no containers in pod %s have no dependencies, cannot start pod", p.ID())
}
// Traverse the graph beginning at nodes with no dependencies
@ -56,7 +57,7 @@ func (p *Pod) Start(ctx context.Context) (map[string]error, error) {
}
if len(ctrErrors) > 0 {
return ctrErrors, errors.Wrapf(ErrCtrExists, "error starting some containers")
return ctrErrors, errors.Wrapf(define.ErrCtrExists, "error starting some containers")
}
defer p.newPodEvent(events.Start)
return nil, nil
@ -88,7 +89,7 @@ func (p *Pod) StopWithTimeout(ctx context.Context, cleanup bool, timeout int) (m
defer p.lock.Unlock()
if !p.valid {
return nil, ErrPodRemoved
return nil, define.ErrPodRemoved
}
allCtrs, err := p.runtime.state.PodContainers(p)
@ -136,7 +137,7 @@ func (p *Pod) StopWithTimeout(ctx context.Context, cleanup bool, timeout int) (m
}
if len(ctrErrors) > 0 {
return ctrErrors, errors.Wrapf(ErrCtrExists, "error stopping some containers")
return ctrErrors, errors.Wrapf(define.ErrCtrExists, "error stopping some containers")
}
defer p.newPodEvent(events.Stop)
return nil, nil
@ -159,7 +160,7 @@ func (p *Pod) Pause() (map[string]error, error) {
defer p.lock.Unlock()
if !p.valid {
return nil, ErrPodRemoved
return nil, define.ErrPodRemoved
}
allCtrs, err := p.runtime.state.PodContainers(p)
@ -195,7 +196,7 @@ func (p *Pod) Pause() (map[string]error, error) {
}
if len(ctrErrors) > 0 {
return ctrErrors, errors.Wrapf(ErrCtrExists, "error pausing some containers")
return ctrErrors, errors.Wrapf(define.ErrCtrExists, "error pausing some containers")
}
defer p.newPodEvent(events.Pause)
return nil, nil
@ -218,7 +219,7 @@ func (p *Pod) Unpause() (map[string]error, error) {
defer p.lock.Unlock()
if !p.valid {
return nil, ErrPodRemoved
return nil, define.ErrPodRemoved
}
allCtrs, err := p.runtime.state.PodContainers(p)
@ -254,7 +255,7 @@ func (p *Pod) Unpause() (map[string]error, error) {
}
if len(ctrErrors) > 0 {
return ctrErrors, errors.Wrapf(ErrCtrExists, "error unpausing some containers")
return ctrErrors, errors.Wrapf(define.ErrCtrExists, "error unpausing some containers")
}
defer p.newPodEvent(events.Unpause)
@ -279,7 +280,7 @@ func (p *Pod) Restart(ctx context.Context) (map[string]error, error) {
defer p.lock.Unlock()
if !p.valid {
return nil, ErrPodRemoved
return nil, define.ErrPodRemoved
}
allCtrs, err := p.runtime.state.PodContainers(p)
@ -299,7 +300,7 @@ func (p *Pod) Restart(ctx context.Context) (map[string]error, error) {
// If there are no containers without dependencies, we can't start
// Error out
if len(graph.noDepNodes) == 0 {
return nil, errors.Wrapf(ErrNoSuchCtr, "no containers in pod %s have no dependencies, cannot start pod", p.ID())
return nil, errors.Wrapf(define.ErrNoSuchCtr, "no containers in pod %s have no dependencies, cannot start pod", p.ID())
}
// Traverse the graph beginning at nodes with no dependencies
@ -308,7 +309,7 @@ func (p *Pod) Restart(ctx context.Context) (map[string]error, error) {
}
if len(ctrErrors) > 0 {
return ctrErrors, errors.Wrapf(ErrCtrExists, "error stopping some containers")
return ctrErrors, errors.Wrapf(define.ErrCtrExists, "error stopping some containers")
}
p.newPodEvent(events.Stop)
p.newPodEvent(events.Start)
@ -331,7 +332,7 @@ func (p *Pod) Kill(signal uint) (map[string]error, error) {
defer p.lock.Unlock()
if !p.valid {
return nil, ErrPodRemoved
return nil, define.ErrPodRemoved
}
allCtrs, err := p.runtime.state.PodContainers(p)
@ -374,7 +375,7 @@ func (p *Pod) Kill(signal uint) (map[string]error, error) {
}
if len(ctrErrors) > 0 {
return ctrErrors, errors.Wrapf(ErrCtrExists, "error killing some containers")
return ctrErrors, errors.Wrapf(define.ErrCtrExists, "error killing some containers")
}
defer p.newPodEvent(events.Kill)
return nil, nil
@ -387,7 +388,7 @@ func (p *Pod) Status() (map[string]ContainerStatus, error) {
defer p.lock.Unlock()
if !p.valid {
return nil, ErrPodRemoved
return nil, define.ErrPodRemoved
}
allCtrs, err := p.runtime.state.PodContainers(p)