client

package
v0.0.0-...-90e0edc Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2025 License: MIT Imports: 22 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// StateDir is the directory where the state file is stored
	StateDir = filepath.Join(stateDir, "defang")
)

Functions

func AcceptTerms

func AcceptTerms() error

func GetAnonID

func GetAnonID() string

func GetRegion

func GetRegion(provider ProviderID) string

func IsNetworkError

func IsNetworkError(err error) bool

func LoadProjectNameWithFallback

func LoadProjectNameWithFallback(ctx context.Context, loader Loader, provider Provider) (string, error)

func PrettyError

func PrettyError(err error) error

func TermsAccepted

func TermsAccepted() bool

Types

type AccountInfo

type AccountInfo struct {
	AccountID string
	Details   string
	Provider  ProviderID
	Region    string
}

func (AccountInfo) String

func (a AccountInfo) String() string

type BootstrapCommandRequest

type BootstrapCommandRequest struct {
	Command string
	Project string
}

type ErrDeploymentFailed

type ErrDeploymentFailed struct {
	Message string
	Service string // optional
}

func (ErrDeploymentFailed) Error

func (e ErrDeploymentFailed) Error() string

type ErrNotImplemented

type ErrNotImplemented string

func (ErrNotImplemented) Error

func (n ErrNotImplemented) Error() string

type FabricClient

type FabricClient interface {
	AgreeToS(context.Context) error
	CanIUse(context.Context, *defangv1.CanIUseRequest) (*defangv1.CanIUseResponse, error)
	CheckLoginAndToS(context.Context) error
	Debug(context.Context, *defangv1.DebugRequest) (*defangv1.DebugResponse, error)
	DelegateSubdomainZone(context.Context, *defangv1.DelegateSubdomainZoneRequest) (*defangv1.DelegateSubdomainZoneResponse, error)
	DeleteSubdomainZone(context.Context, *defangv1.DeleteSubdomainZoneRequest) error
	Estimate(context.Context, *defangv1.EstimateRequest) (*defangv1.EstimateResponse, error)
	GenerateCompose(context.Context, *defangv1.GenerateComposeRequest) (*defangv1.GenerateComposeResponse, error)
	GenerateFiles(context.Context, *defangv1.GenerateFilesRequest) (*defangv1.GenerateFilesResponse, error)
	GetController() defangv1connect.FabricControllerClient
	GetDelegateSubdomainZone(context.Context, *defangv1.GetDelegateSubdomainZoneRequest) (*defangv1.DelegateSubdomainZoneResponse, error)
	GetSelectedProvider(context.Context, *defangv1.GetSelectedProviderRequest) (*defangv1.GetSelectedProviderResponse, error)
	GetTenantName() types.TenantName
	GetVersions(context.Context) (*defangv1.Version, error)
	ListDeployments(context.Context, *defangv1.ListDeploymentsRequest) (*defangv1.ListDeploymentsResponse, error)
	Preview(context.Context, *defangv1.PreviewRequest) (*defangv1.PreviewResponse, error)
	Publish(context.Context, *defangv1.PublishRequest) error
	PutDeployment(context.Context, *defangv1.PutDeploymentRequest) error
	RevokeToken(context.Context) error
	SetSelectedProvider(context.Context, *defangv1.SetSelectedProviderRequest) error
	// Subscribe(context.Context, *v1.SubscribeRequest) (*v1.SubscribeResponse, error)
	Token(context.Context, *defangv1.TokenRequest) (*defangv1.TokenResponse, error)
	Track(string, ...Property) error
	VerifyDNSSetup(context.Context, *defangv1.VerifyDNSSetupRequest) error
	WhoAmI(context.Context) (*defangv1.WhoAmIResponse, error)
}

type GrpcClient

type GrpcClient struct {
	TenantName types.TenantName
	// contains filtered or unexported fields
}

func NewGrpcClient

func NewGrpcClient(host, accessToken string, tenantName types.TenantName) *GrpcClient

func (GrpcClient) AgreeToS

func (g GrpcClient) AgreeToS(ctx context.Context) error

func (GrpcClient) CanIUse

func (GrpcClient) CheckLoginAndToS

func (g GrpcClient) CheckLoginAndToS(ctx context.Context) error

func (GrpcClient) Debug

func (GrpcClient) DeleteSubdomainZone

func (g GrpcClient) DeleteSubdomainZone(ctx context.Context, req *defangv1.DeleteSubdomainZoneRequest) error

func (GrpcClient) Estimate

func (GrpcClient) GetController

func (GrpcClient) GetTenantName

func (g GrpcClient) GetTenantName() types.TenantName

func (GrpcClient) GetVersions

func (g GrpcClient) GetVersions(ctx context.Context) (*defangv1.Version, error)

func (GrpcClient) Preview

func (GrpcClient) Publish

func (g GrpcClient) Publish(ctx context.Context, req *defangv1.PublishRequest) error

func (GrpcClient) PutDeployment

func (g GrpcClient) PutDeployment(ctx context.Context, req *defangv1.PutDeploymentRequest) error

func (GrpcClient) RevokeToken

func (g GrpcClient) RevokeToken(ctx context.Context) error

func (*GrpcClient) SetClient

func (g *GrpcClient) SetClient(client defangv1connect.FabricControllerClient)

func (GrpcClient) SetOptions

func (g GrpcClient) SetOptions(ctx context.Context, req *defangv1.SetOptionsRequest) error

func (GrpcClient) SetSelectedProvider

func (g GrpcClient) SetSelectedProvider(ctx context.Context, req *defangv1.SetSelectedProviderRequest) error

func (GrpcClient) Token

func (GrpcClient) Track

func (g GrpcClient) Track(event string, properties ...Property) error

func (GrpcClient) VerifyDNSSetup

func (g GrpcClient) VerifyDNSSetup(ctx context.Context, req *defangv1.VerifyDNSSetupRequest) error

func (GrpcClient) WhoAmI

type Loader

type Loader interface {
	LoadProject(context.Context) (*composeTypes.Project, error)
	LoadProjectName(context.Context) (string, error)
}

type MockFabricClient

type MockFabricClient struct {
	FabricClient
	DelegateDomain string
}

func (MockFabricClient) AgreeToS

func (m MockFabricClient) AgreeToS(ctx context.Context) error

func (MockFabricClient) CanIUse

func (MockFabricClient) DeleteSubdomainZone

func (MockFabricClient) PutDeployment

type MockLoader

type MockLoader struct {
	Project composeTypes.Project
	Error   error
}

func (MockLoader) LoadProject

func (m MockLoader) LoadProject(ctx context.Context) (*composeTypes.Project, error)

func (MockLoader) LoadProjectName

func (m MockLoader) LoadProjectName(ctx context.Context) (string, error)

type MockProvider

type MockProvider struct {
	Provider
	UploadUrl string
}

func (MockProvider) CreateUploadURL

func (MockProvider) ListConfig

func (MockProvider) ServiceDNS

func (m MockProvider) ServiceDNS(service string) string

type MockServerStream

type MockServerStream[Msg any] struct {
	Resps []*Msg
	Error error
	// contains filtered or unexported fields
}

MockServerStream mocks a ServerStream.

func (*MockServerStream[T]) Close

func (*MockServerStream[T]) Close() error

func (*MockServerStream[T]) Err

func (m *MockServerStream[T]) Err() error

func (*MockServerStream[T]) Msg

func (m *MockServerStream[T]) Msg() *T

func (*MockServerStream[T]) Receive

func (m *MockServerStream[T]) Receive() bool

type MockWaitStream

type MockWaitStream[T any] struct {
	// contains filtered or unexported fields
}

MockWaitStream is a mock implementation of the ServerStream interface that returns messages and errors from channels. It blocks until the channels are closed or an error is received. It is used for testing purposes.

func NewMockWaitStream

func NewMockWaitStream[T any]() *MockWaitStream[T]

NewMockWaitStream returns a ServerStream that will block until closed.

func (*MockWaitStream[T]) Close

func (m *MockWaitStream[T]) Close() error

func (*MockWaitStream[T]) Err

func (m *MockWaitStream[T]) Err() error

func (*MockWaitStream[T]) Msg

func (m *MockWaitStream[T]) Msg() *T

func (*MockWaitStream[T]) Receive

func (m *MockWaitStream[T]) Receive() bool

func (*MockWaitStream[T]) Send

func (m *MockWaitStream[T]) Send(msg *T, err error)

type PlaygroundProvider

type PlaygroundProvider struct {
	FabricClient
	RetryDelayer
}

func (*PlaygroundProvider) AccountInfo

func (g *PlaygroundProvider) AccountInfo(ctx context.Context) (*AccountInfo, error)

func (*PlaygroundProvider) BootstrapCommand

func (g *PlaygroundProvider) BootstrapCommand(ctx context.Context, req BootstrapCommandRequest) (types.ETag, error)

func (*PlaygroundProvider) BootstrapList

func (g *PlaygroundProvider) BootstrapList(context.Context) ([]string, error)

func (*PlaygroundProvider) CreateUploadURL

func (*PlaygroundProvider) Delete

func (*PlaygroundProvider) DeleteConfig

func (g *PlaygroundProvider) DeleteConfig(ctx context.Context, req *defangv1.Secrets) error

func (*PlaygroundProvider) Deploy

func (*PlaygroundProvider) Destroy

func (*PlaygroundProvider) Estimate

func (*PlaygroundProvider) GetDeploymentStatus

func (g *PlaygroundProvider) GetDeploymentStatus(ctx context.Context) error

func (*PlaygroundProvider) GetProjectUpdate

func (*PlaygroundProvider) GetService

func (*PlaygroundProvider) GetServices

func (*PlaygroundProvider) ListConfig

func (*PlaygroundProvider) PrepareDomainDelegation

func (*PlaygroundProvider) Preview

func (*PlaygroundProvider) PutConfig

func (*PlaygroundProvider) QueryForDebug

func (g *PlaygroundProvider) QueryForDebug(ctx context.Context, req *defangv1.DebugRequest) error

func (*PlaygroundProvider) QueryLogs

func (PlaygroundProvider) RemoteProjectName

func (g PlaygroundProvider) RemoteProjectName(ctx context.Context) (string, error)

func (PlaygroundProvider) ServiceDNS

func (g PlaygroundProvider) ServiceDNS(name string) string

func (*PlaygroundProvider) SetCanIUseConfig

func (g *PlaygroundProvider) SetCanIUseConfig(*defangv1.CanIUseResponse)

func (*PlaygroundProvider) Subscribe

func (*PlaygroundProvider) TearDown

func (g *PlaygroundProvider) TearDown(ctx context.Context) error

type PrepareDomainDelegationRequest

type PrepareDomainDelegationRequest struct {
	Project        string
	DelegateDomain string
	Preview        bool
}

type PrepareDomainDelegationResponse

type PrepareDomainDelegationResponse struct {
	NameServers     []string
	DelegationSetId string
}

type ProjectLoader

type ProjectLoader interface {
	LoadProjectName(context.Context) (string, error)
	LoadProject(context.Context) (*composeTypes.Project, error)
}

type Property

type Property struct {
	Name  string
	Value any
}

type Provider

type Provider interface {
	AccountInfo(context.Context) (*AccountInfo, error)
	BootstrapCommand(context.Context, BootstrapCommandRequest) (types.ETag, error)
	BootstrapList(context.Context) ([]string, error)
	CreateUploadURL(context.Context, *defangv1.UploadURLRequest) (*defangv1.UploadURLResponse, error)
	DelayBeforeRetry(context.Context) error
	Delete(context.Context, *defangv1.DeleteRequest) (*defangv1.DeleteResponse, error)
	DeleteConfig(context.Context, *defangv1.Secrets) error
	Deploy(context.Context, *defangv1.DeployRequest) (*defangv1.DeployResponse, error)
	Destroy(context.Context, *defangv1.DestroyRequest) (types.ETag, error)
	GetDeploymentStatus(context.Context) error // nil means deployment is pending/running; io.EOF means deployment is done
	GetProjectUpdate(context.Context, string) (*defangv1.ProjectUpdate, error)
	GetService(context.Context, *defangv1.GetRequest) (*defangv1.ServiceInfo, error)
	GetServices(context.Context, *defangv1.GetServicesRequest) (*defangv1.GetServicesResponse, error)
	ListConfig(context.Context, *defangv1.ListConfigsRequest) (*defangv1.Secrets, error)
	PrepareDomainDelegation(context.Context, PrepareDomainDelegationRequest) (*PrepareDomainDelegationResponse, error)
	Preview(context.Context, *defangv1.DeployRequest) (*defangv1.DeployResponse, error)
	PutConfig(context.Context, *defangv1.PutConfigRequest) error
	QueryForDebug(context.Context, *defangv1.DebugRequest) error
	QueryLogs(context.Context, *defangv1.TailRequest) (ServerStream[defangv1.TailResponse], error)
	RemoteProjectName(context.Context) (string, error)
	ServiceDNS(string) string
	SetCanIUseConfig(*defangv1.CanIUseResponse)
	Subscribe(context.Context, *defangv1.SubscribeRequest) (ServerStream[defangv1.SubscribeResponse], error)
	TearDown(context.Context) error
}

type ProviderID

type ProviderID string
const (
	ProviderAuto   ProviderID = "auto"
	ProviderDefang ProviderID = "defang"
	ProviderAWS    ProviderID = "aws"
	ProviderDO     ProviderID = "digitalocean"
	ProviderGCP    ProviderID = "gcp"
)

func AllProviders

func AllProviders() []ProviderID

func (ProviderID) Name

func (p ProviderID) Name() string

func (*ProviderID) Set

func (p *ProviderID) Set(str string) error

func (*ProviderID) SetValue

func (p *ProviderID) SetValue(val defangv1.Provider)

func (ProviderID) String

func (p ProviderID) String() string

func (ProviderID) Type

func (p ProviderID) Type() string

func (ProviderID) Value

func (p ProviderID) Value() defangv1.Provider

type Retrier

type Retrier struct{}

func (Retrier) WrapStreamingClient

func (Retrier) WrapStreamingClient(next connect.StreamingClientFunc) connect.StreamingClientFunc

func (Retrier) WrapStreamingHandler

func (Retrier) WrapStreamingHandler(next connect.StreamingHandlerFunc) connect.StreamingHandlerFunc

func (Retrier) WrapUnary

func (Retrier) WrapUnary(next connect.UnaryFunc) connect.UnaryFunc

type RetryDelayer

type RetryDelayer struct {
	Delay    time.Duration
	MaxDelay time.Duration
}

func (*RetryDelayer) DelayBeforeRetry

func (r *RetryDelayer) DelayBeforeRetry(ctx context.Context) error

type ServerStream

type ServerStream[Res any] interface {
	Close() error
	Receive() bool
	Msg() *Res
	Err() error
}

type State

type State struct {
	AnonID          string
	TermsAcceptedAt time.Time
}

Directories

Path Synopsis
aws
do
gcp

Jump to

Keyboard shortcuts

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