update_image.go 646 B

123456789101112131415161718192021222324252627
  1. package v2
  2. import (
  3. "context"
  4. "errors"
  5. "fmt"
  6. api "github.com/porter-dev/porter/api/client"
  7. )
  8. // UpdateImage updates the image of an application
  9. func UpdateImage(ctx context.Context, tag string, client api.Client, projectId, clusterId uint, appName string, deploymentTargetName string) (string, error) {
  10. if deploymentTargetName == "" {
  11. return "", errors.New("please provide a deployment target")
  12. }
  13. if tag == "" {
  14. tag = "latest"
  15. }
  16. resp, err := client.UpdateImage(ctx, projectId, clusterId, appName, deploymentTargetName, tag)
  17. if err != nil {
  18. return "", fmt.Errorf("unable to update image: %w", err)
  19. }
  20. return resp.Tag, nil
  21. }