Skip to content

Commit

Permalink
Generate import-into-k3s script
Browse files Browse the repository at this point in the history
Signed-off-by: Tamal Saha <[email protected]>
  • Loading branch information
tamalsaha committed Oct 7, 2024
1 parent f76aa1e commit fdfa09c
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions pkg/cmds/scripts.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,40 @@ if [ -z "${IMAGE_REGISTRY}" ]; then
exit 1
fi
TARBALL=${1:-}
tar -zxvf $TARBALL
`)
for _, img := range images {
// crane push images/cluster-ui.tar $IMAGE_REGISTRY/cluster-ui:0.4.16
ref, err := name.ParseReference(img)
if err != nil {
return err
}
if ref.Tag == "" {
return fmt.Errorf("image %s has no tag", img)
}

buf.WriteString("k3s ctr images import")
buf.WriteString(" ")
buf.WriteString("images/" + strings.ReplaceAll(ref.Repository, "/", "-") + "-" + ref.Tag + ".tar")
buf.WriteRune('\n')
}
err = os.WriteFile(filepath.Join(outdir, "import-into-k3s.sh"), buf.Bytes(), 0o755)
if err != nil {
return err
}

buf.Reset()
buf.WriteString(`#!/bin/bash
set -x
if [ -z "${IMAGE_REGISTRY}" ]; then
echo "IMAGE_REGISTRY is not set"
exit 1
fi
OS=$(uname -o)
if [ "${OS}" = "GNU/Linux" ]; then
OS=Linux
Expand Down

0 comments on commit fdfa09c

Please sign in to comment.