internal

package
v0.0.0-...-0b1f6af Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2026 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ProgramName is the name of this program.
	ProgramName = "authgear-once"
	// BinDocker is the name of the binary of docker.
	BinDocker = "docker"

	// NOTE(once): Possibly breaking change
	// The name of the volume cannot be changed without any consideration.
	// NameDockerVolume is the name of the Docker volume.
	NameDockerVolume = "authgearonce_data"
	// NOTE(once): Possibly breaking change
	// The name of the container cannot be changed without any consideration.
	// NameDockerContainer is the name of the Docker container.
	NameDockerContainer = "authgearonce"

	DefaultDockerName_NoTag = "quay.io/theauthgear/authgear-once"
)
View Source
const (
	LicenseServerEndpoint            = "https://once-license.authgear.com"
	LicenseServerEndpointOverridable = false

	QuestionName_EnableCertbot_PromptEnabled            = false
	QuestionName_SelectCertbotEnvironment_PromptEnabled = false

	KeepInstallationContainerByDefault = false
)
View Source
const (
	CertbotExitCode10 = 10
)
View Source
const (
	DockerVolumeScopeLocal = "local"
)
View Source
const (
	Version = "1.0.0"
)

Variables

View Source
var (
	ErrNoDocker                                = errors.New("no docker")
	ErrDockerContainerNotExists                = errors.New("docker container does not exist")
	ErrCommandUpgradeNotImplemented            = errors.New("command upgrade not implemented")
	ErrLicenseServerUnknownResponse            = errors.New("unknown response from license server")
	ErrLicenseServerLicenseKeyNotFound         = errors.New("license server license key not found")
	ErrLicenseServerLicenseKeyAlreadyActivated = errors.New("license server license key already activated")
	ErrCertbotExitCode10                       = errors.New("certbot exited with 10")
)
View Source
var DockerPublishedPorts []int = []int{80, 443}

Functions

func CheckAllPublishedPortsNotListening

func CheckAllPublishedPortsNotListening() error

CheckAllPublishedPortsNotListening loops through DockerPublishedPorts and checks if any of them are already listening on the host. It returns an error if any of the ports are already in use.

func CheckTCPPortIsListening

func CheckTCPPortIsListening(port int) error

CheckTCPPortIsListening checks if a TCP port can be listened to. Returns nil if the port is available (can be listened to), ErrTCPPortAlreadyListening if the port is already in use.

func CheckVolumeExists

func CheckVolumeExists(ctx context.Context) (bool, error)

func DockerRm

func DockerRm(ctx context.Context, name string, options DockerRmOptions) error

func DockerStart

func DockerStart(ctx context.Context, name string) error

func DockerStop

func DockerStop(ctx context.Context, name string) error

func FlagsGetBool

func FlagsGetBool(cmd *cobra.Command, name string) bool

func GenerateMachineFingerprint

func GenerateMachineFingerprint() string

GenerateMachineFingerprint generates a cryptographically secure random string to represent a machine. This approach works even in a containerized environment, unlike https://github.com/denisbrodbeck/machineid

func GetDockerImage

func GetDockerImage(cmd *cobra.Command) string

func GetLicenseServerEndpoint

func GetLicenseServerEndpoint(cmd *cobra.Command) string

func GetPersistentEnvironmentVariableInVolume

func GetPersistentEnvironmentVariableInVolume(ctx context.Context, envVarName string) (image string, err error)

func PrintError

func PrintError(err error) error

PrintError prints err to stderr and returns err.

Types

type CmdError

type CmdError struct {
	Stdout string
	Stderr string
}

func (*CmdError) Error

func (e *CmdError) Error() string

type DockerContainer

type DockerContainer struct {
	ID    string `json:"ID"`
	Names string `json:"Names"`
}

func DockerLs

func DockerLs(ctx context.Context) ([]DockerContainer, error)

type DockerRmOptions

type DockerRmOptions struct {
	Force bool
}

type DockerRunOptions

type DockerRunOptions struct {
	Detach  bool
	Restart string
	Rm      bool
	Volume  []string
	Publish []string
	Env     []string
	Name    string
	Image   string
	Command []string
}

func NewDockerRunOptionsForStarting

func NewDockerRunOptionsForStarting(image string) DockerRunOptions

type DockerRunResult

type DockerRunResult struct {
	Stdout string
	Stderr string
}

func DockerRun

func DockerRun(ctx context.Context, opts DockerRunOptions) (*DockerRunResult, error)

func DockerRunWithCertbotErrorHandling

func DockerRunWithCertbotErrorHandling(ctx context.Context, opts DockerRunOptions) (*DockerRunResult, error)

type DockerVolume

type DockerVolume struct {
	Name  string `json:"Name"`
	Scope string `json:"Scope"`
}

func DockerVolumeLs

func DockerVolumeLs(ctx context.Context) ([]DockerVolume, error)

type ErrCertbotFailedToGetCertificates

type ErrCertbotFailedToGetCertificates struct {
	Domains []string
}

func (*ErrCertbotFailedToGetCertificates) Error

type ErrTCPPortAlreadyListening

type ErrTCPPortAlreadyListening struct {
	Port int
}

func (*ErrTCPPortAlreadyListening) Error

type ErrorObject

type ErrorObject struct {
	Code string `json:"code"`
}

type FatalError

type FatalError struct {
	Err error
}

func (FatalError) Init

func (m FatalError) Init() tea.Cmd

func (FatalError) Update

func (m FatalError) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (FatalError) View

func (m FatalError) View() string

func (FatalError) WithErr

func (m FatalError) WithErr(err error) FatalError

type LicenseObject

type LicenseObject struct {
	ExpireAt      *time.Time `json:"expire_at"`
	IsActivated   bool       `json:"is_activated"`
	IsExpired     bool       `json:"is_expired"`
	LicenseeEmail *string    `json:"licensee_email"`
}

func ActivateLicense

func ActivateLicense(ctx context.Context, client *http.Client, opts LicenseOptions) (licenseObject *LicenseObject, err error)

func CheckLicense

func CheckLicense(ctx context.Context, client *http.Client, opts LicenseOptions) (licenseObject *LicenseObject, err error)

type LicenseOptions

type LicenseOptions struct {
	Endpoint    string
	LicenseKey  string
	Fingerprint string
}

type LicenseResponse

type LicenseResponse struct {
	Data  *LicenseObject `json:"data"`
	Error *ErrorObject   `json:"error"`
}

type LicenseServerResponseError

type LicenseServerResponseError struct {
	DumpedResponse []byte
}

func (*LicenseServerResponseError) Error

Jump to

Keyboard shortcuts

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