fix: reworked container architecture (#619)
- Don't set architecture, let Docker host decide it's own platform, remove `runtime` dependency and don't show default in `--help` - Remove most tests, we need to check only once if it works on different platform - Rename `DeleteImage` to `RemoveImage` to conform to existing function in `docker` cli, added options to specify `force` and `pruneChildren`
This commit is contained in:
@@ -29,7 +29,7 @@ func ImageExistsLocally(ctx context.Context, imageName string, platform string)
|
||||
}
|
||||
|
||||
if len(images) > 0 {
|
||||
if platform == "any" {
|
||||
if platform == "any" || platform == "" {
|
||||
return true, nil
|
||||
}
|
||||
for _, v := range images {
|
||||
@@ -48,9 +48,9 @@ func ImageExistsLocally(ctx context.Context, imageName string, platform string)
|
||||
return false, nil
|
||||
}
|
||||
|
||||
// DeleteImage removes image from local store, the function is used to run different
|
||||
// RemoveImage removes image from local store, the function is used to run different
|
||||
// container image architectures
|
||||
func DeleteImage(ctx context.Context, imageName string) (bool, error) {
|
||||
func RemoveImage(ctx context.Context, imageName string, force bool, pruneChildren bool) (bool, error) {
|
||||
if exists, err := ImageExistsLocally(ctx, imageName, "any"); !exists {
|
||||
return false, err
|
||||
}
|
||||
@@ -75,8 +75,8 @@ func DeleteImage(ctx context.Context, imageName string) (bool, error) {
|
||||
if len(images) > 0 {
|
||||
for _, v := range images {
|
||||
if _, err = cli.ImageRemove(ctx, v.ID, types.ImageRemoveOptions{
|
||||
Force: true,
|
||||
PruneChildren: true,
|
||||
Force: force,
|
||||
PruneChildren: pruneChildren,
|
||||
}); err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
@@ -293,7 +293,7 @@ func (cr *containerReference) create() common.Executor {
|
||||
}
|
||||
|
||||
var platSpecs *specs.Platform
|
||||
if supportsContainerImagePlatform(cr.cli) {
|
||||
if supportsContainerImagePlatform(cr.cli) && cr.input.Platform != "" {
|
||||
desiredPlatform := strings.SplitN(cr.input.Platform, `/`, 2)
|
||||
|
||||
if len(desiredPlatform) != 2 {
|
||||
|
Reference in New Issue
Block a user