cli exec: fix flag type and remove uneffective ones (#4129)

This commit is contained in:
6543 2024-09-24 19:08:18 +02:00 committed by GitHub
parent c06f3e0843
commit 352201dbbd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 55 additions and 11 deletions

View file

@ -125,229 +125,277 @@ var flags = []cli.Flag{
&cli.StringFlag{ &cli.StringFlag{
Sources: cli.EnvVars("CI_SYSTEM_PLATFORM"), Sources: cli.EnvVars("CI_SYSTEM_PLATFORM"),
Name: "system-platform", Name: "system-platform",
Usage: "Set the metadata environment variable \"CI_SYSTEM_PLATFORM\".",
}, },
&cli.StringFlag{ &cli.StringFlag{
Sources: cli.EnvVars("CI_SYSTEM_HOST"), Sources: cli.EnvVars("CI_SYSTEM_HOST"),
Name: "system-host", Name: "system-host",
Usage: "Set the metadata environment variable \"CI_SYSTEM_HOST\".",
}, },
&cli.StringFlag{ &cli.StringFlag{
Sources: cli.EnvVars("CI_SYSTEM_NAME"), Sources: cli.EnvVars("CI_SYSTEM_NAME"),
Name: "system-name", Name: "system-name",
Usage: "Set the metadata environment variable \"CI_SYSTEM_NAME\".",
Value: "woodpecker", Value: "woodpecker",
}, },
&cli.StringFlag{ &cli.StringFlag{
Sources: cli.EnvVars("CI_SYSTEM_URL"), Sources: cli.EnvVars("CI_SYSTEM_URL"),
Name: "system-url", Name: "system-url",
Usage: "Set the metadata environment variable \"CI_SYSTEM_URL\".",
Value: "https://github.com/woodpecker-ci/woodpecker", Value: "https://github.com/woodpecker-ci/woodpecker",
}, },
&cli.StringFlag{ &cli.StringFlag{
Sources: cli.EnvVars("CI_REPO"), Sources: cli.EnvVars("CI_REPO"),
Name: "repo", Name: "repo",
Usage: "full repo name", Usage: "Set the full name to derive metadata environment variables \"CI_REPO\", \"CI_REPO_NAME\" and \"CI_REPO_OWNER\".",
}, },
&cli.StringFlag{ &cli.StringFlag{
Sources: cli.EnvVars("CI_REPO_REMOTE_ID"), Sources: cli.EnvVars("CI_REPO_REMOTE_ID"),
Name: "repo-remote-id", Name: "repo-remote-id",
Usage: "Set the metadata environment variable \"CI_REPO_REMOTE_ID\".",
}, },
&cli.StringFlag{ &cli.StringFlag{
Sources: cli.EnvVars("CI_REPO_URL"), Sources: cli.EnvVars("CI_REPO_URL"),
Name: "repo-url", Name: "repo-url",
Usage: "Set the metadata environment variable \"CI_REPO_URL\".",
}, },
&cli.StringFlag{ &cli.StringFlag{
Sources: cli.EnvVars("CI_REPO_SCM"), Sources: cli.EnvVars("CI_REPO_SCM"),
Name: "repo-scm", Name: "repo-scm",
Usage: "Set the metadata environment variable \"CI_REPO_SCM\".",
Value: "git", Value: "git",
}, },
&cli.StringFlag{ &cli.StringFlag{
Sources: cli.EnvVars("CI_REPO_DEFAULT_BRANCH"), Sources: cli.EnvVars("CI_REPO_DEFAULT_BRANCH"),
Name: "repo-default-branch", Name: "repo-default-branch",
Usage: "Set the metadata environment variable \"CI_REPO_DEFAULT_BRANCH\".",
Value: "main", Value: "main",
}, },
&cli.StringFlag{ &cli.StringFlag{
Sources: cli.EnvVars("CI_REPO_CLONE_URL"), Sources: cli.EnvVars("CI_REPO_CLONE_URL"),
Name: "repo-clone-url", Name: "repo-clone-url",
Usage: "Set the metadata environment variable \"CI_REPO_CLONE_URL\".",
}, },
&cli.StringFlag{ &cli.StringFlag{
Sources: cli.EnvVars("CI_REPO_CLONE_SSH_URL"), Sources: cli.EnvVars("CI_REPO_CLONE_SSH_URL"),
Name: "repo-clone-ssh-url", Name: "repo-clone-ssh-url",
Usage: "Set the metadata environment variable \"CI_REPO_CLONE_SSH_URL\".",
}, },
&cli.StringFlag{ &cli.StringFlag{
Sources: cli.EnvVars("CI_REPO_PRIVATE"), Sources: cli.EnvVars("CI_REPO_PRIVATE"),
Name: "repo-private", Name: "repo-private",
Usage: "Set the metadata environment variable \"CI_REPO_PRIVATE\".",
}, },
&cli.BoolFlag{ &cli.BoolFlag{
Sources: cli.EnvVars("CI_REPO_TRUSTED"), Sources: cli.EnvVars("CI_REPO_TRUSTED"),
Name: "repo-trusted", Name: "repo-trusted",
Usage: "Set the metadata environment variable \"CI_REPO_TRUSTED\".",
}, },
&cli.IntFlag{ &cli.IntFlag{
Sources: cli.EnvVars("CI_PIPELINE_NUMBER"), Sources: cli.EnvVars("CI_PIPELINE_NUMBER"),
Name: "pipeline-number", Name: "pipeline-number",
Usage: "Set the metadata environment variable \"CI_PIPELINE_NUMBER\".",
}, },
&cli.IntFlag{ &cli.IntFlag{
Sources: cli.EnvVars("CI_PIPELINE_PARENT"), Sources: cli.EnvVars("CI_PIPELINE_PARENT"),
Name: "pipeline-parent", Name: "pipeline-parent",
Usage: "Set the metadata environment variable \"CI_PIPELINE_PARENT\".",
}, },
&cli.IntFlag{ &cli.IntFlag{
Sources: cli.EnvVars("CI_PIPELINE_CREATED"), Sources: cli.EnvVars("CI_PIPELINE_CREATED"),
Name: "pipeline-created", Name: "pipeline-created",
Usage: "Set the metadata environment variable \"CI_PIPELINE_CREATED\".",
}, },
&cli.IntFlag{ &cli.IntFlag{
Sources: cli.EnvVars("CI_PIPELINE_STARTED"), Sources: cli.EnvVars("CI_PIPELINE_STARTED"),
Name: "pipeline-started", Name: "pipeline-started",
Usage: "Set the metadata environment variable \"CI_PIPELINE_STARTED\".",
}, },
&cli.StringFlag{ &cli.StringFlag{
Sources: cli.EnvVars("CI_PIPELINE_EVENT"), Sources: cli.EnvVars("CI_PIPELINE_EVENT"),
Name: "pipeline-event", Name: "pipeline-event",
Usage: "Set the metadata environment variable \"CI_PIPELINE_EVENT\".",
Value: "manual", Value: "manual",
}, },
&cli.StringFlag{ &cli.StringFlag{
Sources: cli.EnvVars("CI_PIPELINE_FORGE_URL"), Sources: cli.EnvVars("CI_PIPELINE_FORGE_URL"),
Name: "pipeline-url", Name: "pipeline-url",
Usage: "Set the metadata environment variable \"CI_PIPELINE_FORGE_URL\".",
}, },
&cli.StringFlag{ &cli.StringFlag{
Sources: cli.EnvVars("CI_PIPELINE_DEPLOY_TARGET"), Sources: cli.EnvVars("CI_PIPELINE_DEPLOY_TARGET"),
Name: "pipeline-deploy-to", Name: "pipeline-deploy-to",
Usage: "Set the metadata environment variable \"CI_PIPELINE_DEPLOY_TARGET\".",
}, },
&cli.StringFlag{ &cli.StringFlag{
Sources: cli.EnvVars("CI_PIPELINE_DEPLOY_TASK"), Sources: cli.EnvVars("CI_PIPELINE_DEPLOY_TASK"),
Name: "pipeline-deploy-task", Name: "pipeline-deploy-task",
Usage: "Set the metadata environment variable \"CI_PIPELINE_DEPLOY_TASK\".",
}, },
&cli.StringFlag{ &cli.StringFlag{
Sources: cli.EnvVars("CI_PIPELINE_FILES"), Sources: cli.EnvVars("CI_PIPELINE_FILES"),
Usage: "either json formatted list of strings, or comma separated string list", Usage: "Set the metadata environment variable \"CI_PIPELINE_FILES\", either json formatted list of strings, or comma separated string list.",
Name: "pipeline-files", Name: "pipeline-files",
}, },
&cli.StringFlag{ &cli.StringFlag{
Sources: cli.EnvVars("CI_COMMIT_SHA"), Sources: cli.EnvVars("CI_COMMIT_SHA"),
Name: "commit-sha", Name: "commit-sha",
Usage: "Set the metadata environment variable \"CI_COMMIT_SHA\".",
}, },
&cli.StringFlag{ &cli.StringFlag{
Sources: cli.EnvVars("CI_COMMIT_REF"), Sources: cli.EnvVars("CI_COMMIT_REF"),
Name: "commit-ref", Name: "commit-ref",
Usage: "Set the metadata environment variable \"CI_COMMIT_REF\".",
}, },
&cli.StringFlag{ &cli.StringFlag{
Sources: cli.EnvVars("CI_COMMIT_REFSPEC"), Sources: cli.EnvVars("CI_COMMIT_REFSPEC"),
Name: "commit-refspec", Name: "commit-refspec",
Usage: "Set the metadata environment variable \"CI_COMMIT_REFSPEC\".",
}, },
&cli.StringFlag{ &cli.StringFlag{
Sources: cli.EnvVars("CI_COMMIT_BRANCH"), Sources: cli.EnvVars("CI_COMMIT_BRANCH"),
Name: "commit-branch", Name: "commit-branch",
Usage: "Set the metadata environment variable \"CI_COMMIT_BRANCH\".",
Value: "main", Value: "main",
}, },
&cli.StringFlag{ &cli.StringFlag{
Sources: cli.EnvVars("CI_COMMIT_MESSAGE"), Sources: cli.EnvVars("CI_COMMIT_MESSAGE"),
Name: "commit-message", Name: "commit-message",
Usage: "Set the metadata environment variable \"CI_COMMIT_MESSAGE\".",
}, },
&cli.StringFlag{ &cli.StringFlag{
Sources: cli.EnvVars("CI_COMMIT_AUTHOR"), Sources: cli.EnvVars("CI_COMMIT_AUTHOR"),
Name: "commit-author-name", Name: "commit-author-name",
Usage: "Set the metadata environment variable \"CI_COMMIT_AUTHOR\".",
}, },
&cli.StringFlag{ &cli.StringFlag{
Sources: cli.EnvVars("CI_COMMIT_AUTHOR_AVATAR"), Sources: cli.EnvVars("CI_COMMIT_AUTHOR_AVATAR"),
Name: "commit-author-avatar", Name: "commit-author-avatar",
Usage: "Set the metadata environment variable \"CI_COMMIT_AUTHOR_AVATAR\".",
}, },
&cli.StringFlag{ &cli.StringFlag{
Sources: cli.EnvVars("CI_COMMIT_AUTHOR_EMAIL"), Sources: cli.EnvVars("CI_COMMIT_AUTHOR_EMAIL"),
Name: "commit-author-email", Name: "commit-author-email",
Usage: "Set the metadata environment variable \"CI_COMMIT_AUTHOR_EMAIL\".",
}, },
&cli.StringSliceFlag{ &cli.StringSliceFlag{
Sources: cli.EnvVars("CI_COMMIT_PULL_REQUEST_LABELS"), Sources: cli.EnvVars("CI_COMMIT_PULL_REQUEST_LABELS"),
Name: "commit-pull-labels", Name: "commit-pull-labels",
Usage: "Set the metadata environment variable \"CI_COMMIT_PULL_REQUEST_LABELS\".",
}, },
&cli.BoolFlag{ &cli.BoolFlag{
Sources: cli.EnvVars("CI_COMMIT_PRERELEASE"), Sources: cli.EnvVars("CI_COMMIT_PRERELEASE"),
Name: "commit-release-is-pre", Name: "commit-release-is-pre",
Usage: "Set the metadata environment variable \"CI_COMMIT_PRERELEASE\".",
}, },
&cli.IntFlag{ &cli.IntFlag{
Sources: cli.EnvVars("CI_PREV_PIPELINE_NUMBER"), Sources: cli.EnvVars("CI_PREV_PIPELINE_NUMBER"),
Name: "prev-pipeline-number", Name: "prev-pipeline-number",
Usage: "Set the metadata environment variable \"CI_PREV_PIPELINE_NUMBER\".",
}, },
&cli.IntFlag{ &cli.IntFlag{
Sources: cli.EnvVars("CI_PREV_PIPELINE_CREATED"), Sources: cli.EnvVars("CI_PREV_PIPELINE_CREATED"),
Name: "prev-pipeline-created", Name: "prev-pipeline-created",
Usage: "Set the metadata environment variable \"CI_PREV_PIPELINE_CREATED\".",
}, },
&cli.IntFlag{ &cli.IntFlag{
Sources: cli.EnvVars("CI_PREV_PIPELINE_STARTED"), Sources: cli.EnvVars("CI_PREV_PIPELINE_STARTED"),
Name: "prev-pipeline-started", Name: "prev-pipeline-started",
Usage: "Set the metadata environment variable \"CI_PREV_PIPELINE_STARTED\".",
}, },
&cli.IntFlag{ &cli.IntFlag{
Sources: cli.EnvVars("CI_PREV_PIPELINE_FINISHED"), Sources: cli.EnvVars("CI_PREV_PIPELINE_FINISHED"),
Name: "prev-pipeline-finished", Name: "prev-pipeline-finished",
Usage: "Set the metadata environment variable \"CI_PREV_PIPELINE_FINISHED\".",
}, },
&cli.StringFlag{ &cli.StringFlag{
Sources: cli.EnvVars("CI_PREV_PIPELINE_STATUS"), Sources: cli.EnvVars("CI_PREV_PIPELINE_STATUS"),
Name: "prev-pipeline-status", Name: "prev-pipeline-status",
Usage: "Set the metadata environment variable \"CI_PREV_PIPELINE_STATUS\".",
}, },
&cli.StringFlag{ &cli.StringFlag{
Sources: cli.EnvVars("CI_PREV_PIPELINE_EVENT"), Sources: cli.EnvVars("CI_PREV_PIPELINE_EVENT"),
Name: "prev-pipeline-event", Name: "prev-pipeline-event",
Usage: "Set the metadata environment variable \"CI_PREV_PIPELINE_EVENT\".",
}, },
&cli.StringFlag{ &cli.StringFlag{
Sources: cli.EnvVars("CI_PREV_PIPELINE_FORGE_URL"), Sources: cli.EnvVars("CI_PREV_PIPELINE_FORGE_URL"),
Name: "prev-pipeline-url", Name: "prev-pipeline-url",
Usage: "Set the metadata environment variable \"CI_PREV_PIPELINE_FORGE_URL\".",
}, },
&cli.StringFlag{ &cli.StringFlag{
Sources: cli.EnvVars("CI_PREV_PIPELINE_DEPLOY_TARGET"), Sources: cli.EnvVars("CI_PREV_PIPELINE_DEPLOY_TARGET"),
Name: "prev-pipeline-deploy-to", Name: "prev-pipeline-deploy-to",
Usage: "Set the metadata environment variable \"CI_PREV_PIPELINE_DEPLOY_TARGET\".",
}, },
&cli.StringFlag{ &cli.StringFlag{
Sources: cli.EnvVars("CI_PREV_PIPELINE_DEPLOY_TASK"), Sources: cli.EnvVars("CI_PREV_PIPELINE_DEPLOY_TASK"),
Name: "prev-pipeline-deploy-task", Name: "prev-pipeline-deploy-task",
Usage: "Set the metadata environment variable \"CI_PREV_PIPELINE_DEPLOY_TASK\".",
}, },
&cli.StringFlag{ &cli.StringFlag{
Sources: cli.EnvVars("CI_PREV_COMMIT_SHA"), Sources: cli.EnvVars("CI_PREV_COMMIT_SHA"),
Name: "prev-commit-sha", Name: "prev-commit-sha",
Usage: "Set the metadata environment variable \"CI_PREV_COMMIT_SHA\".",
}, },
&cli.StringFlag{ &cli.StringFlag{
Sources: cli.EnvVars("CI_PREV_COMMIT_REF"), Sources: cli.EnvVars("CI_PREV_COMMIT_REF"),
Name: "prev-commit-ref", Name: "prev-commit-ref",
Usage: "Set the metadata environment variable \"CI_PREV_COMMIT_REF\".",
}, },
&cli.StringFlag{ &cli.StringFlag{
Sources: cli.EnvVars("CI_PREV_COMMIT_REFSPEC"), Sources: cli.EnvVars("CI_PREV_COMMIT_REFSPEC"),
Name: "prev-commit-refspec", Name: "prev-commit-refspec",
Usage: "Set the metadata environment variable \"CI_PREV_COMMIT_REFSPEC\".",
}, },
&cli.StringFlag{ &cli.StringFlag{
Sources: cli.EnvVars("CI_PREV_COMMIT_BRANCH"), Sources: cli.EnvVars("CI_PREV_COMMIT_BRANCH"),
Name: "prev-commit-branch", Name: "prev-commit-branch",
Usage: "Set the metadata environment variable \"CI_PREV_COMMIT_BRANCH\".",
}, },
&cli.StringFlag{ &cli.StringFlag{
Sources: cli.EnvVars("CI_PREV_COMMIT_MESSAGE"), Sources: cli.EnvVars("CI_PREV_COMMIT_MESSAGE"),
Name: "prev-commit-message", Name: "prev-commit-message",
Usage: "Set the metadata environment variable \"CI_PREV_COMMIT_MESSAGE\".",
}, },
&cli.StringFlag{ &cli.StringFlag{
Sources: cli.EnvVars("CI_PREV_COMMIT_AUTHOR"), Sources: cli.EnvVars("CI_PREV_COMMIT_AUTHOR"),
Name: "prev-commit-author-name", Name: "prev-commit-author-name",
Usage: "Set the metadata environment variable \"CI_PREV_COMMIT_AUTHOR\".",
}, },
&cli.StringFlag{ &cli.StringFlag{
Sources: cli.EnvVars("CI_PREV_COMMIT_AUTHOR_AVATAR"), Sources: cli.EnvVars("CI_PREV_COMMIT_AUTHOR_AVATAR"),
Name: "prev-commit-author-avatar", Name: "prev-commit-author-avatar",
Usage: "Set the metadata environment variable \"CI_PREV_COMMIT_AUTHOR_AVATAR\".",
}, },
&cli.StringFlag{ &cli.StringFlag{
Sources: cli.EnvVars("CI_PREV_COMMIT_AUTHOR_EMAIL"), Sources: cli.EnvVars("CI_PREV_COMMIT_AUTHOR_EMAIL"),
Name: "prev-commit-author-email", Name: "prev-commit-author-email",
Usage: "Set the metadata environment variable \"CI_PREV_COMMIT_AUTHOR_EMAIL\".",
}, },
&cli.IntFlag{ &cli.StringFlag{
Sources: cli.EnvVars("CI_WORKFLOW_NAME"), Sources: cli.EnvVars("CI_WORKFLOW_NAME"),
Name: "workflow-name", Name: "workflow-name",
Usage: "Set the metadata environment variable \"CI_WORKFLOW_NAME\".",
}, },
&cli.IntFlag{ &cli.IntFlag{
Sources: cli.EnvVars("CI_WORKFLOW_NUMBER"), Sources: cli.EnvVars("CI_WORKFLOW_NUMBER"),
Name: "workflow-number", Name: "workflow-number",
}, Usage: "Set the metadata environment variable \"CI_WORKFLOW_NUMBER\".",
&cli.IntFlag{
Sources: cli.EnvVars("CI_STEP_NAME"),
Name: "step-name",
}, },
&cli.StringSliceFlag{ &cli.StringSliceFlag{
Sources: cli.EnvVars("CI_ENV"), Sources: cli.EnvVars("CI_ENV"),
Name: "env", Name: "env",
Usage: "Set the metadata environment variable \"CI_ENV\".",
}, },
&cli.StringFlag{ &cli.StringFlag{
Sources: cli.EnvVars("CI_FORGE_TYPE"), Sources: cli.EnvVars("CI_FORGE_TYPE"),
Name: "forge-type", Name: "forge-type",
Usage: "Set the metadata environment variable \"CI_FORGE_TYPE\".",
}, },
&cli.StringFlag{ &cli.StringFlag{
Sources: cli.EnvVars("CI_FORGE_URL"), Sources: cli.EnvVars("CI_FORGE_URL"),
Name: "forge-url", Name: "forge-url",
Usage: "Set the metadata environment variable \"CI_FORGE_URL\".",
}, },
} }

View file

@ -121,10 +121,6 @@ func metadataFromContext(_ context.Context, c *cli.Command, axis matrix.Axis) (m
Number: int(c.Int("workflow-number")), Number: int(c.Int("workflow-number")),
Matrix: axis, Matrix: axis,
}, },
Step: metadata.Step{
Name: c.String("step-name"),
Number: int(c.Int("step-number")),
},
Sys: metadata.System{ Sys: metadata.System{
Name: c.String("system-name"), Name: c.String("system-name"),
URL: c.String("system-url"), URL: c.String("system-url"),