cmd

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2024 License: Apache-2.0 Imports: 48 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Required = true
	Optional = false
)
View Source
const (
	PROJECT_DEPLOYMENT_ACTION_STOP  string = "stop"
	PROJECT_DEPLOYMENT_ACTION_START string = "start"
	RUNTIME_STOP_WAITTING_DELAY     int    = 1
	ADDONS_RESTART_WAITTING_DELAY   int    = 3
	PAGE_SIZE                       uint64 = 1000
)

Variables

View Source
var CLONE = command.Command{
	Name:      "clone",
	ShortHelp: "clone project or application from Erda",
	Example:   "$ erda-cli clone https://erda.cloud/trial/dop/projects/599",
	Args: []command.Arg{
		command.StringArg{}.Name("url"),
	},
	Flags: []command.Flag{
		command.BoolFlag{Short: "", Name: "cloneApps", Doc: "if false, don't clone applications in the project", DefaultValue: true},
	},
	Run: Clone,
}
View Source
var CONFIG = command.Command{
	Name:      "config",
	ShortHelp: "Config Project workspace configurations operation,including set, get, update, delete",
	Example:   `erda-cli config`,
}
View Source
var CONFIGDELETE = command.Command{
	Name:       "delete",
	ParentName: "CONFIG",
	ShortHelp:  "delete project workspace config",
	Example: `
  $ erda-cli config delete --org xxx --project yyy  --workspace DEV
  $ erda-cli config delete --orgN xxx --project yyy
`,
	Flags: []command.Flag{
		command.StringFlag{Name: "org", Doc: "[required]which org the project belongs", DefaultValue: ""},
		command.StringFlag{Name: "project", Doc: "[required]which project's feature to delete", DefaultValue: ""},
		command.StringFlag{Name: "workspace", Doc: "[optional]which workspace's feature to delete", DefaultValue: ""},
	},
	Run: RunFeaturesDelete,
}
View Source
var CONFIGGET = command.Command{
	Name:       "get",
	ParentName: "CONFIG",
	ShortHelp:  "get project workspace config",
	Example: `
  $ erda-cli config get --org xxx --project yyy --workspace DEV
`,
	Flags: []command.Flag{
		command.StringFlag{Name: "org", Doc: "[required]which org the project belongs", DefaultValue: ""},
		command.StringFlag{Name: "project", Doc: "[required]which project's feature to delete", DefaultValue: ""},
		command.StringFlag{Name: "workspace", Doc: "[optional]which workspace's feature to delete", DefaultValue: ""},
	},
	Run: RunFeaturesGet,
}
View Source
var CONFIGSET = command.Command{
	Name:       "set",
	ParentName: "CONFIG",
	ShortHelp:  "set project workspace config",
	Example: `
  $ erda-cli config set HPA=enable --org xxx --project yyy --workspace DEV
`,
	Args: []command.Arg{
		command.StringArg{}.Name("feature"),
	},
	Flags: []command.Flag{
		command.StringFlag{Name: "org", Doc: "[required]which org the project belongs", DefaultValue: ""},
		command.StringFlag{Name: "project", Doc: "[required]which project's feature to delete", DefaultValue: ""},
		command.StringFlag{Name: "workspace", Doc: "[optional]which workspace's feature to delete", DefaultValue: ""},
	},
	Run: RunFeaturesSet,
}
View Source
var CONFIGUPDATE = command.Command{
	Name:       "update",
	ParentName: "CONFIG",
	ShortHelp:  "update project workspace config",
	Example: `
  $ erda-cli config update ECI=disable --org xxx --project yyy --workspace DEV
`,
	Args: []command.Arg{
		command.StringArg{}.Name("feature"),
	},
	Flags: []command.Flag{
		command.StringFlag{Name: "org", Doc: "[required]which org the project belongs", DefaultValue: ""},
		command.StringFlag{Name: "project", Doc: "[required]which project's feature to delete", DefaultValue: ""},
		command.StringFlag{Name: "workspace", Doc: "[optional]which workspace's feature to delete", DefaultValue: ""},
	},
	Run: RunFeaturesUpdate,
}
View Source
var EXT = command.Command{
	Name:      "ext",
	ShortHelp: "extensions operation sets,including search, pull, push, retag",
	Example:   "$ erda-cli ext",
	Flags: []command.Flag{
		command.BoolFlag{Short: "a", Name: "all", Doc: "if true, query all extensions", DefaultValue: false},
	},
	Run: RunExtensions,
}
View Source
var EXTENSIONSPULL = command.Command{
	Name:       "pull",
	ParentName: "EXT",
	ShortHelp:  "pull extension",
	Example:    "$ erda-cli 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: "the directory to export to", DefaultValue: ""},
	},
	Run: RunExtensionsPull,
}
View Source
var EXTENSIONSPUSH = command.Command{
	Name:       "push",
	ParentName: "EXT",
	ShortHelp:  "push extension",
	Example:    "$ erda-cli ext push -f --public",
	Flags: []command.Flag{
		command.BoolFlag{Short: "f", Name: "force", Doc: "if true, override exist version", DefaultValue: false},
		command.BoolFlag{Short: "a", Name: "all", Doc: "if true, override exist extension and version, must with -f", DefaultValue: false},
		command.StringFlag{Short: "d", Name: "dir", Doc: "the extension dir", DefaultValue: ""},
		command.StringFlag{Short: "r", Name: "registry", Doc: "the new registry", DefaultValue: ""},
	},
	Run: RunExtensionsPush,
}
View Source
var EXTENSIONSRETAG = command.Command{
	Name:       "retag",
	ParentName: "EXT",
	ShortHelp:  "generate retag script",
	Example:    "$ erda-cli ext retag -d extensions -r registry.default.svc.cluster.local:5000 -o retag.sh",
	Flags: []command.Flag{
		command.StringFlag{Short: "d", Name: "dir", Doc: "the extension dir", DefaultValue: "."},
		command.StringFlag{Short: "r", Name: "registry", Doc: "the new registry", DefaultValue: "registry.default.svc.cluster.local:5000"},
		command.StringFlag{Short: "o", Name: "output", Doc: "the output script file", DefaultValue: "retag.sh"},
	},
	Run: RunExtensionsReTag,
}
View Source
var Gorm = command.Command{
	ParentName:                 "",
	Name:                       "gorm",
	ShortHelp:                  "Erda gorm Tools",
	LongHelp:                   "erda-cli gorm --help",
	Example:                    "erda-cli gorm gen --create-table 'create table t (id varchar(64))' --output app/models",
	Hidden:                     false,
	DontHideCursor:             false,
	Args:                       nil,
	MarkFlagRequired:           nil,
	RegisterFlagCompletionFunc: nil,
	ValidArgsFunction:          nil,
	Flags:                      nil,
	Run:                        nil,
}
View Source
var GormGen = command.Command{
	ParentName: "Gorm",
	Name:       "gen",
	ShortHelp:  "gen Go struct from create table stmt",
	LongHelp:   "gen Go struct from create table stmt",
	Example:    "erda-cli gorm gen -f some-file.sql --output app/models",
	Flags: []command.Flag{
		command.StringFlag{
			Short:        "f",
			Name:         "filename",
			Doc:          Doc("the create table stmt", "创建表的 SQL 文件", Required),
			DefaultValue: "",
		},
		command.StringFlag{
			Short:        "o",
			Name:         "output",
			Doc:          Doc("the output directory", "输出的目录", Required),
			DefaultValue: "",
		},
	},
	Run: RunGormGen,
}
View Source
var Gw = command.Command{
	ParentName:                 "",
	Name:                       "gw",
	ShortHelp:                  "Erda Gateway Tools",
	LongHelp:                   "erda-cli gw --help",
	Example:                    "erda-cli gw ls --cluster erda-cloud -o xxxx",
	Hidden:                     false,
	DontHideCursor:             false,
	Args:                       nil,
	MarkFlagRequired:           nil,
	RegisterFlagCompletionFunc: nil,
	ValidArgsFunction:          nil,
	Flags:                      nil,
	Run:                        nil,
}
View Source
var GwCreate = command.Command{
	ParentName: "Gw",
	Name:       "create",
	ShortHelp:  "Creates a gateway package",
	LongHelp:   "Creates a gateway package",
	Example:    "erda-cli gw create hub --domain the-hub.erda.cloud",
	Args: []command.Arg{
		command.StringArg{}.Name("scene"),
	},
	Flags: []command.Flag{
		command.StringFlag{
			Name: "org",
			Doc:  Doc("the org name", "组织名称", Required),
		},
		command.IntFlag{
			Name: "project-id",
			Doc:  Doc("the project id", "项目 ID (随便填一个有权限的项目的 ID)", Required),
		},
		command.StringFlag{
			Name: "env",
			Doc:  Doc("The environment to which the traffic package belongs", "流量入口所属的环境", Required),
		},
		command.StringListFlag{
			Name: "domain",
			Doc:  Doc("the package's domain", "流量入口的域名", true),
		},
	},
	Run: RunGwCreate,
}
View Source
var GwDebugAuth = command.Command{
	ParentName: "Gw",
	Name:       "debug-auth",
	ShortHelp:  "generation auth command lines",
	LongHelp:   "generation auth command lines",
	Example:    `erda-cli gw debug-auth -X POST --uri 'https://sample.io/api?name=chen&age=28' --content-type application/json --data '{"org": "erda"}' --auth-type sign --ak xxx --sk yyy --timestamp `,
	Flags: []command.Flag{
		command.StringFlag{
			Name:         "auth-type",
			Doc:          Doc("auth type, {'sign', 'hmac'}", "", Optional),
			DefaultValue: "sign",
		},
		command.StringFlag{
			Name: "ak",
			Doc:  Doc("the access key id", "", Required),
		},
		command.StringFlag{
			Name: "sk",
			Doc:  Doc("the secret key id", "", Required),
		},
		command.StringFlag{
			Name:         "content-type",
			Doc:          Doc(`the Content-Type, {'', 'x-www-form-urlencoded', 'application/json}`, "", Optional),
			DefaultValue: "application/json",
		},
		command.StringFlag{
			Name: "data",
			Doc:  Doc("request raw body", "", Optional),
		},
		command.StringFlag{
			Name:         "method",
			Short:        "X",
			Doc:          Doc("http method", "", Optional),
			DefaultValue: http.MethodGet,
		},
		command.StringFlag{
			Name: "uri",
			Doc:  Doc("uri", "", Required),
		},
		command.BoolFlag{
			Name: "timestamp",
			Doc:  Doc("with api timestamp", "", Optional),
		},
	},
	Run: RunGwDebugAuth,
}
View Source
var GwDel = command.Command{
	ParentName: "Gw",
	Name:       "del",
	ShortHelp:  "Deletes package apis with the input data",
	LongHelp:   "Deletes package apis with the input data",
	Example:    "erda-cli gw del -f xxx.json",
	Flags: []command.Flag{
		command.StringFlag{
			Name: "pkg-id",
			Doc:  Doc("the package's id", "流量入口的 id", Required),
		},
		command.StringFlag{
			Name:  "input",
			Short: "i",
			Doc:   Doc("api list json file, generated by erda-cli gw dump", "api 列表文件, 由 erda-cli gw dump 生成", Required),
		},
		command.StringFlag{
			Name: "org",
			Doc:  Doc("the org name", "组织名称", Required),
		},
	},
	Run: RunGwDel,
}
View Source
var GwDump = command.Command{
	ParentName: "Gw",
	Name:       "dump",
	ShortHelp:  "Dumps a package's endpoints\\n下载一个流量入口的全部路由",
	LongHelp:   "Dumps a package's endpoints\\n下载一个流量入口的全部路由",
	Example:    "erda-cli gw dump --pkg-id xxx -o xxx.json",
	Flags: []command.Flag{
		command.StringFlag{
			Name: "pkg-id",
			Doc:  Doc("the package's id", "流量入口的 id", Required),
		},
		command.StringFlag{
			Short: "o",
			Name:  "output",
			Doc:   Doc("output json filename", "输出文件", Optional),
		},
		command.StringFlag{
			Name: "org",
			Doc:  Doc("the org name", "组织名称", Required),
		},
	},
	Run: RunGwDump,
}
View Source
var GwGc = command.Command{
	ParentName: "Gw",
	Name:       "gc",
	ShortHelp:  "Erda Gateway delete invalid endpoints",
	LongHelp:   "Erda Gateway delete invalid endpoints",
	Example:    "erda-cli gw gc -i erda.cloud.invalid-endpoints.json --kong-admin https://your-admin-host --cluster your-cluster",
	Flags: []command.Flag{
		command.StringFlag{
			Short:        "i",
			Name:         "input",
			Doc:          "[Required] the input file which is generated from 'erda-cli gw ls'",
			DefaultValue: "",
		},
		command.StringFlag{
			Short:        "o",
			Name:         "output",
			Doc:          "[Optional] the output file for the result",
			DefaultValue: "",
		},
		command.StringFlag{
			Short:        "C",
			Name:         "cluster",
			Doc:          "[Required] cluster specified",
			DefaultValue: "",
		},
		command.StringFlag{
			Short:        "",
			Name:         "kong-admin",
			Doc:          "[Required] replace the kong-admin host from the input file",
			DefaultValue: "",
		},
		command.BoolFlag{
			Short:        "y",
			Name:         "yes",
			Doc:          "[Optional] to be sure to delete",
			DefaultValue: false,
		},
		command.BoolFlag{
			Short:        "",
			Name:         "delete-from-erda",
			Doc:          "[Optional] delete endpoints from erda if specified this, or else only delete from Kong",
			DefaultValue: false,
		},
	},
	Run: RunGwGc,
}
View Source
var GwLs = command.Command{
	ParentName: "Gw",
	Name:       "ls",
	ShortHelp:  "Erda Gateway list all invalid endpoints",
	LongHelp:   "Erda Gateway list all invalid endpoints",
	Example:    "erda-cli gw ls --invalid-only --cluster erda-cloud -o erda-cloud.invalid-endpoints.json",
	Flags: []command.Flag{
		command.BoolFlag{
			Short:        "",
			Name:         "invalid-only",
			Doc:          "[Required] --invalid-only must be specified",
			DefaultValue: false,
		},
		command.StringFlag{
			Short:        "C",
			Name:         "cluster",
			Doc:          "[Required] the cluster name must be specified",
			DefaultValue: "",
		},
		command.StringFlag{
			Short:        "o",
			Name:         "output",
			Doc:          "[Optional] the output file should be specified",
			DefaultValue: "",
		},
		command.StringFlag{
			Short:        "",
			Name:         "hepa",
			Doc:          "[Optional] hepa address like https://hepa.erda.cloud",
			DefaultValue: "",
		},
	},
	Run: RunGwLs,
}
View Source
var ISSUE = command.Command{
	Name:      "issue",
	ShortHelp: "list issue already started to handle",
	Example:   "$ erda-cli issue",
	Flags: []command.Flag{
		command.BoolFlag{Short: "", Name: "no-headers", Doc: "if true, don't print headers (default print headers)", DefaultValue: false},
		command.BoolFlag{Short: "", Name: "requirement", Doc: "if true, list requirements", DefaultValue: false},
		command.BoolFlag{Short: "", Name: "task", Doc: "if true, list tasks", DefaultValue: false},
		command.BoolFlag{Short: "", Name: "bug", Doc: "if true, list bugs", DefaultValue: false},
		command.IntFlag{Short: "", Name: "page-size", Doc: "the number of page size", DefaultValue: 10},
	},
	Run: MyIssueList,
}
View Source
var ISSUECLOSE = command.Command{
	Name:       "close",
	ParentName: "ISSUE",
	ShortHelp:  "close an issue",
	Example:    "$ erda-cli close <issue-id>",
	Args: []command.Arg{
		command.IntArg{}.Name("issue-id"),
	},
	Flags: []command.Flag{
		command.StringFlag{Short: "", Name: "man-hour", Doc: "time for work, in format of 2m/2h/2d/2w", DefaultValue: ""},
	},
	ValidArgsFunction: CloseIssueCompletion,
	Run:               IssueClose,
}
View Source
var ISSUEFIX = command.Command{
	Name:       "fix",
	ParentName: "ISSUE",
	ShortHelp:  "create new branch to fix issue",
	Example:    "$ erda-cli fix <issue-id> --branch=<new> --base-branch=<base> --application=<name>",
	Args: []command.Arg{
		command.IntArg{}.Name("issue-id"),
	},
	Flags: []command.Flag{
		command.StringFlag{Short: "", Name: "application", Doc: "name of the application", DefaultValue: ""},
		command.StringFlag{Short: "", Name: "branch", Doc: "branch to create and checkout", DefaultValue: ""},
		command.StringFlag{Short: "", Name: "base-branch", Doc: "branch as base to create from", DefaultValue: ""},
	},
	ValidArgsFunction: FixIssueCompletion,
	Run:               IssueFix,
}
View Source
var ISSUETOPEN = command.Command{
	Name:       "open",
	ParentName: "ISSUE",
	ShortHelp:  "open the issue page in browser",
	Example:    "$ erda-cli issue open <issue-id>",
	Args: []command.Arg{
		command.IntArg{}.Name("issue-id"),
	},
	ValidArgsFunction: OpenIssueCompletion,
	Run:               IssueOpen,
}
View Source
var MR = command.Command{
	Name:      "mr",
	ShortHelp: "handle merge request in erda",
	Example:   "$ erda-cli mr",
}
View Source
var MRCOMPARE = command.Command{
	Name:       "compare",
	ParentName: "MR",
	ShortHelp:  "compare merge request in browser",
	Example:    "$ erda-cli mr --application=<name> --from=<feature/new> --to=<master>",
	Flags: []command.Flag{
		command.StringFlag{Short: "", Name: "application", Doc: "name of the application", DefaultValue: ""},
		command.StringFlag{Short: "", Name: "from", Doc: "branch contains source code", DefaultValue: ""},
		command.StringFlag{Short: "", Name: "to", Doc: "branch contains base code", DefaultValue: ""},
	},
	Run: MrCompare,
}
View Source
var MRCREATE = command.Command{
	Name:       "create",
	ParentName: "MR",
	ShortHelp:  "create merge request",
	Example:    "$ erda-cli mr create --application=<name> --from=<feature-branch> --to=<master>",
	Flags: []command.Flag{
		command.StringFlag{Short: "", Name: "application", Doc: "name of the application", DefaultValue: ""},
		command.StringFlag{Short: "", Name: "from", Doc: "branch contains source code", DefaultValue: ""},
		command.StringFlag{Short: "", Name: "to", Doc: "branch contains base code", DefaultValue: ""},
		command.StringFlag{Short: "", Name: "title", Doc: "title of merge request", DefaultValue: ""},
		command.StringFlag{Short: "", Name: "description", Doc: "desc of merge request", DefaultValue: ""},
		command.Uint64Flag{Short: "", Name: "issue-id", Doc: "relate issue id", DefaultValue: 0},
		command.BoolFlag{Short: "", Name: "remove", Doc: "if true, remove merge source branch", DefaultValue: true},
		command.BoolFlag{Short: "", Name: "open", Doc: "if true, open merge request page in browser", DefaultValue: false},
	},
	RegisterFlagCompletionFunc: map[string]interface{}{
		"application": MrCreateApplicationCompletion,
		"from":        MrCreateBranchCompletion,
		"to":          MrCreateBranchCompletion,
		"issue-id":    MrCreateIssueCompletion,
	},
	Run: MrCreate,
}
View Source
var MROPEN = command.Command{
	Name:       "open",
	ParentName: "MR",
	ShortHelp:  "open merge request in browser",
	Example:    "$ erda-cli mr open <mr-id>",
	Args: []command.Arg{
		command.IntArg{}.Name("mr-id"),
	},
	Flags: []command.Flag{
		command.StringFlag{Short: "", Name: "application", Doc: "name of the application", DefaultValue: ""},
	},
	Run: MrOpen,
}
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: "",
		},
	},
	Run: RunMigrateLint,
}
View Source
var PIPELINERUN = command.Command{
	Name:      "build",
	ShortHelp: "create a pipeline and run it",
	Example:   "$ erda-cli build <path-to/pipeline.yml>",
	Args: []command.Arg{
		command.StringArg{}.Name("filename"),
	},
	Flags: []command.Flag{
		command.StringFlag{Short: "", Name: "branch", Doc: "branch to create pipeline, default is current branch", DefaultValue: ""},
		command.BoolFlag{Short: "w", Name: "watch", Doc: "watch the status", DefaultValue: false},
	},
	ValidArgsFunction:          FilenameCompletion,
	RegisterFlagCompletionFunc: map[string]interface{}{"branch": BranchCompletion},
	Run:                        PipelineRun,
}
View Source
var PROJECTCREATE = command.Command{
	Name:      "create",
	ShortHelp: "create project",
	Example:   "erda-cli create --name=<name>",
	Flags: []command.Flag{
		command.StringFlag{Short: "", Name: "org", Doc: "the name of an organization", DefaultValue: ""},
		command.StringFlag{Short: "n", Name: "name", Doc: "the name of the project ", DefaultValue: ""},
		command.StringFlag{Short: "d", Name: "description", Doc: "description of the project", DefaultValue: ""},
		command.StringFlag{Short: "", Name: "init-package", Doc: "package for init the project", DefaultValue: ""},
		command.StringListFlag{Short: "", Name: "init-env", Doc: "environment (DEV/TEST/STAGING/PROD) to init", DefaultValue: nil},
		command.IntFlag{Short: "", Name: "wait-import", Doc: "minutes wait for package to be import", DefaultValue: 1},
	},
	Run: ProjectCreate,
}
View Source
var PROJECTDEPLOYMENT = command.Command{
	Name:      "project-deployment",
	ShortHelp: "Project workspace deployment operation,including stop, start",
	Example:   `dice project-deployment`,
}
View Source
var PROJECTDEPLOYMENTSTART = command.Command{
	Name:       "start",
	ParentName: "PROJECTDEPLOYMENT",
	ShortHelp:  "start project's runtimes and addons",
	Example: `
  $ erda-cli project-deployment start --org xxx --project yyy --workspace DEV
`,
	Flags: []command.Flag{
		command.StringFlag{Name: "org", Doc: "[required] the org name the project belongs to", DefaultValue: ""},
		command.StringFlag{Name: "project", Doc: "[required] which project's runtimes to stop", DefaultValue: ""},
		command.StringFlag{Name: "workspace", Doc: "[required] which workspace's runtimes to stop", DefaultValue: ""},
	},
	Run: RunStartProjectInWorkspace,
}
View Source
var PROJECTDEPLOYMENTSTOP = command.Command{
	Name:       "stop",
	ParentName: "PROJECTDEPLOYMENT",
	ShortHelp:  "stop project's runtimes and addons",
	Example: `
  $ erda-cli project-deployment stop --org xxx  --project yyy --workspace DEV
`,
	Flags: []command.Flag{
		command.StringFlag{Name: "org", Doc: "[required] the org name the project belongs to", DefaultValue: ""},
		command.StringFlag{Name: "project", Doc: "[required] which project's runtimes to stop", DefaultValue: ""},
		command.StringFlag{Name: "workspace", Doc: "[required] which workspace's runtimes to stop", DefaultValue: ""},
	},
	Run: RunStopProjectInWorkspace,
}
View Source
var PUSH = command.Command{
	Name:      "push",
	ShortHelp: "push project to a Erda platform",
	Example:   "$ erda-cli push <project-url>",
	Args: []command.Arg{
		command.StringArg{}.Name("url"),
	},
	Flags: []command.Flag{
		command.StringListFlag{Short: "", Name: "application", Doc: "applications to push", DefaultValue: nil},
		command.StringFlag{Short: "", Name: "configfile", Doc: "config file contains applications", DefaultValue: ""},
		command.BoolFlag{Short: "", Name: "all", Doc: "if true, push all applications", DefaultValue: false},
		command.BoolFlag{Short: "", Name: "force", Doc: "if true, git push with --force flag", DefaultValue: false},
	},
	Run: Push,
}
View Source
var VERSION = command.Command{
	Name:      "version",
	ShortHelp: "show erda version info",
	Example:   "$ erda-cli version",
	Run:       RunVersion,
}
View Source
var VIEW = command.Command{
	Name:      "view",
	ShortHelp: "View pipeline status",
	Example:   "$ erda-cli view -i <pipelineId>",
	Flags: []command.Flag{
		command.StringFlag{Short: "b", Name: "branch", Doc: "specify branch to show pipeline status, default is current branch", DefaultValue: ""},
		command.Uint64Flag{Short: "i", Name: "pipelineID", Doc: "specify pipeline id to show pipeline status", DefaultValue: 0},
		command.BoolFlag{Short: "w", Name: "watch", Doc: "watch the status", DefaultValue: false},
	},
	Run: PipelineView,
}

Functions

func BranchCompletion

func BranchCompletion(ctx *cobra.Command, args []string, toComplete string, filename, branch string, watch bool) []string

func Clone

func Clone(ctx *command.Context, ustr string, cloneApps bool) error

func CloseIssueCompletion

func CloseIssueCompletion(ctx *cobra.Command, args []string, toComplete string, issueID int, manHour string) []string

func Doc

func Doc(en, zh string, required bool) string

func FilenameCompletion

func FilenameCompletion(ctx *cobra.Command, args []string, toComplete string, filename, branch string, watch bool) []string

func FixIssueCompletion

func FixIssueCompletion(ctx *cobra.Command, args []string, toComplete string, issueID int, application, branch, baseBranch string) []string

func GenSHA256HashCode

func GenSHA256HashCode(stringMessage string) string

func GetProjectAddonsRoutingKeysForStopOrStart

func GetProjectAddonsRoutingKeysForStopOrStart(ctx *command.Context, params PDParameters) ([]string, error)

func GetProjectApplicationIds

func GetProjectApplicationIds(ctx *command.Context, params PDParameters) ([]string, error)

func GetProjectApplicationRuntimesIDsForStopOrStart

func GetProjectApplicationRuntimesIDsForStopOrStart(ctx *command.Context, params PDParameters, applicationId string) ([]string, error)

func GwDelPreCheck

func GwDelPreCheck(input string, output *string, cluster, kongAdmin string, deleteFromErda bool) error

func HepaHostFromOpenapi

func HepaHostFromOpenapi(ctx *command.Context, hepa string) error

func HmacGenAuthorization

func HmacGenAuthorization(ak, signature, digest string) string

HmacGenAuthorization constructs the value of the request header Authorization

func HmacGenDate

func HmacGenDate() (string, error)

HmacGenDate outputs the current time in the format required by the erda gateway hmac-auth policy.

func HmacGenDigest

func HmacGenDigest(data []byte) (string, error)

HmacGenDigest implements the digest algorithm for raw bodies. Note: When computing the signature, encode it from binary to string using the Base64 method.

func HmacGenSignature

func HmacGenSignature(signingString, sk string) (string, error)

HmacGenSignature generates a signature based on the given date, method, reqeustLine, digest and sk.

func HmacGenSigningString

func HmacGenSigningString(date, method, requestLine, digest string) string

HmacGenSigningString generates the string to be signed

func IssueClose

func IssueClose(ctx *command.Context, issueID int, manHour string) error

func IssueCompletion

func IssueCompletion(ctx *cobra.Command, args []string, toComplete string, issueID int) []string

func IssueFix

func IssueFix(ctx *command.Context, issueID int, application, branch, baseBranch string) error

func IssueOpen

func IssueOpen(ctx *command.Context, issueID int) error

func MrCompare

func MrCompare(ctx *command.Context, application, from, to string) error

func MrCreate

func MrCreate(ctx *command.Context, application, from, to, title, desc string, issueID uint64, remove, open bool) error

func MrCreateApplicationCompletion

func MrCreateApplicationCompletion(ctx *cobra.Command, args []string, toComplete string, application, from, to, title, desc string, issueID uint64, remove, open bool) []string

func MrCreateBranchCompletion

func MrCreateBranchCompletion(ctx *cobra.Command, args []string, toComplete string, application, from, to, title, desc string, issueID uint64, remove, open bool) []string

func MrCreateIssueCompletion

func MrCreateIssueCompletion(ctx *cobra.Command, args []string, toComplete string, application, from, to, title, desc string, issueID uint64, remove, open bool) []string

func MrOpen

func MrOpen(ctx *command.Context, mrID int, application string) error

func MyIssueList

func MyIssueList(ctx *command.Context, noHeaders, requirement, task, bug bool, pageSize int) error

func OpenIssueCompletion

func OpenIssueCompletion(ctx *cobra.Command, args []string, toComplete string, issueID int) []string

func PipelineRun

func PipelineRun(ctx *command.Context, filename, branch string, watch bool) error

Create an pipeline and run it

func PipelineView

func PipelineView(ctx *command.Context, branch string, pipelineID uint64, watch bool) (err error)

func ProjectCreate

func ProjectCreate(ctx *command.Context, org, project, desc, pkg string, envs []string, waitImport int) error

func Push

func Push(ctx *command.Context, urlstr string, applications []string, configfile string, pushall, force bool) error

func RmSandbox

func RmSandbox(name string) error

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 RunFeaturesDelete

func RunFeaturesDelete(ctx *command.Context, org, project, workspace string) error

func RunFeaturesGet

func RunFeaturesGet(ctx *command.Context, org, project, workspace string) error

func RunFeaturesSet

func RunFeaturesSet(ctx *command.Context, feature, org, project, workspace string) error

func RunFeaturesUpdate

func RunFeaturesUpdate(ctx *command.Context, feature, org, project, workspace string) error

func RunGormGen

func RunGormGen(ctx *command.Context, filename, output string) error

func RunGwCreate

func RunGwCreate(ctx *command.Context, scene string, orgName string, projectID int, env string, domains []string) error

func RunGwDebugAuth

func RunGwDebugAuth(ctx *command.Context, auth, ak, sk, contentType, data, method, uri string, timestamp bool) error

func RunGwDel

func RunGwDel(ctx *command.Context, pkgID, input, orgName string) error

func RunGwDump

func RunGwDump(ctx *command.Context, pkgId, output, orgName string) error

func RunGwGc

func RunGwGc(context *command.Context, input, output, cluster, kongAdmin string, yes, deleteFromErda bool) error

func RunGwLs

func RunGwLs(context *command.Context, invalidOnly bool, cluster, output, hepa string) error

func RunMigrate

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

func RunMigrateLint(ctx *command.Context, input, filename string) (err error)

func RunMigrateMkPy

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

func RunMigrateMkPyPkg

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

func RunMigrateRecord

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

func RunStartProjectInWorkspace

func RunStartProjectInWorkspace(ctx *command.Context, org, project, workspace string) error

func RunStopProjectInWorkspace

func RunStopProjectInWorkspace(ctx *command.Context, org, project, workspace string) error

func RunVersion

func RunVersion(ctx *command.Context) error

func SQLTypeToGoType

func SQLTypeToGoType(name string, tp byte) string

func Sha512

func Sha512(s string) string

func StandardMigrateLint

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

func StartProjectWorkspaceAddons

func StartProjectWorkspaceAddons(ctx *command.Context, addonIds []string, params PDParameters) error

func StartProjectWorkspaceRuntimes

func StartProjectWorkspaceRuntimes(ctx *command.Context, runtimeIds []string, params PDParameters) error

func StartSandbox

func StartSandbox(exposePort int, name string) error

func StopProjectWorkspaceAddons

func StopProjectWorkspaceAddons(ctx *command.Context, addonIds []string, params PDParameters) error

func StopProjectWorkspaceRuntimes

func StopProjectWorkspaceRuntimes(ctx *command.Context, runtimeIds []string, params PDParameters) error

func StopSandbox

func StopSandbox(name string) error

func TableNameToStructName

func TableNameToStructName(name string) string

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

type Field

type Field struct {
	Name   string
	Type   string
	Tag    string
	Column string
}

type GetApplicationRuntimesDataEleExtra

type GetApplicationRuntimesDataEleExtra struct {
	ApplicationID uint64
	BuildID       uint64
	Workspace     string
}

type GetApplicationRuntimesResponse

type GetApplicationRuntimesResponse struct {
	apistructs.Header
	Data []*bundle.GetApplicationRuntimesDataEle
}

type InvalidEndpoints

type InvalidEndpoints struct {
	Success bool                 `json:"success"`
	Data    InvalidEndpointsData `json:"data"`
}

type InvalidEndpointsData

type InvalidEndpointsData struct {
	Total                   int                    `json:"total"`
	TotalProjectIsInvalid   int                    `json:"totalProjectIsInvalid"`
	TotalRuntimeIsInvalid   int                    `json:"totalRuntimeIsInvalid"`
	TotalInnerAddrIsInvalid int                    `json:"totalInnerAddrIsInvalid"`
	List                    []InvalidEndpointsItem `json:"list"`
}

type InvalidEndpointsItem

type InvalidEndpointsItem struct {
	InvalidReason   string `json:"invalidReason"`
	Type            string `json:"type"`
	ProjectID       string `json:"projectID"`
	PackageID       string `json:"packageID"`
	PackageApiID    string `json:"packageApiID"`
	RuntimeID       string `json:"runtimeID"`
	InnerHostname   string `json:"innerHostname"`
	KongRouteID     string `json:"kongRouteID"`
	KongServiceID   string `json:"kongServiceID"`
	ClusterName     string `json:"clusterName"`
	RouteDeleting   string `json:"routeDeleting"`
	ServiceDeleting string `json:"serviceDeleting"`
}

type ListPackageAPIsResponse

type ListPackageAPIsResponse struct {
	Success bool                        `json:"success"`
	Data    ListPackageAPIsResponseData `json:"data"`
}

type ListPackageAPIsResponseData

type ListPackageAPIsResponseData struct {
	List  []ListPackageAPIsResponseItem `json:"list"`
	Total int                           `json:"total"`
}

type ListPackageAPIsResponseItem

type ListPackageAPIsResponseItem struct {
	AllowPassAuth       bool        `json:"allowPassAuth"`
	ApiId               string      `json:"apiId"`
	ApiPath             string      `json:"apiPath"`
	CreateAt            string      `json:"createAt"`
	Description         string      `json:"description"`
	DiceApp             string      `json:"diceApp"`
	DiceService         string      `json:"diceService"`
	Hosts               interface{} `json:"hosts"`
	Mutable             bool        `json:"mutable"`
	Origin              string      `json:"origin"`
	RedirectAddr        string      `json:"redirectAddr"`
	RedirectApp         string      `json:"redirectApp"`
	RedirectPath        string      `json:"redirectPath"`
	RedirectRuntimeId   string      `json:"redirectRuntimeId"`
	RedirectRuntimeName string      `json:"redirectRuntimeName"`
	RedirectService     string      `json:"redirectService"`
	RedirectType        string      `json:"redirectType"`
}

type PDParameters

type PDParameters struct {
	// contains filtered or unexported fields
}

type Package

type Package struct {
	License string `json:"license"`
	Source  string
	Package string
}

type Table

type Table struct {
	SName     string
	TableName string
	Fields    []Field
}

func Stmt2Struct

func Stmt2Struct(stmt *ast.CreateTableStmt) *Table

Jump to

Keyboard shortcuts

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