|
@@ -2,7 +2,6 @@ package v1 // import "github.com/docker/docker/image/v1"
|
|
|
|
|
|
import (
|
|
|
"encoding/json"
|
|
|
- "reflect"
|
|
|
"strings"
|
|
|
|
|
|
"github.com/docker/docker/api/types/versions"
|
|
@@ -16,7 +15,7 @@ import (
|
|
|
// noFallbackMinVersion is the minimum version for which v1compatibility
|
|
|
// information will not be marshaled through the Image struct to remove
|
|
|
// blank fields.
|
|
|
-var noFallbackMinVersion = "1.8.3"
|
|
|
+const noFallbackMinVersion = "1.8.3"
|
|
|
|
|
|
// HistoryFromConfig creates a History struct from v1 configuration JSON
|
|
|
func HistoryFromConfig(imageJSON []byte, emptyLayer bool) (image.History, error) {
|
|
@@ -106,36 +105,6 @@ func MakeConfigFromV1Config(imageJSON []byte, rootfs *image.RootFS, history []im
|
|
|
return json.Marshal(c)
|
|
|
}
|
|
|
|
|
|
-// MakeV1ConfigFromConfig creates a legacy V1 image config from an Image struct
|
|
|
-func MakeV1ConfigFromConfig(img *image.Image, v1ID, parentV1ID string, throwaway bool) ([]byte, error) {
|
|
|
- // Top-level v1compatibility string should be a modified version of the
|
|
|
- // image config.
|
|
|
- var configAsMap map[string]*json.RawMessage
|
|
|
- if err := json.Unmarshal(img.RawJSON(), &configAsMap); err != nil {
|
|
|
- return nil, err
|
|
|
- }
|
|
|
-
|
|
|
- // Delete fields that didn't exist in old manifest
|
|
|
- imageType := reflect.TypeOf(img).Elem()
|
|
|
- for i := 0; i < imageType.NumField(); i++ {
|
|
|
- f := imageType.Field(i)
|
|
|
- jsonName := strings.Split(f.Tag.Get("json"), ",")[0]
|
|
|
- // Parent is handled specially below.
|
|
|
- if jsonName != "" && jsonName != "parent" {
|
|
|
- delete(configAsMap, jsonName)
|
|
|
- }
|
|
|
- }
|
|
|
- configAsMap["id"] = rawJSON(v1ID)
|
|
|
- if parentV1ID != "" {
|
|
|
- configAsMap["parent"] = rawJSON(parentV1ID)
|
|
|
- }
|
|
|
- if throwaway {
|
|
|
- configAsMap["throwaway"] = rawJSON(true)
|
|
|
- }
|
|
|
-
|
|
|
- return json.Marshal(configAsMap)
|
|
|
-}
|
|
|
-
|
|
|
func rawJSON(value interface{}) *json.RawMessage {
|
|
|
jsonval, err := json.Marshal(value)
|
|
|
if err != nil {
|