environment.go 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. package client
  2. import (
  3. "context"
  4. "fmt"
  5. "github.com/porter-dev/porter/api/types"
  6. )
  7. func (c *Client) CreateDeployment(
  8. ctx context.Context,
  9. projID, gitInstallationID, clusterID uint,
  10. req *types.CreateDeploymentRequest,
  11. ) (*types.Deployment, error) {
  12. resp := &types.Deployment{}
  13. err := c.postRequest(
  14. fmt.Sprintf(
  15. "/projects/%d/gitrepos/%d/clusters/%d/deployment",
  16. projID, gitInstallationID, clusterID,
  17. ),
  18. req,
  19. resp,
  20. )
  21. return resp, err
  22. }
  23. func (c *Client) GetDeployment(
  24. ctx context.Context,
  25. projID, gitInstallationID, clusterID uint,
  26. req *types.GetDeploymentRequest,
  27. ) (*types.Deployment, error) {
  28. resp := &types.Deployment{}
  29. err := c.getRequest(
  30. fmt.Sprintf(
  31. "/projects/%d/gitrepos/%d/clusters/%d/deployment",
  32. projID, gitInstallationID, clusterID,
  33. ),
  34. req,
  35. resp,
  36. )
  37. return resp, err
  38. }
  39. func (c *Client) FinalizeDeployment(
  40. ctx context.Context,
  41. projID, gitInstallationID, clusterID uint,
  42. req *types.FinalizeDeploymentRequest,
  43. ) (*types.Deployment, error) {
  44. resp := &types.Deployment{}
  45. err := c.postRequest(
  46. fmt.Sprintf(
  47. "/projects/%d/gitrepos/%d/clusters/%d/deployment/finalize",
  48. projID, gitInstallationID, clusterID,
  49. ),
  50. req,
  51. resp,
  52. )
  53. return resp, err
  54. }