Single Go binary with five commands: - build: podman build locally with registry tags + git version - push: podman push to MCR - deploy: SSH pull/stop/rm/run on target node - cert renew: issue TLS cert from Metacrypt via REST API - status: show container status on a node Config-driven via TOML service registry describing images, Dockerfiles, container configs per node. Shells out to podman for container operations and ssh for remote access. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
52 lines
1017 B
Go
52 lines
1017 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
func pushCommand() *cobra.Command {
|
|
var imageFlag string
|
|
|
|
cmd := &cobra.Command{
|
|
Use: "push <service>",
|
|
Short: "Push container images to the registry",
|
|
Args: cobra.ExactArgs(1),
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
cfg, err := loadCfg()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
svc, err := cfg.FindService(args[0])
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
images := svc.Images
|
|
if imageFlag != "" {
|
|
images = []string{imageFlag}
|
|
}
|
|
|
|
var pushed []string
|
|
for _, image := range images {
|
|
ref := cfg.ImageRef(image) + ":latest"
|
|
if err := run("podman", "push", ref); err != nil {
|
|
return fmt.Errorf("push %s: %w", image, err)
|
|
}
|
|
pushed = append(pushed, ref)
|
|
}
|
|
|
|
fmt.Printf("\nPushed %d image(s):\n", len(pushed))
|
|
for _, ref := range pushed {
|
|
fmt.Printf(" %s\n", ref)
|
|
}
|
|
return nil
|
|
},
|
|
}
|
|
|
|
cmd.Flags().StringVar(&imageFlag, "image", "", "push only this image")
|
|
return cmd
|
|
}
|