pkg/cri/util/: remove deprecated NormalizeImageRef alias
Has been deprecated in containerd v1.3.0, so we can remove this. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
		@@ -1,33 +0,0 @@
 | 
			
		||||
/*
 | 
			
		||||
   Copyright The containerd Authors.
 | 
			
		||||
 | 
			
		||||
   Licensed under the Apache License, Version 2.0 (the "License");
 | 
			
		||||
   you may not use this file except in compliance with the License.
 | 
			
		||||
   You may obtain a copy of the License at
 | 
			
		||||
 | 
			
		||||
       http://www.apache.org/licenses/LICENSE-2.0
 | 
			
		||||
 | 
			
		||||
   Unless required by applicable law or agreed to in writing, software
 | 
			
		||||
   distributed under the License is distributed on an "AS IS" BASIS,
 | 
			
		||||
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | 
			
		||||
   See the License for the specific language governing permissions and
 | 
			
		||||
   limitations under the License.
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
package util
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"github.com/containerd/containerd/reference/docker"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// NormalizeImageRef normalizes the image reference following the docker convention. This is added
 | 
			
		||||
// mainly for backward compatibility.
 | 
			
		||||
// The reference returned can only be either tagged or digested. For reference contains both tag
 | 
			
		||||
// and digest, the function returns digested reference, e.g. docker.io/library/busybox:latest@
 | 
			
		||||
// sha256:7cc4b5aefd1d0cadf8d97d4350462ba51c694ebca145b08d7d41b41acc8db5aa will be returned as
 | 
			
		||||
// docker.io/library/busybox@sha256:7cc4b5aefd1d0cadf8d97d4350462ba51c694ebca145b08d7d41b41acc8db5aa.
 | 
			
		||||
//
 | 
			
		||||
// Deprecated: use github.com/containerd/containerd/reference/docker.ParseDockerRef() instead
 | 
			
		||||
func NormalizeImageRef(ref string) (docker.Named, error) {
 | 
			
		||||
	return docker.ParseDockerRef(ref)
 | 
			
		||||
}
 | 
			
		||||
@@ -1,85 +0,0 @@
 | 
			
		||||
/*
 | 
			
		||||
   Copyright The containerd Authors.
 | 
			
		||||
 | 
			
		||||
   Licensed under the Apache License, Version 2.0 (the "License");
 | 
			
		||||
   you may not use this file except in compliance with the License.
 | 
			
		||||
   You may obtain a copy of the License at
 | 
			
		||||
 | 
			
		||||
       http://www.apache.org/licenses/LICENSE-2.0
 | 
			
		||||
 | 
			
		||||
   Unless required by applicable law or agreed to in writing, software
 | 
			
		||||
   distributed under the License is distributed on an "AS IS" BASIS,
 | 
			
		||||
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | 
			
		||||
   See the License for the specific language governing permissions and
 | 
			
		||||
   limitations under the License.
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
package util
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"testing"
 | 
			
		||||
 | 
			
		||||
	"github.com/containerd/containerd/reference"
 | 
			
		||||
	"github.com/stretchr/testify/assert"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func TestNormalizeImageRef(t *testing.T) {
 | 
			
		||||
	for _, test := range []struct {
 | 
			
		||||
		input  string
 | 
			
		||||
		expect string
 | 
			
		||||
	}{
 | 
			
		||||
		{ // has nothing
 | 
			
		||||
			input:  "busybox",
 | 
			
		||||
			expect: "docker.io/library/busybox:latest",
 | 
			
		||||
		},
 | 
			
		||||
		{ // only has tag
 | 
			
		||||
			input:  "busybox:latest",
 | 
			
		||||
			expect: "docker.io/library/busybox:latest",
 | 
			
		||||
		},
 | 
			
		||||
		{ // only has digest
 | 
			
		||||
			input:  "busybox@sha256:e6693c20186f837fc393390135d8a598a96a833917917789d63766cab6c59582",
 | 
			
		||||
			expect: "docker.io/library/busybox@sha256:e6693c20186f837fc393390135d8a598a96a833917917789d63766cab6c59582",
 | 
			
		||||
		},
 | 
			
		||||
		{ // only has path
 | 
			
		||||
			input:  "library/busybox",
 | 
			
		||||
			expect: "docker.io/library/busybox:latest",
 | 
			
		||||
		},
 | 
			
		||||
		{ // only has hostname
 | 
			
		||||
			input:  "docker.io/busybox",
 | 
			
		||||
			expect: "docker.io/library/busybox:latest",
 | 
			
		||||
		},
 | 
			
		||||
		{ // has no tag
 | 
			
		||||
			input:  "docker.io/library/busybox",
 | 
			
		||||
			expect: "docker.io/library/busybox:latest",
 | 
			
		||||
		},
 | 
			
		||||
		{ // has no path
 | 
			
		||||
			input:  "docker.io/busybox:latest",
 | 
			
		||||
			expect: "docker.io/library/busybox:latest",
 | 
			
		||||
		},
 | 
			
		||||
		{ // has no hostname
 | 
			
		||||
			input:  "library/busybox:latest",
 | 
			
		||||
			expect: "docker.io/library/busybox:latest",
 | 
			
		||||
		},
 | 
			
		||||
		{ // full reference
 | 
			
		||||
			input:  "docker.io/library/busybox:latest",
 | 
			
		||||
			expect: "docker.io/library/busybox:latest",
 | 
			
		||||
		},
 | 
			
		||||
		{ // gcr reference
 | 
			
		||||
			input:  "gcr.io/library/busybox",
 | 
			
		||||
			expect: "gcr.io/library/busybox:latest",
 | 
			
		||||
		},
 | 
			
		||||
		{ // both tag and digest
 | 
			
		||||
			input:  "gcr.io/library/busybox:latest@sha256:e6693c20186f837fc393390135d8a598a96a833917917789d63766cab6c59582",
 | 
			
		||||
			expect: "gcr.io/library/busybox@sha256:e6693c20186f837fc393390135d8a598a96a833917917789d63766cab6c59582",
 | 
			
		||||
		},
 | 
			
		||||
	} {
 | 
			
		||||
		t.Run(test.input, func(t *testing.T) {
 | 
			
		||||
			normalized, err := NormalizeImageRef(test.input)
 | 
			
		||||
			assert.NoError(t, err)
 | 
			
		||||
			output := normalized.String()
 | 
			
		||||
			assert.Equal(t, test.expect, output)
 | 
			
		||||
			_, err = reference.Parse(output)
 | 
			
		||||
			assert.NoError(t, err, "%q should be containerd supported reference", output)
 | 
			
		||||
		})
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user