common

package
v0.1.17 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2024 License: GPL-3.0 Imports: 18 Imported by: 0

Documentation

Overview

internal/common/version.go

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckForNewVersion

func CheckForNewVersion(currentVersion string) (bool, string, error)

CheckForNewVersion checks if a newer version is available on GitHub

func CheckVersionPeriodically

func CheckVersionPeriodically(currentVersion string, checkInterval time.Duration)

CheckVersionPeriodically checks for new versions periodically

func DockerInit

func DockerInit(cc *ContainerEngineConfig)

func NewDockerConfig

func NewDockerConfig(cc *ContainerEngineConfig) *docker.Config

NewDockerConfig creates and returns a new Docker client configuration

func ReadConfirmation added in v0.1.16

func ReadConfirmation(prompt string) bool

ReadConfirmation reads a yes/no confirmation from the user.

func ReadUserInput

func ReadUserInput(prompt string) string

ReadUserInput reads a string input from the user with a prompt. It handles multi-word inputs and properly checks for errors.

func ReadUserInputWithDefault added in v0.1.16

func ReadUserInputWithDefault(prompt string, defaultValue string) string

ReadUserInputWithDefault reads user input with a default value if input is empty.

func ReadUserInputWithValidation added in v0.1.16

func ReadUserInputWithValidation(prompt string, validate func(string) bool) string

ReadUserInputWithValidation reads user input and validates it using a provided function. It keeps prompting until valid input is received.

Types

type AdminConfig

type AdminConfig struct {
	Path string `yaml:"path"`
}

type BuildConfig

type BuildConfig struct {
	RunEnv       string `yaml:"-"` // come from env
	BuildVersion string `yaml:"-"` // come from build ldflags
	BuildCommit  string `yaml:"-"` // come from build ldflags
	BuildDate    string `yaml:"-"` // come from build ldflags
	ProxyURL     string `yaml:"-"`
}

func (*BuildConfig) GetRunEnv

func (config *BuildConfig) GetRunEnv() string

GetRunEnv returns the run environment

type ChunkMetadata added in v0.1.15

type ChunkMetadata struct {
	ChunkNumber int    `json:"chunk_number"`
	TotalChunks int    `json:"total_chunks"`
	ChunkSize   int64  `json:"chunk_size"`
	TotalSize   int64  `json:"total_size"`
	ImageName   string `json:"image_name"`
	TransferID  string `json:"transfer_id"`
}

type Config

type Config struct {
	General         GeneralConfig         `yaml:"General"`
	Http            HttpConfig            `yaml:"Http"`
	Admin           AdminConfig           `yaml:"Admin"`
	ContainerEngine ContainerEngineConfig `yaml:"ContainerEngine"`
	Traefik         TraefikConfig         `yaml:"Traefik"`
	Build           BuildConfig           `yaml:"-"`
}

func (*Config) GetBackendURL

func (c *Config) GetBackendURL() string

func (*Config) GetStorageDir

func (config *Config) GetStorageDir() string

get storage dir

func (*Config) GetToken

func (config *Config) GetToken() (string, error)

func (*Config) GetVersion

func (c *Config) GetVersion() string

GetVersion

func (*Config) LoadConfig

func (config *Config) LoadConfig() (*Config, error)

func (*Config) SaveConfig

func (config *Config) SaveConfig() error

func (*Config) SetToken

func (c *Config) SetToken(token string)

type ConflictAction added in v0.1.15

type ConflictAction struct {
	Action string `json:"action"` // "stop", "remove", or "cancel"
	Force  bool   `json:"force"`
}

type ConflictCheckResponse added in v0.1.15

type ConflictCheckResponse struct {
	Success       bool   `json:"success"`
	Message       string `json:"message"`
	ContainerID   string `json:"container_id"`
	ContainerName string `json:"container_name"`
	Domain        string `json:"domain"`
	State         string `json:"state"`
	RunningTime   string `json:"running_time"`
	Ports         string `json:"ports"`
}

type ContainerEngineConfig

type ContainerEngineConfig struct {
	Sock       string `yaml:"dockersock"`
	PodmanSock string `yaml:"podmansock"`
	Podman     bool   `yaml:"podman"`
	Network    string `yaml:"network"`
}

type DeployPayload

type DeployPayload struct {
	Port         string `json:"port"`
	TargetDomain string `json:"targetdomain"`
	ImageName    string `json:"imagename"`
	ImageID      string `json:"imageid"`
	Data         io.ReadCloser
}

DeployPayload represents the payload for deployment requests

func (DeployPayload) GetType

func (p DeployPayload) GetType() string

GetType returns the type of the DeployPayload

type DeployResponse

type DeployResponse struct {
	Success       bool   `json:"success"`
	Message       string `json:"message"`
	Domain        string `json:"domain"`
	ContainerID   string `json:"container_id"`
	ContainerName string `json:"container_name"`
}

DeployResponse represents the response structure for deployment requests

type DeploymentError

type DeploymentError struct {
	StatusCode  int    `json:"status"`
	Message     string `json:"message"`
	RawResponse string `json:"raw_response"`
}

DeploymentError represents an error that occurred during deployment

func (*DeploymentError) Error

func (e *DeploymentError) Error() string

Error implements the error interface for DeploymentError

type DeviceFlowResponse added in v0.1.15

type DeviceFlowResponse struct {
	Code    string `json:"code"`
	Message string `json:"message"`
}

type GeneralConfig

type GeneralConfig struct {
	StorageDir string `yaml:"storageDir"`
	Token      string `yaml:"token"`
}

type GitHubRelease added in v0.1.17

type GitHubRelease struct {
	TagName     string    `json:"tag_name"`
	Name        string    `json:"name"`
	PublishedAt time.Time `json:"published_at"`
}

GitHubRelease represents the GitHub API response

type HttpConfig

type HttpConfig struct {
	Port       string `yaml:"port"`
	Domain     string `yaml:"domain"`
	SubDomain  string `yaml:"subDomain"`
	BackendURL string `yaml:"backendURL"`
	Https      bool   `yaml:"https"`
}

func (*HttpConfig) FullDomain

func (c *HttpConfig) FullDomain() string

func (*HttpConfig) Protocol

func (c *HttpConfig) Protocol() string

type Info added in v0.1.17

type Info struct {
	Version string
	Commit  string
	Date    string
}

Info represents version information

func GetVersionInfo added in v0.1.17

func GetVersionInfo(buildVersion, buildCommit, buildDate string) Info

GetVersionInfo returns the current version information based on BuildConfig

func (Info) String added in v0.1.17

func (i Info) String() string

String returns a formatted version string

type Payload

type Payload interface {
	GetType() string
}

Payload is an interface for different types of payloads

type PingPayload

type PingPayload struct {
	Message string `json:"message"`
}

PingPayload represents the payload for ping requests

func NewPingPayload

func NewPingPayload(data map[string]interface{}) (PingPayload, error)

NewPingPayload creates a new PingPayload from a map of data

func (PingPayload) GetType

func (p PingPayload) GetType() string

GetType returns the type of the PingPayload

type PushPayload

type PushPayload struct {
	ImageName string `json:"imagename"`
	ImageID   string `json:"imageid"`
	Data      io.Reader
}

PushPayload represents the payload for push requests

func (PushPayload) GetType

func (p PushPayload) GetType() string

GetType returns the type of the PushPayload

type PushResponse

type PushResponse struct {
	Success            bool   `json:"success"`
	Message            string `json:"message"`
	CreateContainerURL string `json:"create_container_url,omitempty"`
	ImageID            string `json:"image_id,omitempty"`
}

PushResponse represents the response structure for push requests

type RemovePayload added in v0.1.13

type RemovePayload struct {
	ContainerID string `json:"container_id"`
}

RemovePayload represents the payload for remove requests

func (RemovePayload) GetType added in v0.1.13

func (p RemovePayload) GetType() string

GetType returns the type of the RemovePayload

type RemoveResponse added in v0.1.14

type RemoveResponse struct {
	Success bool   `json:"success"`
	Message string `json:"message"`
}

type RequestPayload

type RequestPayload struct {
	Type    string  `json:"type"`
	Payload Payload `json:"payload"`
}

RequestPayload represents the structure of incoming requests

func (*RequestPayload) UnmarshalJSON

func (p *RequestPayload) UnmarshalJSON(data []byte) error

UnmarshalJSON custom unmarshaler for RequestPayload

type StartPayload added in v0.1.13

type StartPayload struct {
	ContainerID   string `json:"container_id"`
	ContainerName string `json:"container_name"`
}

StartPayload represents the payload for start requests

func (StartPayload) GetType added in v0.1.13

func (p StartPayload) GetType() string

GetType returns the type of the StartPayload

type StartResponse added in v0.1.14

type StartResponse struct {
	Success bool   `json:"success"`
	Message string `json:"message"`
}

type StopPayload added in v0.1.13

type StopPayload struct {
	ContainerID   string `json:"container_id"`
	ContainerName string `json:"container_name"`
}

StopPayload represents the payload for stop requests

func (StopPayload) GetType added in v0.1.13

func (p StopPayload) GetType() string

GetType returns the type of the StopPayload

type StopResponse added in v0.1.14

type StopResponse struct {
	Success bool   `json:"success"`
	Message string `json:"message"`
}

type TraefikConfig

type TraefikConfig struct {
	EntryPoint       string `yaml:"entryPoint"`
	SecureEntryPoint string `yaml:"secureEntryPoint"`
	Resolver         string `yaml:"resolver"`
}

Jump to

Keyboard shortcuts

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