command

package
v0.0.0-...-cb0ee0a Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2025 License: MIT Imports: 42 Imported by: 1

Documentation

Index

Constants

View Source
const DEFANG_PORTAL_HOST = "portal.defang.io"
View Source
const SERVICE_PORTAL_URL = "https://" + DEFANG_PORTAL_HOST + "/service"

Variables

View Source
var P = track.P
View Source
var RootCmd = &cobra.Command{
	SilenceUsage:  true,
	SilenceErrors: true,
	Use:           "defang",
	Args:          cobra.NoArgs,
	Short:         "Defang CLI is used to take your app from Docker Compose to a secure and scalable deployment on your favorite cloud in minutes.",
	PersistentPreRunE: func(cmd *cobra.Command, args []string) (err error) {
		ctx := cmd.Context()
		term.SetDebug(doDebug)

		if IsCompletionCommand(cmd) {
			return nil
		}

		defer func() {
			track.Cmd(cmd, "Invoked", P("args", args), P("err", err), P("non-interactive", nonInteractive), P("provider", providerID))
		}()

		switch colorMode {
		case ColorNever:
			term.ForceColor(false)
		case ColorAlways:
			term.ForceColor(true)
		}

		if cwd, _ := cmd.Flags().GetString("cwd"); cwd != "" {

			if err = os.Chdir(cwd); err != nil {
				return err
			}
		}

		client, err = cli.Connect(ctx, getCluster())

		if v, err := client.GetVersions(ctx); err == nil {
			version := cmd.Root().Version
			term.Debug("Fabric:", v.Fabric, "CLI:", version, "CLI-Min:", v.CliMin)
			if hasTty && isNewer(version, v.CliMin) && !isUpgradeCommand(cmd) {
				term.Warn("Your CLI version is outdated. Please upgrade to the latest version by running:\n\n  defang upgrade\n")
				hideUpdate = true
			}
		}

		if _, ok := cmd.Annotations[authNeeded]; !ok {
			return nil
		}

		if nonInteractive {
			err = client.CheckLoginAndToS(ctx)
		} else {
			err = login.InteractiveRequireLoginAndToS(ctx, client, getCluster())
		}

		return err
	},
}

Functions

func CreateRandomConfigValue

func CreateRandomConfigValue() string

func Execute

func Execute(ctx context.Context) error

func GetCurrentVersion

func GetCurrentVersion() string

func GetLatestVersion

func GetLatestVersion(ctx context.Context) (string, error)

func IsCompletionCommand

func IsCompletionCommand(cmd *cobra.Command) bool

func SetupCommands

func SetupCommands(ctx context.Context, version string)

Types

type ColorMode

type ColorMode string
const (
	// ColorNever disables color output.
	ColorNever ColorMode = "never"
	// ColorAuto enables color output only if the output is connected to a terminal.
	ColorAuto ColorMode = "auto"
	// ColorAlways enables color output.
	ColorAlways ColorMode = "always"
)

func (*ColorMode) Set

func (c *ColorMode) Set(value string) error

func (ColorMode) String

func (c ColorMode) String() string

func (ColorMode) Type

func (c ColorMode) Type() string

type ExitCode

type ExitCode int

func (ExitCode) Error

func (e ExitCode) Error() string

type Mode

func (*Mode) Set

func (b *Mode) Set(s string) error

func (Mode) String

func (b Mode) String() string

func (Mode) Type

func (b Mode) Type() string

func (Mode) Value

func (b Mode) Value() defangv1.DeploymentMode

type ServiceTableItem

type ServiceTableItem struct {
	Deployment string `json:"Deployment"`
	Status     string `json:"Status"`
	Name       string `json:"Name"`
	DomainName string `json:"DomainName"`
	Endpoints  string `json:"Endpoints"`
}

Jump to

Keyboard shortcuts

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