mirror of
https://github.com/containers/podman.git
synced 2025-06-23 10:38:20 +08:00
[NO TESTS NEEDED] Shrink the size of podman-remote
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
This commit is contained in:
@ -8,7 +8,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/containers/buildah/define"
|
buildahDefine "github.com/containers/buildah/define"
|
||||||
buildahCLI "github.com/containers/buildah/pkg/cli"
|
buildahCLI "github.com/containers/buildah/pkg/cli"
|
||||||
"github.com/containers/buildah/pkg/parse"
|
"github.com/containers/buildah/pkg/parse"
|
||||||
"github.com/containers/common/pkg/completion"
|
"github.com/containers/common/pkg/completion"
|
||||||
@ -158,11 +158,11 @@ func buildFlags(cmd *cobra.Command) {
|
|||||||
flags.SetNormalizeFunc(buildahCLI.AliasFlags)
|
flags.SetNormalizeFunc(buildahCLI.AliasFlags)
|
||||||
if registry.IsRemote() {
|
if registry.IsRemote() {
|
||||||
flag = flags.Lookup("isolation")
|
flag = flags.Lookup("isolation")
|
||||||
buildOpts.Isolation = define.OCI
|
buildOpts.Isolation = buildahDefine.OCI
|
||||||
if err := flag.Value.Set(define.OCI); err != nil {
|
if err := flag.Value.Set(buildahDefine.OCI); err != nil {
|
||||||
logrus.Errorf("unable to set --isolation to %v: %v", define.OCI, err)
|
logrus.Errorf("unable to set --isolation to %v: %v", buildahDefine.OCI, err)
|
||||||
}
|
}
|
||||||
flag.DefValue = define.OCI
|
flag.DefValue = buildahDefine.OCI
|
||||||
_ = flags.MarkHidden("disable-content-trust")
|
_ = flags.MarkHidden("disable-content-trust")
|
||||||
_ = flags.MarkHidden("cache-from")
|
_ = flags.MarkHidden("cache-from")
|
||||||
_ = flags.MarkHidden("sign-by")
|
_ = flags.MarkHidden("sign-by")
|
||||||
@ -195,7 +195,7 @@ func build(cmd *cobra.Command, args []string) error {
|
|||||||
var contextDir string
|
var contextDir string
|
||||||
if len(args) > 0 {
|
if len(args) > 0 {
|
||||||
// The context directory could be a URL. Try to handle that.
|
// The context directory could be a URL. Try to handle that.
|
||||||
tempDir, subDir, err := define.TempDirForURL("", "buildah", args[0])
|
tempDir, subDir, err := buildahDefine.TempDirForURL("", "buildah", args[0])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrapf(err, "error prepping temporary context directory")
|
return errors.Wrapf(err, "error prepping temporary context directory")
|
||||||
}
|
}
|
||||||
@ -318,16 +318,16 @@ func buildFlagsWrapperToOptions(c *cobra.Command, contextDir string, flags *buil
|
|||||||
return nil, errors.Errorf("can only set one of 'pull' or 'pull-always' or 'pull-never'")
|
return nil, errors.Errorf("can only set one of 'pull' or 'pull-always' or 'pull-never'")
|
||||||
}
|
}
|
||||||
|
|
||||||
pullPolicy := define.PullIfMissing
|
pullPolicy := buildahDefine.PullIfMissing
|
||||||
if c.Flags().Changed("pull") && flags.Pull {
|
if c.Flags().Changed("pull") && flags.Pull {
|
||||||
pullPolicy = define.PullAlways
|
pullPolicy = buildahDefine.PullAlways
|
||||||
}
|
}
|
||||||
if flags.PullAlways {
|
if flags.PullAlways {
|
||||||
pullPolicy = define.PullAlways
|
pullPolicy = buildahDefine.PullAlways
|
||||||
}
|
}
|
||||||
|
|
||||||
if flags.PullNever {
|
if flags.PullNever {
|
||||||
pullPolicy = define.PullNever
|
pullPolicy = buildahDefine.PullNever
|
||||||
}
|
}
|
||||||
|
|
||||||
args := make(map[string]string)
|
args := make(map[string]string)
|
||||||
@ -402,9 +402,9 @@ func buildFlagsWrapperToOptions(c *cobra.Command, contextDir string, flags *buil
|
|||||||
flags.Layers = false
|
flags.Layers = false
|
||||||
}
|
}
|
||||||
|
|
||||||
compression := define.Gzip
|
compression := buildahDefine.Gzip
|
||||||
if flags.DisableCompression {
|
if flags.DisableCompression {
|
||||||
compression = define.Uncompressed
|
compression = buildahDefine.Uncompressed
|
||||||
}
|
}
|
||||||
|
|
||||||
isolation, err := parse.IsolationOption(flags.Isolation)
|
isolation, err := parse.IsolationOption(flags.Isolation)
|
||||||
@ -426,10 +426,10 @@ func buildFlagsWrapperToOptions(c *cobra.Command, contextDir string, flags *buil
|
|||||||
format := ""
|
format := ""
|
||||||
flags.Format = strings.ToLower(flags.Format)
|
flags.Format = strings.ToLower(flags.Format)
|
||||||
switch {
|
switch {
|
||||||
case strings.HasPrefix(flags.Format, define.OCI):
|
case strings.HasPrefix(flags.Format, buildahDefine.OCI):
|
||||||
format = define.OCIv1ImageManifest
|
format = buildahDefine.OCIv1ImageManifest
|
||||||
case strings.HasPrefix(flags.Format, define.DOCKER):
|
case strings.HasPrefix(flags.Format, buildahDefine.DOCKER):
|
||||||
format = define.Dockerv2ImageManifest
|
format = buildahDefine.Dockerv2ImageManifest
|
||||||
default:
|
default:
|
||||||
return nil, errors.Errorf("unrecognized image type %q", flags.Format)
|
return nil, errors.Errorf("unrecognized image type %q", flags.Format)
|
||||||
}
|
}
|
||||||
@ -457,7 +457,7 @@ func buildFlagsWrapperToOptions(c *cobra.Command, contextDir string, flags *buil
|
|||||||
return nil, errors.Wrapf(err, "unable to obtain decrypt config")
|
return nil, errors.Wrapf(err, "unable to obtain decrypt config")
|
||||||
}
|
}
|
||||||
|
|
||||||
opts := define.BuildOptions{
|
opts := buildahDefine.BuildOptions{
|
||||||
AddCapabilities: flags.CapAdd,
|
AddCapabilities: flags.CapAdd,
|
||||||
AdditionalTags: tags,
|
AdditionalTags: tags,
|
||||||
Annotations: flags.Annotation,
|
Annotations: flags.Annotation,
|
||||||
|
@ -7,7 +7,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/containers/podman/v3/pkg/util"
|
"github.com/containers/podman/v3/pkg/util"
|
||||||
"github.com/containers/storage"
|
"github.com/containers/storage/pkg/lockfile"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -20,7 +20,7 @@ type EventLogFile struct {
|
|||||||
// Writes to the log file
|
// Writes to the log file
|
||||||
func (e EventLogFile) Write(ee Event) error {
|
func (e EventLogFile) Write(ee Event) error {
|
||||||
// We need to lock events file
|
// We need to lock events file
|
||||||
lock, err := storage.GetLockfile(e.options.LogFilePath + ".lock")
|
lock, err := lockfile.GetLockfile(e.options.LogFilePath + ".lock")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ import (
|
|||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
|
buildahDefine "github.com/containers/buildah/define"
|
||||||
"github.com/containers/buildah/imagebuildah"
|
"github.com/containers/buildah/imagebuildah"
|
||||||
"github.com/containers/image/v5/directory"
|
"github.com/containers/image/v5/directory"
|
||||||
"github.com/containers/image/v5/docker/reference"
|
"github.com/containers/image/v5/docker/reference"
|
||||||
@ -165,7 +166,7 @@ func (r *Runtime) newImageBuildCompleteEvent(idOrName string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Build adds the runtime to the imagebuildah call
|
// Build adds the runtime to the imagebuildah call
|
||||||
func (r *Runtime) Build(ctx context.Context, options imagebuildah.BuildOptions, dockerfiles ...string) (string, reference.Canonical, error) {
|
func (r *Runtime) Build(ctx context.Context, options buildahDefine.BuildOptions, dockerfiles ...string) (string, reference.Canonical, error) {
|
||||||
if options.Runtime == "" {
|
if options.Runtime == "" {
|
||||||
// Make sure that build containers use the same runtime as Podman (see #9365).
|
// Make sure that build containers use the same runtime as Podman (see #9365).
|
||||||
conf := util.DefaultContainerConfig()
|
conf := util.DefaultContainerConfig()
|
||||||
|
@ -13,8 +13,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/containers/buildah"
|
"github.com/containers/buildah"
|
||||||
"github.com/containers/buildah/define"
|
buildahDefine "github.com/containers/buildah/define"
|
||||||
"github.com/containers/buildah/imagebuildah"
|
|
||||||
"github.com/containers/buildah/util"
|
"github.com/containers/buildah/util"
|
||||||
"github.com/containers/image/v5/types"
|
"github.com/containers/image/v5/types"
|
||||||
"github.com/containers/podman/v3/libpod"
|
"github.com/containers/podman/v3/libpod"
|
||||||
@ -277,13 +276,13 @@ func BuildImage(w http.ResponseWriter, r *http.Request) {
|
|||||||
jobs = query.Jobs
|
jobs = query.Jobs
|
||||||
}
|
}
|
||||||
|
|
||||||
pullPolicy := define.PullIfMissing
|
pullPolicy := buildahDefine.PullIfMissing
|
||||||
if utils.IsLibpodRequest(r) {
|
if utils.IsLibpodRequest(r) {
|
||||||
pullPolicy = define.PolicyMap[query.PullPolicy]
|
pullPolicy = buildahDefine.PolicyMap[query.PullPolicy]
|
||||||
} else {
|
} else {
|
||||||
if _, found := r.URL.Query()["pull"]; found {
|
if _, found := r.URL.Query()["pull"]; found {
|
||||||
if query.Pull {
|
if query.Pull {
|
||||||
pullPolicy = define.PullAlways
|
pullPolicy = buildahDefine.PullAlways
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -315,7 +314,7 @@ func BuildImage(w http.ResponseWriter, r *http.Request) {
|
|||||||
utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrap(err, "Decode()"))
|
utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrap(err, "Decode()"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
buildOptions := imagebuildah.BuildOptions{
|
buildOptions := buildahDefine.BuildOptions{
|
||||||
AddCapabilities: addCaps,
|
AddCapabilities: addCaps,
|
||||||
AdditionalTags: additionalTags,
|
AdditionalTags: additionalTags,
|
||||||
Annotations: annotations,
|
Annotations: annotations,
|
||||||
|
@ -10,8 +10,8 @@ import (
|
|||||||
"github.com/containers/podman/v3/libpod/define"
|
"github.com/containers/podman/v3/libpod/define"
|
||||||
"github.com/containers/podman/v3/pkg/api/handlers/utils"
|
"github.com/containers/podman/v3/pkg/api/handlers/utils"
|
||||||
"github.com/containers/podman/v3/pkg/domain/entities"
|
"github.com/containers/podman/v3/pkg/domain/entities"
|
||||||
|
"github.com/containers/podman/v3/pkg/domain/entities/types"
|
||||||
"github.com/containers/podman/v3/version"
|
"github.com/containers/podman/v3/version"
|
||||||
docker "github.com/docker/docker/api/types"
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -32,7 +32,7 @@ func VersionHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
components := []docker.ComponentVersion{{
|
components := []types.ComponentVersion{{
|
||||||
Name: "Podman Engine",
|
Name: "Podman Engine",
|
||||||
Version: versionInfo.Version,
|
Version: versionInfo.Version,
|
||||||
Details: map[string]string{
|
Details: map[string]string{
|
||||||
@ -52,7 +52,7 @@ func VersionHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
minVersion := version.APIVersion[version.Compat][version.MinimalAPI]
|
minVersion := version.APIVersion[version.Compat][version.MinimalAPI]
|
||||||
|
|
||||||
utils.WriteResponse(w, http.StatusOK, entities.ComponentVersion{
|
utils.WriteResponse(w, http.StatusOK, entities.ComponentVersion{
|
||||||
Version: docker.Version{
|
Version: types.Version{
|
||||||
Platform: struct {
|
Platform: struct {
|
||||||
Name string
|
Name string
|
||||||
}{
|
}{
|
||||||
|
@ -28,10 +28,6 @@ type ContainerConfig struct {
|
|||||||
dockerContainer.Config
|
dockerContainer.Config
|
||||||
}
|
}
|
||||||
|
|
||||||
type LibpodImagesLoadReport struct {
|
|
||||||
ID string `json:"id"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type LibpodImagesPullReport struct {
|
type LibpodImagesPullReport struct {
|
||||||
entities.ImagePullReport
|
entities.ImagePullReport
|
||||||
}
|
}
|
||||||
|
23
pkg/api/handlers/types/types.go
Normal file
23
pkg/api/handlers/types/types.go
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
package types
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/containers/podman/v3/pkg/domain/entities"
|
||||||
|
)
|
||||||
|
|
||||||
|
// LibpodImagesRemoveReport is the return type for image removal via the rest
|
||||||
|
// api.
|
||||||
|
type LibpodImagesRemoveReport struct {
|
||||||
|
entities.ImageRemoveReport
|
||||||
|
// Image removal requires is to return data and an error.
|
||||||
|
Errors []string
|
||||||
|
}
|
||||||
|
|
||||||
|
// HistoryResponse provides details on image layers
|
||||||
|
type HistoryResponse struct {
|
||||||
|
ID string `json:"Id"`
|
||||||
|
Created int64
|
||||||
|
CreatedBy string
|
||||||
|
Tags []string
|
||||||
|
Size int64
|
||||||
|
Comment string
|
||||||
|
}
|
@ -174,7 +174,6 @@ func Build(ctx context.Context, containerFiles []string, options entities.BuildO
|
|||||||
if len(platform) > 0 {
|
if len(platform) > 0 {
|
||||||
params.Set("platform", platform)
|
params.Set("platform", platform)
|
||||||
}
|
}
|
||||||
|
|
||||||
params.Set("pullpolicy", options.PullPolicy.String())
|
params.Set("pullpolicy", options.PullPolicy.String())
|
||||||
|
|
||||||
if options.Quiet {
|
if options.Quiet {
|
||||||
|
@ -8,7 +8,7 @@ import (
|
|||||||
"net/url"
|
"net/url"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/containers/podman/v3/pkg/api/handlers"
|
"github.com/containers/podman/v3/pkg/api/handlers/types"
|
||||||
"github.com/containers/podman/v3/pkg/auth"
|
"github.com/containers/podman/v3/pkg/auth"
|
||||||
"github.com/containers/podman/v3/pkg/bindings"
|
"github.com/containers/podman/v3/pkg/bindings"
|
||||||
"github.com/containers/podman/v3/pkg/domain/entities"
|
"github.com/containers/podman/v3/pkg/domain/entities"
|
||||||
@ -96,12 +96,12 @@ func Tree(ctx context.Context, nameOrID string, options *TreeOptions) (*entities
|
|||||||
}
|
}
|
||||||
|
|
||||||
// History returns the parent layers of an image.
|
// History returns the parent layers of an image.
|
||||||
func History(ctx context.Context, nameOrID string, options *HistoryOptions) ([]*handlers.HistoryResponse, error) {
|
func History(ctx context.Context, nameOrID string, options *HistoryOptions) ([]*types.HistoryResponse, error) {
|
||||||
if options == nil {
|
if options == nil {
|
||||||
options = new(HistoryOptions)
|
options = new(HistoryOptions)
|
||||||
}
|
}
|
||||||
_ = options
|
_ = options
|
||||||
var history []*handlers.HistoryResponse
|
var history []*types.HistoryResponse
|
||||||
conn, err := bindings.GetClient(ctx)
|
conn, err := bindings.GetClient(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -4,7 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/containers/podman/v3/pkg/api/handlers"
|
"github.com/containers/podman/v3/pkg/api/handlers/types"
|
||||||
"github.com/containers/podman/v3/pkg/bindings"
|
"github.com/containers/podman/v3/pkg/bindings"
|
||||||
"github.com/containers/podman/v3/pkg/domain/entities"
|
"github.com/containers/podman/v3/pkg/domain/entities"
|
||||||
"github.com/containers/podman/v3/pkg/errorhandling"
|
"github.com/containers/podman/v3/pkg/errorhandling"
|
||||||
@ -19,7 +19,7 @@ func Remove(ctx context.Context, images []string, options *RemoveOptions) (*enti
|
|||||||
// FIXME - bindings tests are missing for this endpoint. Once the CI is
|
// FIXME - bindings tests are missing for this endpoint. Once the CI is
|
||||||
// re-enabled for bindings, we need to add them. At the time of writing,
|
// re-enabled for bindings, we need to add them. At the time of writing,
|
||||||
// the tests don't compile.
|
// the tests don't compile.
|
||||||
var report handlers.LibpodImagesRemoveReport
|
var report types.LibpodImagesRemoveReport
|
||||||
conn, err := bindings.GetClient(ctx)
|
conn, err := bindings.GetClient(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, []error{err}
|
return nil, []error{err}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package images
|
package images
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/containers/buildah/imagebuildah"
|
buildahDefine "github.com/containers/buildah/define"
|
||||||
)
|
)
|
||||||
|
|
||||||
//go:generate go run ../generator/generator.go RemoveOptions
|
//go:generate go run ../generator/generator.go RemoveOptions
|
||||||
@ -162,7 +162,7 @@ type PullOptions struct {
|
|||||||
|
|
||||||
//BuildOptions are optional options for building images
|
//BuildOptions are optional options for building images
|
||||||
type BuildOptions struct {
|
type BuildOptions struct {
|
||||||
imagebuildah.BuildOptions
|
buildahDefine.BuildOptions
|
||||||
}
|
}
|
||||||
|
|
||||||
//go:generate go run ../generator/generator.go ExistsOptions
|
//go:generate go run ../generator/generator.go ExistsOptions
|
||||||
|
@ -8,33 +8,32 @@ import (
|
|||||||
"github.com/containers/image/v5/types"
|
"github.com/containers/image/v5/types"
|
||||||
"github.com/containers/podman/v3/pkg/inspect"
|
"github.com/containers/podman/v3/pkg/inspect"
|
||||||
"github.com/containers/podman/v3/pkg/trust"
|
"github.com/containers/podman/v3/pkg/trust"
|
||||||
docker "github.com/docker/docker/api/types"
|
|
||||||
"github.com/docker/docker/api/types/container"
|
"github.com/docker/docker/api/types/container"
|
||||||
"github.com/opencontainers/go-digest"
|
"github.com/opencontainers/go-digest"
|
||||||
v1 "github.com/opencontainers/image-spec/specs-go/v1"
|
v1 "github.com/opencontainers/image-spec/specs-go/v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Image struct {
|
type Image struct {
|
||||||
ID string `json:"Id"`
|
ID string `json:"Id"`
|
||||||
RepoTags []string `json:",omitempty"`
|
RepoTags []string `json:",omitempty"`
|
||||||
RepoDigests []string `json:",omitempty"`
|
RepoDigests []string `json:",omitempty"`
|
||||||
Parent string `json:",omitempty"`
|
Parent string `json:",omitempty"`
|
||||||
Comment string `json:",omitempty"`
|
Comment string `json:",omitempty"`
|
||||||
Created string `json:",omitempty"`
|
Created string `json:",omitempty"`
|
||||||
Container string `json:",omitempty"`
|
Container string `json:",omitempty"`
|
||||||
ContainerConfig *container.Config `json:",omitempty"`
|
ContainerConfig *container.Config `json:",omitempty"`
|
||||||
DockerVersion string `json:",omitempty"`
|
DockerVersion string `json:",omitempty"`
|
||||||
Author string `json:",omitempty"`
|
Author string `json:",omitempty"`
|
||||||
Config *container.Config `json:",omitempty"`
|
Config *container.Config `json:",omitempty"`
|
||||||
Architecture string `json:",omitempty"`
|
Architecture string `json:",omitempty"`
|
||||||
Variant string `json:",omitempty"`
|
Variant string `json:",omitempty"`
|
||||||
Os string `json:",omitempty"`
|
Os string `json:",omitempty"`
|
||||||
OsVersion string `json:",omitempty"`
|
OsVersion string `json:",omitempty"`
|
||||||
Size int64 `json:",omitempty"`
|
Size int64 `json:",omitempty"`
|
||||||
VirtualSize int64 `json:",omitempty"`
|
VirtualSize int64 `json:",omitempty"`
|
||||||
GraphDriver docker.GraphDriverData `json:",omitempty"`
|
GraphDriver string `json:",omitempty"`
|
||||||
RootFS docker.RootFS `json:",omitempty"`
|
RootFS string `json:",omitempty"`
|
||||||
Metadata docker.ImageMetadata `json:",omitempty"`
|
Metadata string `json:",omitempty"`
|
||||||
|
|
||||||
// Podman extensions
|
// Podman extensions
|
||||||
Digest digest.Digest `json:",omitempty"`
|
Digest digest.Digest `json:",omitempty"`
|
||||||
|
@ -5,7 +5,7 @@ import (
|
|||||||
|
|
||||||
"github.com/containers/podman/v3/libpod/define"
|
"github.com/containers/podman/v3/libpod/define"
|
||||||
"github.com/containers/podman/v3/pkg/domain/entities/reports"
|
"github.com/containers/podman/v3/pkg/domain/entities/reports"
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/containers/podman/v3/pkg/domain/entities/types"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ package entities
|
|||||||
import (
|
import (
|
||||||
"net"
|
"net"
|
||||||
|
|
||||||
"github.com/containers/buildah/imagebuildah"
|
buildahDefine "github.com/containers/buildah/define"
|
||||||
"github.com/containers/podman/v3/libpod/events"
|
"github.com/containers/podman/v3/libpod/events"
|
||||||
"github.com/containers/podman/v3/pkg/specgen"
|
"github.com/containers/podman/v3/pkg/specgen"
|
||||||
"github.com/containers/storage/pkg/archive"
|
"github.com/containers/storage/pkg/archive"
|
||||||
@ -91,7 +91,7 @@ type ContainerCreateResponse struct {
|
|||||||
|
|
||||||
// BuildOptions describe the options for building container images.
|
// BuildOptions describe the options for building container images.
|
||||||
type BuildOptions struct {
|
type BuildOptions struct {
|
||||||
imagebuildah.BuildOptions
|
buildahDefine.BuildOptions
|
||||||
}
|
}
|
||||||
|
|
||||||
// BuildReport is the image-build report.
|
// BuildReport is the image-build report.
|
||||||
|
22
pkg/domain/entities/types/auth.go
Normal file
22
pkg/domain/entities/types/auth.go
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
package types // import "github.com/docker/docker/api/types"
|
||||||
|
|
||||||
|
// AuthConfig contains authorization information for connecting to a Registry
|
||||||
|
type AuthConfig struct {
|
||||||
|
Username string `json:"username,omitempty"`
|
||||||
|
Password string `json:"password,omitempty"`
|
||||||
|
Auth string `json:"auth,omitempty"`
|
||||||
|
|
||||||
|
// Email is an optional value associated with the username.
|
||||||
|
// This field is deprecated and will be removed in a later
|
||||||
|
// version of docker.
|
||||||
|
Email string `json:"email,omitempty"`
|
||||||
|
|
||||||
|
ServerAddress string `json:"serveraddress,omitempty"`
|
||||||
|
|
||||||
|
// IdentityToken is used to authenticate the user and get
|
||||||
|
// an access token for the registry.
|
||||||
|
IdentityToken string `json:"identitytoken,omitempty"`
|
||||||
|
|
||||||
|
// RegistryToken is a bearer token to be sent to a registry
|
||||||
|
RegistryToken string `json:"registrytoken,omitempty"`
|
||||||
|
}
|
28
pkg/domain/entities/types/types.go
Normal file
28
pkg/domain/entities/types/types.go
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
package types // import "github.com/docker/docker/api/types"
|
||||||
|
|
||||||
|
// ComponentVersion describes the version information for a specific component.
|
||||||
|
type ComponentVersion struct {
|
||||||
|
Name string
|
||||||
|
Version string
|
||||||
|
Details map[string]string `json:",omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Version contains response of Engine API:
|
||||||
|
// GET "/version"
|
||||||
|
type Version struct {
|
||||||
|
Platform struct{ Name string } `json:",omitempty"`
|
||||||
|
Components []ComponentVersion `json:",omitempty"`
|
||||||
|
|
||||||
|
// The following fields are deprecated, they relate to the Engine component and are kept for backwards compatibility
|
||||||
|
|
||||||
|
Version string
|
||||||
|
APIVersion string `json:"ApiVersion"`
|
||||||
|
MinAPIVersion string `json:"MinAPIVersion,omitempty"`
|
||||||
|
GitCommit string
|
||||||
|
GoVersion string
|
||||||
|
Os string
|
||||||
|
Arch string
|
||||||
|
KernelVersion string `json:",omitempty"`
|
||||||
|
Experimental bool `json:",omitempty"`
|
||||||
|
BuildTime string `json:",omitempty"`
|
||||||
|
}
|
@ -4,10 +4,72 @@ import (
|
|||||||
"net/url"
|
"net/url"
|
||||||
|
|
||||||
"github.com/containers/podman/v3/libpod/define"
|
"github.com/containers/podman/v3/libpod/define"
|
||||||
docker_api_types "github.com/docker/docker/api/types"
|
|
||||||
docker_api_types_volume "github.com/docker/docker/api/types/volume"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Volume volume
|
||||||
|
// swagger:model Volume
|
||||||
|
type volume struct {
|
||||||
|
|
||||||
|
// Date/Time the volume was created.
|
||||||
|
CreatedAt string `json:"CreatedAt,omitempty"`
|
||||||
|
|
||||||
|
// Name of the volume driver used by the volume.
|
||||||
|
// Required: true
|
||||||
|
Driver string `json:"Driver"`
|
||||||
|
|
||||||
|
// User-defined key/value metadata.
|
||||||
|
// Required: true
|
||||||
|
Labels map[string]string `json:"Labels"`
|
||||||
|
|
||||||
|
// Mount path of the volume on the host.
|
||||||
|
// Required: true
|
||||||
|
Mountpoint string `json:"Mountpoint"`
|
||||||
|
|
||||||
|
// Name of the volume.
|
||||||
|
// Required: true
|
||||||
|
Name string `json:"Name"`
|
||||||
|
|
||||||
|
// The driver specific options used when creating the volume.
|
||||||
|
//
|
||||||
|
// Required: true
|
||||||
|
Options map[string]string `json:"Options"`
|
||||||
|
|
||||||
|
// The level at which the volume exists. Either `global` for cluster-wide,
|
||||||
|
// or `local` for machine level.
|
||||||
|
//
|
||||||
|
// Required: true
|
||||||
|
Scope string `json:"Scope"`
|
||||||
|
|
||||||
|
// Low-level details about the volume, provided by the volume driver.
|
||||||
|
// Details are returned as a map with key/value pairs:
|
||||||
|
// `{"key":"value","key2":"value2"}`.
|
||||||
|
//
|
||||||
|
// The `Status` field is optional, and is omitted if the volume driver
|
||||||
|
// does not support this feature.
|
||||||
|
//
|
||||||
|
Status map[string]interface{} `json:"Status,omitempty"`
|
||||||
|
|
||||||
|
// usage data
|
||||||
|
UsageData *VolumeUsageData `json:"UsageData,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type VolumeUsageData struct {
|
||||||
|
|
||||||
|
// The number of containers referencing this volume. This field
|
||||||
|
// is set to `-1` if the reference-count is not available.
|
||||||
|
//
|
||||||
|
// Required: true
|
||||||
|
RefCount int64 `json:"RefCount"`
|
||||||
|
|
||||||
|
// Amount of disk space used by the volume (in bytes). This information
|
||||||
|
// is only available for volumes created with the `"local"` volume
|
||||||
|
// driver. For volumes created with other volume drivers, this field
|
||||||
|
// is set to `-1` ("not available")
|
||||||
|
//
|
||||||
|
// Required: true
|
||||||
|
Size int64 `json:"Size"`
|
||||||
|
}
|
||||||
|
|
||||||
// swagger:model VolumeCreate
|
// swagger:model VolumeCreate
|
||||||
type VolumeCreateOptions struct {
|
type VolumeCreateOptions struct {
|
||||||
// New volume's name. Can be left blank
|
// New volume's name. Can be left blank
|
||||||
@ -113,14 +175,14 @@ type SwagVolumeListResponse struct {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// swagger:model DockerVolumeCreate
|
// swagger:model DockerVolumeCreate
|
||||||
type DockerVolumeCreate docker_api_types_volume.VolumeCreateBody
|
type DockerVolumeCreate VolumeCreateBody
|
||||||
|
|
||||||
// This response definition is used for both the create and inspect endpoints
|
// This response definition is used for both the create and inspect endpoints
|
||||||
// swagger:response DockerVolumeInfoResponse
|
// swagger:response DockerVolumeInfoResponse
|
||||||
type SwagDockerVolumeInfoResponse struct {
|
type SwagDockerVolumeInfoResponse struct {
|
||||||
// in:body
|
// in:body
|
||||||
Body struct {
|
Body struct {
|
||||||
docker_api_types.Volume
|
volume
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -129,6 +191,30 @@ type SwagDockerVolumeInfoResponse struct {
|
|||||||
type SwagDockerVolumePruneResponse struct {
|
type SwagDockerVolumePruneResponse struct {
|
||||||
// in:body
|
// in:body
|
||||||
Body struct {
|
Body struct {
|
||||||
docker_api_types.VolumesPruneReport
|
// docker_api_types.VolumesPruneReport
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// VolumeCreateBody Volume configuration
|
||||||
|
// swagger:model VolumeCreateBody
|
||||||
|
type VolumeCreateBody struct {
|
||||||
|
|
||||||
|
// Name of the volume driver to use.
|
||||||
|
// Required: true
|
||||||
|
Driver string `json:"Driver"`
|
||||||
|
|
||||||
|
// A mapping of driver options and values. These options are
|
||||||
|
// passed directly to the driver and are driver specific.
|
||||||
|
//
|
||||||
|
// Required: true
|
||||||
|
DriverOpts map[string]string `json:"DriverOpts"`
|
||||||
|
|
||||||
|
// User-defined key/value metadata.
|
||||||
|
// Required: true
|
||||||
|
Labels map[string]string `json:"Labels"`
|
||||||
|
|
||||||
|
// The new volume's name. If not specified, Docker generates a name.
|
||||||
|
//
|
||||||
|
// Required: true
|
||||||
|
Name string `json:"Name"`
|
||||||
|
}
|
||||||
|
@ -15,8 +15,8 @@ import (
|
|||||||
"github.com/containers/podman/v3/pkg/domain/entities"
|
"github.com/containers/podman/v3/pkg/domain/entities"
|
||||||
"github.com/containers/podman/v3/pkg/namespaces"
|
"github.com/containers/podman/v3/pkg/namespaces"
|
||||||
"github.com/containers/podman/v3/pkg/rootless"
|
"github.com/containers/podman/v3/pkg/rootless"
|
||||||
"github.com/containers/storage"
|
|
||||||
"github.com/containers/storage/pkg/idtools"
|
"github.com/containers/storage/pkg/idtools"
|
||||||
|
"github.com/containers/storage/types"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
flag "github.com/spf13/pflag"
|
flag "github.com/spf13/pflag"
|
||||||
@ -100,7 +100,7 @@ func GetRuntimeNoStore(ctx context.Context, fs *flag.FlagSet, cfg *entities.Podm
|
|||||||
|
|
||||||
func getRuntime(ctx context.Context, fs *flag.FlagSet, opts *engineOpts) (*libpod.Runtime, error) {
|
func getRuntime(ctx context.Context, fs *flag.FlagSet, opts *engineOpts) (*libpod.Runtime, error) {
|
||||||
options := []libpod.RuntimeOption{}
|
options := []libpod.RuntimeOption{}
|
||||||
storageOpts := storage.StoreOptions{}
|
storageOpts := types.StoreOptions{}
|
||||||
cfg := opts.config
|
cfg := opts.config
|
||||||
|
|
||||||
storageSet := false
|
storageSet := false
|
||||||
@ -237,8 +237,8 @@ func getRuntime(ctx context.Context, fs *flag.FlagSet, opts *engineOpts) (*libpo
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ParseIDMapping takes idmappings and subuid and subgid maps and returns a storage mapping
|
// ParseIDMapping takes idmappings and subuid and subgid maps and returns a storage mapping
|
||||||
func ParseIDMapping(mode namespaces.UsernsMode, uidMapSlice, gidMapSlice []string, subUIDMap, subGIDMap string) (*storage.IDMappingOptions, error) {
|
func ParseIDMapping(mode namespaces.UsernsMode, uidMapSlice, gidMapSlice []string, subUIDMap, subGIDMap string) (*types.IDMappingOptions, error) {
|
||||||
options := storage.IDMappingOptions{
|
options := types.IDMappingOptions{
|
||||||
HostUIDMapping: true,
|
HostUIDMapping: true,
|
||||||
HostGIDMapping: true,
|
HostGIDMapping: true,
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/containers/storage"
|
"github.com/containers/storage/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -109,12 +109,12 @@ func (n UsernsMode) IsDefaultValue() bool {
|
|||||||
|
|
||||||
// GetAutoOptions returns a AutoUserNsOptions with the settings to setup automatically
|
// GetAutoOptions returns a AutoUserNsOptions with the settings to setup automatically
|
||||||
// a user namespace.
|
// a user namespace.
|
||||||
func (n UsernsMode) GetAutoOptions() (*storage.AutoUserNsOptions, error) {
|
func (n UsernsMode) GetAutoOptions() (*types.AutoUserNsOptions, error) {
|
||||||
parts := strings.SplitN(string(n), ":", 2)
|
parts := strings.SplitN(string(n), ":", 2)
|
||||||
if parts[0] != "auto" {
|
if parts[0] != "auto" {
|
||||||
return nil, fmt.Errorf("wrong user namespace mode")
|
return nil, fmt.Errorf("wrong user namespace mode")
|
||||||
}
|
}
|
||||||
options := storage.AutoUserNsOptions{}
|
options := types.AutoUserNsOptions{}
|
||||||
if len(parts) == 1 {
|
if len(parts) == 1 {
|
||||||
return &options, nil
|
return &options, nil
|
||||||
}
|
}
|
||||||
@ -131,13 +131,13 @@ func (n UsernsMode) GetAutoOptions() (*storage.AutoUserNsOptions, error) {
|
|||||||
}
|
}
|
||||||
options.Size = uint32(s)
|
options.Size = uint32(s)
|
||||||
case "uidmapping":
|
case "uidmapping":
|
||||||
mapping, err := storage.ParseIDMapping([]string{v[1]}, nil, "", "")
|
mapping, err := types.ParseIDMapping([]string{v[1]}, nil, "", "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
options.AdditionalUIDMappings = append(options.AdditionalUIDMappings, mapping.UIDMap...)
|
options.AdditionalUIDMappings = append(options.AdditionalUIDMappings, mapping.UIDMap...)
|
||||||
case "gidmapping":
|
case "gidmapping":
|
||||||
mapping, err := storage.ParseIDMapping(nil, []string{v[1]}, "", "")
|
mapping, err := types.ParseIDMapping(nil, []string{v[1]}, "", "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@ import (
|
|||||||
"sort"
|
"sort"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/containers/storage"
|
"github.com/containers/storage/pkg/lockfile"
|
||||||
"github.com/opencontainers/runc/libcontainer/user"
|
"github.com/opencontainers/runc/libcontainer/user"
|
||||||
spec "github.com/opencontainers/runtime-spec/specs-go"
|
spec "github.com/opencontainers/runtime-spec/specs-go"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
@ -25,7 +25,7 @@ func TryJoinPauseProcess(pausePidPath string) (bool, int, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// It could not join the pause process, let's lock the file before trying to delete it.
|
// It could not join the pause process, let's lock the file before trying to delete it.
|
||||||
pidFileLock, err := storage.GetLockfile(pausePidPath)
|
pidFileLock, err := lockfile.GetLockfile(pausePidPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// The file was deleted by another process.
|
// The file was deleted by another process.
|
||||||
if os.IsNotExist(err) {
|
if os.IsNotExist(err) {
|
||||||
|
@ -11,7 +11,7 @@ import (
|
|||||||
"github.com/containers/podman/v3/libpod/image"
|
"github.com/containers/podman/v3/libpod/image"
|
||||||
"github.com/containers/podman/v3/pkg/specgen"
|
"github.com/containers/podman/v3/pkg/specgen"
|
||||||
"github.com/containers/podman/v3/pkg/util"
|
"github.com/containers/podman/v3/pkg/util"
|
||||||
"github.com/containers/storage"
|
"github.com/containers/storage/types"
|
||||||
"github.com/opencontainers/selinux/go-selinux/label"
|
"github.com/opencontainers/selinux/go-selinux/label"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
@ -367,7 +367,7 @@ func createContainerOptions(ctx context.Context, rt *libpod.Runtime, s *specgen.
|
|||||||
return options, nil
|
return options, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func CreateExitCommandArgs(storageConfig storage.StoreOptions, config *config.Config, syslog, rm, exec bool) ([]string, error) {
|
func CreateExitCommandArgs(storageConfig types.StoreOptions, config *config.Config, syslog, rm, exec bool) ([]string, error) {
|
||||||
// We need a cleanup process for containers in the current model.
|
// We need a cleanup process for containers in the current model.
|
||||||
// But we can't assume that the caller is Podman - it could be another
|
// But we can't assume that the caller is Podman - it could be another
|
||||||
// user of the API.
|
// user of the API.
|
||||||
|
@ -5,7 +5,7 @@ import (
|
|||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
"github.com/containers/image/v5/manifest"
|
"github.com/containers/image/v5/manifest"
|
||||||
"github.com/containers/storage"
|
"github.com/containers/storage/types"
|
||||||
spec "github.com/opencontainers/runtime-spec/specs-go"
|
spec "github.com/opencontainers/runtime-spec/specs-go"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
@ -302,7 +302,7 @@ type ContainerSecurityConfig struct {
|
|||||||
// IDMappings are UID and GID mappings that will be used by user
|
// IDMappings are UID and GID mappings that will be used by user
|
||||||
// namespaces.
|
// namespaces.
|
||||||
// Required if UserNS is private.
|
// Required if UserNS is private.
|
||||||
IDMappings *storage.IDMappingOptions `json:"idmappings,omitempty"`
|
IDMappings *types.IDMappingOptions `json:"idmappings,omitempty"`
|
||||||
// ReadOnlyFilesystem indicates that everything will be mounted
|
// ReadOnlyFilesystem indicates that everything will be mounted
|
||||||
// as read-only
|
// as read-only
|
||||||
ReadOnlyFilesystem bool `json:"read_only_filesystem,omitempty"`
|
ReadOnlyFilesystem bool `json:"read_only_filesystem,omitempty"`
|
||||||
|
@ -20,8 +20,8 @@ import (
|
|||||||
"github.com/containers/podman/v3/pkg/namespaces"
|
"github.com/containers/podman/v3/pkg/namespaces"
|
||||||
"github.com/containers/podman/v3/pkg/rootless"
|
"github.com/containers/podman/v3/pkg/rootless"
|
||||||
"github.com/containers/podman/v3/pkg/signal"
|
"github.com/containers/podman/v3/pkg/signal"
|
||||||
"github.com/containers/storage"
|
|
||||||
"github.com/containers/storage/pkg/idtools"
|
"github.com/containers/storage/pkg/idtools"
|
||||||
|
stypes "github.com/containers/storage/types"
|
||||||
v1 "github.com/opencontainers/image-spec/specs-go/v1"
|
v1 "github.com/opencontainers/image-spec/specs-go/v1"
|
||||||
"github.com/opencontainers/runtime-spec/specs-go"
|
"github.com/opencontainers/runtime-spec/specs-go"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
@ -344,8 +344,8 @@ func ParseSignal(rawSignal string) (syscall.Signal, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetKeepIDMapping returns the mappings and the user to use when keep-id is used
|
// GetKeepIDMapping returns the mappings and the user to use when keep-id is used
|
||||||
func GetKeepIDMapping() (*storage.IDMappingOptions, int, int, error) {
|
func GetKeepIDMapping() (*stypes.IDMappingOptions, int, int, error) {
|
||||||
options := storage.IDMappingOptions{
|
options := stypes.IDMappingOptions{
|
||||||
HostUIDMapping: true,
|
HostUIDMapping: true,
|
||||||
HostGIDMapping: true,
|
HostGIDMapping: true,
|
||||||
}
|
}
|
||||||
@ -395,8 +395,8 @@ func GetKeepIDMapping() (*storage.IDMappingOptions, int, int, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ParseIDMapping takes idmappings and subuid and subgid maps and returns a storage mapping
|
// ParseIDMapping takes idmappings and subuid and subgid maps and returns a storage mapping
|
||||||
func ParseIDMapping(mode namespaces.UsernsMode, uidMapSlice, gidMapSlice []string, subUIDMap, subGIDMap string) (*storage.IDMappingOptions, error) {
|
func ParseIDMapping(mode namespaces.UsernsMode, uidMapSlice, gidMapSlice []string, subUIDMap, subGIDMap string) (*stypes.IDMappingOptions, error) {
|
||||||
options := storage.IDMappingOptions{
|
options := stypes.IDMappingOptions{
|
||||||
HostUIDMapping: true,
|
HostUIDMapping: true,
|
||||||
HostGIDMapping: true,
|
HostGIDMapping: true,
|
||||||
}
|
}
|
||||||
@ -479,7 +479,7 @@ type tomlConfig struct {
|
|||||||
} `toml:"storage"`
|
} `toml:"storage"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func getTomlStorage(storeOptions *storage.StoreOptions) *tomlConfig {
|
func getTomlStorage(storeOptions *stypes.StoreOptions) *tomlConfig {
|
||||||
config := new(tomlConfig)
|
config := new(tomlConfig)
|
||||||
|
|
||||||
config.Storage.Driver = storeOptions.GraphDriverName
|
config.Storage.Driver = storeOptions.GraphDriverName
|
||||||
@ -496,7 +496,7 @@ func getTomlStorage(storeOptions *storage.StoreOptions) *tomlConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// WriteStorageConfigFile writes the configuration to a file
|
// WriteStorageConfigFile writes the configuration to a file
|
||||||
func WriteStorageConfigFile(storageOpts *storage.StoreOptions, storageConf string) error {
|
func WriteStorageConfigFile(storageOpts *stypes.StoreOptions, storageConf string) error {
|
||||||
if err := os.MkdirAll(filepath.Dir(storageConf), 0755); err != nil {
|
if err := os.MkdirAll(filepath.Dir(storageConf), 0755); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user