Ability to pre-pull VM images by targeting workers with labels

This commit is contained in:
Nikolay Edigaryev
2025-12-10 20:43:34 +01:00
parent 173a34b083
commit aa36ad4cb6
29 changed files with 1463 additions and 8 deletions
+53
View File
@@ -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
}
+54
View File
@@ -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
}
+7 -1
View File
@@ -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")