stack.go 1012 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. package client
  2. import (
  3. "context"
  4. "fmt"
  5. "github.com/porter-dev/porter/api/types"
  6. )
  7. // CreateStack creates the stack
  8. func (c *Client) CreateStack(
  9. ctx context.Context,
  10. projectID, clusterID uint,
  11. req *types.CreateStackReleaseRequest,
  12. ) error {
  13. return c.postRequest(
  14. fmt.Sprintf(
  15. "/projects/%d/clusters/%d/stacks",
  16. projectID, clusterID,
  17. ),
  18. req,
  19. nil,
  20. )
  21. }
  22. // UpdateStack updates the stack
  23. func (c *Client) UpdateStack(
  24. ctx context.Context,
  25. projectID, clusterID uint,
  26. stackName string,
  27. req *types.CreateStackReleaseRequest,
  28. ) error {
  29. return c.patchRequest(
  30. fmt.Sprintf(
  31. "/projects/%d/clusters/%d/stacks/%s",
  32. projectID, clusterID, stackName,
  33. ),
  34. req,
  35. nil,
  36. )
  37. }
  38. func (c *Client) GetStack(
  39. ctx context.Context,
  40. projectID, clusterID uint,
  41. stackName string,
  42. ) (*types.PorterApp, error) {
  43. resp := &types.PorterApp{}
  44. err := c.getRequest(
  45. fmt.Sprintf(
  46. "/projects/%d/clusters/%d/stacks/%s",
  47. projectID, clusterID, stackName,
  48. ),
  49. nil,
  50. resp,
  51. )
  52. return resp, err
  53. }