cloud

package
v0.8.9 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: MPL-2.0 Imports: 51 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// SatelliteStatusOperational indicates an on satellite that is ready to accept connections.
	SatelliteStatusOperational = "Operational"
	// SatelliteStatusSleep indicates a satellite that is in a sleep state.
	SatelliteStatusSleep = "Sleeping"
	// SatelliteStatusStarting indicates a satellite that is waking from a sleep state.
	SatelliteStatusStarting = "Starting"
	// SatelliteStatusStopping indicates a new satellite that is currently going to sleep.
	SatelliteStatusStopping = "Stopping"
	// SatelliteStatusCreating indicates a new satellite that is currently being launched.
	SatelliteStatusCreating = "Creating"
	// SatelliteStatusUpdating indicates a satellite that is upgrading to a new version, either manually or via maintenance window.
	SatelliteStatusUpdating = "Updating"
	// SatelliteStatusFailed indicates a satellite that has crashed and cannot be used.
	SatelliteStatusFailed = "Failed"
	// SatelliteStatusDestroying indicates a satellite that is actively being deleted.
	SatelliteStatusDestroying = "Destroying"
	// SatelliteStatusOffline indicates a satellite that has been stopped and will not be woken up normally via build.
	SatelliteStatusOffline = "Offline"
	// SatelliteStatusUnknown is used when an unexpected satellite status is returned by the server.
	SatelliteStatusUnknown = "Unknown"
)
View Source
const (
	SatelliteSizeXSmall  = "xsmall"
	SatelliteSizeSmall   = "small"
	SatelliteSizeMedium  = "medium"
	SatelliteSizeLarge   = "large"
	SatelliteSizeXLarge  = "xlarge"
	SatelliteSize2XLarge = "2xlarge"
	SatelliteSize3XLarge = "3xlarge"
	SatelliteSize4XLarge = "4xlarge"
)
View Source
const (
	SatellitePlatformAMD64 = "linux/amd64"
	SatellitePlatformARM64 = "linux/arm64"
)
View Source
const DefaultSatelliteSize = SatelliteSizeMedium

Variables

View Source
var (
	// ErrUnauthorized occurs when a user is unauthorized to access a resource
	ErrUnauthorized     = errors.New("unauthorized")
	ErrAuthTokenExpired = errors.New("auth token expired")
	// ErrNoAuthorizedPublicKeys occurs when no authorized public keys are found
	ErrNoAuthorizedPublicKeys = errors.New("no authorized public keys found")
	ErrNotFound               = errors.Errorf("not found")
	ErrMalformedSecretPath    = errors.Errorf("malformed secret path")
)
View Source
var ErrNoSSHAgent = errors.Errorf("no ssh auth agent socket")

ErrNoSSHAgent occurs when no ssh auth agent exists

View Source
var RPCErrRegex = regexp.MustCompile(`(?U)rpc error: code = .+ desc = `)

Functions

func IsValidEmail

func IsValidEmail(ctx context.Context, email string) bool

IsValidEmail returns true if email is valid

func LocalMaintenanceWindowToUTC added in v0.7.0

func LocalMaintenanceWindowToUTC(window string, loc *time.Location) (string, error)

LocalMaintenanceWindowToUTC checks if the provided maintenance window is valid and returns a new maintenance window converted from local time to UTC format.

func UTCMaintenanceWindowToLocal added in v0.7.0

func UTCMaintenanceWindowToLocal(window string, loc *time.Location) (string, error)

UTCMaintenanceWindowToLocal checks if the provided maintenance window is valid and returns a new maintenance window converted from local time to UTC format.

func ValidSatellitePlatform added in v0.7.0

func ValidSatellitePlatform(size string) bool

func ValidSatelliteSize added in v0.7.0

func ValidSatelliteSize(size string) bool

Types

type AuthMethod added in v0.7.13

type AuthMethod string
const (
	AuthMethodSSH       AuthMethod = "ssh"
	AuthMethodPassword  AuthMethod = "password"
	AuthMethodToken     AuthMethod = "token"
	AuthMethodCachedJWT AuthMethod = "cached jwt"
)

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(httpAddr, grpcAddr string, useInsecure bool, agentSockPath, authCredsOverride,
	authJWTOverride, installationName, requestID string, warnFunc func(string, ...interface{}),
	debugFunc func(string, ...interface{}), serverConnTimeout time.Duration, opts ...ClientOpt) (*Client, error)

NewClient provides a new Earthly Cloud client

func (*Client) AcceptInvite added in v0.6.21

func (c *Client) AcceptInvite(ctx context.Context, inviteCode string) error

AcceptInvite accepts the org invitation and adds the user to the org.

func (*Client) AccountReset added in v0.6.21

func (c *Client) AccountReset(ctx context.Context, email, token, password string) error

func (*Client) AccountResetRequestToken added in v0.6.29

func (c *Client) AccountResetRequestToken(ctx context.Context, email string) error

func (*Client) AddProjectMember added in v0.6.20

func (c *Client) AddProjectMember(ctx context.Context, orgName, name, userEmail, permission string) error

AddProjectMember adds a new member to the project by email or user ID.

func (*Client) AddPublicKey added in v0.6.27

func (c *Client) AddPublicKey(ctx context.Context, key string) error

func (*Client) Authenticate

func (c *Client) Authenticate(ctx context.Context) (AuthMethod, error)

Authenticate fetches a new auth token from the server and saves it to the client. The user should have credentials store on disk within the ~/.earthly directory. Credentials may be either email/password, ssh-based, or a custom token. Upon successful authenticate, the JWT provided by the server is stored in ~/.earthly/auth.jwt, and can be refreshed any time via another call to Authenticate().

func (*Client) AutoSkipAdd added in v0.7.6

func (c *Client) AutoSkipAdd(ctx context.Context, org, path, target string, hash []byte) error

func (*Client) AutoSkipExists added in v0.7.6

func (c *Client) AutoSkipExists(ctx context.Context, org string, hash []byte) (bool, error)

func (*Client) AutoSkipPrune added in v0.7.23

func (c *Client) AutoSkipPrune(ctx context.Context, org, pathPrefix, target string, deep bool) (int, error)

func (*Client) CreateAccount

func (c *Client) CreateAccount(ctx context.Context, email, verificationToken, password, publicKey string, termsConditionsPrivacy bool) error

func (*Client) CreateOrg

func (c *Client) CreateOrg(ctx context.Context, org string) error

CreateOrg creates a new org by name.

func (*Client) CreateProject added in v0.6.20

func (c *Client) CreateProject(ctx context.Context, name, orgName string) (*Project, error)

CreateProject creates a new project within the specified organization.

func (*Client) CreateToken

func (c *Client) CreateToken(ctx context.Context, name string, write bool, expiry *time.Time, overWrite bool) (string, error)

func (*Client) DeleteAuthCache

func (c *Client) DeleteAuthCache(ctx context.Context) error

func (*Client) DeleteCachedToken

func (c *Client) DeleteCachedToken(ctx context.Context) error

func (*Client) DeleteProject added in v0.6.20

func (c *Client) DeleteProject(ctx context.Context, orgName, name string) error

DeleteProject deletes a given project by name.

func (*Client) DeleteSatellite added in v0.6.16

func (c *Client) DeleteSatellite(ctx context.Context, name, orgName string, force bool) error

func (*Client) DisableAutoLogin added in v0.7.9

func (c *Client) DisableAutoLogin(ctx context.Context) error

func (*Client) DisableSSHKeyGuessing

func (c *Client) DisableSSHKeyGuessing(ctx context.Context)

func (*Client) EnableAutoLogin added in v0.7.9

func (c *Client) EnableAutoLogin(ctx context.Context) error

func (*Client) FindSSHCredentials

func (c *Client) FindSSHCredentials(ctx context.Context, emailToFind string) error

func (*Client) Get

func (c *Client) Get(ctx context.Context, path string) ([]byte, error)

func (*Client) GetAuthToken

func (c *Client) GetAuthToken(ctx context.Context) (string, error)

func (*Client) GetBillingPlan added in v0.7.22

func (c *Client) GetBillingPlan(ctx context.Context, org string) (*billing.GetBillingPlanResponse, error)

func (*Client) GetOrgID added in v0.6.16

func (c *Client) GetOrgID(ctx context.Context, orgName string) (string, error)

GetOrgID retrieves the org ID for a named org.

func (*Client) GetProject added in v0.6.20

func (c *Client) GetProject(ctx context.Context, orgName, name string) (*Project, error)

GetProject loads a single project from the projects endpoint.

func (*Client) GetProjectSecret added in v0.7.0

func (c *Client) GetProjectSecret(ctx context.Context, org, project, secretName string) (*Secret, error)

GetProjectSecret gets a secret from a project secret store

func (*Client) GetPublicKeys

func (c *Client) GetPublicKeys(ctx context.Context) ([]*agent.Key, error)

func (*Client) GetSatellite added in v0.6.16

func (c *Client) GetSatellite(ctx context.Context, name, orgName string) (*SatelliteInstance, error)

func (*Client) GetUserOrProjectSecret added in v0.7.0

func (c *Client) GetUserOrProjectSecret(ctx context.Context, path string) (*Secret, error)

GetUserOrProjectSecret gets a secret from a project or the current user's personal secret store, depending on the path being structured as /org/project/... or /user/... respectively.

func (*Client) GetUserSecret added in v0.7.0

func (c *Client) GetUserSecret(ctx context.Context, secretName string) (*Secret, error)

GetUserSecret gets a secret from the current user's personal secret store

func (*Client) GuessOrgMembership added in v0.7.9

func (c *Client) GuessOrgMembership(ctx context.Context) (orgName, orgID string, err error)

GuessOrgMembership returns an org name and ID if the user belongs to a single org Deprecated: we should stop "guessing" org membership and have the user always specify they want to use. A future `org select` command would make specifying the org easier.

func (*Client) Invite

func (c *Client) Invite(ctx context.Context, path, user string, write bool) error

Invite a user to an org.

func (*Client) InviteToOrg added in v0.6.20

func (c *Client) InviteToOrg(ctx context.Context, invite *OrgInvitation) (string, error)

InviteToOrg sends an email invitation to a user and asks for them to join an org.

func (*Client) IsAutoLoginPermitted added in v0.7.9

func (c *Client) IsAutoLoginPermitted(ctx context.Context) (bool, error)

func (*Client) IsLoggedIn

func (c *Client) IsLoggedIn(ctx context.Context) bool

func (*Client) LaunchSatellite added in v0.6.16

func (c *Client) LaunchSatellite(ctx context.Context, opt LaunchSatelliteOpt) error

func (*Client) List

func (c *Client) List(ctx context.Context, path string) ([]string, error)

func (*Client) ListInvites added in v0.6.24

func (c *Client) ListInvites(ctx context.Context, org string) ([]*OrgInvitation, error)

ListInvites returns a collection of organization invites and their status.

func (*Client) ListOrgMembers added in v0.6.21

func (c *Client) ListOrgMembers(ctx context.Context, orgName string) ([]*OrgMember, error)

ListOrgMembers returns a collection of org members.

func (*Client) ListOrgPermissions

func (c *Client) ListOrgPermissions(ctx context.Context, path string) ([]*OrgPermissions, error)

ListOrgPermissions returns all configured permissions for the org.

func (*Client) ListOrgs

func (c *Client) ListOrgs(ctx context.Context) ([]*OrgDetail, error)

ListOrgs lists all orgs a user has permission to view.

func (*Client) ListPipelines added in v0.7.3

func (c *Client) ListPipelines(ctx context.Context, project, org, earthfileHash string) ([]Pipeline, error)

func (*Client) ListProjectMembers added in v0.6.20

func (c *Client) ListProjectMembers(ctx context.Context, orgName, name string) ([]*ProjectMember, error)

ListProjectMembers will return all project members if the user has permission to do so.

func (*Client) ListProjects added in v0.6.20

func (c *Client) ListProjects(ctx context.Context, orgName string) ([]*Project, error)

ListProjects returns all projects in the organization that are visible to the logged-in user.

func (*Client) ListPublicKeys

func (c *Client) ListPublicKeys(ctx context.Context) ([]string, error)

func (*Client) ListSatellites added in v0.6.16

func (c *Client) ListSatellites(ctx context.Context, orgName string, includeHidden bool) ([]SatelliteInstance, error)

func (*Client) ListSecretPermissions added in v0.6.20

func (c *Client) ListSecretPermissions(ctx context.Context, path string) ([]*SecretPermission, error)

ListSecretPermissions returns a set of user permissions for project secrets.

func (*Client) ListSecrets added in v0.6.20

func (c *Client) ListSecrets(ctx context.Context, path string) ([]*Secret, error)

ListSecrets returns a list of secrets base on the given path.

func (*Client) ListTokens

func (c *Client) ListTokens(ctx context.Context) ([]*TokenDetail, error)

func (*Client) RegisterEmail

func (c *Client) RegisterEmail(ctx context.Context, email string) error

func (*Client) Remove

func (c *Client) Remove(ctx context.Context, path string) error

func (*Client) RemoveOrgMember added in v0.6.21

func (c *Client) RemoveOrgMember(ctx context.Context, orgName, userEmail string) error

RemoveOrgMember removes a member from the org.

func (*Client) RemoveProjectMember added in v0.6.20

func (c *Client) RemoveProjectMember(ctx context.Context, orgName, name, userEmail string) error

RemoveProjectMember will remove a member from a project.

func (*Client) RemovePublicKey added in v0.6.27

func (c *Client) RemovePublicKey(ctx context.Context, key string) error

func (*Client) RemoveSecret added in v0.6.20

func (c *Client) RemoveSecret(ctx context.Context, path string) error

RemoveSecret deletes a secret by path name.

func (*Client) RemoveSecretPermission added in v0.6.20

func (c *Client) RemoveSecretPermission(ctx context.Context, path, userEmail string) error

RemoveSecretPermission removes a secret permission for the user and path.

func (*Client) RemoveToken

func (c *Client) RemoveToken(ctx context.Context, name string) error

func (*Client) ReserveSatellite added in v0.6.24

func (c *Client) ReserveSatellite(ctx context.Context, name, orgName, gitAuthor, gitConfigEmail string, isCI bool) (out chan SatelliteStatusUpdate)

func (*Client) RevokePermission

func (c *Client) RevokePermission(ctx context.Context, path, user string) error

RevokePermission removes the org permission from the user.

func (*Client) SendAnalytics

func (c *Client) SendAnalytics(ctx context.Context, data *analytics.SendAnalyticsRequest) error

SendAnalytics send an analytics event to the Cloud server.

func (*Client) Set

func (c *Client) Set(ctx context.Context, path string, data []byte) error

func (*Client) SetAuthTokenDir

func (c *Client) SetAuthTokenDir(ctx context.Context, path string)

func (*Client) SetGithubToken added in v0.8.8

func (c *Client) SetGithubToken(ctx context.Context, orgName string, ghOrg string, ghRepo string, token string) error

func (*Client) SetPasswordCredentials

func (c *Client) SetPasswordCredentials(ctx context.Context, email, password string) error

func (*Client) SetSSHCredentials

func (c *Client) SetSSHCredentials(ctx context.Context, email, sshKey string) error

func (*Client) SetSecret added in v0.6.20

func (c *Client) SetSecret(ctx context.Context, path string, secret []byte) error

SetSecret adds or updates the given path and secret combination.

func (*Client) SetSecretPermission added in v0.6.20

func (c *Client) SetSecretPermission(ctx context.Context, path, userEmail, permission string) error

SetSecretPermission is used to set a user permission on a given secret path.

func (*Client) SetTokenCredentials

func (c *Client) SetTokenCredentials(ctx context.Context, token string) (string, error)

func (*Client) SleepSatellite added in v0.6.29

func (c *Client) SleepSatellite(ctx context.Context, name, orgName string) (out chan SatelliteStatusUpdate)

func (*Client) StreamInterceptor added in v0.7.0

func (c *Client) StreamInterceptor() grpc.StreamClientInterceptor

StreamInterceptor is a stream middleware function for the Earthly gRPC client which handle re-authentication when necessary, and automatically prints requestIDs to errors when errors are received from the server.

func (*Client) StreamLogs added in v0.6.30

func (c *Client) StreamLogs(ctx context.Context, man *pb.RunManifest, ch <-chan *pb.Delta) <-chan error

func (*Client) UnaryInterceptor added in v0.7.0

func (c *Client) UnaryInterceptor(opts ...InterceptorOpt) grpc.UnaryClientInterceptor

UnaryInterceptor is a unary middleware function for the Earthly gRPC client which handle re-authentication when necessary, and automatically prints requestIDs to errors when errors are received from the server.

func (*Client) UpdateOrgMember added in v0.6.21

func (c *Client) UpdateOrgMember(ctx context.Context, orgName, userEmail, permission string) error

UpdateOrgMember updates a member's permission in an org.

func (*Client) UpdateProjectMember added in v0.6.20

func (c *Client) UpdateProjectMember(ctx context.Context, orgName, name, userEmail, permission string) error

UpdateProjectMember updates an existing member with the new permission

func (*Client) UpdateSatellite added in v0.7.0

func (c *Client) UpdateSatellite(ctx context.Context, opt UpdateSatelliteOpt) error

func (*Client) UploadLog

func (c *Client) UploadLog(ctx context.Context, pathOnDisk string) (string, error)

func (*Client) WakeSatellite added in v0.6.28

func (c *Client) WakeSatellite(ctx context.Context, name, orgName string) (out chan SatelliteStatusUpdate)

func (*Client) WhoAmI

func (c *Client) WhoAmI(ctx context.Context) (string, AuthMethod, bool, error)

type ClientOpt added in v0.7.1

type ClientOpt func(*Client)

ClientOpt is used to customize the Cloud client.

func WithAuthToken added in v0.8.0

func WithAuthToken(token string) ClientOpt

WithAuthToken can be used to ignore other authentication mechanisms besides the given token. Any previously set JWT tokens are cleared.

func WithLogstreamGRPCAddressOverride added in v0.7.1

func WithLogstreamGRPCAddressOverride(address string) ClientOpt

WithLogstreamGRPCAddressOverride can be used to override the Logstream gRPC address.

type InterceptorOpt added in v0.7.0

type InterceptorOpt func(opt *interceptorOpts)

func WithSkipAuth added in v0.7.0

func WithSkipAuth(methods ...string) InterceptorOpt

type LaunchSatelliteOpt added in v0.7.0

type LaunchSatelliteOpt struct {
	Name                    string
	OrgName                 string
	Size                    string
	Platform                string
	PinnedVersion           string
	MaintenanceWindowStart  string
	MaintenanceWeekendsOnly bool
	FeatureFlags            []string
}

type OrgDetail

type OrgDetail struct {
	ID       string
	Name     string
	Admin    bool
	Personal bool
}

OrgDetail contains an organization and details

type OrgInvitation added in v0.6.20

type OrgInvitation struct {
	Name       string
	Email      string
	Permission string
	Message    string
	OrgName    string
	CreatedAt  time.Time
	AcceptedAt time.Time
}

OrgInvitation can be used to invite a user to become a member in an org.

type OrgMember added in v0.6.21

type OrgMember struct {
	UserEmail  string
	Permission string
	OrgName    string
}

OrgMember represents a user that belongs to an org

type OrgPermissions

type OrgPermissions struct {
	User  string
	Path  string
	Write bool
}

OrgPermissions contains permission details within an org

type Pipeline added in v0.7.3

type Pipeline struct {
	Repo          string
	Path          string
	Name          string
	Org           string
	Triggers      []*PipelineTrigger
	Args          []*PipelineArg
	RepoId        string
	Project       string
	IsPush        bool
	ID            string
	PathHash      string
	ProviderOrg   string
	SatelliteName string
}

type PipelineArg added in v0.7.3

type PipelineArg struct {
	Name         string
	DefaultValue string
}

type PipelineTrigger added in v0.7.3

type PipelineTrigger struct {
	Type     string
	Modifier string
}

type Project added in v0.6.20

type Project struct {
	ID         string
	Name       string
	OrgName    string
	CreatedAt  time.Time
	ModifiedAt time.Time
}

Project contains information about the org project.

type ProjectMember added in v0.6.20

type ProjectMember struct {
	UserID     string
	UserEmail  string
	UserName   string
	Permission string
	CreatedAt  time.Time
	ModifiedAt time.Time
}

ProjectMember contains information about the project member.

type SatelliteInstance added in v0.6.16

type SatelliteInstance struct {
	Name                    string
	Org                     string
	State                   string
	Platform                string
	Size                    string
	Version                 string
	VersionPinned           bool
	FeatureFlags            []string
	MaintenanceWindowStart  string
	MaintenanceWindowEnd    string
	MaintenanceWeekendsOnly bool
	RevisionID              int32
	Hidden                  bool
	LastUsed                time.Time
	CacheRetention          time.Duration
	Address                 string
	IsManaged               bool
	Certificate             *pb.TLSCertificate
}

SatelliteInstance contains details about a remote Buildkit instance.

type SatelliteStatusUpdate added in v0.6.28

type SatelliteStatusUpdate struct {
	State string
	Err   error
}

type Secret added in v0.6.20

type Secret struct {
	Path       string
	Value      string
	CreatedAt  time.Time
	ModifiedAt time.Time
}

Secret represents a Cloud secret with a path key and a string value.

type SecretPermission added in v0.6.20

type SecretPermission struct {
	Path       string
	UserEmail  string
	Permission string
	CreatedAt  time.Time
	ModifiedAt time.Time
}

SecretPermission contains information about a user-specific secret permission override.

type StreamError added in v0.7.19

type StreamError struct {
	Recoverable bool
	Err         error
}

func (*StreamError) Error added in v0.7.19

func (s *StreamError) Error() string

type TokenDetail

type TokenDetail struct {
	Name           string
	Write          bool
	Expiry         time.Time
	Indefinite     bool
	LastAccessedAt time.Time
}

TokenDetail contains token information

type UpdateSatelliteOpt added in v0.7.0

type UpdateSatelliteOpt struct {
	Name                    string
	OrgName                 string
	PinnedVersion           string
	Size                    string
	Platform                string
	MaintenanceWindowStart  string
	MaintenanceWeekendsOnly bool
	DropCache               bool
	FeatureFlags            []string
}

Jump to

Keyboard shortcuts

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