67 lines
1.5 KiB
Go
67 lines
1.5 KiB
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"gitea.stuzer.link/stuzer05/docker-registry-manager/cmd"
|
|
"gitea.stuzer.link/stuzer05/docker-registry-manager/internal/app"
|
|
"github.com/joho/godotenv"
|
|
"log"
|
|
"os"
|
|
"path/filepath"
|
|
)
|
|
|
|
func main() {
|
|
// Get executable directory
|
|
exePath, err := os.Executable()
|
|
if err != nil {
|
|
log.Fatal("Error getting executable path:", err)
|
|
}
|
|
exeDir := filepath.Dir(exePath)
|
|
|
|
// Load .env file
|
|
godotenv.Load(filepath.Join(exeDir, ".env"))
|
|
|
|
// Initialize app
|
|
app, err := app.NewApp()
|
|
if err != nil {
|
|
fmt.Println("Error initializing app:", err)
|
|
return
|
|
}
|
|
|
|
if len(os.Args) < 2 {
|
|
fmt.Println("Invalid command. Usage: registry [images|tags|rm|push|tag] <args>")
|
|
return
|
|
}
|
|
|
|
switch os.Args[1] {
|
|
case "images":
|
|
cmd.RegistryImages(app)
|
|
case "tags":
|
|
if len(os.Args) < 3 {
|
|
fmt.Println("Error: Please provide an image name.")
|
|
return
|
|
}
|
|
cmd.RegistryTags(app, os.Args[2])
|
|
case "rm":
|
|
if len(os.Args) < 3 {
|
|
fmt.Println("Error: Please provide an image name and optionally a tag (e.g., my-image or my-image:latest).")
|
|
return
|
|
}
|
|
cmd.RegistryRm(app, os.Args[2])
|
|
case "push":
|
|
if len(os.Args) < 3 {
|
|
fmt.Println("Error: Please provide an image name to push.")
|
|
return
|
|
}
|
|
cmd.RegistryPush(app, os.Args[2])
|
|
case "tag":
|
|
if len(os.Args) < 4 {
|
|
fmt.Println("Error: Please provide both source and target image names.")
|
|
return
|
|
}
|
|
cmd.RegistryTag(app, os.Args[2], os.Args[3])
|
|
default:
|
|
fmt.Println("Invalid command. Usage: registry [images|tags|rm|push|tag] <args>")
|
|
}
|
|
}
|