cli

package
v0.1.2-0...-a4b4768 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2025 License: Apache-2.0 Imports: 43 Imported by: 0

README

dyrector.io platform: cli

We are working on the source code documentation, until then please use the root README.md for further information or check our official documentation site.

Documentation

Overview

Package cli is the package behind dyo command line executable

Index

Constants

View Source
const (
	FlagDisableCrux        = "disable-crux"
	FlagDisableCruxUI      = "disable-crux-ui"
	FlagLocalAgent         = "local-agent"
	FlagWrite              = "write"
	FlagDebug              = "debug"
	FlagPreferLocalImages  = "prefer-local-images"
	FlagConfigPath         = "config"
	FlagHosts              = "host"
	FlagPrefix             = "prefix"
	FlagImageTag           = "image-tag"
	FlagSilent             = "silent"
	FlagExpectContainerEnv = "expect-container-env"
	FlagNetwork            = "network"
	FlagEnvFile            = "env-file"
)

flags

View Source
const (
	// SettingsFileName is the filename we use for storing configuration
	SettingsFileName = "settings.yaml"
	// CLIDirName is the directory where we save the configuration file under the users configuration directory
	CLIDirName = "dyo-cli"
)
View Source
const (
	UpCommand      = "up"
	DownCommand    = "down"
	VersionCommand = "version"
)

commands

View Source
const (
	GenerateCommand = "generate"
)

Variables

This section is empty.

Functions

func CheckSettings

func CheckSettings(state *State, args *ArgsFlags)

CheckSettings makes sure your state is correct

func CopyTraefikConfiguration

func CopyTraefikConfiguration(ctx context.Context, containerName string, traefikTmplConfig traefikFileProviderData) error

CopyTraefikConfiguration copies a config file to Traefik Container

func DockerPullProgressDisplayer

func DockerPullProgressDisplayer(header string, respIn io.ReadCloser) error

func EnsureNetworkExists

func EnsureNetworkExists(state *State)

EnsureNetworkExists makes sure the container network exists

func GetCrux

func GetCrux(state *State, args *ArgsFlags) containerbuilder.Builder

GetCrux services: db migrations and crux api service

func GetCruxUI

func GetCruxUI(state *State, args *ArgsFlags) containerbuilder.Builder

GetCruxUI returns a configured crux-ui service

func GetGenerateCommand

func GetGenerateCommand() *ucli.Command

func GetKratos

func GetKratos(state *State, args *ArgsFlags) containerbuilder.Builder

GetKratos returns Kratos services' containers

func GetMailSlurper

func GetMailSlurper(state *State, args *ArgsFlags) containerbuilder.Builder

GetMailSlurper returns the mailslurper service's container

func GetMultidatabase

func GetMultidatabase(state *State, args *ArgsFlags) containerbuilder.Builder

GetMultidatabase returns platform's Postgres services' containers

func GetTraefik

func GetTraefik(state *State, args *ArgsFlags) containerbuilder.Builder

GetTraefik returns a traefik services container

func InitCLI

func InitCLI() *ucli.App

InitCLI returns the configuration flags of the program

func LoadEnvFile

func LoadEnvFile(envFile string) []string

func NotifyOnce

func NotifyOnce(name string, notifyFunc func())

NotifyOnce makes sure user only gets some information only once

func PrintInfo

func PrintInfo(state *State, args *ArgsFlags)

PrintInfo tells the user not to use in prod and prints postgres information if crux is disabled

func PrintWelcomeMessage

func PrintWelcomeMessage(settingsPath string)

PrintWelcomeMessage prints a welcome mesage before the command runs

func ProcessCommand

func ProcessCommand(ctx context.Context, initialState *State, args *ArgsFlags)

ProcessCommand is the main control function

func RenderTraefikHostRules

func RenderTraefikHostRules(hosts ...string) string

func SaveSettings

func SaveSettings(state *State, args *ArgsFlags)

SaveSettings saves the settings

func SettingsExists

func SettingsExists(settingsPath string) bool

SettingsExists is a check if the settings file is exists

func SettingsFileLocation

func SettingsFileLocation(settingsPath string) string

SettingsFileLocation is assembling the location of the settings file

func SettingsPath

func SettingsPath() string

SettingsPath returns the full path to the settingsfile

func StartContainers

func StartContainers(stack *dyrectorioStack)

StartContainers is for creating and starting containers

func StopContainers

func StopContainers(ctx context.Context, args *ArgsFlags)

StopContainers is a cleanup for "down" command, prefix can be provided with for multi removal

Types

type ArgsFlags

type ArgsFlags struct {
	EnvFile            string
	Network            string
	SettingsFilePath   string
	Command            string
	ImageTag           string
	Prefix             string
	Hosts              []string
	CruxDisabled       bool
	CruxUIDisabled     bool
	LocalAgent         bool
	PreferLocalImages  bool
	SettingsWrite      bool
	FullyContainerized bool
	SettingsExists     bool
	Silent             bool
}

ArgsFlags are commandline arguments

type ContainerSettings

type ContainerSettings struct {
	Image    string
	Name     string
	CruxAddr string
	Disabled bool
}

ContainerSettings are container specific settings

type Containers

type Containers struct {
	Crux          ContainerSettings
	CruxMigrate   ContainerSettings
	CruxUI        ContainerSettings
	Traefik       ContainerSettings
	Kratos        ContainerSettings
	KratosMigrate ContainerSettings
	Multidatabase ContainerSettings
	MailSlurper   ContainerSettings
}

Containers contain container/service specific settings

type Options

type Options struct {
	RootPostgresPassword           string `yaml:"rootPostgresPassword"`
	RootPostgresUser               string `yaml:"rootPostgresUser" env-default:"root"`
	KratosPostgresDB               string `yaml:"kratosPostgresDB" env-default:"kratos"`
	KratosPostgresUser             string `yaml:"kratosPostgresUser" env-default:"kratos_user"`
	KratosPostgresPassword         string `yaml:"kratosPostgresPassword"`
	TraefikDockerSocket            string `yaml:"traefikDockerSocket" env-default:"/var/run/docker.sock"`
	MailFromName                   string `yaml:"mailFromName" env-default:"dyrector.io - Platform"`
	CruxSecret                     string `yaml:"crux-secret"`
	CruxEncryptionKey              string `yaml:"crux-encryption-key"`
	KratosSecret                   string `yaml:"kratosSecret"`
	CruxPostgresDB                 string `yaml:"cruxPostgresDB" env-default:"crux"`
	CruxPostgresUser               string `yaml:"cruxPostgresUser" env-default:"crux_user"`
	CruxPostgresPassword           string `yaml:"cruxPostgresPassword"`
	TimeZone                       string `yaml:"timezone" env-default:"UTC"`
	MailFromEmail                  string `yaml:"mailFromEmail" env-default:"noreply@example.com"`
	TraefikWebPort                 uint   `yaml:"traefikWebPort" env-default:"8000"`
	CruxUIPort                     uint   `yaml:"crux-ui-port" env-default:"3000"`
	KratosPublicPort               uint   `yaml:"kratosPublicPort" env-default:"4433"`
	TraefikUIPort                  uint   `yaml:"traefikUIPort" env-default:"8080"`
	CruxHTTPPort                   uint   `yaml:"crux-http-port" env-default:"1848"`
	CruxAgentGrpcPort              uint   `yaml:"crux-agentgrpc-port" env-default:"5000"`
	MailSlurperUIPort              uint   `yaml:"mailSlurperUIPort" env-default:"4436"`
	MailSlurperSMTPPort            uint   `yaml:"mailSlurperSMTPPort" env-default:"1025"`
	MultidatabasePostgresPort      uint   `yaml:"multidatabasePostgresPort" env-default:"5432"`
	MailSlurperAPIPort             uint   `yaml:"mailSlurperAPIPort" env-default:"4437"`
	KratosAdminPort                uint   `yaml:"kratosAdminPort" env-default:"4434"`
	TraefikIsDockerSocketNamedPipe bool   `yaml:"traefikIsDockerSocketNamedPipe" env-default:"false"`
}

Options are "globals" for the SettingsFile struct

type SettingsFile

type SettingsFile struct {
	// version as in image tag like "latest" or "stable"
	Version string `yaml:"version" env-default:"stable"`
	Network string `yaml:"network-name" env-default:"dyo-stable"`
	Prefix  string `yaml:"prefix" env-default:"dyo-stable"`
	Options
}

SettingsFile will be read/written as this struct

type State

type State struct {
	Ctx context.Context
	*Containers
	InternalHostDomain string
	EnvFile            []string
	SettingsFile       SettingsFile
}

State itself exists per-execution, settingsFile is persisted freedesktop spec folders used by default, $XDG_CONFIG_HOME

func DisabledServiceSettings

func DisabledServiceSettings(state *State, args *ArgsFlags) *State

DisabledServiceSettings modifies the setting if the crux-ui is disabled

func LoadDefaultsOnEmpty

func LoadDefaultsOnEmpty(state *State, args *ArgsFlags) *State

LoadDefaultsOnEmpty There are options which are not filled out by default, we need to initialize values

func SettingsFileDefaults

func SettingsFileDefaults(initialState *State, args *ArgsFlags) *State

SettingsFileDefaults creating, reading and parsing the settings.yaml

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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