mirror of
https://github.com/cirruslabs/orchard.git
synced 2026-10-21 02:22:46 +02:00
Ability to pre-pull VM images by targeting workers with labels
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
package list
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/cirruslabs/orchard/pkg/client"
|
||||
"github.com/gosuri/uitable"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
func newListImagePullJobsCommand() *cobra.Command {
|
||||
command := &cobra.Command{
|
||||
Use: "imagepulljobs",
|
||||
Short: "List image pull jobs",
|
||||
RunE: runListImagePullJobs,
|
||||
}
|
||||
|
||||
return command
|
||||
}
|
||||
|
||||
func runListImagePullJobs(cmd *cobra.Command, args []string) error {
|
||||
client, err := client.New()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
imagePullJobs, err := client.ImagePullJobs().List(cmd.Context())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if quiet {
|
||||
for _, imagePullJob := range imagePullJobs {
|
||||
fmt.Println(imagePullJob.Name)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
table := uitable.New()
|
||||
table.Wrap = true
|
||||
|
||||
table.AddRow("Name", "Image", "Labels", "Progressing", "Succeeded", "Failed", "Total")
|
||||
|
||||
for _, imagePullJob := range imagePullJobs {
|
||||
table.AddRow(imagePullJob.Name, imagePullJob.Image, imagePullJob.Labels, imagePullJob.Progressing,
|
||||
imagePullJob.Succeeded, imagePullJob.Failed, imagePullJob.Total)
|
||||
}
|
||||
|
||||
fmt.Println(table)
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package list
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/cirruslabs/orchard/pkg/client"
|
||||
v1 "github.com/cirruslabs/orchard/pkg/resource/v1"
|
||||
"github.com/gosuri/uitable"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
func newListImagePullsCommand() *cobra.Command {
|
||||
command := &cobra.Command{
|
||||
Use: "imagepulls",
|
||||
Short: "List image pulls",
|
||||
RunE: runListImagePulls,
|
||||
}
|
||||
|
||||
return command
|
||||
}
|
||||
|
||||
func runListImagePulls(cmd *cobra.Command, args []string) error {
|
||||
client, err := client.New()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
imagePulls, err := client.ImagePulls().List(cmd.Context())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if quiet {
|
||||
for _, imagePull := range imagePulls {
|
||||
fmt.Println(imagePull.Name)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
table := uitable.New()
|
||||
table.Wrap = true
|
||||
|
||||
table.AddRow("Name", "Image", "Worker", "Conditions")
|
||||
|
||||
for _, imagePullJob := range imagePulls {
|
||||
table.AddRow(imagePullJob.Name, imagePullJob.Image, imagePullJob.Worker,
|
||||
v1.ConditionsHumanize(imagePullJob.Conditions))
|
||||
}
|
||||
|
||||
fmt.Println(table)
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -12,7 +12,13 @@ func NewCommand() *cobra.Command {
|
||||
Short: "List resources on the controller",
|
||||
}
|
||||
|
||||
command.AddCommand(newListWorkersCommand(), newListVMsCommand(), newListServiceAccountsCommand())
|
||||
command.AddCommand(
|
||||
newListWorkersCommand(),
|
||||
newListVMsCommand(),
|
||||
newListServiceAccountsCommand(),
|
||||
newListImagePullsCommand(),
|
||||
newListImagePullJobsCommand(),
|
||||
)
|
||||
|
||||
command.Flags().BoolVarP(&quiet, "", "q", false, "only show resource names")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user