Skip to content

Commit 2be26e6

Browse files
authored
Drop container_config from v1.Config (google#546)
This is a holdover from docker days and isn't present in opencontainers/image-spec.
1 parent d2c9827 commit 2be26e6

File tree

8 files changed

+22
-27
lines changed

8 files changed

+22
-27
lines changed

pkg/crane/example_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,5 @@ func Example() {
2727
i, _ := crane.Image(c)
2828
d, _ := i.Digest()
2929
fmt.Println(d)
30-
// Output: sha256:7f384dc9f331568b53484d1a31b85188be61c1161e37c5988abe304969268a8c
30+
// Output: sha256:09fb0c6289cefaad8c74c7e5fd6758ad6906ab8f57f1350d9f4eb5a7df45ff8b
3131
}

pkg/crane/filemap_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,20 +91,20 @@ func TestImage(t *testing.T) {
9191
Digest string
9292
}{{
9393
Name: "Empty contents",
94-
Digest: "sha256:009d931e3fe0c1375ccb0dbe221d83f5f8a292c8ba6a9ac04725b2ee36b51df0",
94+
Digest: "sha256:98132f58b523c391a5788997327cac95e114e3a6609d01163189774510705399",
9595
}, {
9696
Name: "One file",
9797
FileMap: map[string][]byte{
9898
"/test": []byte("testy"),
9999
},
100-
Digest: "sha256:baa4ccec230e2f3cf640afb857188238956bc1990aa63e59bc596dc4de42da0d",
100+
Digest: "sha256:d905c03ac635172a96c12b8af6c90cfd028e3edaa3114b31a9e196ab38c16963",
101101
}, {
102102
Name: "Two files",
103103
FileMap: map[string][]byte{
104104
"/test": []byte("testy"),
105105
"/bar": []byte("not useful"),
106106
},
107-
Digest: "sha256:a6c773d2afa4fd7d8b429f013a2f23615571e97207391545a748e3546f9e1f46",
107+
Digest: "sha256:20e7e4800e5eb167f170970936c08d9e1bcbe91372420eeb6ab8d1a07752c3a3",
108108
}, {
109109
Name: "Many files",
110110
FileMap: map[string][]byte{
@@ -118,7 +118,7 @@ func TestImage(t *testing.T) {
118118
"/8": []byte("8"),
119119
"/9": []byte("9"),
120120
},
121-
Digest: "sha256:c2ee9d5aba32d42088ac5561e5f8bc9795a4abca2475264a4aa729fd1ee8ef22",
121+
Digest: "sha256:dfca2803510c8e3b83a3151f7c035c60cfa2a8a52465b802e18b85014de361f1",
122122
}}
123123
for _, tc := range tcs {
124124
t.Run(tc.Name, func(t *testing.T) {

pkg/legacy/config.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ import (
2323
// https://github.com/moby/moby/blob/master/image/spec/v1.md
2424
type LayerConfigFile struct {
2525
v1.ConfigFile
26+
27+
ContainerConfig v1.Config `json:"container_config,omitempty"`
28+
2629
ID string `json:"id,omitempty"`
2730
Parent string `json:"parent,omitempty"`
2831
Throwaway bool `json:"throwaway,omitempty"`

pkg/legacy/tarball/write.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,9 @@ func newV1Layer(layer v1.Layer, parent *v1Layer, history v1.History) (*v1Layer,
8484
ConfigFile: v1.ConfigFile{
8585
Created: history.Created,
8686
Author: history.Author,
87-
ContainerConfig: v1.Config{
88-
Cmd: []string{history.CreatedBy},
89-
},
87+
},
88+
ContainerConfig: v1.Config{
89+
Cmd: []string{history.CreatedBy},
9090
},
9191
ID: id,
9292
Parent: parentID,
@@ -113,7 +113,6 @@ func newTopV1Layer(layer v1.Layer, parent *v1Layer, history v1.History, imgConfi
113113
result.config.DockerVersion = imgConfig.DockerVersion
114114
result.config.OS = imgConfig.OS
115115
result.config.Config = imgConfig.Config
116-
result.config.ContainerConfig = imgConfig.ContainerConfig
117116
result.config.Created = imgConfig.Created
118117
return result, nil
119118
}

pkg/v1/config.go

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,16 @@ import (
2424
// how to launch a container. See:
2525
// https://github.com/opencontainers/image-spec/blob/master/config.md
2626
type ConfigFile struct {
27-
Architecture string `json:"architecture"`
28-
Author string `json:"author,omitempty"`
29-
Container string `json:"container,omitempty"`
30-
Created Time `json:"created,omitempty"`
31-
DockerVersion string `json:"docker_version,omitempty"`
32-
History []History `json:"history,omitempty"`
33-
OS string `json:"os"`
34-
RootFS RootFS `json:"rootfs"`
35-
Config Config `json:"config"`
36-
ContainerConfig Config `json:"container_config,omitempty"`
37-
OSVersion string `json:"osversion,omitempty"`
27+
Architecture string `json:"architecture"`
28+
Author string `json:"author,omitempty"`
29+
Container string `json:"container,omitempty"`
30+
Created Time `json:"created,omitempty"`
31+
DockerVersion string `json:"docker_version,omitempty"`
32+
History []History `json:"history,omitempty"`
33+
OS string `json:"os"`
34+
RootFS RootFS `json:"rootfs"`
35+
Config Config `json:"config"`
36+
OSVersion string `json:"osversion,omitempty"`
3837
}
3938

4039
// History is one entry of a list recording how this container image was built.

pkg/v1/mutate/mutate.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,6 @@ func Config(base v1.Image, cfg v1.Config) (v1.Image, error) {
9999
}
100100

101101
cf.Config = cfg
102-
// Downstream tooling expects these to match.
103-
cf.ContainerConfig = cfg
104102

105103
return ConfigFile(base, cf)
106104
}
@@ -283,7 +281,6 @@ func Time(img v1.Image, t time.Time) (v1.Image, error) {
283281

284282
// Copy basic config over
285283
cfg.Config = ocf.Config
286-
cfg.ContainerConfig = ocf.Config // Downstream tooling expects these to match.
287284

288285
// Strip away timestamps from the config file
289286
cfg.Created = v1.Time{Time: t}
@@ -363,7 +360,6 @@ func Canonical(img v1.Image) (v1.Image, error) {
363360

364361
cfg.Container = ""
365362
cfg.Config.Hostname = ""
366-
cfg.ContainerConfig.Hostname = ""
367363
cfg.DockerVersion = ""
368364

369365
return ConfigFile(img, cfg)

pkg/v1/mutate/mutate_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ func TestAppendStreamableLayer(t *testing.T) {
357357
if err != nil {
358358
t.Errorf("Digest: %v", err)
359359
}
360-
wantDigest := "sha256:3ce401493b0faa0f0640afb50975aba3c3f8cc237ff17a5b3a0720dea5514eb7"
360+
wantDigest := "sha256:14d140947afedc6901b490265a08bc8ebe7f9d9faed6fdf19a451f054a7dd746"
361361
if h.String() != wantDigest {
362362
t.Errorf("Image digest got %q, want %q", h, wantDigest)
363363
}
@@ -377,7 +377,6 @@ func TestCanonical(t *testing.T) {
377377
for _, s := range []string{
378378
cf.Container,
379379
cf.Config.Hostname,
380-
cf.ContainerConfig.Hostname,
381380
cf.DockerVersion,
382381
} {
383382
if s != "" {

pkg/v1/zz_deepcopy_generated.go

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)