diff --git a/cmd/kk/pkg/images/tasks.go b/cmd/kk/pkg/images/tasks.go index 438da571..afa8651a 100644 --- a/cmd/kk/pkg/images/tasks.go +++ b/cmd/kk/pkg/images/tasks.go @@ -179,7 +179,7 @@ func (s *SaveImages) Execute(runtime connector.Runtime) error { // Ex: // oci:./kubekey/artifact/images:kubesphere:kube-apiserver:v1.21.5-amd64 // oci:./kubekey/artifact/images:kubesphere:kube-apiserver:v1.21.5-arm-v7 - destName := fmt.Sprintf("oci:%s:%s:%s-%s%s", dirName, imageFullName[1], imageFullName[2], arch, variant) + destName := fmt.Sprintf("oci:%s:%s:%s-%s%s", dirName, imageFullName[1], suffixImageName(imageFullName[2:]), arch, variant) logger.Log.Infof("Source: %s", srcName) logger.Log.Infof("Destination: %s", destName) diff --git a/cmd/kk/pkg/images/utils.go b/cmd/kk/pkg/images/utils.go index 72b76733..7e7a3ea6 100644 --- a/cmd/kk/pkg/images/utils.go +++ b/cmd/kk/pkg/images/utils.go @@ -173,11 +173,18 @@ func NewManifestSpec(image string, entries []manifesttypes.ManifestEntry) manife func validateImageName(imageFullName string) error { image := strings.Split(imageFullName, "/") - if len(image) != 3 { - return errors.Errorf("image %s is invalid, only the format \"registry/namespace/name:tag\" is supported", imageFullName) + if len(image) < 3 { + return errors.Errorf("image %s is invalid, image PATH need contain at least two slash-separated", imageFullName) } - if len(strings.Split(image[2], ":")) != 2 { - return errors.Errorf("image %s is invalid, only the format \"registry/namespace/name:tag\" is supported", imageFullName) + if len(strings.Split(image[len(image)-1], ":")) != 2 { + return errors.Errorf(`image %s is invalid, image PATH need contain ":"`, imageFullName) } return nil } + +func suffixImageName(imageFullName []string) string { + if len(imageFullName) >= 2 { + return strings.Join(imageFullName, "/") + } + return imageFullName[0] +}