Documentation ¶
Index ¶
- Constants
- Variables
- func Execute(ctx context.Context) error
- func GetCurrentVersion() string
- func GetLatestVersion(ctx context.Context) (string, error)
- func IsCompletionCommand(cmd *cobra.Command) bool
- func P(name string, value interface{}) cliClient.Property
- func SetupCommands(ctx context.Context, version string)
- type ColorMode
- type ErrNoPermission
- type ExitCode
- type Mode
Constants ¶
View Source
const DEFANG_PORTAL_HOST = "portal.defang.dev"
View Source
const SERVICE_PORTAL_URL = "https://" + DEFANG_PORTAL_HOST + "/service"
View Source
const TIER_ERROR_MESSAGE = "current subscription tier does not allow this action: "
Variables ¶
View Source
var RootCmd = &cobra.Command{ SilenceUsage: true, SilenceErrors: true, Use: "defang", Args: cobra.NoArgs, Short: "Defang CLI is used to develop, deploy, and debug your cloud services", PersistentPreRunE: func(cmd *cobra.Command, args []string) (err error) { 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 = cli.NewGrpcClient(cmd.Context(), getCluster()) if v, err := client.GetVersions(cmd.Context()); err == nil { version := cmd.Root().Version term.Debug("Fabric:", v.Fabric, "CLI:", version, "CLI-Min:", v.CliMin) if hasTty && isNewer(version, v.CliMin) { term.Warn("Your CLI version is outdated. Please upgrade to the latest version by running:\n\n defang upgrade\n") os.Setenv("DEFANG_HIDE_UPDATE", "1") } } if _, ok := cmd.Annotations[authNeeded]; !ok { return nil } if err = client.CheckLoginAndToS(cmd.Context()); err != nil { if nonInteractive { return err } if connect.CodeOf(err) == connect.CodeUnauthenticated { term.Debug("Server error:", err) term.Warn("Please log in to continue.") defer func() { track.Cmd(nil, "Login", P("reason", err)) }() if err = cli.InteractiveLogin(cmd.Context(), client, gitHubClientId, getCluster()); err != nil { return err } client = cli.NewGrpcClient(cmd.Context(), getCluster()) if err = client.CheckLoginAndToS(cmd.Context()); err == nil { return nil } } if connect.CodeOf(err) == connect.CodeFailedPrecondition { term.Warn(prettyError(err)) defer func() { track.Cmd(nil, "Terms", P("reason", err)) }() if err = cli.InteractiveAgreeToS(cmd.Context(), client); err != nil { return err } } } return err }, }
Functions ¶
func GetCurrentVersion ¶
func GetCurrentVersion() string
func IsCompletionCommand ¶
func SetupCommands ¶
Types ¶
type ErrNoPermission ¶
type ErrNoPermission string
func (ErrNoPermission) Error ¶
func (e ErrNoPermission) Error() string
Click to show internal directories.
Click to hide internal directories.