pipeline

package
v0.23.3 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package pipeline provides the defined pipeline CLI commands for Vela.

Usage:

import "github.com/go-vela/cli/command/pipeline"

Index

Constants

This section is empty.

Variables

View Source
var CommandCompile = &cli.Command{
	Name:        "pipeline",
	Description: "Use this command to compile a pipeline.",
	Usage:       "Compile the provided pipeline",
	Action:      compile,
	Flags: []cli.Flag{

		&cli.StringFlag{
			EnvVars: []string{"VELA_ORG", "REPO_ORG"},
			Name:    internal.FlagOrg,
			Aliases: []string{"o"},
			Usage:   "provide the organization for the pipeline",
		},
		&cli.StringFlag{
			EnvVars: []string{"VELA_REPO", "REPO_NAME"},
			Name:    internal.FlagRepo,
			Aliases: []string{"r"},
			Usage:   "provide the repository for the pipeline",
		},

		&cli.StringFlag{
			EnvVars: []string{"VELA_OUTPUT", "REPO_OUTPUT"},
			Name:    internal.FlagOutput,
			Aliases: []string{"op"},
			Usage:   "format the output in json, spew or yaml",
			Value:   "yaml",
		},

		&cli.StringFlag{
			EnvVars: []string{"VELA_REF", "PIPELINE_REF"},
			Name:    "ref",
			Usage:   "provide the repository reference for the pipeline",
			Value:   "main",
		},
	},
	CustomHelpTemplate: fmt.Sprintf(`%s
EXAMPLES:
  1. Compile a pipeline for a repository.
    $ {{.HelpName}} --org MyOrg --repo MyRepo
  2. Compile a pipeline for a repository with json output.
    $ {{.HelpName}} --org MyOrg --repo MyRepo --output json
  3. Compile a pipeline for a repository when config or environment variables are set.
    $ {{.HelpName}}

DOCUMENTATION:

  https://go-vela.github.io/docs/reference/cli/pipeline/compile/
`, cli.CommandHelpTemplate),
}

CommandCompile defines the command for compiling a pipeline.

View Source
var CommandExec = &cli.Command{
	Name:        "pipeline",
	Description: "Use this command to execute a pipeline.",
	Usage:       "Execute the provided pipeline",
	Action:      exec,
	Flags: []cli.Flag{

		&cli.StringFlag{
			EnvVars: []string{"VELA_BRANCH", "PIPELINE_BRANCH", "VELA_BUILD_BRANCH"},
			Name:    "branch",
			Aliases: []string{"b"},
			Usage:   "provide the build branch for the pipeline",
		},
		&cli.StringFlag{
			EnvVars: []string{"VELA_COMMENT", "PIPELINE_COMMENT", "VELA_BUILD_COMMENT"},
			Name:    "comment",
			Aliases: []string{"c"},
			Usage:   "provide the build comment for the pipeline",
		},
		&cli.StringFlag{
			EnvVars: []string{"VELA_EVENT", "PIPELINE_EVENT", "VELA_BUILD_EVENT"},
			Name:    "event",
			Aliases: []string{"e"},
			Usage:   "provide the build event for the pipeline",
		},
		&cli.StringFlag{
			EnvVars: []string{"VELA_TAG", "PIPELINE_TAG", "VELA_BUILD_TAG"},
			Name:    "tag",
			Aliases: []string{"t"},
			Usage:   "provide the build tag for the pipeline",
		},
		&cli.StringFlag{
			EnvVars: []string{"VELA_TARGET", "PIPELINE_TARGET", "VELA_BUILD_TARGET"},
			Name:    "target",
			Usage:   "provide the build target for the pipeline",
		},
		&cli.StringSliceFlag{
			EnvVars: []string{"VELA_FILE_CHANGESET", "FILE_CHANGESET"},
			Name:    "file-changeset",
			Aliases: []string{"fcs"},
			Usage:   "provide a list of files changed for ruleset matching",
		},

		&cli.StringFlag{
			EnvVars: []string{"VELA_OUTPUT", "PIPELINE_OUTPUT"},
			Name:    internal.FlagOutput,
			Aliases: []string{"op"},
			Usage:   "format the output in json, spew or yaml",
			Value:   "yaml",
		},

		&cli.StringFlag{
			EnvVars: []string{"VELA_FILE", "PIPELINE_FILE"},
			Name:    "file",
			Aliases: []string{"f"},
			Usage:   "provide the file name for the pipeline",
			Value:   ".vela.yml",
		},
		&cli.BoolFlag{
			EnvVars: []string{"VELA_LOCAL", "PIPELINE_LOCAL"},
			Name:    "local",
			Aliases: []string{"l"},
			Usage:   "enables mounting local directory to pipeline",
			Value:   true,
		},
		&cli.StringFlag{
			EnvVars: []string{"VELA_PATH", "PIPELINE_PATH"},
			Name:    "path",
			Aliases: []string{"p"},
			Usage:   "provide the path to the file for the pipeline",
		},

		&cli.StringSliceFlag{
			EnvVars: []string{"VELA_VOLUMES", "PIPELINE_VOLUMES"},
			Name:    "volume",
			Aliases: []string{"v"},
			Usage:   "provide list of local volumes to mount",
		},
		&cli.StringSliceFlag{
			EnvVars: []string{"VELA_PRIVILEGED_IMAGES", "PIPELINE_PRIVILEGED_IMAGES"},
			Name:    "privileged-images",
			Aliases: []string{"pi"},
			Usage:   "provide list of pipeline images that will run in privileged mode",
		},

		&cli.StringFlag{
			EnvVars: []string{"VELA_ORG", "PIPELINE_ORG"},
			Name:    internal.FlagOrg,
			Aliases: []string{"o"},
			Usage:   "provide the organization for the pipeline",
		},
		&cli.StringFlag{
			EnvVars: []string{"VELA_REPO", "PIPELINE_REPO"},
			Name:    internal.FlagRepo,
			Aliases: []string{"r"},
			Usage:   "provide the repository for the pipeline",
		},
		&cli.StringFlag{
			EnvVars: []string{"VELA_PIPELINE_TYPE", "PIPELINE_TYPE"},
			Name:    "pipeline-type",
			Aliases: []string{"pt"},
			Usage:   "type of pipeline for the compiler to render",
			Value:   constants.PipelineTypeYAML,
		},

		&cli.StringFlag{
			EnvVars: []string{"VELA_COMPILER_GITHUB_TOKEN", "COMPILER_GITHUB_TOKEN"},
			Name:    internal.FlagCompilerGitHubToken,
			Aliases: []string{"ct"},
			Usage:   "github compiler token",
		},
		&cli.StringFlag{
			EnvVars: []string{"VELA_COMPILER_GITHUB_URL", "COMPILER_GITHUB_URL"},
			Name:    internal.FlagCompilerGitHubURL,
			Aliases: []string{"cgu"},
			Usage:   "github url, used by compiler, for pulling registry templates",
		},
		&cli.StringSliceFlag{
			EnvVars: []string{"VELA_TEMPLATE_FILE", "PIPELINE_TEMPLATE_FILE"},
			Name:    "template-file",
			Aliases: []string{"tf, tfs, template-files"},
			Usage:   "enables using a local template file for expansion in the form <name>:<path>",
		},
		&cli.IntFlag{
			EnvVars: []string{"VELA_MAX_TEMPLATE_DEPTH", "MAX_TEMPLATE_DEPTH"},
			Name:    "max-template-depth",
			Usage:   "set the maximum depth for nested templates",
			Value:   3,
		},
		&cli.Uint64Flag{
			EnvVars: []string{"VELA_COMPILER_STARLARK_EXEC_LIMIT", "COMPILER_STARLARK_EXEC_LIMIT"},
			Name:    "compiler-starlark-exec-limit",
			Aliases: []string{"starlark-exec-limit", "sel"},
			Usage:   "set the starlark execution step limit for compiling starlark pipelines",
			Value:   7500,
		},

		&cli.BoolFlag{
			EnvVars: []string{"VELA_ENV_FILE", "ENV_FILE"},
			Name:    "env-file",
			Aliases: []string{"ef"},
			Usage:   "load environment variables from a .env file",
			Value:   false,
		},
		&cli.StringFlag{
			EnvVars: []string{"VELA_ENV_FILE_PATH", "ENV_FILE_PATH"},
			Name:    "env-file-path",
			Aliases: []string{"efp"},
			Usage:   "provide the path to the file for the environment",
		},
		&cli.BoolFlag{
			EnvVars: []string{"ONBOARD_LOCAL_ENV", "LOCAL_ENV"},
			Name:    "local-env",
			Usage:   "load environment variables from local environment",
			Value:   false,
		},
		&cli.StringSliceFlag{
			EnvVars: []string{"VELA_ENV_VARS"},
			Name:    "env-vars",
			Aliases: []string{"env"},
			Usage:   "load a set of environment variables in the form of KEY1=VAL1,KEY2=VAL2",
		},
	},
	CustomHelpTemplate: fmt.Sprintf(`%s
EXAMPLES:
  1. Execute a local Vela pipeline.
    $ {{.HelpName}}
  2. Execute a local Vela pipeline in a nested directory.
    $ {{.HelpName}} --path nested/path/to/dir --file .vela.local.yml
  3. Execute a local Vela pipeline in a specific directory.
    $ {{.HelpName}} --path /absolute/full/path/to/dir --file .vela.local.yml
  4. Execute a local Vela pipeline with ruleset information.
    $ {{.HelpName}} --branch main --event push
  5. Execute a local Vela pipeline with a read-only local volume.
    $ {{.HelpName}} --volume /tmp/foo.txt:/tmp/foo.txt:ro
  6. Execute a local Vela pipeline with a writeable local volume.
    $ {{.HelpName}} --volume /tmp/bar.txt:/tmp/bar.txt:rw
  7. Execute a local Vela pipeline with type of go
    $ {{.HelpName}} --pipeline-type go
  8. Execute a local Vela pipeline with local templates
    $ {{.HelpName}} --template-file <template_name>:<path_to_template>
  9. Execute a local Vela pipeline with specific environment variables
    $ {{.HelpName}} --env KEY1=VAL1,KEY2=VAL2
  10. Execute a local Vela pipeline with your existing local environment loaded into pipeline
    $ {{.HelpName}} --local-env
  11. Execute a local Vela pipeline with an environment file loaded in
    $ {{.HelpName}} --env-file (uses .env by default)
      OR
    $ {{.HelpName}} --env-file-path <path_to_file>
  12. Execute a local Vela pipeline using remote templates
    $ {{.HelpName}} --compiler.github.token <GITHUB_PAT> --compiler.github.url <GITHUB_URL>

DOCUMENTATION:

  https://go-vela.github.io/docs/reference/cli/pipeline/exec/
`, cli.CommandHelpTemplate),
}

CommandExec defines the command for executing a pipeline.

View Source
var CommandExpand = &cli.Command{
	Name:        "pipeline",
	Description: "Use this command to expand a pipeline.",
	Usage:       "Expand the provided pipeline",
	Action:      expand,
	Flags: []cli.Flag{

		&cli.StringFlag{
			EnvVars: []string{"VELA_ORG", "REPO_ORG"},
			Name:    internal.FlagOrg,
			Aliases: []string{"o"},
			Usage:   "provide the organization for the pipeline",
		},
		&cli.StringFlag{
			EnvVars: []string{"VELA_REPO", "REPO_NAME"},
			Name:    internal.FlagRepo,
			Aliases: []string{"r"},
			Usage:   "provide the repository for the pipeline",
		},

		&cli.StringFlag{
			EnvVars: []string{"VELA_OUTPUT", "REPO_OUTPUT"},
			Name:    internal.FlagOutput,
			Aliases: []string{"op"},
			Usage:   "format the output in json, spew or yaml",
			Value:   "yaml",
		},

		&cli.StringFlag{
			EnvVars: []string{"VELA_REF", "PIPELINE_REF"},
			Name:    "ref",
			Usage:   "provide the repository reference for the pipeline",
			Value:   "main",
		},
	},
	CustomHelpTemplate: fmt.Sprintf(`%s
EXAMPLES:
  1. Expand a pipeline for a repository.
    $ {{.HelpName}} --org MyOrg --repo MyRepo
  2. Expand a pipeline for a repository with json output.
    $ {{.HelpName}} --org MyOrg --repo MyRepo --output json
  3. Expand a pipeline for a repository when config or environment variables are set.
    $ {{.HelpName}}

DOCUMENTATION:

  https://go-vela.github.io/docs/reference/cli/pipeline/expand/
`, cli.CommandHelpTemplate),
}

CommandExpand defines the command for expanding a pipeline.

View Source
var CommandGenerate = &cli.Command{
	Name:        "pipeline",
	Description: "Use this command to generate a pipeline.",
	Usage:       "Generate a valid Vela pipeline",
	Action:      generate,
	Flags: []cli.Flag{

		&cli.StringFlag{
			EnvVars: []string{"VELA_FILE", "PIPELINE_FILE"},
			Name:    "file",
			Aliases: []string{"f"},
			Usage:   "provide the file name for the pipeline",
			Value:   ".vela.yml",
		},
		&cli.StringFlag{
			EnvVars: []string{"VELA_PATH", "PIPELINE_PATH"},
			Name:    "path",
			Aliases: []string{"p"},
			Usage:   "provide the path to the file for the pipeline",
		},
		&cli.StringFlag{
			EnvVars: []string{"VELA_STAGES", "PIPELINE_STAGES"},
			Name:    "stages",
			Aliases: []string{"s"},
			Usage:   "enable generating the pipeline with stages",
			Value:   "false",
		},
		&cli.StringFlag{
			EnvVars: []string{"VELA_TYPE", "PIPELINE_TYPE"},
			Name:    "type",
			Aliases: []string{"t"},
			Usage:   "provide the type of pipeline being generated",
		},
	},
	CustomHelpTemplate: fmt.Sprintf(`%s
EXAMPLES:
  1. Generate a Vela pipeline.
    $ {{.HelpName}}
  2. Generate a Vela pipeline in a nested directory.
    $ {{.HelpName}} --path nested/path/to/dir
  3. Generate a Vela pipeline in a specific directory.
    $ {{.HelpName}} --path /absolute/full/path/to/dir
  4. Generate a Vela pipeline with stages.
    $ {{.HelpName}} --stages true
  5. Generate a go Vela pipeline.
    $ {{.HelpName}} --secret.type go
  6. Generate a java Vela pipeline.
    $ {{.HelpName}} --secret.type java
  7. Generate a node Vela pipeline.
    $ {{.HelpName}} --secret.type node

DOCUMENTATION:

  https://go-vela.github.io/docs/reference/cli/pipeline/generate/
`, cli.CommandHelpTemplate),
}

CommandGenerate defines the command for producing a pipeline.

View Source
var CommandGet = &cli.Command{
	Name:        "pipeline",
	Aliases:     []string{"pipelines"},
	Description: "Use this command to get a list of pipelines.",
	Usage:       "Display a list of pipelines",
	Action:      get,
	Flags: []cli.Flag{

		&cli.StringFlag{
			EnvVars: []string{"VELA_ORG", "PIPELINE_ORG"},
			Name:    internal.FlagOrg,
			Aliases: []string{"o"},
			Usage:   "provide the organization for the pipeline",
		},
		&cli.StringFlag{
			EnvVars: []string{"VELA_REPO", "PIPELINE_REPO"},
			Name:    internal.FlagRepo,
			Aliases: []string{"r"},
			Usage:   "provide the repository for the pipeline",
		},

		&cli.StringFlag{
			EnvVars: []string{"VELA_OUTPUT", "PIPELINE_OUTPUT"},
			Name:    internal.FlagOutput,
			Aliases: []string{"op"},
			Usage:   "format the output in json, spew, wide or yaml",
		},

		&cli.IntFlag{
			EnvVars: []string{"VELA_PAGE", "PIPELINE_PAGE"},
			Name:    internal.FlagPage,
			Aliases: []string{"p"},
			Usage:   "print a specific page of pipelines",
			Value:   1,
		},
		&cli.IntFlag{
			EnvVars: []string{"VELA_PER_PAGE", "PIPELINE_PER_PAGE"},
			Name:    internal.FlagPerPage,
			Aliases: []string{"pp"},
			Usage:   "number of pipelines to print per page",
			Value:   10,
		},
	},
	CustomHelpTemplate: fmt.Sprintf(`%s
EXAMPLES:
  1. Get pipelines for a repository.
    $ {{.HelpName}} --org MyOrg --repo MyRepo
  2. Get pipelines for a repository with wide view output.
    $ {{.HelpName}} --org MyOrg --repo MyRepo --output wide
  3. Get pipelines for a repository with yaml output.
    $ {{.HelpName}} --org MyOrg --repo MyRepo --output yaml
  4. Get pipelines for a repository with json output.
    $ {{.HelpName}} --org MyOrg --repo MyRepo --output json
  5. Get pipelines for a repository when config or environment variables are set.
    $ {{.HelpName}}

DOCUMENTATION:

  https://go-vela.github.io/docs/reference/cli/pipeline/get/
`, cli.CommandHelpTemplate),
}

CommandGet defines the command for capturing a list of pipelines.

View Source
var CommandValidate = &cli.Command{
	Name:        "pipeline",
	Description: "Use this command to validate a pipeline.",
	Usage:       "Validate a Vela pipeline",
	Action:      validate,
	Flags: []cli.Flag{

		&cli.StringFlag{
			EnvVars: []string{"VELA_ORG", "REPO_ORG"},
			Name:    internal.FlagOrg,
			Aliases: []string{"o"},
			Usage:   "provide the organization for the pipeline",
		},
		&cli.StringFlag{
			EnvVars: []string{"VELA_REPO", "REPO_NAME"},
			Name:    internal.FlagRepo,
			Aliases: []string{"r"},
			Usage:   "provide the repository for the pipeline",
		},
		&cli.StringFlag{
			EnvVars: []string{"VELA_PIPELINE_TYPE", "PIPELINE_TYPE"},
			Name:    "pipeline-type",
			Aliases: []string{"pt"},
			Usage:   "type of pipeline for the compiler to render",
			Value:   constants.PipelineTypeYAML,
		},

		&cli.StringFlag{
			EnvVars: []string{"VELA_FILE", "PIPELINE_FILE"},
			Name:    "file",
			Aliases: []string{"f"},
			Usage:   "provide the file name for the pipeline",
			Value:   ".vela.yml",
		},
		&cli.StringFlag{
			EnvVars: []string{"VELA_PATH", "PIPELINE_PATH"},
			Name:    "path",
			Aliases: []string{"p"},
			Usage:   "provide the path to the file for the pipeline",
		},
		&cli.StringFlag{
			EnvVars: []string{"VELA_REF", "PIPELINE_REF"},
			Name:    "ref",
			Usage:   "provide the repository reference for the pipeline",
			Value:   "main",
		},
		&cli.BoolFlag{
			EnvVars: []string{"VELA_TEMPLATE", "PIPELINE_TEMPLATE"},
			Name:    "template",
			Usage:   "DEPRECATED (Vela CLI will attempt to fetch templates if they exist)",
		},
		&cli.StringSliceFlag{
			EnvVars: []string{"VELA_TEMPLATE_FILE", "PIPELINE_TEMPLATE_FILE"},
			Name:    "template-file",
			Usage:   "enables using a local template file for expansion",
		},
		&cli.IntFlag{
			EnvVars: []string{"VELA_MAX_TEMPLATE_DEPTH", "MAX_TEMPLATE_DEPTH"},
			Name:    "max-template-depth",
			Usage:   "set the maximum depth for nested templates",
			Value:   3,
		},
		&cli.Uint64Flag{
			EnvVars: []string{"VELA_COMPILER_STARLARK_EXEC_LIMIT", "COMPILER_STARLARK_EXEC_LIMIT"},
			Name:    "compiler-starlark-exec-limit",
			Aliases: []string{"starlark-exec-limit", "sel"},
			Usage:   "set the starlark execution step limit for compiling starlark pipelines",
			Value:   7500,
		},
		&cli.BoolFlag{
			EnvVars: []string{"VELA_REMOTE", "PIPELINE_REMOTE"},
			Name:    "remote",
			Usage:   "enables validating a pipeline on a remote server",
			Value:   false,
		},

		&cli.StringFlag{
			EnvVars: []string{"VELA_COMPILER_GITHUB_TOKEN", "COMPILER_GITHUB_TOKEN"},
			Name:    internal.FlagCompilerGitHubToken,
			Aliases: []string{"ct"},
			Usage:   "github compiler token",
		},
		&cli.StringFlag{
			EnvVars: []string{"VELA_COMPILER_GITHUB_URL", "COMPILER_GITHUB_URL"},
			Name:    internal.FlagCompilerGitHubURL,
			Aliases: []string{"cgu"},
			Usage:   "github url, used by compiler, for pulling registry templates",
		},
	},
	CustomHelpTemplate: fmt.Sprintf(`%s
EXAMPLES:
  1. Validate a local Vela pipeline.
    $ {{.HelpName}}
  2. Validate a local Vela pipeline in a nested directory.
    $ {{.HelpName}} --path nested/path/to/dir
  3. Validate a local Vela pipeline in a specific directory.
    $ {{.HelpName}} --path /absolute/full/path/to/dir
  4. Validate a remote pipeline for a repository.
    $ {{.HelpName}} --remote --org MyOrg --repo MyRepo
  5. Validate a remote pipeline for a repository with json output.
    $ {{.HelpName}} --remote --org MyOrg --repo MyRepo --output json
  6. Validate a template pipeline with expanding steps (when templates are sourced from private Github instance)
    $ {{.HelpName}} --compiler.github.token <token> --compiler.github.url <url>
  7. Validate a local template pipeline with expanding steps
    $ {{.HelpName}} --template-file name:/path/to/file
  8. Validate a local, nested template pipeline with custom template depth.
    $ {{.HelpName}} --template-file name:/path/to/file name:/path/to/file --max-template-depth 2
DOCUMENTATION:

  https://go-vela.github.io/docs/reference/cli/pipeline/validate/
`, cli.CommandHelpTemplate),
}

CommandValidate defines the command for verifying a pipeline.

View Source
var CommandView = &cli.Command{
	Name:        "pipeline",
	Description: "Use this command to view a pipeline.",
	Usage:       "View details of the provided pipeline",
	Action:      view,
	Flags: []cli.Flag{

		&cli.StringFlag{
			EnvVars: []string{"VELA_ORG", "REPO_ORG"},
			Name:    internal.FlagOrg,
			Aliases: []string{"o"},
			Usage:   "provide the organization for the pipeline",
		},
		&cli.StringFlag{
			EnvVars: []string{"VELA_REPO", "REPO_NAME"},
			Name:    internal.FlagRepo,
			Aliases: []string{"r"},
			Usage:   "provide the repository for the pipeline",
		},

		&cli.StringFlag{
			EnvVars: []string{"VELA_OUTPUT", "REPO_OUTPUT"},
			Name:    internal.FlagOutput,
			Aliases: []string{"op"},
			Usage:   "format the output in json, spew or yaml",
		},

		&cli.StringFlag{
			EnvVars: []string{"VELA_REF", "PIPELINE_REF"},
			Name:    "ref",
			Usage:   "provide the repository reference for the pipeline",
		},
	},
	CustomHelpTemplate: fmt.Sprintf(`%s
EXAMPLES:
  1. View details of a pipeline for a repository.
    $ {{.HelpName}} --org MyOrg --repo MyRepo --ref MyCommitSHA
  2. View details of a pipeline for a repository with json output.
    $ {{.HelpName}} --org MyOrg --repo MyRepo --ref MyCommitSHA
  3. View details of a pipeline for a repository when config or environment variables are set.
    $ {{.HelpName}}

DOCUMENTATION:

  https://go-vela.github.io/docs/reference/cli/pipeline/view/
`, cli.CommandHelpTemplate),
}

CommandView defines the command for inspecting a pipeline.

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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