cli

package
v0.0.0-...-bb42387 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2025 License: MIT Imports: 42 Imported by: 0

Documentation

Index

Constants

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

Variables

View Source
var (
	DoDryRun = false

	ErrDryRun = errors.New("dry run")
)
View Source
var DefangFabric = pkg.Getenv("DEFANG_FABRIC", DefaultCluster)
View Source
var (
	ErrDebugSkipped = errors.New("debug skipped")
)
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 ErrTermsNotAgreed = errors.New("you must agree to the Defang terms of service to use this tool")
View Source
var P = track.P
View Source
var SupportedLanguages = []string{"Nodejs", "Golang", "Python"}

Functions

func BootstrapCommand

func BootstrapCommand(ctx context.Context, projectName string, c client.FabricClient, p client.Provider, cmd string) error

func BootstrapLocalList

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

func ComposeDown

func ComposeDown(ctx context.Context, projectName string, c client.FabricClient, provider client.Provider, names ...string) (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 Debug

func Debug(ctx context.Context, c client.FabricClient, p client.Provider, etag types.ETag, project *compose.Project, failedServices []string) error

func Delete

func Delete(ctx context.Context, projectName string, c client.FabricClient, provider client.Provider, names ...string) (types.ETag, error)

func DeploymentsList

func DeploymentsList(ctx context.Context, projectName string, client client.GrpcClient) error

func GenerateLetsEncryptCert

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

func GenerateWithAI

func GenerateWithAI(ctx context.Context, client client.FabricClient, language, dir, description string) ([]string, error)

func GetExistingToken

func GetExistingToken(fabric string) string

func GetServices

func GetServices(ctx context.Context, projectName string, provider client.Provider, long bool) 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 InteractiveAgreeToS

func InteractiveAgreeToS(ctx context.Context, c client.FabricClient) error

func InteractiveComposeDown

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

func InteractiveDebug

func InteractiveDebug(ctx context.Context, c client.FabricClient, p client.Provider, etag types.ETag, project *compose.Project, failedServices []string) error

func InteractiveLogin

func InteractiveLogin(ctx context.Context, client client.FabricClient, gitHubClientId, fabric string) error

func IsProjectFile

func IsProjectFile(basename string) bool

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 NewGrpcClient

func NewGrpcClient(ctx context.Context, cluster string) client.GrpcClient

func NewProvider

func NewProvider(ctx context.Context, providerID client.ProviderID, grpcClient client.GrpcClient) (client.Provider, error)

func NonInteractiveAgreeToS

func NonInteractiveAgreeToS(ctx context.Context, c client.FabricClient) error

func NonInteractiveLogin

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

func ParseTimeOrDuration

func ParseTimeOrDuration(str string, now time.Time) (time.Time, error)

ParseTimeOrDuration parses a time string or duration string (e.g. 1h30m) and returns a time.Time. At a minimum, this function supports RFC3339Nano, Go durations, and our own TimestampFormat (local).

func PrintObject

func PrintObject(root string, data proto.Message) 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 SplitTenantHost

func SplitTenantHost(cluster string) (types.TenantName, string)

func Tail

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

func TearDown

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

func Token

func Token(ctx context.Context, client client.FabricClient, clientId string, tenant types.TenantName, dur time.Duration, scope scope.Scope) error

func Upgrade

func Upgrade(ctx context.Context) error

func WaitServiceState

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

func Whoami

func Whoami(ctx context.Context, fabric client.FabricClient, provider client.Provider) (string, 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 DNSResult

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

type EndLogConditional deprecated

type EndLogConditional struct {
	Service  string
	Host     string
	EventLog string
}

Deprecated: use Subscribe instead #851

type ErrNoServices

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

func (ErrNoServices) Error

func (e ErrNoServices) Error() string

type HTTPClient

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

type PrintConfig

type PrintConfig struct {
	Name string
}

type PrintDeployment

type PrintDeployment struct {
	Id         string
	Provider   string
	DeployedAt 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 ServiceStatus

type ServiceStatus string
const (
	ServiceUnspecified ServiceStatus = "UNSPECIFIED"

	// build states
	ServiceBuildQueued       ServiceStatus = "BUILD_QUEUED"
	ServiceBuildProvisioning ServiceStatus = "BUILD_PROVISIONING"
	ServiceBuildPending      ServiceStatus = "BUILD_PENDING"
	ServiceBuildActivating   ServiceStatus = "BUILD_ACTIVATING"
	ServiceBuildRunning      ServiceStatus = "BUILD_RUNNING"
	ServiceBuildDeactivating ServiceStatus = "BUILD_DEACTIVATING" // build completed

	// update states
	ServiceUpdateQueued ServiceStatus = "UPDATE_QUEUED" // queued for deployment

	// deplpyment states
	ServicePending   ServiceStatus = "PENDING"
	ServiceCompleted ServiceStatus = "COMPLETED"
	ServiceFailed    ServiceStatus = "FAILED"
)

type ShowAccountData

type ShowAccountData struct {
	Provider       string
	AccountID      string
	Details        string
	Region         string
	SubscriberTier defangv1.SubscriptionTier
	Tenant         string
}

type TailDetectStopEventFunc deprecated

type TailDetectStopEventFunc func(services []string, host string, eventlog string) bool

Deprecated: use Subscribe instead #851

func CreateEndLogEventDetectFunc deprecated

func CreateEndLogEventDetectFunc(conditionals []EndLogConditional) TailDetectStopEventFunc

Deprecated: use Subscribe instead #851

type TailOptions

type TailOptions struct {
	Services           []string
	Etag               types.ETag
	Since              time.Time
	Raw                bool
	EndEventDetectFunc TailDetectStopEventFunc // Deprecated: use Subscribe instead #851
	Verbose            bool
	LogType            logs.LogType
}

func (TailOptions) String

func (to TailOptions) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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