153 lines
3.0 KiB
Go
153 lines
3.0 KiB
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
func main() {
|
|
root := &cobra.Command{
|
|
Use: "mcrctl",
|
|
Short: "Metacircular Container Registry admin CLI",
|
|
}
|
|
|
|
root.AddCommand(statusCmd())
|
|
root.AddCommand(repoCmd())
|
|
root.AddCommand(gcCmd())
|
|
root.AddCommand(policyCmd())
|
|
root.AddCommand(auditCmd())
|
|
root.AddCommand(snapshotCmd())
|
|
|
|
if err := root.Execute(); err != nil {
|
|
os.Exit(1)
|
|
}
|
|
}
|
|
|
|
func statusCmd() *cobra.Command {
|
|
return &cobra.Command{
|
|
Use: "status",
|
|
Short: "Query server health",
|
|
RunE: func(_ *cobra.Command, _ []string) error {
|
|
return fmt.Errorf("not implemented")
|
|
},
|
|
}
|
|
}
|
|
|
|
func repoCmd() *cobra.Command {
|
|
cmd := &cobra.Command{
|
|
Use: "repo",
|
|
Short: "Repository management",
|
|
}
|
|
|
|
cmd.AddCommand(&cobra.Command{
|
|
Use: "list",
|
|
Short: "List repositories",
|
|
RunE: func(_ *cobra.Command, _ []string) error {
|
|
return fmt.Errorf("not implemented")
|
|
},
|
|
})
|
|
|
|
cmd.AddCommand(&cobra.Command{
|
|
Use: "delete [name]",
|
|
Short: "Delete a repository",
|
|
Args: cobra.ExactArgs(1),
|
|
RunE: func(_ *cobra.Command, _ []string) error {
|
|
return fmt.Errorf("not implemented")
|
|
},
|
|
})
|
|
|
|
return cmd
|
|
}
|
|
|
|
func gcCmd() *cobra.Command {
|
|
cmd := &cobra.Command{
|
|
Use: "gc",
|
|
Short: "Trigger garbage collection",
|
|
RunE: func(_ *cobra.Command, _ []string) error {
|
|
return fmt.Errorf("not implemented")
|
|
},
|
|
}
|
|
|
|
cmd.AddCommand(&cobra.Command{
|
|
Use: "status",
|
|
Short: "Check GC status",
|
|
RunE: func(_ *cobra.Command, _ []string) error {
|
|
return fmt.Errorf("not implemented")
|
|
},
|
|
})
|
|
|
|
return cmd
|
|
}
|
|
|
|
func policyCmd() *cobra.Command {
|
|
cmd := &cobra.Command{
|
|
Use: "policy",
|
|
Short: "Policy rule management",
|
|
}
|
|
|
|
cmd.AddCommand(&cobra.Command{
|
|
Use: "list",
|
|
Short: "List policy rules",
|
|
RunE: func(_ *cobra.Command, _ []string) error {
|
|
return fmt.Errorf("not implemented")
|
|
},
|
|
})
|
|
|
|
cmd.AddCommand(&cobra.Command{
|
|
Use: "create",
|
|
Short: "Create a policy rule",
|
|
RunE: func(_ *cobra.Command, _ []string) error {
|
|
return fmt.Errorf("not implemented")
|
|
},
|
|
})
|
|
|
|
cmd.AddCommand(&cobra.Command{
|
|
Use: "update [id]",
|
|
Short: "Update a policy rule",
|
|
Args: cobra.ExactArgs(1),
|
|
RunE: func(_ *cobra.Command, _ []string) error {
|
|
return fmt.Errorf("not implemented")
|
|
},
|
|
})
|
|
|
|
cmd.AddCommand(&cobra.Command{
|
|
Use: "delete [id]",
|
|
Short: "Delete a policy rule",
|
|
Args: cobra.ExactArgs(1),
|
|
RunE: func(_ *cobra.Command, _ []string) error {
|
|
return fmt.Errorf("not implemented")
|
|
},
|
|
})
|
|
|
|
return cmd
|
|
}
|
|
|
|
func auditCmd() *cobra.Command {
|
|
cmd := &cobra.Command{
|
|
Use: "audit",
|
|
Short: "Audit log management",
|
|
}
|
|
|
|
cmd.AddCommand(&cobra.Command{
|
|
Use: "tail",
|
|
Short: "Print recent audit events",
|
|
RunE: func(_ *cobra.Command, _ []string) error {
|
|
return fmt.Errorf("not implemented")
|
|
},
|
|
})
|
|
|
|
return cmd
|
|
}
|
|
|
|
func snapshotCmd() *cobra.Command {
|
|
return &cobra.Command{
|
|
Use: "snapshot",
|
|
Short: "Trigger database backup via VACUUM INTO",
|
|
RunE: func(_ *cobra.Command, _ []string) error {
|
|
return fmt.Errorf("not implemented")
|
|
},
|
|
}
|
|
}
|