deploy.go 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. package client
  2. import (
  3. "context"
  4. "fmt"
  5. "github.com/porter-dev/porter/api/types"
  6. )
  7. // GetReleaseWebhook retrieves the release webhook for a given release
  8. func (c *Client) GetReleaseWebhook(
  9. ctx context.Context,
  10. projID, clusterID uint,
  11. name, namespace string,
  12. ) (*types.PorterRelease, error) {
  13. resp := &types.PorterRelease{}
  14. err := c.getRequest(
  15. fmt.Sprintf(
  16. "/projects/%d/clusters/%d/namespaces/%s/releases/%s/webhook",
  17. projID,
  18. clusterID,
  19. namespace,
  20. name,
  21. ),
  22. nil,
  23. resp,
  24. )
  25. return resp, err
  26. }
  27. // DeployWithWebhook deploys an application with an image tag using a unique webhook URI
  28. func (c *Client) DeployWithWebhook(
  29. ctx context.Context,
  30. webhook string,
  31. req *types.WebhookRequest,
  32. ) error {
  33. return c.postRequest(
  34. fmt.Sprintf(
  35. "/webhooks/deploy/%s",
  36. webhook,
  37. ),
  38. req,
  39. nil,
  40. )
  41. }
  42. // UpdateBatchImage updates all releases that use a certain image with a new tag,
  43. // within a single namespace
  44. func (c *Client) UpdateBatchImage(
  45. ctx context.Context,
  46. projID, clusterID uint,
  47. namespace string,
  48. req *types.UpdateImageBatchRequest,
  49. ) error {
  50. return c.postRequest(
  51. fmt.Sprintf("/projects/%d/clusters/%d/namespaces/%s/releases/image/batch", projID, clusterID, namespace),
  52. req,
  53. nil,
  54. )
  55. }
  56. func (c *Client) DeployTemplate(
  57. ctx context.Context,
  58. projID, clusterID uint,
  59. namespace string,
  60. req *types.CreateReleaseRequest,
  61. ) error {
  62. return c.postRequest(
  63. fmt.Sprintf("/projects/%d/clusters/%d/namespaces/%s/releases", projID, clusterID, namespace),
  64. req,
  65. nil,
  66. )
  67. }
  68. // UpgradeRelease upgrades a specific release with new values or chart version
  69. func (c *Client) UpgradeRelease(
  70. ctx context.Context,
  71. projID, clusterID uint,
  72. namespace, name string,
  73. req *types.UpgradeReleaseRequest,
  74. ) error {
  75. return c.postRequest(
  76. fmt.Sprintf(
  77. "/projects/%d/clusters/%d/namespaces/%s/releases/%s/0/upgrade",
  78. projID, clusterID,
  79. namespace, name,
  80. ),
  81. req,
  82. nil,
  83. )
  84. }