Skip to content

Commit

Permalink
fix: deprecated docker field leads to failure of nydusify check
Browse files Browse the repository at this point in the history
`NydusImage.Config.Config.ArgsEscaped` is present only for legacy compatibility
with Docker and should not be used by new image builders. Nydusify (1.6 and
above) ignores it, which is an expected behavior.

This pr ignores comparision of it in nydusify checking, which leads to failure.

Signed-off-by: 泰友 <cuichengxu.ccx@antgroup.com>
  • Loading branch information
泰友 authored and imeoer committed Jul 11, 2023
1 parent 0c225ca commit 9bb5151
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
14 changes: 14 additions & 0 deletions contrib/nydusify/pkg/checker/rule/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,20 @@ func (rule *ManifestRule) Validate() error {

// Check Nydus image config with OCI image
if rule.SourceParsed.OCIImage != nil {

//nolint:staticcheck
// ignore static check SA1019 here. We have to assign deprecated field.
//
// Skip ArgsEscaped's Check
//
// This field is present only for legacy compatibility with Docker and
// should not be used by new image builders. Nydusify (1.6 and above)
// ignores it, which is an expected behavior.
// Also ignore it in check.
//
// Addition: [ArgsEscaped in spec](https://github.com/opencontainers/image-spec/pull/892)
rule.TargetParsed.NydusImage.Config.Config.ArgsEscaped = rule.SourceParsed.OCIImage.Config.Config.ArgsEscaped

ociConfig, err := json.Marshal(rule.SourceParsed.OCIImage.Config.Config)
if err != nil {
return errors.New("marshal oci image config")
Expand Down
38 changes: 38 additions & 0 deletions contrib/nydusify/pkg/checker/rule/manifest_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package rule

import (
"testing"

"github.com/dragonflyoss/image-service/contrib/nydusify/pkg/parser"
"github.com/stretchr/testify/assert"

v1 "github.com/opencontainers/image-spec/specs-go/v1"
)

func TestManifestRuleValidate_IgnoreDeprecatedField(t *testing.T) {
source := &parser.Parsed{
NydusImage: &parser.Image{
Config: v1.Image{
Config: v1.ImageConfig{
ArgsEscaped: true, // deprecated field
},
},
},
}
target := &parser.Parsed{
NydusImage: &parser.Image{
Config: v1.Image{
Config: v1.ImageConfig{
ArgsEscaped: false,
},
},
},
}

rule := ManifestRule{
SourceParsed: source,
TargetParsed: target,
}

assert.Nil(t, rule.Validate())
}

0 comments on commit 9bb5151

Please sign in to comment.