Files
at-container-registry/cmd/credential-helper/main.go

55 lines
1.3 KiB
Go

package main
import (
"fmt"
"os"
"time"
"github.com/spf13/cobra"
)
var (
version = "dev"
commit = "none"
date = "unknown"
// Update check cache TTL (24 hours)
updateCheckCacheTTL = 24 * time.Hour
)
// timeNow is a variable so tests can override it.
var timeNow = time.Now
func main() {
rootCmd := &cobra.Command{
Use: "docker-credential-atcr",
Short: "ATCR container registry credential helper",
Long: `docker-credential-atcr manages authentication for ATCR-compatible container registries.
It implements the Docker credential helper protocol and provides commands
for managing multiple accounts across multiple registries.`,
Version: fmt.Sprintf("%s (commit: %s, built: %s)", version, commit, date),
SilenceUsage: true,
SilenceErrors: true,
}
// Docker protocol commands (hidden — called by Docker, not users)
rootCmd.AddCommand(newGetCmd())
rootCmd.AddCommand(newStoreCmd())
rootCmd.AddCommand(newEraseCmd())
rootCmd.AddCommand(newListCmd())
// User-facing commands
rootCmd.AddCommand(newLoginCmd())
rootCmd.AddCommand(newLogoutCmd())
rootCmd.AddCommand(newStatusCmd())
rootCmd.AddCommand(newSwitchCmd())
rootCmd.AddCommand(newConfigureDockerCmd())
rootCmd.AddCommand(newUpdateCmd())
if err := rootCmd.Execute(); err != nil {
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
os.Exit(1)
}
}