cli

package
v0.0.0-...-db05034 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2026 License: MIT Imports: 55 Imported by: 2

Documentation

Index

Constants

View Source
const (
	RFC3339Milli = "2006-01-02T15:04:05.000Z07:00" // like RFC3339Nano but with 3 digits of precision
)

Variables

View Source
var ErrDoNotComposeDown = errors.New("user did not want to compose down")
View Source
var ErrNothingToMonitor = errors.New("no services to monitor")
View Source
var ErrSampleNotFound = errors.New("sample not found")
View Source
var P = track.P
View Source
var SupportedLanguages = []string{"Nodejs", "Golang", "Python"}

Functions

func CanMonitorService

func CanMonitorService(service *compose.ServiceConfig) bool

func CdCommand

func CdCommand(ctx context.Context, projectName string, provider client.Provider, fabric client.FabricClient, command client.CdCommand) (types.ETag, error)

func CdCommandAndTail

func CdCommandAndTail(ctx context.Context, provider client.Provider, projectName string, verbose bool, command client.CdCommand, fabric client.FabricClient) error

func CdListLocal

func CdListLocal(ctx context.Context, provider client.Provider, allRegions bool) error

func ComposeDown

func ComposeDown(ctx context.Context, projectName string, fabric client.FabricClient, provider client.Provider) (types.ETag, error)

func ComposeUp

ComposeUp validates a compose project and uploads the services using the client

func ConfigDelete

func ConfigDelete(ctx context.Context, projectName string, provider client.Provider, names ...string) error

func ConfigList

func ConfigList(ctx context.Context, projectName string, provider client.Provider) error

func ConfigSet

func ConfigSet(ctx context.Context, projectName string, provider client.Provider, name string, value string) error

func Connect

func Connect(cluster string, requestedTenant types.TenantNameOrID) *client.GrpcClient

Connect builds a client carrying the requested tenant (name or ID).

func ConnectWithTenant

func ConnectWithTenant(ctx context.Context, addr string, requestedTenant types.TenantNameOrID) (*client.GrpcClient, error)

func CreateRandomConfigValue

func CreateRandomConfigValue() string

func DeploymentsList

func DeploymentsList(ctx context.Context, client client.FabricClient, params ListDeploymentsParams) error

func EnableUTCMode

func EnableUTCMode()

EnableUTCMode sets the local time zone to UTC.

func GenerateLetsEncryptCert

func GenerateLetsEncryptCert(ctx context.Context, project *compose.Project, client client.FabricClient, provider client.Provider) error

func GeneratePreview

func GeneratePreview(ctx context.Context, project *compose.Project, client client.FabricClient, previewProvider client.Provider, estimateProviderID client.ProviderID, mode modes.Mode, region string) (string, error)

func GenerateWithAI

func GenerateWithAI(ctx context.Context, client client.FabricClient, args GenerateArgs) ([]string, error)

func GetServices

func GetServices(ctx context.Context, projectName string, provider client.Provider) (*defangv1.GetServicesResponse, error)

func GetStatesAndEventsUploadUrls

func GetStatesAndEventsUploadUrls(ctx context.Context, projectName string, provider client.Provider, fabric client.FabricClient) (statesUrl string, eventsUrl string, err error)

func GetVersion

func GetVersion(ctx context.Context, client client.FabricClient) (string, error)

func InitFromSamples

func InitFromSamples(ctx context.Context, dir string, names []string) error

InitFromSamples copies the sample(s) into the given directory, aborting if any files already exist.

func InstallCD

func InstallCD(ctx context.Context, provider client.Provider) error

func InteractiveComposeDown

func InteractiveComposeDown(ctx context.Context, projectName string, fabric client.FabricClient, provider client.Provider) (types.ETag, error)

func Logout

func Logout(ctx context.Context, client client.FabricClient) error

func MarshalPretty

func MarshalPretty(root string, data proto.Message) ([]byte, error)

func MixinFromSample

func MixinFromSample(ctx context.Context, dir string, name string) error

MixinFromSamples copies the sample files into the given directory, skipping existing files.

func NewProvider

func NewProvider(ctx context.Context, providerID client.ProviderID, fabricClient client.FabricClient, stack string) client.Provider

func Preview

func Preview(ctx context.Context, project *compose.Project, fabric client.FabricClient, provider client.Provider, params ComposeUpParams) error

func PrintConfigSummaryAndValidate

func PrintConfigSummaryAndValidate(ctx context.Context, provider client.Provider, project *compose.Project) error

func PrintEstimate

func PrintEstimate(mode modes.Mode, estimate *defangv1.EstimateResponse, term *term.Term)

func PrintObject

func PrintObject(root string, data proto.Message) error

func PrintServiceStatesAndEndpoints

func PrintServiceStatesAndEndpoints(serviceInfos []*defangv1.ServiceInfo) error

func PrintServices

func PrintServices(ctx context.Context, projectName string, provider client.Provider, long bool) error

func ResolveWorkspaceID

func ResolveWorkspaceID(info *auth.UserInfo, tenantSelection types.TenantNameOrID) string

ResolveWorkspaceID returns the workspace ID matching the provided selection (flag/env/token subject). If no match is found, returns an empty string.

func ResolveWorkspaceName

func ResolveWorkspaceName(info *auth.UserInfo, tenantSelection types.TenantNameOrID) string

ResolveWorkspaceName maps the selected tenant (flag/env/token subject) to a known workspace name when available. If no selection is set, returns an empty string.

func RunEstimate

func RunEstimate(ctx context.Context, project *compose.Project, client client.FabricClient, previewProvider client.Provider, estimateProviderID client.ProviderID, region string, mode modes.Mode) (*defangv1.EstimateResponse, error)

func SendMsg

func SendMsg(ctx context.Context, client client.FabricClient, subject, _type, id string, data []byte, contenttype string) error

func SplitProjectStack

func SplitProjectStack(name string) (projectName string, stackName string)

func Tail

func Tail(ctx context.Context, provider client.Provider, projectName string, options TailOptions) error

func TailAndWaitForCD

func TailAndWaitForCD(ctx context.Context, provider client.Provider, projectName string, tailOptions TailOptions) error

func TearDownCD

func TearDownCD(ctx context.Context, provider client.Provider, force bool) error

func Token

func Token(ctx context.Context, client client.FabricClient, tenant types.TenantNameOrID, dur time.Duration, s scope.Scope) error

func UpdateServiceStates

func UpdateServiceStates(ctx context.Context, serviceInfos []*defangv1.ServiceInfo)

func Upgrade

func Upgrade(ctx context.Context) error

func WaitForCdTaskExit

func WaitForCdTaskExit(ctx context.Context, provider client.Provider) error

Types

type CancelError

type CancelError struct {
	TailOptions
	ProjectName string
	// contains filtered or unexported fields
}

func (CancelError) Error

func (cerr CancelError) Error() string

func (CancelError) Unwrap

func (cerr CancelError) Unwrap() error

type ComposeError

type ComposeError struct {
	// contains filtered or unexported fields
}

func (ComposeError) Unwrap

func (e ComposeError) Unwrap() error

type ComposeUpParams

type ComposeUpParams struct {
	Project    *compose.Project
	UploadMode compose.UploadMode
	Mode       modes.Mode
}

type DNSResult

type DNSResult struct {
	IPs    []net.IPAddr
	Expiry time.Time
}

type ErrNoServices

type ErrNoServices struct {
	ProjectName string // may be empty
}

func (ErrNoServices) Error

func (e ErrNoServices) Error() string

type EstimateLineItemTableItem

type EstimateLineItemTableItem struct {
	Cost        string
	Quantity    string
	Service     string
	Description string
}

type GenerateArgs

type GenerateArgs struct {
	Description string
	Folder      string
	Language    string
	ModelId     string
}

type HTTPClient

type HTTPClient interface {
	Do(req *http.Request) (*http.Response, error)
}

type ListDeploymentsParams

type ListDeploymentsParams struct {
	ListType    defangv1.DeploymentType
	ProjectName string
	StackName   string
	Limit       uint32
}

type LogEntryHandler

type LogEntryHandler func(*defangv1.LogEntry, *TailOptions, *term.Term) error

type PrintConfig

type PrintConfig struct {
	Name string
}

type PrintDeployment

type PrintDeployment struct {
	AccountId   string
	Deployment  string
	DeployedAt  string
	ProjectName string
	Provider    string
	Region      string
	Mode        string
}

type Sample

type Sample struct {
	Name             string   `json:"name"`
	Title            string   `json:"title"`
	Category         string   `json:"category"` // Deprecated: use Languages instead
	Readme           string   `json:"readme"`   // unused
	DirectoryName    string   `json:"directoryName"`
	ShortDescription string   `json:"shortDescription"`
	Tags             []string `json:"tags"`
	Languages        []string `json:"languages"`
	Configs          []string `json:"configs"`
}

func FetchSamples

func FetchSamples(ctx context.Context) ([]Sample, error)

type Service

type Service struct {
	Deployment string
	Endpoint   string
	Service    string
	State      defangv1.ServiceState
	Status     string
	Fqdn       string
}

func GetServiceStatesAndEndpoints

func GetServiceStatesAndEndpoints(serviceInfos []*defangv1.ServiceInfo) ([]*Service, bool, error)

type ServiceStates

type ServiceStates = map[string]defangv1.ServiceState

func TailAndMonitor

func TailAndMonitor(ctx context.Context, project *compose.Project, provider client.Provider, waitTimeout time.Duration, tailOptions TailOptions) (ServiceStates, error)

func WaitServiceState

func WaitServiceState(
	ctx context.Context,
	provider client.Provider,
	targetState defangv1.ServiceState,
	projectName string,
	etag types.ETag,
	services []string,
) (ServiceStates, error)

type ShowAccountData

type ShowAccountData struct {
	Provider       client.ProviderID         `json:"provider"`
	SubscriberTier defangv1.SubscriptionTier `json:"subscriberTier"`
	Region         string                    `json:"region"`
	Workspace      string                    `json:"workspace"`
	Tenant         string                    `json:"tenant,omitempty"` // this is the subdomain
	TenantID       string                    `json:"tenantId,omitempty"`
	Email          string                    `json:"email"`
	Name           string                    `json:"name"`
}

func Whoami

func Whoami(ctx context.Context, fabric client.FabricClient, provider client.Provider, userInfo *auth.UserInfo, tenantSelection types.TenantNameOrID) (ShowAccountData, error)

type Source

type Source string
const (
	SourceComposeFile   Source = "Compose"
	SourceDefangConfig  Source = "Config"
	SourceInterpolation Source = "Config (interpolated)"
)

func (Source) String

func (s Source) String() string

type TailDetectStopEventFunc deprecated

type TailDetectStopEventFunc func(eventLog *defangv1.LogEntry) error

Deprecated: use Subscribe instead #851

type TailOptions

type TailOptions struct {
	Deployment         types.ETag
	EndEventDetectFunc TailDetectStopEventFunc // Deprecated: use Subscribe and GetDeploymentStatus instead #851
	Filter             string
	Follow             bool
	Limit              int32
	LogType            logs.LogType
	Raw                bool
	Services           []string
	Since              time.Time
	Until              time.Time
	Verbose            bool
	PrintBookends      bool
}

func (TailOptions) String

func (to TailOptions) String() string

type WorkspaceRow

type WorkspaceRow struct {
	Name    string `json:"name"`
	ID      string `json:"id,omitempty"`
	Current bool   `json:"current"`
}

func WorkspaceRows

func WorkspaceRows(info *auth.UserInfo, tenantSelection types.TenantNameOrID) []WorkspaceRow

WorkspaceRows marks the current workspace using the provided tenant selection.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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