cmd

package
Version: v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2021 License: Apache-2.0 Imports: 37 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BUILD = command.Command{
	Name:      "build",
	ShortHelp: "Create an pipeline and run it",
	Example:   `$ dice build`,
	Flags: []command.Flag{
		command.StringFlag{Short: "b", Name: "branch", Doc: "branch to create pipeline, default is current branch", DefaultValue: ""},
	},
	Run: RunBuild,
}

BUILD command

View Source
var CHECK = command.Command{
	Name:      "check",
	ShortHelp: "Validate dice.yml file",
	Example: `
  $ dice check -f dice.yml
`,
	Flags: []command.Flag{
		command.StringFlag{Short: "f", Name: "file",
			Doc: "Specify the path of dice.yml file, default: .dice/dice.yml", DefaultValue: ""},
	},
	Run:    RunCheck,
	Hidden: true,
}

CHECK command

View Source
var EXT = command.Command{
	Name:      "ext",
	ShortHelp: "Extensions operation sets,including search, pull, push, retag",
	Example:   `dice ext`,
	Flags: []command.Flag{
		command.BoolFlag{Short: "a", Name: "all", Doc: "query all extensions", DefaultValue: false},
	},
	Run: RunExtensions,
}
View Source
var EXTENSIONSPULL = command.Command{
	Name:       "pull",
	ParentName: "EXT",
	ShortHelp:  "pull extension",
	Example: `
  $ dice ext pull git-checkout@1.0 -o git-checkout
`,
	Args: []command.Arg{
		command.StringArg{}.Name("extension"),
	},
	Flags: []command.Flag{
		command.StringFlag{Short: "o", Name: "output", Doc: "which directory to export to", DefaultValue: ""},
	},
	Run: RunExtensionsPull,
}
View Source
var EXTENSIONSPUSH = command.Command{
	Name:       "push",
	ParentName: "EXT",
	ShortHelp:  "push extension",
	Example: `
  $ dice ext push -f --public
`,
	Flags: []command.Flag{
		command.BoolFlag{Short: "f", Name: "force", Doc: "override exist version", DefaultValue: false},
		command.BoolFlag{Short: "a", Name: "all", Doc: "override exist extension and version,must with -f", DefaultValue: false},
		command.StringFlag{Short: "d", Name: "dir", Doc: "extension dir", DefaultValue: ""},
		command.StringFlag{Short: "r", Name: "registry", Doc: "new registry", DefaultValue: ""},
	},
	Run: RunExtensionsPush,
}
View Source
var EXTENSIONSRETAG = command.Command{
	Name:       "retag",
	ParentName: "EXT",
	ShortHelp:  "generate retag script",
	Example: `
  $ dice ext retag -d extensions -r registry.default.svc.cluster.local:5000 -o retag.sh
`,
	Flags: []command.Flag{
		command.StringFlag{Short: "d", Name: "dir", Doc: "extension dir", DefaultValue: "."},
		command.StringFlag{Short: "r", Name: "registry", Doc: "new registry", DefaultValue: "registry.default.svc.cluster.local:5000"},
		command.StringFlag{Short: "o", Name: "output", Doc: "output script file", DefaultValue: "retag.sh"},
	},
	Run: RunExtensionsReTag,
}
View Source
var INIT = Command{
	Name:      "init",
	ShortHelp: "Init a dice.yml template",
	LongHelp:  "Make a .dice dir in current directory, then create a dice.yml template",
	Example: `
  $ dice init
`,
	Run:    RunInit,
	Hidden: true,
}
View Source
var Migrate = command.Command{
	ParentName:     "",
	Name:           "migrate",
	ShortHelp:      "Erda MySQL Migrate",
	LongHelp:       "erda-cli migrate --mysql-host localhost --mysql-username root --mysql-password my_password --database erda",
	Example:        "erda-cli migrate --mysql-host localhost --mysql-username root --mysql-password my_password --database erda",
	Hidden:         false,
	DontHideCursor: false,
	Args:           nil,
	Flags: append(mysqlFlags,
		command.StringFlag{
			Short:        "",
			Name:         "lint-config",
			Doc:          "[Lint] Erda MySQL Lint config file",
			DefaultValue: "",
		},
		command.StringListFlag{
			Short:        "",
			Name:         "modules",
			Doc:          "[Lint] the modules for migrating",
			DefaultValue: nil,
		},
		command.BoolFlag{
			Short:        "",
			Name:         "debug-sql",
			Doc:          "[Migrate] print SQLs",
			DefaultValue: false,
		},
		command.BoolFlag{
			Short:        "",
			Name:         "skip-lint",
			Doc:          "[Lint] don't do Erda MySQL Lint",
			DefaultValue: false,
		},
		command.BoolFlag{
			Short:        "",
			Name:         "skip-sandbox",
			Doc:          "[Migrate] skip doing migration in sandbox",
			DefaultValue: false,
		},
		command.BoolFlag{
			Short:        "",
			Name:         "skip-pre-mig",
			Doc:          "[Migrate] skip doing pre-migration",
			DefaultValue: false,
		},
		command.BoolFlag{
			Short:        "",
			Name:         "skip-mig",
			Doc:          "[Migrate] skip doing pre-migration and real migration",
			DefaultValue: false,
		},
		command.StringFlag{
			Short:        "",
			Name:         "output",
			Doc:          "[Migrate] the directory for collecting SQLs",
			DefaultValue: "",
		},
	),
	Run: RunMigrate,
}
View Source
var MigrateMkPyPkg = command.Command{
	ParentName:     "Migrate",
	Name:           "mkpypkg",
	ShortHelp:      "generate python package",
	LongHelp:       "generate python package",
	Example:        "erda-cli migrate mkpypkg --filename=my_script.py --mysql-host localhost --mysql-port 3306 --mysql-username root --mysql-password *** --database erda --sandbox-port 3307",
	Hidden:         true,
	DontHideCursor: false,
	Args:           nil,
	Flags: append(
		mysqlFlags,
		command.StringFlag{
			Short:        "",
			Name:         "filename",
			Doc:          "python script filename",
			DefaultValue: "",
		},
		command.StringFlag{
			Short:        "",
			Name:         "requirements",
			Doc:          "requirements.txt file name",
			DefaultValue: "",
		},
		command.BoolFlag{
			Short:        "",
			Name:         "commit",
			Doc:          "",
			DefaultValue: false,
		},
	),
	Run: RunMigrateMkPyPkg,
}
View Source
var MigratePy = command.Command{
	ParentName:     "Migrate",
	Name:           "mkpy",
	ShortHelp:      "make a python migration script pattern",
	LongHelp:       "make a python migration scritp pattern.",
	Example:        "erda-cli migrate mkpy --module my_module --name my_script_name",
	Hidden:         false,
	DontHideCursor: false,
	Args:           nil,
	Flags: []command.Flag{
		command.StringFlag{
			Short:        "",
			Name:         "workdir",
			Doc:          "workdir",
			DefaultValue: ".",
		},
		command.StringFlag{
			Short:        "m",
			Name:         "module",
			Doc:          "migration module name",
			DefaultValue: "",
		},
		command.StringFlag{
			Short:        "n",
			Name:         "name",
			Doc:          "script name",
			DefaultValue: "",
		},
		command.StringListFlag{
			Short:        "",
			Name:         "tables",
			Doc:          "dependency tables",
			DefaultValue: nil,
		},
	},
	Run: RunMigrateMkPy,
}
View Source
var MigrateRecord = command.Command{
	ParentName:     "Migrate",
	Name:           "record",
	ShortHelp:      "manually insert the migration record",
	LongHelp:       "manually isnert the migration record",
	Example:        "erda-cli migrate record --filename a.sql",
	Hidden:         false,
	DontHideCursor: false,
	Args:           nil,
	Flags: append(mysqlFlags,
		command.StringFlag{
			Short:        "",
			Name:         "module",
			Doc:          "the recording script module name",
			DefaultValue: "",
		},
		command.StringFlag{
			Short:        "",
			Name:         "filename",
			Doc:          "the recording script filename",
			DefaultValue: "",
		},
		command.BoolFlag{
			Short:        "",
			Name:         "dry",
			Doc:          "dry run",
			DefaultValue: false,
		},
	),
	Run: RunMigrateRecord,
}
View Source
var MigrationLint = command.Command{
	ParentName:     "Migrate",
	Name:           "lint",
	ShortHelp:      "Erda MySQL Migration lint",
	LongHelp:       "Erda MySQL Migration lint",
	Example:        "erda-cli migrate lint --input=. --config=default.yaml --detail",
	Hidden:         false,
	DontHideCursor: false,
	Args:           nil,
	Flags: []command.Flag{
		command.StringFlag{
			Short:        "",
			Name:         "input",
			Doc:          "[optional] the file or directory for linting",
			DefaultValue: ".",
		},
		command.StringFlag{
			Short:        "",
			Name:         "lint-config",
			Doc:          "[optional] the lint config file",
			DefaultValue: "",
		},
		command.BoolFlag{
			Short:        "",
			Name:         "no-detail",
			Doc:          "[optional] do not print details of lint result",
			DefaultValue: false,
		},
		command.StringFlag{
			Short:        "o",
			Name:         "output",
			Doc:          "[optional] result output file name",
			DefaultValue: "",
		},
		command.BoolFlag{
			Short:        "",
			Name:         "custom",
			Doc:          "custom directory",
			DefaultValue: false,
		},
	},
	Run: RunMigrateLint,
}
View Source
var PARSE = Command{
	Name:      "parse",
	ShortHelp: "Parse the dice.yml file",
	Flags: []Flag{
		StringFlag{"f", "file",
			"Specify the path of dice.yml file, default: .dice/dice.yml", ""},
		StringFlag{"s", "str", "Provide the content of dice.yml file as a string", ""},
		BoolFlag{"", "dev", "Parse the dice.yml file in development environment ", false},
		BoolFlag{"", "test", "Parse the dice.yml file in test environment", false},
		BoolFlag{"", "staging", "Parse the dice.yml file in staging environment", false},
		BoolFlag{"", "prod", "Parse the dice.yml in production environment", false},
		BoolFlag{"o", "output", "Output the content as yaml", false},
	},
	Run:    RunParse,
	Hidden: true,
}
View Source
var STATUS = command.Command{
	Name:      "status",
	ShortHelp: "Show build status",
	Example: `
  $ dice status -b develop
`,
	Flags: []command.Flag{
		command.StringFlag{Short: "b", Name: "branch", Doc: "specify branch to show pipeline status, default is current branch", DefaultValue: ""},
		command.IntFlag{Short: "i", Name: "pipelineID", Doc: "specify pipeline id to show pipeline status", DefaultValue: 0},
	},
	Run: RunPipelineStatus,
}
View Source
var VERSION = Command{
	Name:      "version",
	ShortHelp: "Show dice version info",
	Example:   `$ dice version`,
	Run:       RunVersion,
}

Functions

func BuildCheckLoop

func BuildCheckLoop(ctx *command.Context, buildID string) error

BuildCheckLoop checks build status in a loop while interactive is true

func CustomMigrateLint added in v1.1.0

func CustomMigrateLint(ctx *command.Context, input, config string, noDetail bool, output string) (err error)

func PrintWorkFlow

func PrintWorkFlow(ctx *command.Context, buildID string) error

PrintWorkFlow prints build work flow in diagram format

func RmSandbox added in v1.1.0

func RmSandbox(name string) error

func RunBuild

func RunBuild(ctx *command.Context, branch string) error

RunBuild Create an pipeline and run it

func RunCheck

func RunCheck(ctx *command.Context, ymlPath string) error

RunCheck validates dice.yml file

func RunExtensions

func RunExtensions(ctx *command.Context, all bool) error

func RunExtensionsPull

func RunExtensionsPull(ctx *command.Context, extension string, dir string) error

func RunExtensionsPush

func RunExtensionsPush(ctx *command.Context, force bool, all bool, dir, registry string) error

func RunExtensionsReTag

func RunExtensionsReTag(ctx *command.Context, dir string, registry string, output string) error

func RunInit

func RunInit(ctx *Context) error

func RunMigrate added in v1.1.0

func RunMigrate(ctx *command.Context, host string, port int, username, password, database string, sandboxPort int,
	lintConfig string, modules []string, debugSQL, skipLint, skipSandbox, skipPreMig, skipMig bool, output string) error

func RunMigrateLint added in v1.1.0

func RunMigrateLint(ctx *command.Context, input, config string, noDetail bool, output string, custom bool) (err error)

func RunMigrateMkPy added in v1.1.0

func RunMigrateMkPy(ctx *command.Context, workdir, module, name string, tables []string) error

func RunMigrateMkPyPkg added in v1.1.0

func RunMigrateMkPyPkg(ctx *command.Context, host string, port int, username, password, database string, sandboxPort int,
	filename, requirements string, commit bool) (err error)

func RunMigrateRecord added in v1.1.0

func RunMigrateRecord(ctx *command.Context, host string, port int, username, password, database string, sandboxPort int,
	module, filename string, dry bool) error

func RunParse

func RunParse(ctx *Context, ymlPath string, ymlContent string, dev, test, staging, prod, outputYml bool) error

func RunPipelineStatus

func RunPipelineStatus(ctx *command.Context, branch string, pipelineID int) error

RunBuildsInspect displays detailed information on the build record

func RunVersion

func RunVersion(ctx *Context) error

func StandardMigrateLint added in v1.1.0

func StandardMigrateLint(ctx *command.Context, input, config string) (err error)

func StartSandbox added in v1.1.0

func StartSandbox(exposePort int, name string) error

func StopSandbox added in v1.1.0

func StopSandbox(name string) error

Types

type DockerAuth

type DockerAuth struct {
	Auth string `json:"auth"`
}

type DockerConfig

type DockerConfig struct {
	Auths map[string]DockerAuth `json:"auths"`
}

type ExtensionInfo

type ExtensionInfo struct {
	Path    string
	Spec    apistructs.Spec
	Dice    map[string]interface{}
	DiceErr error
	SpecErr error
}

func GetExtMetas

func GetExtMetas(dir string) []ExtensionInfo

Jump to

Keyboard shortcuts

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