| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- package client
- import (
- "context"
- "fmt"
- "github.com/porter-dev/porter/api/types"
- )
- // GetReleaseWebhook retrieves the release webhook for a given release
- func (c *Client) GetReleaseWebhook(
- ctx context.Context,
- projID, clusterID uint,
- name, namespace string,
- ) (*types.PorterRelease, error) {
- resp := &types.PorterRelease{}
- err := c.getRequest(
- fmt.Sprintf(
- "/projects/%d/clusters/%d/namespaces/%s/releases/%s/webhook",
- projID,
- clusterID,
- namespace,
- name,
- ),
- nil,
- resp,
- )
- return resp, err
- }
- // DeployWithWebhook deploys an application with an image tag using a unique webhook URI
- func (c *Client) DeployWithWebhook(
- ctx context.Context,
- webhook string,
- req *types.WebhookRequest,
- ) error {
- return c.postRequest(
- fmt.Sprintf(
- "/webhooks/deploy/%s",
- webhook,
- ),
- req,
- nil,
- )
- }
- // UpdateBatchImage updates all releases that use a certain image with a new tag,
- // within a single namespace
- func (c *Client) UpdateBatchImage(
- ctx context.Context,
- projID, clusterID uint,
- namespace string,
- req *types.UpdateImageBatchRequest,
- ) error {
- return c.postRequest(
- fmt.Sprintf("/projects/%d/clusters/%d/namespaces/%s/releases/image/batch", projID, clusterID, namespace),
- req,
- nil,
- )
- }
- func (c *Client) DeployTemplate(
- ctx context.Context,
- projID, clusterID uint,
- namespace string,
- req *types.CreateReleaseRequest,
- ) error {
- return c.postRequest(
- fmt.Sprintf("/projects/%d/clusters/%d/namespaces/%s/releases", projID, clusterID, namespace),
- req,
- nil,
- )
- }
- func (c *Client) DeployAddon(
- ctx context.Context,
- projID, clusterID uint,
- namespace string,
- req *types.CreateAddonRequest,
- ) error {
- return c.postRequest(
- fmt.Sprintf("/projects/%d/clusters/%d/namespaces/%s/addons", projID, clusterID, namespace),
- req,
- nil,
- )
- }
- // UpgradeRelease upgrades a specific release with new values or chart version
- func (c *Client) UpgradeRelease(
- ctx context.Context,
- projID, clusterID uint,
- namespace, name string,
- req *types.UpgradeReleaseRequest,
- ) error {
- return c.postRequest(
- fmt.Sprintf(
- "/projects/%d/clusters/%d/namespaces/%s/releases/%s/0/upgrade",
- projID, clusterID,
- namespace, name,
- ),
- req,
- nil,
- postRequestOpts{
- retryCount: 3,
- },
- )
- }
- // DeleteRelease deletes a Porter release
- func (c *Client) DeleteRelease(
- ctx context.Context,
- projID, clusterID uint,
- namespace, name string,
- ) error {
- return c.deleteRequest(
- fmt.Sprintf(
- "/projects/%d/clusters/%d/namespaces/%s/releases/%s/0",
- projID, clusterID,
- namespace, name,
- ),
- nil,
- nil,
- )
- }
|