Documentation
¶
Index ¶
- Constants
- func CreateUserError(clusterID string, status int, body []byte) error
- func HasAPIErrorMessage(body []byte) bool
- func NoUserError(clusterID string, status int, body []byte) error
- func PublicCreateUserError(clusterID string, err error) error
- func ReadCreateUserError(clusterID string, status int, err error) error
- func ResponseSnippet(status int, body []byte) string
- func TransportCreateUserError(clusterID string, err error) error
- func UserMayExistHint(clusterID string) string
- type AttachedApp
- type Cluster
- type ManagedClusterIpAssignments
- type Version
Constants ¶
const MaxResponseBody = 1 << 20
MaxResponseBody caps how much of a create user response is read. A user response is a few hundred bytes; anything larger is an error page.
Variables ¶
This section is empty.
Functions ¶
func CreateUserError ¶ added in v0.5.27
CreateUserError describes a create user request that got an unexpected status. Callers wrap it in "failed to create user: ", so it doesn't repeat that. A JSON body's message (errors.detail, error or message) is shown if it has one; otherwise the body itself, shortened by ResponseSnippet, with passwords redacted. When the user may exist anyway, the error says how to check before a retry.
func HasAPIErrorMessage ¶ added in v0.5.27
HasAPIErrorMessage reports whether body is a JSON error in one of the shapes the MPG APIs use.
func NoUserError ¶ added in v0.5.27
NoUserError reports a 2xx create user response that names no user, such as an error body sent with a success status. Given the body, it shows the API's message if there is one. Pass status 0 and no body when the caller can't see the response. The request may have created the user, so it says how to check: reporting success would let attach fall back to the cluster's default credentials, or print a user that doesn't exist.
func PublicCreateUserError ¶ added in v0.5.27
PublicCreateUserError describes a failed create user request to the public Machines API, which v2 clusters try first. An API error gets the same text as CreateUserError: the API's message or a redacted snippet, not the whole body. Any other failure, such as a timeout or a response that couldn't be decoded, may have created the user, so it gets the hint. The result still unwraps to err, so the Request ID is printed and errors.Is works.
func ReadCreateUserError ¶ added in v0.5.27
ReadCreateUserError reports a create user response whose body couldn't be read. Unless the status shows the request was rejected, the user may exist.
func ResponseSnippet ¶ added in v0.5.27
ResponseSnippet returns a short, single-line, printable description of an unexpected response body for an error message: the body with whitespace collapsed and control characters dropped, cut to maxErrorBodyLen bytes, or the status text when nothing is left.
func TransportCreateUserError ¶ added in v0.5.27
TransportCreateUserError describes a create user request that got no response, such as a timeout or a reset connection. The request may have reached the API, so the error says to check before retrying, unless it failed to connect at all.
func UserMayExistHint ¶ added in v0.5.27
UserMayExistHint is appended to create user errors where the request may have succeeded, so a retry doesn't fail with "already exists".
Types ¶
type AttachedApp ¶
type Cluster ¶
type Cluster struct {
Id string
Name string
Region string
Status string
Plan string
Disk int
Replicas int
Organization fly.Organization
IpAssignments ManagedClusterIpAssignments
AttachedApps []AttachedApp
Version Version
}
Unified type for v1 and v2 MPG clusters
type ManagedClusterIpAssignments ¶
type ManagedClusterIpAssignments struct {
Direct string `json:"direct"`
}