2022-05-03 20:03:37 +00:00
|
|
|
// Copyright (c) 2019, Drone Plugins project authors
|
|
|
|
// Copyright (c) 2021, Robert Kaussow <mail@thegeeklab.de>
|
|
|
|
|
2019-12-20 20:47:50 +00:00
|
|
|
// Use of this source code is governed by an Apache 2.0 license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
|
|
|
package urfave
|
|
|
|
|
|
|
|
import (
|
2022-05-03 20:03:37 +00:00
|
|
|
"github.com/thegeeklab/drone-plugin-lib/drone"
|
2019-12-20 20:47:50 +00:00
|
|
|
"github.com/urfave/cli/v2"
|
|
|
|
)
|
|
|
|
|
2022-05-29 11:15:31 +00:00
|
|
|
var (
|
|
|
|
FlagsBuildCategory = "Drone Build Flags"
|
|
|
|
FlagsRepoCategory = "Drone Repo Flags"
|
|
|
|
FlagsCommitCategory = "Drone Commit Flags"
|
|
|
|
FlagsStageCategory = "Drone Stage Flags"
|
|
|
|
FlagsStepCategory = "Drone Step Flags"
|
|
|
|
FlagsVersioningCategory = "Drone Versioning Flags"
|
|
|
|
FlagsSystemCategory = "Drone System Flags"
|
|
|
|
FlagsPluginCategory = "Plugin Flags"
|
|
|
|
)
|
|
|
|
|
2019-12-20 20:47:50 +00:00
|
|
|
// Flags has the cli.Flags for the Drone plugin.
|
|
|
|
func Flags() []cli.Flag {
|
|
|
|
flags := []cli.Flag{}
|
|
|
|
|
2022-05-29 11:15:31 +00:00
|
|
|
flags = append(flags, buildFlags(FlagsBuildCategory)...)
|
|
|
|
flags = append(flags, repoFlags(FlagsRepoCategory)...)
|
|
|
|
flags = append(flags, commitFlags(FlagsCommitCategory)...)
|
|
|
|
flags = append(flags, stageFlags(FlagsStageCategory)...)
|
|
|
|
flags = append(flags, stepFlags(FlagsStepCategory)...)
|
|
|
|
flags = append(flags, semVerFlags(FlagsVersioningCategory)...)
|
|
|
|
flags = append(flags, calVerFlags(FlagsVersioningCategory)...)
|
|
|
|
flags = append(flags, systemFlags(FlagsSystemCategory)...)
|
|
|
|
flags = append(flags, networkFlags(FlagsPluginCategory)...)
|
|
|
|
flags = append(flags, loggingFlags(FlagsPluginCategory)...)
|
2019-12-20 20:47:50 +00:00
|
|
|
|
|
|
|
return flags
|
|
|
|
}
|
|
|
|
|
2020-01-20 21:58:54 +00:00
|
|
|
// PipelineFromContext creates a drone.Pipeline from the cli.Context.
|
|
|
|
func PipelineFromContext(ctx *cli.Context) drone.Pipeline {
|
2019-12-20 20:47:50 +00:00
|
|
|
return drone.Pipeline{
|
2020-01-20 21:58:54 +00:00
|
|
|
Build: buildFromContext(ctx),
|
|
|
|
Repo: repoFromContext(ctx),
|
|
|
|
Commit: commitFromContext(ctx),
|
|
|
|
Stage: stageFromContext(ctx),
|
|
|
|
Step: stepFromContext(ctx),
|
|
|
|
SemVer: semVerFromContext(ctx),
|
2020-09-11 13:36:36 +00:00
|
|
|
CalVer: calVerFromContext(ctx),
|
2020-01-20 21:58:54 +00:00
|
|
|
System: systemFromContext(ctx),
|
2019-12-20 20:47:50 +00:00
|
|
|
}
|
|
|
|
}
|