add reload command

pull/6051/head
Medya Gh 2019-12-10 18:44:03 -08:00
parent 2d1fffe1d1
commit a3e16fae72
2 changed files with 15 additions and 3 deletions

View File

@ -70,6 +70,16 @@ var deleteCacheCmd = &cobra.Command{
},
}
// reloadCacheCmd represents the cache reload command
var reloadCacheCmd = &cobra.Command{
Use: "reload",
Short: "reload cached images.",
Long: "reloads the cached images specificed by user in the config file.",
Run: func(cmd *cobra.Command, args []string) {
cacheAndLoadImagesInConfig()
},
}
func imagesInConfigFile() ([]string, error) {
configFile, err := config.ReadConfig(localpath.ConfigFile)
if err != nil {
@ -98,8 +108,9 @@ func saveImagesToTarFromConfig() error {
return machine.CacheImagesToTar(images, constants.ImageCacheDir)
}
// loadCachedImagesInConfigFile loads the images currently in the config file (minikube start)
func loadCachedImagesInConfigFile() error {
// cacheAndLoadImagesInConfig loads the images currently in the config file
// called by 'start' and 'cache reload' commands.
func cacheAndLoadImagesInConfig() error {
images, err := imagesInConfigFile()
if err != nil {
return err
@ -113,4 +124,5 @@ func loadCachedImagesInConfigFile() error {
func init() {
cacheCmd.AddCommand(addCacheCmd)
cacheCmd.AddCommand(deleteCacheCmd)
cacheCmd.AddCommand(reloadCacheCmd)
}

View File

@ -360,7 +360,7 @@ func runStart(cmd *cobra.Command, args []string) {
// enable addons with start command
enableAddons()
if err = loadCachedImagesInConfigFile(); err != nil {
if err = cacheAndLoadImagesInConfig(); err != nil {
out.T(out.FailureType, "Unable to load cached images from config file.")
}