utils

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2025 License: MIT Imports: 45 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 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, 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

Types

type AppInfo

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

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