Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
/mobyPublic

Commitf533464

Browse files
authored
Merge pull request#47986 from vvoland/v26.1-47985
[26.1 backport] builder/mobyexporter: Add missing nil check
2 parentsd642804 +c1d4587 commitf533464

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

‎builder/builder-next/exporter/mobyexporter/writer.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ func patchImageConfig(dt []byte, dps []digest.Digest, history []ocispec.History,
4545
returnnil,errors.Wrap(err,"failed to parse image config for patch")
4646
}
4747

48+
ifm==nil {
49+
returnnil,errors.New("null image config")
50+
}
51+
4852
varrootFS ocispec.RootFS
4953
rootFS.Type="layers"
5054
rootFS.DiffIDs=append(rootFS.DiffIDs,dps...)
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package mobyexporter
2+
3+
import (
4+
"testing"
5+
6+
"gotest.tools/v3/assert"
7+
)
8+
9+
funcTestPatchImageConfig(t*testing.T) {
10+
for_,tc:=range []struct {
11+
namestring
12+
cfgJSONstring
13+
errstring
14+
}{
15+
{
16+
name:"empty",
17+
cfgJSON:"{}",
18+
},
19+
{
20+
name:"history only",
21+
cfgJSON:`{"history": []}`,
22+
},
23+
{
24+
name:"rootfs only",
25+
cfgJSON:`{"rootfs": {}}`,
26+
},
27+
{
28+
name:"null",
29+
cfgJSON:"null",
30+
err:"null image config",
31+
},
32+
} {
33+
t.Run(tc.name,func(t*testing.T) {
34+
_,err:=patchImageConfig([]byte(tc.cfgJSON),nil,nil,nil)
35+
iftc.err=="" {
36+
assert.NilError(t,err)
37+
}else {
38+
assert.ErrorContains(t,err,tc.err)
39+
}
40+
})
41+
}
42+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp