forked from minishift/minishift
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue minishift#952 Implementing image caching using OCI based image …
…cache - Switching to containers/image OCI tansport for image caching - Addressing cross compilation issues by making sure the right build tags are used - Replacing current ImageHandler with an OCI based ImageHandler - Making sure image caching work in conjunction with profiles (issue minishift#1666) - Implementing image commands import, export and list - Adding commands image config [view|add|remove] for configuring the list of persistent cache images
- Loading branch information
1 parent
124ceee
commit 5196cfe
Showing
33 changed files
with
1,934 additions
and
579 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
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,38 @@ | ||
/* | ||
Copyright (C) 2017 Red Hat, Inc. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package image | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
const ( | ||
noImageSpecified = "You need to specify one or more images." | ||
) | ||
|
||
var ImageConfigCmd = &cobra.Command{ | ||
Use: "config SUBCOMMAND [flags]", | ||
Short: "Controls the list of cached images which are implicitly imported and exported.", | ||
Long: "Controls the list of cached images which are implicitly imported and exported.", | ||
Run: func(cmd *cobra.Command, args []string) { | ||
cmd.Help() | ||
}, | ||
} | ||
|
||
func init() { | ||
ImageCmd.AddCommand(ImageConfigCmd) | ||
} |
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,66 @@ | ||
/* | ||
Copyright (C) 2017 Red Hat, Inc. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package image | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
|
||
"fmt" | ||
"github.com/minishift/minishift/cmd/minishift/cmd/config" | ||
"github.com/minishift/minishift/pkg/util/os/atexit" | ||
"github.com/minishift/minishift/pkg/util/strings" | ||
) | ||
|
||
var ( | ||
addConfiguredImageCmd = &cobra.Command{ | ||
Use: "add [image ...]", | ||
Short: "Adds the specified images to the list of configured images for import and export.", | ||
Long: "Adds the specified images to the list of configured images for import and export.", | ||
Run: addConfiguredImage, | ||
} | ||
) | ||
|
||
func addConfiguredImage(cmd *cobra.Command, args []string) { | ||
if len(args) == 0 { | ||
atexit.ExitWithMessage(1, noImageSpecified) | ||
} | ||
|
||
configMap, err := config.ReadConfig() | ||
if err != nil { | ||
atexit.ExitWithMessage(1, fmt.Sprintf("Cannot read the Minishift configuration: %s", err.Error())) | ||
} | ||
|
||
var cacheImages []string | ||
if configMap[config.CacheImages.Name] == nil { | ||
cacheImages = []string{} | ||
} else { | ||
cacheImages = toStringSlice(configMap[config.CacheImages.Name].([]interface{})) | ||
} | ||
|
||
for _, image := range args { | ||
if !strings.Contains(cacheImages, image) { | ||
cacheImages = append(cacheImages, image) | ||
} | ||
} | ||
|
||
configMap[config.CacheImages.Name] = cacheImages | ||
config.WriteConfig(configMap) | ||
} | ||
|
||
func init() { | ||
ImageConfigCmd.AddCommand(addConfiguredImageCmd) | ||
} |
Oops, something went wrong.