316 lines
6.8 KiB
Go
316 lines
6.8 KiB
Go
package internal
|
|
|
|
import (
|
|
"os"
|
|
|
|
logrusStack "github.com/Gurpartap/logrus-stack"
|
|
"github.com/sirupsen/logrus"
|
|
"github.com/urfave/cli/v2"
|
|
)
|
|
|
|
// Secrets stores the variable from SecretsFlag
|
|
var Secrets bool
|
|
|
|
// SecretsFlag turns on/off automatically generating secrets
|
|
var SecretsFlag = &cli.BoolFlag{
|
|
Name: "secrets",
|
|
Aliases: []string{"S"},
|
|
Usage: "Automatically generate secrets",
|
|
Destination: &Secrets,
|
|
}
|
|
|
|
// Pass stores the variable from PassFlag
|
|
var Pass bool
|
|
|
|
// PassFlag turns on/off storing generated secrets in pass
|
|
var PassFlag = &cli.BoolFlag{
|
|
Name: "pass",
|
|
Aliases: []string{"p"},
|
|
Usage: "Store the generated secrets in a local pass store",
|
|
Destination: &Pass,
|
|
}
|
|
|
|
// PassRemove stores the variable for PassRemoveFlag
|
|
var PassRemove bool
|
|
|
|
// PassRemoveFlag turns on/off removing generated secrets from pass
|
|
var PassRemoveFlag = &cli.BoolFlag{
|
|
Name: "pass",
|
|
Aliases: []string{"p"},
|
|
Usage: "Remove generated secrets from a local pass store",
|
|
Destination: &PassRemove,
|
|
}
|
|
|
|
// Force force functionality without asking.
|
|
var Force bool
|
|
|
|
// ForceFlag turns on/off force functionality.
|
|
var ForceFlag = &cli.BoolFlag{
|
|
Name: "force",
|
|
Aliases: []string{"f"},
|
|
Usage: "Perform action without further prompt. Use with care!",
|
|
Destination: &Force,
|
|
}
|
|
|
|
// Chaos engages chaos mode.
|
|
var Chaos bool
|
|
|
|
// ChaosFlag turns on/off chaos functionality.
|
|
var ChaosFlag = &cli.BoolFlag{
|
|
Name: "chaos",
|
|
Aliases: []string{"C"},
|
|
Usage: "Proceed with uncommitted recipes changes. Use with care!",
|
|
Destination: &Chaos,
|
|
}
|
|
|
|
// Disable tty to run commands from script
|
|
var Tty bool
|
|
|
|
// TtyFlag turns on/off tty mode.
|
|
var TtyFlag = &cli.BoolFlag{
|
|
Name: "tty",
|
|
Aliases: []string{"T"},
|
|
Usage: "Disables TTY mode to run this command from a script.",
|
|
Destination: &Tty,
|
|
}
|
|
|
|
var (
|
|
NoInput bool
|
|
NoInputFlag = &cli.BoolFlag{
|
|
Name: "no-input",
|
|
Aliases: []string{"n"},
|
|
Usage: "Toggle non-interactive mode",
|
|
Destination: &NoInput,
|
|
}
|
|
)
|
|
|
|
// Debug stores the variable from DebugFlag.
|
|
var Debug bool
|
|
|
|
// DebugFlag turns on/off verbose logging down to the DEBUG level.
|
|
var DebugFlag = &cli.BoolFlag{
|
|
Name: "debug",
|
|
Aliases: []string{"d"},
|
|
Destination: &Debug,
|
|
Usage: "Show DEBUG messages",
|
|
}
|
|
|
|
// Offline stores the variable from OfflineFlag.
|
|
var Offline bool
|
|
|
|
// DebugFlag turns on/off offline mode.
|
|
var OfflineFlag = &cli.BoolFlag{
|
|
Name: "offline",
|
|
Aliases: []string{"o"},
|
|
Destination: &Offline,
|
|
Usage: "Prefer offline & filesystem access when possible",
|
|
}
|
|
|
|
// MachineReadable stores the variable from MachineReadableFlag
|
|
var MachineReadable bool
|
|
|
|
// MachineReadableFlag turns on/off machine readable output where supported
|
|
var MachineReadableFlag = &cli.BoolFlag{
|
|
Name: "machine",
|
|
Aliases: []string{"m"},
|
|
Destination: &MachineReadable,
|
|
Usage: "Output in a machine-readable format (where supported)",
|
|
}
|
|
|
|
// RC signifies the latest release candidate
|
|
var RC bool
|
|
|
|
// RCFlag chooses the latest release candidate for install
|
|
var RCFlag = &cli.BoolFlag{
|
|
Name: "rc",
|
|
Aliases: []string{"c"},
|
|
Destination: &RC,
|
|
Usage: "Install the latest release candidate",
|
|
}
|
|
|
|
var (
|
|
Major bool
|
|
MajorFlag = &cli.BoolFlag{
|
|
Name: "major",
|
|
Aliases: []string{"x"},
|
|
Usage: "Increase the major part of the version",
|
|
Destination: &Major,
|
|
}
|
|
)
|
|
|
|
var (
|
|
Minor bool
|
|
MinorFlag = &cli.BoolFlag{
|
|
Name: "minor",
|
|
Aliases: []string{"y"},
|
|
Usage: "Increase the minor part of the version",
|
|
Destination: &Minor,
|
|
}
|
|
)
|
|
|
|
var (
|
|
Patch bool
|
|
PatchFlag = &cli.BoolFlag{
|
|
Name: "patch",
|
|
Aliases: []string{"z"},
|
|
Usage: "Increase the patch part of the version",
|
|
Destination: &Patch,
|
|
}
|
|
)
|
|
|
|
var (
|
|
Dry bool
|
|
DryFlag = &cli.BoolFlag{
|
|
Name: "dry-run",
|
|
Aliases: []string{"r"},
|
|
Usage: "Only reports changes that would be made",
|
|
Destination: &Dry,
|
|
}
|
|
)
|
|
|
|
var (
|
|
Publish bool
|
|
PublishFlag = &cli.BoolFlag{
|
|
Name: "publish",
|
|
Aliases: []string{"p"},
|
|
Usage: "Publish changes to git.coopcloud.tech",
|
|
Destination: &Publish,
|
|
}
|
|
)
|
|
|
|
var (
|
|
Domain string
|
|
DomainFlag = &cli.StringFlag{
|
|
Name: "domain",
|
|
Aliases: []string{"D"},
|
|
Value: "",
|
|
Usage: "Choose a domain name",
|
|
Destination: &Domain,
|
|
}
|
|
)
|
|
|
|
var (
|
|
NewAppServer string
|
|
NewAppServerFlag = &cli.StringFlag{
|
|
Name: "server",
|
|
Aliases: []string{"s"},
|
|
Value: "",
|
|
Usage: "Show apps of a specific server",
|
|
Destination: &NewAppServer,
|
|
}
|
|
)
|
|
|
|
var (
|
|
NoDomainChecks bool
|
|
NoDomainChecksFlag = &cli.BoolFlag{
|
|
Name: "no-domain-checks",
|
|
Aliases: []string{"D"},
|
|
Usage: "Disable app domain sanity checks",
|
|
Destination: &NoDomainChecks,
|
|
}
|
|
)
|
|
|
|
var (
|
|
StdErrOnly bool
|
|
StdErrOnlyFlag = &cli.BoolFlag{
|
|
Name: "stderr",
|
|
Aliases: []string{"s"},
|
|
Usage: "Only tail stderr",
|
|
Destination: &StdErrOnly,
|
|
}
|
|
)
|
|
|
|
var (
|
|
SinceLogs string
|
|
SinceLogsFlag = &cli.StringFlag{
|
|
Name: "since",
|
|
Aliases: []string{"S"},
|
|
Value: "",
|
|
Usage: "tail logs since YYYY-MM-DDTHH:MM:SSZ",
|
|
Destination: &SinceLogs,
|
|
}
|
|
)
|
|
|
|
var (
|
|
DontWaitConverge bool
|
|
DontWaitConvergeFlag = &cli.BoolFlag{
|
|
Name: "no-converge-checks",
|
|
Aliases: []string{"c"},
|
|
Usage: "Don't wait for converge logic checks",
|
|
Destination: &DontWaitConverge,
|
|
}
|
|
)
|
|
|
|
var (
|
|
Watch bool
|
|
WatchFlag = &cli.BoolFlag{
|
|
Name: "watch",
|
|
Aliases: []string{"w"},
|
|
Usage: "Watch status by polling repeatedly",
|
|
Destination: &Watch,
|
|
}
|
|
)
|
|
|
|
var (
|
|
OnlyErrors bool
|
|
OnlyErrorFlag = &cli.BoolFlag{
|
|
Name: "errors",
|
|
Aliases: []string{"e"},
|
|
Usage: "Only show errors",
|
|
Destination: &OnlyErrors,
|
|
}
|
|
)
|
|
|
|
var (
|
|
SkipUpdates bool
|
|
SkipUpdatesFlag = &cli.BoolFlag{
|
|
Name: "skip-updates",
|
|
Aliases: []string{"s"},
|
|
Usage: "Skip updating recipe repositories",
|
|
Destination: &SkipUpdates,
|
|
}
|
|
)
|
|
|
|
var (
|
|
AllTags bool
|
|
AllTagsFlag = &cli.BoolFlag{
|
|
Name: "all-tags",
|
|
Aliases: []string{"a"},
|
|
Usage: "List all tags, not just upgrades",
|
|
Destination: &AllTags,
|
|
}
|
|
)
|
|
|
|
var (
|
|
LocalCmd bool
|
|
LocalCmdFlag = &cli.BoolFlag{
|
|
Name: "local",
|
|
Aliases: []string{"l"},
|
|
Usage: "Run command locally",
|
|
Destination: &LocalCmd,
|
|
}
|
|
)
|
|
|
|
var (
|
|
RemoteUser string
|
|
RemoteUserFlag = &cli.StringFlag{
|
|
Name: "user",
|
|
Aliases: []string{"u"},
|
|
Value: "",
|
|
Usage: "User to run command within a service context",
|
|
Destination: &RemoteUser,
|
|
}
|
|
)
|
|
|
|
// SubCommandBefore wires up pre-action machinery (e.g. --debug handling).
|
|
func SubCommandBefore(c *cli.Context) error {
|
|
if Debug {
|
|
logrus.SetLevel(logrus.DebugLevel)
|
|
logrus.SetFormatter(&logrus.TextFormatter{})
|
|
logrus.SetOutput(os.Stderr)
|
|
logrus.AddHook(logrusStack.StandardHook())
|
|
}
|
|
|
|
return nil
|
|
}
|