Documentation
¶
Index ¶
- Constants
- func FromCPU(n int64) *resource.Quantity
- func FromGibibytes(n int64) *resource.Quantity
- func ManagedInstallationReconciler(m manager.Manager, newClient func() *Client) error
- func ToGibibytes(q resource.Quantity) int64
- type AuthObject
- type Client
- func (c *Client) CreateAuthObject(ctx context.Context, authn AuthObject) (AuthObject, error)
- func (c *Client) CreateCluster(ctx context.Context, apiKey string, ...) (*ClusterApiResource, error)
- func (c *Client) CreateInstallation(ctx context.Context) (Installation, error)
- func (c *Client) DeleteCluster(ctx context.Context, apiKey, id string) (*ClusterApiResource, bool, error)
- func (c *Client) GetCluster(ctx context.Context, apiKey, id string) (*ClusterApiResource, error)
- func (c *Client) GetClusterRole(ctx context.Context, apiKey, clusterId, roleName string) (*ClusterRoleApiResource, error)
- func (c *Client) GetClusterStatus(ctx context.Context, apiKey, id string) (*ClusterStatusApiResource, error)
- func (c *Client) GetClusterUpgrade(ctx context.Context, apiKey, id string) (*ClusterUpgradeApiResource, error)
- func (c *Client) ListClusterRoles(ctx context.Context, apiKey, id string) ([]*ClusterRoleApiResource, error)
- func (c *Client) ListClusters(ctx context.Context, apiKey, teamId string) ([]*ClusterApiResource, error)
- func (c *Client) UpdateCluster(ctx context.Context, apiKey, id string, ...) (*ClusterApiResource, error)
- func (c *Client) UpgradeCluster(ctx context.Context, apiKey, id string, ...) (*ClusterUpgradeApiResource, error)
- func (c *Client) UpgradeClusterHA(ctx context.Context, apiKey, id, action string) (*ClusterUpgradeApiResource, error)
- type ClientInterface
- type ClusterApiResource
- type ClusterDiskUsageApiResource
- type ClusterGroupApiResource
- type ClusterList
- type ClusterRoleApiResource
- type ClusterRoleList
- type ClusterStatusApiResource
- type ClusterUpgradeApiResource
- type ClusterUpgradeOperationApiResource
- type Installation
- type InstallationReconciler
- type PatchClustersRequestPayload
- type PostClustersRequestPayload
- type PostClustersUpgradeRequestPayload
- type PutClustersUpgradeRequestPayload
Constants ¶
const ( KeyBridgeLocalTime = "bridge-local-time" KeyBridgeToken = "bridge-token" )
Variables ¶
This section is empty.
Functions ¶
func FromGibibytes ¶
FromGibibytes returns n gibibytes as a resource.Quantity.
func ManagedInstallationReconciler ¶
ManagedInstallationReconciler creates an InstallationReconciler and adds it to m.
func ToGibibytes ¶
ToGibibytes returns q rounded up to a non-negative gibibyte.
Types ¶
type AuthObject ¶
type Client ¶
func NewClient ¶
NewClient creates a Client with backoff settings that amount to ~10 attempts over ~2 minutes. A default is used when apiURL is not an acceptable URL.
func (*Client) CreateAuthObject ¶
func (c *Client) CreateAuthObject(ctx context.Context, authn AuthObject) (AuthObject, error)
func (*Client) CreateCluster ¶
func (c *Client) CreateCluster( ctx context.Context, apiKey string, clusterRequestPayload *PostClustersRequestPayload, ) (*ClusterApiResource, error)
CreateCluster makes a POST request to the "/clusters" endpoint thereby creating a cluster in Bridge with the settings specified in the request payload.
func (*Client) CreateInstallation ¶
func (c *Client) CreateInstallation(ctx context.Context) (Installation, error)
func (*Client) DeleteCluster ¶
func (c *Client) DeleteCluster(ctx context.Context, apiKey, id string) (*ClusterApiResource, bool, error)
DeleteCluster calls the delete endpoint, returning
the cluster, whether the cluster is deleted already, and an error.
func (*Client) GetCluster ¶
GetCluster makes a GET request to the "/clusters/<id>" endpoint, thereby retrieving details for a given cluster in Bridge specified by the provided cluster id.
func (*Client) GetClusterRole ¶
func (c *Client) GetClusterRole(ctx context.Context, apiKey, clusterId, roleName string) (*ClusterRoleApiResource, error)
GetClusterRole sends a GET request to the "/clusters/<id>/roles/<roleName>" endpoint, thereby retrieving Role information for a specific role from a specific cluster in Bridge.
func (*Client) GetClusterStatus ¶
func (c *Client) GetClusterStatus(ctx context.Context, apiKey, id string) (*ClusterStatusApiResource, error)
GetClusterStatus makes a GET request to the "/clusters/<id>/status" endpoint, thereby retrieving details for a given cluster's status in Bridge, specified by the provided cluster id.
func (*Client) GetClusterUpgrade ¶
func (c *Client) GetClusterUpgrade(ctx context.Context, apiKey, id string) (*ClusterUpgradeApiResource, error)
GetClusterUpgrade makes a GET request to the "/clusters/<id>/upgrade" endpoint, thereby retrieving details for a given cluster's upgrade status in Bridge, specified by the provided cluster id.
func (*Client) ListClusterRoles ¶
func (c *Client) ListClusterRoles(ctx context.Context, apiKey, id string) ([]*ClusterRoleApiResource, error)
ListClusterRoles sends a GET request to the "/clusters/<id>/roles" endpoint thereby retrieving a list of all cluster roles for a specific cluster in Bridge.
func (*Client) ListClusters ¶
func (c *Client) ListClusters(ctx context.Context, apiKey, teamId string) ([]*ClusterApiResource, error)
ListClusters makes a GET request to the "/clusters" endpoint to retrieve a list of all clusters in Bridge that are owned by the team specified by the provided team id.
func (*Client) UpdateCluster ¶
func (c *Client) UpdateCluster( ctx context.Context, apiKey, id string, clusterRequestPayload *PatchClustersRequestPayload, ) (*ClusterApiResource, error)
UpdateCluster makes a PATCH request to the "/clusters/<id>" endpoint, thereby attempting to update certain settings for a given cluster in Bridge.
func (*Client) UpgradeCluster ¶
func (c *Client) UpgradeCluster( ctx context.Context, apiKey, id string, clusterRequestPayload *PostClustersUpgradeRequestPayload, ) (*ClusterUpgradeApiResource, error)
UpgradeCluster makes a POST request to the "/clusters/<id>/upgrade" endpoint, thereby attempting to upgrade certain settings for a given cluster in Bridge.
func (*Client) UpgradeClusterHA ¶
func (c *Client) UpgradeClusterHA(ctx context.Context, apiKey, id, action string) (*ClusterUpgradeApiResource, error)
UpgradeClusterHA makes a PUT request to the "/clusters/<id>/actions/<action>" endpoint, where <action> is either "enable-ha" or "disable-ha", thereby attempting to change the HA setting for a given cluster in Bridge.
type ClientInterface ¶
type ClientInterface interface {
ListClusters(ctx context.Context, apiKey, teamId string) ([]*ClusterApiResource, error)
CreateCluster(ctx context.Context, apiKey string, clusterRequestPayload *PostClustersRequestPayload) (*ClusterApiResource, error)
DeleteCluster(ctx context.Context, apiKey, id string) (*ClusterApiResource, bool, error)
GetCluster(ctx context.Context, apiKey, id string) (*ClusterApiResource, error)
GetClusterStatus(ctx context.Context, apiKey, id string) (*ClusterStatusApiResource, error)
GetClusterUpgrade(ctx context.Context, apiKey, id string) (*ClusterUpgradeApiResource, error)
UpgradeCluster(ctx context.Context, apiKey, id string, clusterRequestPayload *PostClustersUpgradeRequestPayload) (*ClusterUpgradeApiResource, error)
UpgradeClusterHA(ctx context.Context, apiKey, id, action string) (*ClusterUpgradeApiResource, error)
UpdateCluster(ctx context.Context, apiKey, id string, clusterRequestPayload *PatchClustersRequestPayload) (*ClusterApiResource, error)
GetClusterRole(ctx context.Context, apiKey, clusterId, roleName string) (*ClusterRoleApiResource, error)
}
type ClusterApiResource ¶
type ClusterApiResource struct {
ID string `json:"id,omitempty"`
ClusterGroup *ClusterGroupApiResource `json:"cluster_group,omitempty"`
PrimaryClusterID string `json:"cluster_id,omitempty"`
CPU int64 `json:"cpu,omitempty"`
CreatedAt string `json:"created_at,omitempty"`
DiskUsage *ClusterDiskUsageApiResource `json:"disk_usage,omitempty"`
Environment string `json:"environment,omitempty"`
Host string `json:"host,omitempty"`
IsHA *bool `json:"is_ha,omitempty"`
IsProtected *bool `json:"is_protected,omitempty"`
IsSuspended *bool `json:"is_suspended,omitempty"`
Keychain string `json:"keychain_id,omitempty"`
MaintenanceWindowStart int64 `json:"maintenance_window_start,omitempty"`
MajorVersion int `json:"major_version,omitempty"`
Memory float64 `json:"memory,omitempty"`
ClusterName string `json:"name,omitempty"`
Network string `json:"network_id,omitempty"`
Parent string `json:"parent_id,omitempty"`
Plan string `json:"plan_id,omitempty"`
PostgresVersion intstr.IntOrString `json:"postgres_version_id,omitempty"`
Provider string `json:"provider_id,omitempty"`
Region string `json:"region_id,omitempty"`
Replicas []*ClusterApiResource `json:"replicas,omitempty"`
Storage int64 `json:"storage,omitempty"`
Tailscale *bool `json:"tailscale_active,omitempty"`
Team string `json:"team_id,omitempty"`
LastUpdate string `json:"updated_at,omitempty"`
ResponsePayload v1beta1.SchemalessObject `json:""`
}
ClusterApiResource is used to hold cluster information received in Bridge API response.
func (*ClusterApiResource) AddDataToClusterStatus ¶
func (c *ClusterApiResource) AddDataToClusterStatus(cluster *v1beta1.CrunchyBridgeCluster)
type ClusterDiskUsageApiResource ¶
type ClusterDiskUsageApiResource struct {
DiskAvailableMB int64 `json:"disk_available_mb,omitempty"`
DiskTotalSizeMB int64 `json:"disk_total_size_mb,omitempty"`
DiskUsedMB int64 `json:"disk_used_mb,omitempty"`
}
ClusterDiskUsageApiResource hold information on disk usage for a particular cluster.
type ClusterGroupApiResource ¶
type ClusterGroupApiResource struct {
ID string `json:"id,omitempty"`
Clusters []*ClusterApiResource `json:"clusters,omitempty"`
Kind string `json:"kind,omitempty"`
Name string `json:"name,omitempty"`
Network string `json:"network_id,omitempty"`
Provider string `json:"provider_id,omitempty"`
Region string `json:"region_id,omitempty"`
Team string `json:"team_id,omitempty"`
}
ClusterGroupApiResource holds information on a ClusterGroup
type ClusterList ¶
type ClusterList struct {
Clusters []*ClusterApiResource `json:"clusters"`
}
type ClusterRoleApiResource ¶
type ClusterRoleApiResource struct {
AccountEmail string `json:"account_email"`
AccountId string `json:"account_id"`
ClusterId string `json:"cluster_id"`
Flavor string `json:"flavor"`
Name string `json:"name"`
Password string `json:"password"`
Team string `json:"team_id"`
URI string `json:"uri"`
}
ClusterRoleApiResource is used for retrieving details on ClusterRole from the Bridge API
type ClusterRoleList ¶
type ClusterRoleList struct {
Roles []*ClusterRoleApiResource `json:"roles"`
}
ClusterRoleList holds a slice of ClusterRoleApiResource
type ClusterStatusApiResource ¶
type ClusterStatusApiResource struct {
DiskUsage *ClusterDiskUsageApiResource `json:"disk_usage,omitempty"`
OldestBackup string `json:"oldest_backup_at,omitempty"`
OngoingUpgrade *ClusterUpgradeApiResource `json:"ongoing_upgrade,omitempty"`
State string `json:"state,omitempty"`
ResponsePayload v1beta1.SchemalessObject `json:""`
}
func (*ClusterStatusApiResource) AddDataToClusterStatus ¶
func (c *ClusterStatusApiResource) AddDataToClusterStatus(cluster *v1beta1.CrunchyBridgeCluster)
type ClusterUpgradeApiResource ¶
type ClusterUpgradeApiResource struct {
ClusterID string `json:"cluster_id,omitempty"`
Operations []*v1beta1.UpgradeOperation `json:"operations,omitempty"`
Team string `json:"team_id,omitempty"`
ResponsePayload v1beta1.SchemalessObject `json:""`
}
func (*ClusterUpgradeApiResource) AddDataToClusterStatus ¶
func (c *ClusterUpgradeApiResource) AddDataToClusterStatus(cluster *v1beta1.CrunchyBridgeCluster)
type Installation ¶
type Installation struct {
ID string `json:"id"`
AuthObject AuthObject `json:"auth_object"`
}
type InstallationReconciler ¶
type InstallationReconciler struct {
Owner client.FieldOwner
Reader interface {
Get(context.Context, client.ObjectKey, client.Object, ...client.GetOption) error
}
Writer interface {
Patch(context.Context, client.Object, client.Patch, ...client.PatchOption) error
}
// Refresh is the frequency at which AuthObjects should be renewed.
Refresh time.Duration
// SecretRef is the name of the corev1.Secret in which to store Bridge tokens.
SecretRef client.ObjectKey
// NewClient is called each time a new Client is needed.
NewClient func() *Client
}
type PatchClustersRequestPayload ¶
type PatchClustersRequestPayload struct {
ClusterGroup string `json:"cluster_group_id,omitempty"`
// DashboardSettings *ClusterDashboardSettings `json:"dashboard_settings,omitempty"`
// TODO (dsessler7): Find docs for DashboardSettings and create appropriate struct
Environment string `json:"environment,omitempty"`
IsProtected *bool `json:"is_protected,omitempty"`
MaintenanceWindowStart int64 `json:"maintenance_window_start,omitempty"`
Name string `json:"name,omitempty"`
}
PatchClustersRequestPayload is used for updating various properties of an existing cluster.
type PostClustersRequestPayload ¶
type PostClustersRequestPayload struct {
Name string `json:"name"`
Plan string `json:"plan_id"`
Team string `json:"team_id"`
ClusterGroup string `json:"cluster_group_id,omitempty"`
Environment string `json:"environment,omitempty"`
IsHA bool `json:"is_ha,omitempty"`
Keychain string `json:"keychain_id,omitempty"`
Network string `json:"network_id,omitempty"`
PostgresVersion intstr.IntOrString `json:"postgres_version_id,omitempty"`
Provider string `json:"provider_id,omitempty"`
Region string `json:"region_id,omitempty"`
Storage int64 `json:"storage,omitempty"`
}
PostClustersRequestPayload is used for creating a new cluster.
type PostClustersUpgradeRequestPayload ¶
type PostClustersUpgradeRequestPayload struct {
Plan string `json:"plan_id,omitempty"`
PostgresVersion intstr.IntOrString `json:"postgres_version_id,omitempty"`
UpgradeStartTime string `json:"starting_from,omitempty"`
Storage int64 `json:"storage,omitempty"`
}
PostClustersUpgradeRequestPayload is used for creating a new cluster upgrade which may include changing its plan, upgrading its major version, or increasing its storage size.
type PutClustersUpgradeRequestPayload ¶
type PutClustersUpgradeRequestPayload struct {
Plan string `json:"plan_id,omitempty"`
PostgresVersion intstr.IntOrString `json:"postgres_version_id,omitempty"`
UpgradeStartTime string `json:"starting_from,omitempty"`
Storage int64 `json:"storage,omitempty"`
UseMaintenanceWindow *bool `json:"use_cluster_maintenance_window,omitempty"`
}
PutClustersUpgradeRequestPayload is used for updating an ongoing or scheduled upgrade. TODO: Implement the ability to update an upgrade (this isn't currently being used)