conf

package
v1.45.1 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2024 License: MPL-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package conf writes and reads the Encore configuration file for the user.

Index

Constants

This section is empty.

Variables

View Source
var APIBaseURL = (func() string {
	if u := os.Getenv("ENCORE_PLATFORM_API_URL"); u != "" {
		return u
	}
	return defaultPlatformURL
})()

APIBaseURL is the base URL for communicating with the Encore Platform.

AuthClient is an *http.Client that authenticates requests using the logged-in user.

View Source
var CacheDevDash = (func() bool {
	return !strings.Contains(DevDashURL, "localhost")
})()

CacheDevDash reports whether or not the dev dash contents should be cached.

View Source
var DefaultClient = &http.Client{Transport: defaultTransport{}}

DefaultClient is an *http.Client that authenticates requests if the user is logged in. If the user is not logged in, the request is sent without authentication.

View Source
var DefaultTokenSource = NewTokenSource()
View Source
var DevDaemon = (func() bool {
	return os.Getenv("ENCORE_DAEMON_DEV") != ""
})()

DevDaemon reports whether or not the daemon is running in development mode.

View Source
var DevDashURL = (func() string {
	if u := os.Getenv("ENCORE_DEVDASH_URL"); u != "" {
		return u
	}
	return defaultDevDashURL
})()

DevDashURL is the base URL to retrieve the dev dashboard code from.

View Source
var ErrInvalidRefreshToken = errors.New("invalid refresh token")
View Source
var ErrNotLoggedIn = errors.New("not logged in: run 'encore auth login' first")
View Source
var WSBaseURL = (func() string {
	return strings.Replace(APIBaseURL, "http", "ws", -1)
})()

WSBaseURL is the base URL for communicating with the Encore Platform over WebSocket.

Functions

func CacheDir added in v1.31.0

func CacheDir() (string, error)

CacheDir reports the base directory for storing data which can be cached and deleted at any time by the user without affecting the Encore daemon.

The directory may or may not exist already.

func DataDir added in v1.23.0

func DataDir() (string, error)

DataDir reports the base directory for storing data, like database volumes. The directory may or may not exist already.

func Dir

func Dir() (string, error)

Dir reports the directory where Encore's configuration is stored.

func Logout

func Logout() error

func Write

func Write(cfg *Config) (err error)

Write persists the configuration for the user.

Types

type Config

type Config struct {
	oauth2.Token
	Actor     string `json:"actor,omitempty"`    // The ID of either the user or app authenticated
	Email     string `json:"email,omitempty"`    // non-zero if logged in as a user
	AppSlug   string `json:"app_slug,omitempty"` // non-zero if logged in as an app
	WireGuard struct {
		PublicKey  string `json:"pub,omitempty"`
		PrivateKey string `json:"priv,omitempty"`
	} `json:"wg,omitempty"`
}

Config represents the stored Encore configuration.

func CurrentUser

func CurrentUser() (*Config, error)

func OriginalUser

func OriginalUser(configDir string) (cfg *Config, err error)

type TokenSource

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

TokenSource implements oauth2.TokenSource by looking up the current logged in user's API Token.

func NewTokenSource added in v1.22.1

func NewTokenSource() *TokenSource

func (*TokenSource) Token

func (ts *TokenSource) Token() (*oauth2.Token, error)

Token implements oauth2.TokenSource.

Jump to

Keyboard shortcuts

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