mirror of
https://github.com/containers/podman.git
synced 2025-07-15 03:02:52 +08:00
migrate Podman to containers/common/libimage
Migrate the Podman code base over to `common/libimage` which replaces `libpod/image` and a lot of glue code entirely. Note that I tried to leave bread crumbs for changed tests. Miscellaneous changes: * Some errors yield different messages which required to alter some tests. * I fixed some pre-existing issues in the code. Others were marked as `//TODO`s to prevent the PR from exploding. * The `NamesHistory` of an image is returned as is from the storage. Previously, we did some filtering which I think is undesirable. Instead we should return the data as stored in the storage. * Touched handlers use the ABI interfaces where possible. * Local image resolution: previously Podman would match "foo" on "myfoo". This behaviour has been changed and Podman will now only match on repository boundaries such that "foo" would match "my/foo" but not "myfoo". I consider the old behaviour to be a bug, at the very least an exotic corner case. * Futhermore, "foo:none" does *not* resolve to a local image "foo" without tag anymore. It's a hill I am (almost) willing to die on. * `image prune` prints the IDs of pruned images. Previously, in some cases, the names were printed instead. The API clearly states ID, so we should stick to it. * Compat endpoint image removal with _force_ deletes the entire not only the specified tag. Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
This commit is contained in:
57
vendor/github.com/containers/buildah/pkg/parse/parse.go
generated
vendored
57
vendor/github.com/containers/buildah/pkg/parse/parse.go
generated
vendored
@ -125,6 +125,8 @@ func CommonBuildOptions(c *cobra.Command) (*define.CommonBuildOptions, error) {
|
||||
ulimit, _ = c.Flags().GetStringSlice("ulimit")
|
||||
}
|
||||
|
||||
secrets, _ := c.Flags().GetStringArray("secret")
|
||||
|
||||
commonOpts := &define.CommonBuildOptions{
|
||||
AddHost: addHost,
|
||||
CPUPeriod: cpuPeriod,
|
||||
@ -142,6 +144,7 @@ func CommonBuildOptions(c *cobra.Command) (*define.CommonBuildOptions, error) {
|
||||
ShmSize: c.Flag("shm-size").Value.String(),
|
||||
Ulimit: ulimit,
|
||||
Volumes: volumes,
|
||||
Secrets: secrets,
|
||||
}
|
||||
securityOpts, _ := c.Flags().GetStringArray("security-opt")
|
||||
if err := parseSecurityOpts(securityOpts, commonOpts); err != nil {
|
||||
@ -178,11 +181,11 @@ func parseSecurityOpts(securityOpts []string, commonOpts *define.CommonBuildOpti
|
||||
commonOpts.SeccompProfilePath = SeccompOverridePath
|
||||
} else {
|
||||
if !os.IsNotExist(err) {
|
||||
return errors.Wrapf(err, "can't check if %q exists", SeccompOverridePath)
|
||||
return errors.WithStack(err)
|
||||
}
|
||||
if _, err := os.Stat(SeccompDefaultPath); err != nil {
|
||||
if !os.IsNotExist(err) {
|
||||
return errors.Wrapf(err, "can't check if %q exists", SeccompDefaultPath)
|
||||
return errors.WithStack(err)
|
||||
}
|
||||
} else {
|
||||
commonOpts.SeccompProfilePath = SeccompDefaultPath
|
||||
@ -454,7 +457,7 @@ func ValidateVolumeHostDir(hostDir string) error {
|
||||
}
|
||||
if filepath.IsAbs(hostDir) {
|
||||
if _, err := os.Stat(hostDir); err != nil {
|
||||
return errors.Wrapf(err, "error checking path %q", hostDir)
|
||||
return errors.WithStack(err)
|
||||
}
|
||||
}
|
||||
// If hostDir is not an absolute path, that means the user wants to create a
|
||||
@ -468,7 +471,7 @@ func validateVolumeMountHostDir(hostDir string) error {
|
||||
return errors.Errorf("invalid host path, must be an absolute path %q", hostDir)
|
||||
}
|
||||
if _, err := os.Stat(hostDir); err != nil {
|
||||
return errors.Wrapf(err, "error checking path %q", hostDir)
|
||||
return errors.WithStack(err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@ -587,6 +590,14 @@ func SystemContextFromOptions(c *cobra.Command) (*types.SystemContext, error) {
|
||||
ctx.OCIInsecureSkipTLSVerify = !tlsVerify
|
||||
ctx.DockerDaemonInsecureSkipTLSVerify = !tlsVerify
|
||||
}
|
||||
disableCompression, err := c.Flags().GetBool("disable-compression")
|
||||
if err == nil {
|
||||
if disableCompression {
|
||||
ctx.OCIAcceptUncompressedLayers = true
|
||||
} else {
|
||||
ctx.DirForceCompress = true
|
||||
}
|
||||
}
|
||||
creds, err := c.Flags().GetString("creds")
|
||||
if err == nil && c.Flag("creds").Changed {
|
||||
var err error
|
||||
@ -832,7 +843,7 @@ func IDMappingOptions(c *cobra.Command, isolation define.Isolation) (usernsOptio
|
||||
default:
|
||||
how = strings.TrimPrefix(how, "ns:")
|
||||
if _, err := os.Stat(how); err != nil {
|
||||
return nil, nil, errors.Wrapf(err, "error checking for %s namespace at %q", string(specs.UserNamespace), how)
|
||||
return nil, nil, errors.Wrapf(err, "checking %s namespace", string(specs.UserNamespace))
|
||||
}
|
||||
logrus.Debugf("setting %q namespace to %q", string(specs.UserNamespace), how)
|
||||
usernsOption.Path = how
|
||||
@ -922,7 +933,7 @@ func NamespaceOptions(c *cobra.Command) (namespaceOptions define.NamespaceOption
|
||||
}
|
||||
how = strings.TrimPrefix(how, "ns:")
|
||||
if _, err := os.Stat(how); err != nil {
|
||||
return nil, define.NetworkDefault, errors.Wrapf(err, "error checking for %s namespace", what)
|
||||
return nil, define.NetworkDefault, errors.Wrapf(err, "checking %s namespace", what)
|
||||
}
|
||||
policy = define.NetworkEnabled
|
||||
logrus.Debugf("setting %q namespace to %q", what, how)
|
||||
@ -1043,3 +1054,37 @@ func GetTempDir() string {
|
||||
}
|
||||
return "/var/tmp"
|
||||
}
|
||||
|
||||
// Secrets parses the --secret flag
|
||||
func Secrets(secrets []string) (map[string]string, error) {
|
||||
parsed := make(map[string]string)
|
||||
invalidSyntax := errors.Errorf("incorrect secret flag format: should be --secret id=foo,src=bar")
|
||||
for _, secret := range secrets {
|
||||
split := strings.Split(secret, ",")
|
||||
if len(split) > 2 {
|
||||
return nil, invalidSyntax
|
||||
}
|
||||
if len(split) == 2 {
|
||||
id := strings.Split(split[0], "=")
|
||||
src := strings.Split(split[1], "=")
|
||||
if len(split) == 2 && strings.ToLower(id[0]) == "id" && strings.ToLower(src[0]) == "src" {
|
||||
fullPath, err := filepath.Abs(src[1])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
_, err = os.Stat(fullPath)
|
||||
if err == nil {
|
||||
parsed[id[1]] = fullPath
|
||||
}
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not parse secrets")
|
||||
}
|
||||
} else {
|
||||
return nil, invalidSyntax
|
||||
}
|
||||
} else {
|
||||
return nil, invalidSyntax
|
||||
}
|
||||
}
|
||||
return parsed, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user