Skip to content

Commit

Permalink
Skip latest tags
Browse files Browse the repository at this point in the history
Signed-off-by: Tamal Saha <[email protected]>
  • Loading branch information
tamalsaha committed Oct 1, 2024
1 parent dbfa0f6 commit 254d7b1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
2 changes: 2 additions & 0 deletions pkg/cmds/gcp_script.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ fi
}
if ref.Tag == "" {
return fmt.Errorf("image %s has no tag", img)
} else if ref.Tag == "latest" {
continue
}

buf.WriteString("crane cp")
Expand Down
15 changes: 10 additions & 5 deletions pkg/cmds/scripts.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ import (
"net/url"
"os"
"path/filepath"
"sort"
"strings"

"kmodules.xyz/go-containerregistry/name"

"github.com/spf13/cobra"
"k8s.io/apimachinery/pkg/util/sets"
"sigs.k8s.io/yaml"
)

Expand Down Expand Up @@ -58,17 +58,16 @@ func NewCmdGenerateScripts() *cobra.Command {
}

func generateImageList(files []string) ([]string, error) {
var images []string
images := sets.Set[string]{}

for _, file := range files {
list, err := readImageList(file)
if err != nil {
return nil, fmt.Errorf("failed to read image list from %s: %w", file, err)
}
images = append(images, list...)
images.Insert(list...)
}
sort.Strings(images)
return images, nil
return sets.List(images), nil
}

func readImageList(file string) ([]string, error) {
Expand Down Expand Up @@ -138,6 +137,8 @@ CMD="./images/crane"
}
if ref.Tag == "" {
return fmt.Errorf("image %s has no tag", img)
} else if ref.Tag == "latest" {
continue
}

buf.WriteString("$CMD pull")
Expand Down Expand Up @@ -186,6 +187,8 @@ CMD="./crane"
}
if ref.Tag == "" {
return fmt.Errorf("image %s has no tag", img)
} else if ref.Tag == "latest" {
continue
}

buf.WriteString("$CMD push")
Expand Down Expand Up @@ -243,6 +246,8 @@ CMD="./crane"
}
if ref.Tag == "" {
return fmt.Errorf("image %s has no tag", img)
} else if ref.Tag == "latest" {
continue
}

buf.WriteString("$CMD cp")
Expand Down

0 comments on commit 254d7b1

Please sign in to comment.