Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: deprecated docker field leads to failure of nydusify check #1349

Merged
merged 1 commit into from
Jul 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
ccx1024cc marked this conversation as resolved.
Show resolved Hide resolved
// 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())
}