mpg

package
v0.5.27 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 4, 2026 License: Apache-2.0 Imports: 14 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
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

func CreateUserError(clusterID string, status int, body []byte) error

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

func HasAPIErrorMessage(body []byte) bool

HasAPIErrorMessage reports whether body is a JSON error in one of the shapes the MPG APIs use.

func NoUserError added in v0.5.27

func NoUserError(clusterID string, status int, body []byte) error

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

func PublicCreateUserError(clusterID string, err error) error

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

func ReadCreateUserError(clusterID string, status int, err error) error

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

func ResponseSnippet(status int, body []byte) string

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

func TransportCreateUserError(clusterID string, err error) error

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

func UserMayExistHint(clusterID string) string

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 AttachedApp struct {
	Name string `json:"name"`
	Id   int64  `json:"id"`
}

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"`
}

type Version

type Version int
const (
	VersionV1 Version = iota
	VersionV2
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL