This repository has been archived by the owner on Jun 13, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 174
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add command to remove applicationh images
Signed-off-by: Djordje Lukic <djordje.lukic@docker.com>
- Loading branch information
Showing
5 changed files
with
162 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package image | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/docker/cli/cli" | ||
|
||
"github.com/docker/app/internal/store" | ||
"github.com/docker/cli/cli/config" | ||
"github.com/docker/distribution/reference" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
func rmCmd() *cobra.Command { | ||
return &cobra.Command{ | ||
Use: "rm [IMAGE] [IMAGE...]", | ||
Short: "Remove an application image", | ||
Args: cli.RequiresMinArgs(1), | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
appstore, err := store.NewApplicationStore(config.Dir()) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
bundleStore, err := appstore.BundleStore() | ||
if err != nil { | ||
return err | ||
} | ||
|
||
for _, arg := range args { | ||
ref, err := reference.ParseNormalizedNamed(arg) | ||
if err != nil { | ||
fmt.Println("Error:", err.Error()) | ||
continue | ||
} | ||
|
||
rmErr := runRm(bundleStore, arg) | ||
if rmErr != nil { | ||
fmt.Println("Error:", rmErr.Error()) | ||
} else { | ||
fmt.Println("Deleted: " + ref.String()) | ||
} | ||
} | ||
|
||
return err | ||
}, | ||
} | ||
} | ||
|
||
func runRm(bundleStore store.BundleStore, app string) error { | ||
ref, err := reference.ParseNormalizedNamed(app) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return bundleStore.Remove(ref) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters