cli

package
v0.1.2-0...-3e0559f Latest Latest
Warning

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

Go to latest
Published: May 12, 2023 License: Apache-2.0 Imports: 33 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 (
	// 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"
)

UpCommand and DownCommand is the magic words we use to bring up/down the stack

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, name, internalHostDomain string, cruxPort, cruxUIPort uint) error

CopyTraefikConfiguration copies a config file to Traefik Container

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 GetCruxPostgres

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

GetCruxPostgres returns crux's Postgres services' containers

func GetCruxUI

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

GetCruxUI returns a configured crux-ui service

func GetKratos

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

GetKratos returns Kratos services' containers

func GetKratosPostgres

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

GetKratosPostgres returns crux's Postgres services' containers

func GetMailSlurper

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

GetMailSlurper returns the mailslurper service's container

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 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 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

func TryImage

func TryImage(dockerImage, specialTag string) string

TryImage function will check if an image with the given custom tag is existing on the local system, otherwise will fall back and pull This func is for testing locally built docker images

Types

type ArgsFlags

type ArgsFlags struct {
	SettingsWrite      bool
	SettingsExists     bool
	SettingsFilePath   string
	Command            string
	ImageTag           string
	Prefix             string
	SpecialImageTag    string
	DisableForcepull   bool
	CruxDisabled       bool
	CruxUIDisabled     bool
	LocalAgent         bool
	FullyContainerized bool
	Network            string
	Silent             bool
}

ArgsFlags are commandline arguments

type ContainerSettings

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

ContainerSettings are container specific settings

type Containers

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

Containers contain container/service specific settings

type Options

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

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
	SettingsFile       SettingsFile
	InternalHostDomain string
	*Containers
}

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

Jump to

Keyboard shortcuts

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