job.go 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. package cmd
  2. import (
  3. "context"
  4. "os"
  5. "github.com/fatih/color"
  6. "github.com/porter-dev/porter/cli/cmd/api"
  7. "github.com/spf13/cobra"
  8. )
  9. var batchImageUpdateCmd = &cobra.Command{
  10. Use: "update-image",
  11. Short: "Blerp.",
  12. Run: func(cmd *cobra.Command, args []string) {
  13. err := checkLoginAndRun(args, batchImageUpdate)
  14. if err != nil {
  15. os.Exit(1)
  16. }
  17. },
  18. }
  19. var imageRepoURI string
  20. func init() {
  21. rootCmd.AddCommand(batchImageUpdateCmd)
  22. batchImageUpdateCmd.PersistentFlags().StringVar(
  23. &tag,
  24. "tag",
  25. "",
  26. "Tag",
  27. )
  28. batchImageUpdateCmd.MarkPersistentFlagRequired("app")
  29. batchImageUpdateCmd.PersistentFlags().StringVarP(
  30. &imageRepoURI,
  31. "image-repo-uri",
  32. "i",
  33. "",
  34. "Image repo uri",
  35. )
  36. }
  37. func batchImageUpdate(resp *api.AuthCheckResponse, client *api.Client, args []string) error {
  38. color.New(color.FgGreen).Println("Update releases with image:", imageRepoURI)
  39. return client.UpdateBatchImage(
  40. context.TODO(),
  41. config.Project,
  42. config.Cluster,
  43. &api.UpdateBatchImageRequest{
  44. ImageRepoURI: imageRepoURI,
  45. Tag: tag,
  46. },
  47. )
  48. }