stack.go 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. package client
  2. import (
  3. "context"
  4. "fmt"
  5. "github.com/porter-dev/porter/api/types"
  6. )
  7. func (c *Client) GetPorterApp(
  8. ctx context.Context,
  9. projectID, clusterID uint,
  10. stackName string,
  11. ) (*types.PorterApp, error) {
  12. resp := &types.PorterApp{}
  13. err := c.getRequest(
  14. fmt.Sprintf(
  15. "/projects/%d/clusters/%d/stacks/%s",
  16. projectID, clusterID, stackName,
  17. ),
  18. nil,
  19. resp,
  20. )
  21. return resp, err
  22. }
  23. func (c *Client) CreatePorterApp(
  24. ctx context.Context,
  25. projectID, clusterID uint,
  26. name string,
  27. req *types.CreatePorterAppRequest,
  28. ) (*types.PorterApp, error) {
  29. resp := &types.PorterApp{}
  30. err := c.postRequest(
  31. fmt.Sprintf(
  32. "/projects/%d/clusters/%d/stacks/%s",
  33. projectID, clusterID, name,
  34. ),
  35. req,
  36. resp,
  37. )
  38. return resp, err
  39. }
  40. // CreateOrUpdatePorterAppEvent will create a porter app event if one does not exist, or else it will update the existing one if an ID is passed in the object
  41. func (c *Client) CreateOrUpdatePorterAppEvent(
  42. ctx context.Context,
  43. projectID, clusterID uint,
  44. name string,
  45. req *types.CreateOrUpdatePorterAppEventRequest,
  46. ) (types.PorterAppEvent, error) {
  47. resp := &types.PorterAppEvent{}
  48. err := c.postRequest(
  49. fmt.Sprintf(
  50. "/projects/%d/clusters/%d/stacks/%s/events",
  51. projectID, clusterID, name,
  52. ),
  53. req,
  54. resp,
  55. )
  56. return *resp, err
  57. }