Documentation ¶
Index ¶
- func ClusterApps() (appbase.Applications, error)
- func ClusterOperator() (*opsclient.Client, error)
- func ClusterPackages() (pack.PackageService, error)
- func DetectCluster(ctx context.Context, env *LocalEnvironment) error
- func InGravity(dir ...string) (string, error)
- func LocalCluster() (*ops.Site, error)
- func LocalGravityDir() (string, error)
- func NewAppsClient(entry users.LoginEntry, opsCenterURL string, params ...appclient.Param) (client appbase.Applications, err error)
- func NewOpsClient(entry users.LoginEntry, opsCenterURL string, params ...opsclient.ClientParam) (client *opsclient.Client, err error)
- func SiteDir() (string, error)
- func SitePackagesDir() (string, error)
- func SiteUnpackedDir() (string, error)
- type AppConfig
- type ClusterEnvironment
- type ClusterEnvironmentOption
- type DNSConfig
- type ImageEnvironment
- type ImageEnvironmentOption
- type LocalEnvironment
- func (env *LocalEnvironment) AppService(opsCenterURL string, config AppConfig, options ...httplib.ClientOption) (appbase.Applications, error)
- func (env *LocalEnvironment) AppServiceCluster() (appbase.Applications, error)
- func (env *LocalEnvironment) AppServiceLocal(config AppConfig) (service appbase.Applications, err error)
- func (env *LocalEnvironment) AuditLog(ctx context.Context) (teleevents.IAuditLog, error)
- func (env *LocalEnvironment) Close() error
- func (env *LocalEnvironment) ClusterPackages() (pack.PackageService, error)
- func (env *LocalEnvironment) CurrentUser() string
- func (env *LocalEnvironment) EmitAuditEvent(ctx context.Context, event teleevents.Event, fields events.Fields)
- func (env *LocalEnvironment) EmitOperationEvent(ctx context.Context, operation ops.SiteOperation) error
- func (env *LocalEnvironment) GetLocalState() (*LocalState, error)
- func (env *LocalEnvironment) GravityCommand(gravityPath string, args ...string) []string
- func (env *LocalEnvironment) GravityCommandInPlanet(args ...string) []string
- func (env *LocalEnvironment) HTTPClient(options ...httplib.ClientOption) *http.Client
- func (env *LocalEnvironment) InGravity() bool
- func (env *LocalEnvironment) LocalCluster() (*ops.Site, error)
- func (env *LocalEnvironment) NewClusterEnvironment(opts ...ClusterEnvironmentOption) (*ClusterEnvironment, error)
- func (env *LocalEnvironment) OperatorService(opsCenterURL string, options ...httplib.ClientOption) (*opsclient.Client, error)
- func (env *LocalEnvironment) PackageService(opsCenterURL string, options ...httplib.ClientOption) (pack.PackageService, error)
- func (env *LocalEnvironment) SelectOpsCenter(opsURL string) (string, error)
- func (env *LocalEnvironment) SelectOpsCenterWithDefault(opsURL, defaultURL string) (string, error)
- func (env *LocalEnvironment) SiteApps() (appbase.Applications, error)
- func (env *LocalEnvironment) SiteOperator(options ...httplib.ClientOption) (*opsclient.Client, error)
- func (env *LocalEnvironment) TeleportClient(ctx context.Context, proxyHost string) (*client.TeleportClient, error)
- type LocalEnvironmentArgs
- type LocalState
- type RemoteEnvironment
- type Silent
- type TarballEnvironment
- type TarballEnvironmentArgs
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ClusterApps ¶
func ClusterApps() (appbase.Applications, error)
ClusterApps returns apps service for the local cluster.
func ClusterOperator ¶
ClusterOperator returns the local cluster ops service
func ClusterPackages ¶
func ClusterPackages() (pack.PackageService, error)
ClusterPackages returns the local cluster packages service
func DetectCluster ¶
func DetectCluster(ctx context.Context, env *LocalEnvironment) error
DetectCluster attempts to detect whether there is a deployed cluster.
The behavior is as follows:
- If the cluster is deployed/healthy, returns nil.
- If the cluster is not deployed and the node's clean, returns NotFound.
- If partial state is detected, returns a specific error.
func LocalGravityDir ¶
LocalGravityDir returns host directory where local environment stores its data on this node
func NewAppsClient ¶
func NewAppsClient(entry users.LoginEntry, opsCenterURL string, params ...appclient.Param) (client appbase.Applications, err error)
NewAppsClient creates a new app service client.
func NewOpsClient ¶
func NewOpsClient(entry users.LoginEntry, opsCenterURL string, params ...opsclient.ClientParam) (client *opsclient.Client, err error)
NewOpsClient creates a new client to Operator service using the specified login entry, address of the Ops Center and a set of optional connection options
func SitePackagesDir ¶
SitePackagesDir returns host directory where packages are stored on this node
func SiteUnpackedDir ¶
SiteUnpackedDir returns host directory where unpacked packages are stored on this node
Types ¶
type AppConfig ¶
type AppConfig struct { // DockerURL specifies the address of the docker daemon DockerURL string // RegistryURL is the address of the private docker registry // running inside a kubernetes cluster. // // This attribute is only applicable in a local planet environment RegistryURL string // Packages allows to override default packages when creating the service Packages pack.PackageService // ExcludeDeps defines a list of dependencies that will be excluded from the app image ExcludeDeps []loc.Locator // Backend allows to override default backend when creating the service Backend storage.Backend }
AppConfig is applications-specific configuration
type ClusterEnvironment ¶
type ClusterEnvironment struct { // Backend is the cluster etcd backend Backend storage.Backend // Packages is the package service that talks to local storage Packages pack.PackageService // ClusterPackages is the package service that talks to cluster API ClusterPackages pack.PackageService // Apps is the cluster apps service Apps app.Applications // Users is the cluster identity service Users users.Identity // Operator is the local operator service Operator *opsservice.Operator // Client is the cluster Kubernetes client Client *kubernetes.Clientset }
ClusterEnvironment provides access to local cluster services
func NewClusterEnvironment ¶
func NewClusterEnvironment() (*ClusterEnvironment, error)
NewClusterEnvironment initializes local cluster services and returns a new instance of cluster environment. The resulting environment will not have a kubernetes client
type ClusterEnvironmentOption ¶
type ClusterEnvironmentOption func(*clusterEnvironmentConfig)
ClusterEnvironmentOption describes a functional option for customizing a cluster environment
func WithClient ¶
func WithClient(client *kubernetes.Clientset) ClusterEnvironmentOption
WithClient is an option to override the kubernetes client to use in the cluster environment
func WithEtcdTimeout ¶
func WithEtcdTimeout(timeout time.Duration) ClusterEnvironmentOption
WithEtcdTimeout is an option to override the etcd timeout
type DNSConfig ¶
DNSConfig is the DNS configuration with a fallback to storage.DefaultDNSConfig
type ImageEnvironment ¶
type ImageEnvironment struct { // LocalEnvironment is a wrapped local environment. *LocalEnvironment // Manifest is an application/cluster manifest. Manifest *schema.Manifest // contains filtered or unexported fields }
ImageEnvironment is a special case of a local environment with the state directory rooted in the unpacked application/cluster image tarball.
func NewImageEnvironment ¶
func NewImageEnvironment(path string) (*ImageEnvironment, error)
NewImageEnvironment returns a new environment for a specified image.
The path can be either an image tarball or an unpacked image tarball.
func (*ImageEnvironment) Close ¶
func (e *ImageEnvironment) Close() error
Close closes the image environment.
type ImageEnvironmentOption ¶
type ImageEnvironmentOption func(*ImageEnvironment)
ImageEnvironmentOption defines an image environment functional argument.
func WithCleanup ¶
func WithCleanup() ImageEnvironmentOption
WithCleanup cleans up an image environment state directory on close.
type LocalEnvironment ¶
type LocalEnvironment struct { LocalEnvironmentArgs // Backend is the local backend client Backend storage.LocalBackend // Objects is the local objects storage client Objects blob.Objects // Packages is the local package service Packages *localpack.PackageServer // Apps is the local application service Apps appbase.Applications // Credentials provides access to user credentials Credentials credentials.Service }
LocalEnvironment sets up local gravity environment and services that make sense for it:
* local package service * local site service * access to local OpsCenter
func New ¶
func New(stateDir string) (*LocalEnvironment, error)
New is a shortcut that creates a local environment from provided state directory
func NewLocalEnvironment ¶
func NewLocalEnvironment(args LocalEnvironmentArgs) (*LocalEnvironment, error)
NewLocalEnvironment creates a new LocalEnvironment given the specified configuration arguments. It is caller's responsibility to close the environment with Close after use
func NewLocalWizardEnvironment ¶
func NewLocalWizardEnvironment() (*LocalEnvironment, error)
NewLocalWizardEnvironment creates a new local environment to access wizard-specific state
func (*LocalEnvironment) AppService ¶
func (env *LocalEnvironment) AppService(opsCenterURL string, config AppConfig, options ...httplib.ClientOption) (appbase.Applications, error)
func (*LocalEnvironment) AppServiceCluster ¶
func (env *LocalEnvironment) AppServiceCluster() (appbase.Applications, error)
AppServiceCluster creates the *local* app service that uses the cluster's backend (etcd) and packages (via HTTP client).
The local service is needed to handle cases such as newly introduced manifest field which gravity-site (that may be running the old code) does not recognize.
func (*LocalEnvironment) AppServiceLocal ¶
func (env *LocalEnvironment) AppServiceLocal(config AppConfig) (service appbase.Applications, err error)
func (*LocalEnvironment) AuditLog ¶
func (env *LocalEnvironment) AuditLog(ctx context.Context) (teleevents.IAuditLog, error)
AuditLog returns the cluster audit log service
func (*LocalEnvironment) Close ¶
func (env *LocalEnvironment) Close() error
Close closes backend and object storage used in LocalEnvironment
func (*LocalEnvironment) ClusterPackages ¶
func (env *LocalEnvironment) ClusterPackages() (pack.PackageService, error)
ClusterPackages returns package service for the local cluster
func (*LocalEnvironment) CurrentUser ¶
func (env *LocalEnvironment) CurrentUser() string
CurrentUser returns name of the currently logged in user
func (*LocalEnvironment) EmitAuditEvent ¶
func (env *LocalEnvironment) EmitAuditEvent(ctx context.Context, event teleevents.Event, fields events.Fields)
EmitAuditEvent saves the specified event in the audit log of the local cluster.
func (*LocalEnvironment) EmitOperationEvent ¶
func (env *LocalEnvironment) EmitOperationEvent(ctx context.Context, operation ops.SiteOperation) error
EmitOperationEvent emits audit event for the provided operation.
func (*LocalEnvironment) GetLocalState ¶
func (env *LocalEnvironment) GetLocalState() (*LocalState, error)
GetLocalState returns cluster state from the local node backend.
func (*LocalEnvironment) GravityCommand ¶
func (env *LocalEnvironment) GravityCommand(gravityPath string, args ...string) []string
GravityCommand builds gravity command
func (*LocalEnvironment) GravityCommandInPlanet ¶
func (env *LocalEnvironment) GravityCommandInPlanet(args ...string) []string
GravityCommandInPlanet builds gravity command that runs inside planet
func (*LocalEnvironment) HTTPClient ¶
func (env *LocalEnvironment) HTTPClient(options ...httplib.ClientOption) *http.Client
func (*LocalEnvironment) InGravity ¶
func (env *LocalEnvironment) InGravity() bool
InGravity returns true if Gravity cluster is available locally.
func (*LocalEnvironment) LocalCluster ¶
func (env *LocalEnvironment) LocalCluster() (*ops.Site, error)
LocalCluster queries a local Gravity cluster.
func (*LocalEnvironment) NewClusterEnvironment ¶
func (env *LocalEnvironment) NewClusterEnvironment(opts ...ClusterEnvironmentOption) (*ClusterEnvironment, error)
NewClusterEnvironment returns a new instance of ClusterEnvironment with all services initialized
func (*LocalEnvironment) OperatorService ¶
func (env *LocalEnvironment) OperatorService(opsCenterURL string, options ...httplib.ClientOption) (*opsclient.Client, error)
OperatorService provides access to remote sites and creates new sites
func (*LocalEnvironment) PackageService ¶
func (env *LocalEnvironment) PackageService(opsCenterURL string, options ...httplib.ClientOption) (pack.PackageService, error)
PackageService returns a service managing gravity packages on the specified OpsCenter or the local packages if the OpsCenter has not been specified.
func (*LocalEnvironment) SelectOpsCenter ¶
func (env *LocalEnvironment) SelectOpsCenter(opsURL string) (string, error)
func (*LocalEnvironment) SelectOpsCenterWithDefault ¶
func (env *LocalEnvironment) SelectOpsCenterWithDefault(opsURL, defaultURL string) (string, error)
func (*LocalEnvironment) SiteApps ¶
func (env *LocalEnvironment) SiteApps() (appbase.Applications, error)
SiteApps returns Apps service for the local gravity site
func (*LocalEnvironment) SiteOperator ¶
func (env *LocalEnvironment) SiteOperator(options ...httplib.ClientOption) (*opsclient.Client, error)
SiteOperator returns Operator for the local gravity site
func (*LocalEnvironment) TeleportClient ¶
func (env *LocalEnvironment) TeleportClient(ctx context.Context, proxyHost string) (*client.TeleportClient, error)
TeleportClient returns a new teleport client for the local cluster
type LocalEnvironmentArgs ¶
type LocalEnvironmentArgs struct { // LocalKeyStoreDir specifies an optional directory in which to place the LocalKeyStore // for holding user and auth state LocalKeyStoreDir string // StateDir specifes the directory in which state (gravity db, packages) will be placed StateDir string // Insecure indicates whether or not to perform TLS name verification Insecure bool // Silent indicates whether or not LocalEnvironment operations will log or not Silent // Debug indicates whether or not the command is run in debug mode Debug bool // EtcdRetryTimeout specifies the timeout on ETCD transient errors. // Defaults to EtcdRetryInterval if unspecified EtcdRetryTimeout time.Duration // BoltOpenTimeout specifies the timeout on opening the local state database. // Negative value means no timeout. // Defaults to defaults.DBOpenTimeout if unspecified BoltOpenTimeout time.Duration // Reporter controls progress output Reporter pack.ProgressReporter // DNS is the local cluster DNS server configuration DNS DNSConfig // SELinux specifies whether SELinux support is on SELinux bool // ReadonlyBackend specifies if the backend should be opened // read-only. ReadonlyBackend bool // Credentials is the predefined static credentials entry Credentials *credentials.Credentials // Close allows to perform extra cleanup actions Close func() error }
LocalEnvironmentArgs holds configuration values for opening or creating a LocalEnvironment
type LocalState ¶
type LocalState struct { // Cluster is the cluster that's installed on the node. Cluster storage.Site // InstallOperation is the original install operation. InstallOperation storage.SiteOperation }
LocalState describes the local state of the cluster as represented by the information found in the node-local backend.
type RemoteEnvironment ¶
type RemoteEnvironment struct { // FieldLogger is used for logging logrus.FieldLogger // Packages is authenticated pack client Packages pack.PackageService // Apps is authenticated apps client Apps app.Applications // Operator is authenticated ops client Operator *opsclient.Client // StateDir is where this environment keeps login entries StateDir string }
RemoteEnvironment provides access to a remote Ops Center services
func LoginRemote ¶
func LoginRemote(url, token string) (*RemoteEnvironment, error)
LoginRemote creates remote environment and logs into with provided creds
func LoginWizard ¶
func LoginWizard(addr, token string) (*RemoteEnvironment, error)
LoginWizard creates remote environment and logs into it as a wizard user
func NewRemoteEnvironment ¶
func NewRemoteEnvironment() (*RemoteEnvironment, error)
NewRemoteEnvironment creates a new remote environment
func (*RemoteEnvironment) Login ¶
func (w *RemoteEnvironment) Login(url, token string) error
Login logs this environment into the Ops Center with specified credentials
func (*RemoteEnvironment) LoginCluster ¶
func (w *RemoteEnvironment) LoginCluster(url, token string) error
LoginCluster logs this environment into the specified cluster
func (*RemoteEnvironment) LoginWizard ¶
func (w *RemoteEnvironment) LoginWizard(addr, token string) (entry *storage.LoginEntry, err error)
LoginWizard logs this environment into wizard with specified address
func (*RemoteEnvironment) WaitForOperator ¶
func (w *RemoteEnvironment) WaitForOperator(ctx context.Context) error
WaitForOperator blocks until the configured operator becomes available or context expires.
type Silent ¶
type Silent bool
Silent implements a silent flag and controls console output. Implements utils.Printer
func (Silent) Print ¶
func (r Silent) Print(args ...interface{})
Print outputs specified arguments to stdout if the silent mode is not on.
type TarballEnvironment ¶
type TarballEnvironment struct { io.Closer // Packages specifies the local package service Packages pack.PackageService // Apps specifies the local application service Apps libapp.Applications }
TarballEnvironment describes application environment in the directory with unpacked installer
func NewTarballEnvironment ¶
func NewTarballEnvironment(config TarballEnvironmentArgs) (*TarballEnvironment, error)
NewTarballEnvironment creates new environment for the cluster image unpacked at the configured location
type TarballEnvironmentArgs ¶
type TarballEnvironmentArgs struct { // StateDir specifies optional state directory. // If unspecified, current process's working directory is used StateDir string // License specifies optional license payload to decode packages License string }
TarballEnvironmentArgs defines configuration for the environment
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package credentials provides interface for retrieving local user credentials.
|
Package credentials provides interface for retrieving local user credentials. |