Documentation ¶
Index ¶
- Constants
- func IsRequestError(err error) bool
- type BackupRemoteUploadResponse
- type BackupRequest
- type Client
- type ClientOption
- type InstallationScript
- type OutputLineMatcher
- type Pagination
- type ProcessConfiguration
- type ProcessStopConfiguration
- type RawServerData
- type RequestError
- type RequestErrors
- type Response
- type ServerConfigurationResponse
- type SftpAuthRequest
- type SftpAuthResponse
- type SftpInvalidCredentialsError
Constants ¶
const ( ProcessStopCommand = "command" ProcessStopSignal = "signal" ProcessStopNativeStop = "stop" )
Variables ¶
This section is empty.
Functions ¶
func IsRequestError ¶
Types ¶
type BackupRequest ¶
type Client ¶
type Client interface { GetBackupRemoteUploadURLs(ctx context.Context, backup string, size int64) (BackupRemoteUploadResponse, error) GetInstallationScript(ctx context.Context, uuid string) (InstallationScript, error) GetServerConfiguration(ctx context.Context, uuid string) (ServerConfigurationResponse, error) GetServers(context context.Context, perPage int) ([]RawServerData, error) ResetServersState(ctx context.Context) error SetArchiveStatus(ctx context.Context, uuid string, successful bool) error SetBackupStatus(ctx context.Context, backup string, data BackupRequest) error SendRestorationStatus(ctx context.Context, backup string, successful bool) error SetInstallationStatus(ctx context.Context, uuid string, successful bool) error SetTransferStatus(ctx context.Context, uuid string, successful bool) error ValidateSftpCredentials(ctx context.Context, request SftpAuthRequest) (SftpAuthResponse, error) }
func New ¶
func New(base string, opts ...ClientOption) Client
New returns a new HTTP request client that is used for making authenticated requests to the Panel that this instance is running under.
type ClientOption ¶
type ClientOption func(c *client)
func WithCredentials ¶
func WithCredentials(id, token string) ClientOption
WithCredentials sets the credentials to use when making request to the remote API endpoint.
func WithHttpClient ¶
func WithHttpClient(httpClient *http.Client) ClientOption
WithHttpClient sets the underlying HTTP client instance to use when making requests to the Panel API.
type InstallationScript ¶
type InstallationScript struct { ContainerImage string `json:"container_image"` Entrypoint string `json:"entrypoint"` Script string `json:"script"` }
InstallationScript defines installation script information for a server process. This is used when a server is installed for the first time, and when a server is marked for re-installation.
type OutputLineMatcher ¶
type OutputLineMatcher struct {
// contains filtered or unexported fields
}
func (*OutputLineMatcher) Matches ¶
func (olm *OutputLineMatcher) Matches(s string) bool
Matches determines if a given string "s" matches the given line.
func (*OutputLineMatcher) String ¶
func (olm *OutputLineMatcher) String() string
String returns the matcher's raw comparison string.
func (*OutputLineMatcher) UnmarshalJSON ¶
func (olm *OutputLineMatcher) UnmarshalJSON(data []byte) error
UnmarshalJSON unmarshals the startup lines into individual structs for easier matching abilities.
type Pagination ¶
type ProcessConfiguration ¶
type ProcessConfiguration struct { Startup struct { Done []*OutputLineMatcher `json:"done"` UserInteraction []string `json:"user_interaction"` StripAnsi bool `json:"strip_ansi"` } `json:"startup"` Stop ProcessStopConfiguration `json:"stop"` ConfigurationFiles []parser.ConfigurationFile `json:"configs"` }
ProcessConfiguration defines the process configuration for a given server instance. This sets what Wings is looking for to mark a server as done starting what to do when stopping, and what changes to make to the configuration file for a server.
type ProcessStopConfiguration ¶
ProcessStopConfiguration defines what is used when stopping an instance.
type RawServerData ¶
type RawServerData struct { Uuid string `json:"uuid"` Settings json.RawMessage `json:"settings"` ProcessConfiguration json.RawMessage `json:"process_configuration"` }
RawServerData is a raw response from the API for a server.
type RequestError ¶
type RequestError struct { Code string `json:"code"` Status string `json:"status"` Detail string `json:"detail"` // contains filtered or unexported fields }
func (*RequestError) Error ¶
func (re *RequestError) Error() string
Returns the error response in a string form that can be more easily consumed.
type RequestErrors ¶
type RequestErrors struct {
Errors []RequestError `json:"errors"`
}
type Response ¶
Response is a custom response type that allows for commonly used error handling and response parsing from the Panel API. This just embeds the normal HTTP response from Go and we attach a few helper functions to it.
func (*Response) BindJSON ¶
BindJSON binds a given interface with the data returned in the response. This is a shortcut for calling Read and then manually calling json.Unmarshal on the raw bytes.
func (*Response) Error ¶
Returns the first error message from the API call as a string. The error message will be formatted similar to the below example:
HttpNotFoundException: The requested resource does not exist. (HTTP/404)
func (*Response) HasError ¶
HasError determines if the API call encountered an error. If no request has been made the response will be false. This function will evaluate to true if the response code is anything 300 or higher.
type ServerConfigurationResponse ¶
type ServerConfigurationResponse struct { Settings json.RawMessage `json:"settings"` ProcessConfiguration *ProcessConfiguration `json:"process_configuration"` }
ServerConfigurationResponse holds the server configuration data returned from the Panel. When a server process is started, Wings communicates with the Panel to fetch the latest build information as well as get all of the details needed to parse the given Egg.
This means we do not need to hit Wings each time part of the server is updated, and the Panel serves as the source of truth at all times. This also means if a configuration is accidentally wiped on Wings we can self-recover without too much hassle, so long as Wings is aware of what servers should exist on it.
type SftpAuthRequest ¶
type SftpAuthRequest struct { User string `json:"username"` Pass string `json:"password"` IP string `json:"ip"` SessionID []byte `json:"session_id"` ClientVersion []byte `json:"client_version"` }
SftpAuthRequest defines the request details that are passed along to the Panel when determining if the credentials provided to Wings are valid.
type SftpAuthResponse ¶
type SftpAuthResponse struct { Server string `json:"server"` Token string `json:"token"` Permissions []string `json:"permissions"` }
SftpAuthResponse is returned by the Panel when a pair of SFTP credentials is successfully validated. This will include the specific server that was matched as well as the permissions that are assigned to the authenticated user for the SFTP subsystem.
type SftpInvalidCredentialsError ¶
type SftpInvalidCredentialsError struct { }
func (SftpInvalidCredentialsError) Error ¶
func (ice SftpInvalidCredentialsError) Error() string