Skip to content

Commit 0662917

Browse files
authored
Made code more clear
1 parent e619e18 commit 0662917

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

runsc/specutils/specutils.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -218,11 +218,11 @@ func ReadSpecFromFile(bundleDir string, specFile *os.File, conf *config.Config)
218218
var spec specs.Spec
219219
decoder := json.NewDecoder(bytes.NewReader(specBytes))
220220
decoder.DisallowUnknownFields()
221-
if err := decoder.Decode(&spec); err != nil {
222-
if err2 := json.Unmarshal(specBytes, &spec); err2 != nil {
223-
return nil, fmt.Errorf("error unmarshaling spec from file %q: %v\n %s", specFile.Name(), err2, string(specBytes))
221+
if errLooseDecode := decoder.Decode(&spec); errLooseDecode != nil {
222+
if errStrictDecode := json.Unmarshal(specBytes, &spec); errStrictDecode != nil {
223+
return nil, fmt.Errorf("error unmarshaling spec from file %q: %v\n %s", specFile.Name(), errStrictDecode, string(specBytes))
224224
} else {
225-
log.Warningf("Problem with spec file %q: %v. Consider removing unnecessary fields.", specFile.Name(), err)
225+
log.Warningf("OCI spec file %q contains fields unknown to `runsc`: %v. Ignoring these fields and continuing anyway.", specFile.Name(), errLooseDecode)
226226
}
227227
}
228228
if err := ValidateSpec(&spec); err != nil {

0 commit comments

Comments
 (0)