utils

package
v0.2.11 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2025 License: MIT Imports: 46 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KMSEncryptionPublicKeyPath  = "keys/%s/kms-encryption-public-key.pem"
	KMSSigningPublicKeyPath     = "keys/%s/kms-signing-public-key.pem"
	KMSClientPath               = "tools/kms-client"
	LayeredDockerfilePath       = "internal/templates/docker/Dockerfile.layered.tmpl"
	EnvSourceScriptTemplatePath = "internal/templates/scripts/compute-source-env.sh.tmpl"
	JWTFilePath                 = "/run/container_launcher/attestation_verifier_claims_token"

	// Build-related constants
	TempImagePrefix       = "eigenx-temp-"
	LayeredBuildDirPrefix = "eigenx-layered-build"
	LayeredDockerfileName = "Dockerfile.eigencompute"
	EnvSourceScriptName   = "compute-source-env.sh"
	KMSClientBinaryName   = "kms-client"
	KMSEncryptionKeyName  = "kms-encryption-public-key.pem"
	KMSSigningKeyName     = "kms-signing-public-key.pem"
	TlsKeygenBinaryName   = "tls-keygen"
	CaddyfileName         = "Caddyfile"
	DockerPlatform        = "linux/amd64"
	LinuxOS               = "linux"
	AMD64Arch             = "amd64"
	SHA256Prefix          = "sha256:"

	RegistryPropagationWaitSeconds = 3
)
View Source
const MAX_ADDRESS_COUNT = 5

Variables

This section is empty.

Functions

func CalculateAndSignApiPermissionDigest

func CalculateAndSignApiPermissionDigest(
	cCtx *cli.Context,
	permission [4]byte,
	expiry *big.Int,
) ([]byte, error)

CalculateAndSignApiPermissionDigest calculates the API permission digest using the contract and signs it with the user's private key

func CheckAppLogPermission

func CheckAppLogPermission(cCtx *cli.Context, appAddress ethcommon.Address) (bool, error)

CheckAppLogPermission checks if an app currently has public log viewing permissions

func ConfirmMainnetEnvironment

func ConfirmMainnetEnvironment(env string) error

ConfirmMainnetEnvironment shows a confirmation prompt for mainnet environments

func GenerateAuthHeaders

func GenerateAuthHeaders(
	cCtx *cli.Context,
	permission [4]byte,
	expiry *big.Int,
) (map[string]string, error)

GenerateAuthHeaders generates Authorization and X-eigenx-expiry headers for API authentication by using the contract to calculate and sign the permission digest

func GetAndPrintAppInfo

func GetAndPrintAppInfo(cCtx *cli.Context, appID ethcommon.Address, statusOverride ...string) error

func GetAppControllerBinding

func GetAppControllerBinding(cCtx *cli.Context) (*ethclient.Client, *AppController.AppController, error)

func GetAppID

func GetAppID(cCtx *cli.Context, argIndex int) (ethcommon.Address, error)

GetAppID gets the app id from CLI args or auto-detects from project context. App id is the address of the app contract on L1.

func GetAppIDInteractive

func GetAppIDInteractive(cCtx *cli.Context, argIndex int, action string) (ethcommon.Address, error)

GetAppIDInteractive gets app ID from args or interactive selection

func GetAvailableAppNameInteractive

func GetAvailableAppNameInteractive(context, imageRef string) (string, error)

GetAvailableAppNameInteractive interactively gets an available app name

func GetContractCaller

func GetContractCaller(cCtx *cli.Context) (*common.ContractCaller, error)

GetContractCaller creates a contract caller from the CLI context

func GetDeveloperAddress

func GetDeveloperAddress(cCtx *cli.Context) (ethcommon.Address, error)

GetDeveloperAddress gets developer address from private key

func GetDockerfileInteractive

func GetDockerfileInteractive(cCtx *cli.Context) (string, error)

GetDockerfileInteractive prompts to build from Dockerfile if it exists

func GetEnvFileInteractive

func GetEnvFileInteractive(cCtx *cli.Context) (string, error)

GetEnvFileInteractive prompts for env file path if not provided

func GetEnvironmentConfig

func GetEnvironmentConfig(cCtx *cli.Context) (common.EnvironmentConfig, error)

func GetEnvironmentDescription

func GetEnvironmentDescription(name, fallback string, withPrefix bool) string

GetEnvironmentDescription returns a human-readable description for an environment

func GetEnvironmentInteractive

func GetEnvironmentInteractive(cCtx *cli.Context, argIndex int) (string, error)

GetEnvironmentInteractive gets environment from args or interactive selection

func GetImageReferenceInteractive

func GetImageReferenceInteractive(cCtx *cli.Context, argIndex int, buildFromDockerfile bool) (string, error)

GetImageReferenceInteractive prompts for image reference if not provided

func GetInstanceTypeInteractive added in v0.2.8

func GetInstanceTypeInteractive(cCtx *cli.Context, defaultSKU string) (string, error)

GetInstanceTypeInteractive prompts for instance type if not provided via flag. The defaultSKU parameter is used as the default selection in interactive mode: - For new deployments: pass empty string (uses first SKU from backend) - For upgrades: pass current app's instance type

func GetLayeredTargetImageInteractive

func GetLayeredTargetImageInteractive(cCtx *cli.Context, sourceImageRef string) (string, error)

GetLayeredTargetImageInteractive prompts for target image when layering a published image

func GetLogSettingsInteractive

func GetLogSettingsInteractive(cCtx *cli.Context) (logRedirect string, publicLogs bool, err error)

GetLogSettingsInteractive gets log redirection and visibility settings from flags or interactive prompt

func GetOrPromptAppName

func GetOrPromptAppName(cCtx *cli.Context, context string, imageRef string) (string, error)

GetOrPromptAppName gets app name from flag or prompts interactively

func GetPrivateKeyOrFail

func GetPrivateKeyOrFail(cCtx *cli.Context) (string, error)

GetPrivateKeyOrFail gets the private key from flag, environment, or keyring, failing with clear instructions if not found

func IsAppNameAvailable

func IsAppNameAvailable(context, name string) bool

IsAppNameAvailable checks if an app name is available in the given context

func IsPushPermissionError

func IsPushPermissionError(err error) bool

IsPushPermissionError checks if an error is a push permission error

func PrepareReleaseFromContext

func PrepareReleaseFromContext(cCtx *cli.Context, environmentConfig *common.EnvironmentConfig, appID gethcommon.Address, dockerfilePath string, imageRef string, envFilePath string, logRedirect string, instanceType string, maxPushRetries int) (appcontrollerV2.IAppControllerRelease, string, error)

PrepareReleaseFromContext prepares a release with separated Dockerfile handling The dockerfile path and env file path are provided as parameters (already collected earlier) maxPushRetries controls how many times to retry on push permission errors (0 = no retries)

func PrintAppInfo

func PrintAppInfo(ctx context.Context, logger iface.Logger, client *ethclient.Client, appID ethcommon.Address, config AppController.IAppControllerAppConfig, info AppInfo, environmentName string) error

func PrintAppInfoWithStatus

func PrintAppInfoWithStatus(ctx context.Context, logger iface.Logger, client *ethclient.Client, appID ethcommon.Address, config AppController.IAppControllerAppConfig, info AppInfo, environmentName string, statusOverride string) error

func SelectRegistryInteractive

func SelectRegistryInteractive(registries []registryInfo, imageName string, tag string, promptMessage string, validator func(string) error) (string, error)

SelectRegistryInteractive provides interactive selection of registry for image reference

func ShowCountdown added in v0.2.5

func ShowCountdown(ctx context.Context, seconds int)

ShowCountdown displays a countdown timer with gray text

func WatchAppInfoLoop added in v0.2.5

func WatchAppInfoLoop(cCtx *cli.Context, appID ethcommon.Address, stopCondition func(string, string) (bool, error), notifyOnStates []string, statusOverride ...string) error

WatchAppInfoLoop is the shared watch logic for monitoring app status changes stopCondition is called with (status, ip) and returns (shouldStop, error) If stopCondition is nil, watches indefinitely notifyOnStates: if provided, only print status changes when transitioning TO these states statusOverride: if provided, overrides the initial status display for user clarity

func WatchUntilRunning added in v0.2.5

func WatchUntilRunning(cCtx *cli.Context, appID ethcommon.Address, statusOverride ...string) error

WatchUntilRunning watches app info until it reaches Running status with an IP address statusOverride: if provided, overrides the initial status display (e.g., "Deploying", "Upgrading")

Types

type AppInfo

type AppInfo struct {
	Addresses   kmstypes.SignedResponse[kmstypes.AddressesResponse] `json:"addresses"`
	Status      string                                              `json:"app_status"`
	Ip          string                                              `json:"ip"`
	MachineType string                                              `json:"machine_type"`
}

type AppInfoResponse

type AppInfoResponse struct {
	Apps []AppInfo `json:"apps"`
}

type AppStatus

type AppStatus struct {
	Status string `json:"app_status"`
}

type AppStatusResponse

type AppStatusResponse struct {
	Apps []AppStatus `json:"apps"`
}

type EnvSourceScriptTemplateData

type EnvSourceScriptTemplateData struct {
	KMSServerURL string
	JWTFile      string
	UserAPIURL   string
}

type InstanceType added in v0.2.8

type InstanceType struct {
	SKU         string `json:"sku"`         // SKU value (e.g., "g1-standard-4t")
	Description string `json:"description"` // Human-readable description (e.g., "4 vCPUs, 16 GB memory, TDX")
}

InstanceType represents a machine instance type configuration. This struct matches the backend API response format for SKUs.

type LayeredDockerfileTemplateData

type LayeredDockerfileTemplateData struct {
	BaseImage        string
	OriginalCmd      string
	OriginalUser     string
	LogRedirect      string
	IncludeTLS       bool
	EigenXCLIVersion string
}

type Platform

type Platform struct {
	OS   string
	Arch string
}

Platform represents a container platform

func (Platform) IsLinuxAMD64

func (p Platform) IsLinuxAMD64() bool

IsLinuxAMD64 checks if platform matches required linux/amd64

func (Platform) String

func (p Platform) String() string

String returns the platform in standard format

type PreflightContext

type PreflightContext struct {
	Caller            *common.ContractCaller
	EnvironmentConfig *common.EnvironmentConfig
	Client            *ethclient.Client
	PrivateKey        string
}

PreflightContext contains validated context needed for contract operations

func DoPreflightChecks

func DoPreflightChecks(cCtx *cli.Context) (*PreflightContext, error)

DoPreflightChecks performs early validation of authentication and network connectivity This should be called at the beginning of any command that requires contract interaction

type PushPermissionError

type PushPermissionError struct {
	ImageRef string
	Err      error
}

PushPermissionError indicates a push failed due to authentication/permission issues

func (*PushPermissionError) Error

func (e *PushPermissionError) Error() string

func (*PushPermissionError) Unwrap

func (e *PushPermissionError) Unwrap() error

type SKUListResponse added in v0.2.8

type SKUListResponse struct {
	SKUs []InstanceType `json:"skus"`
}

type UserApiClient

type UserApiClient struct {
	Client *http.Client
	// contains filtered or unexported fields
}

func NewUserApiClient

func NewUserApiClient(cCtx *cli.Context) (*UserApiClient, error)

func (*UserApiClient) GetInfos

func (cc *UserApiClient) GetInfos(cCtx *cli.Context, appIDs []ethcommon.Address, addressCount int) (*AppInfoResponse, error)

func (*UserApiClient) GetLogs

func (cc *UserApiClient) GetLogs(cCtx *cli.Context, appID ethcommon.Address) (string, error)

func (*UserApiClient) GetSKUs added in v0.2.8

func (cc *UserApiClient) GetSKUs(cCtx *cli.Context) (*SKUListResponse, error)

func (*UserApiClient) GetStatuses

func (cc *UserApiClient) GetStatuses(cCtx *cli.Context, appIDs []ethcommon.Address) (*AppStatusResponse, error)

Jump to

Keyboard shortcuts

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