docker-register-manager/cmd/tag.go

23 lines
501 B
Go

package cmd
import (
"fmt"
"gitea.stuzer.link/stuzer05/docker-registry-manager/internal/app"
"os"
"os/exec"
"strings"
)
func RegistryTag(app *app.App, sourceImage, targetImage string) {
if !strings.HasPrefix(targetImage, app.RegistryName) {
targetImage = app.RegistryName + "/" + targetImage
}
cmd := exec.Command("docker", "tag", sourceImage, targetImage)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
if err := cmd.Run(); err != nil {
fmt.Println("Error tagging image:", err)
}
}