mirror of
https://github.com/thegeeklab/drone-plugin-lib.git
synced 2024-11-13 03:30:40 +00:00
Add Pipeline type
This commit is contained in:
parent
99e18f9a03
commit
294ca8c890
@ -8,6 +8,18 @@ package plugin
|
||||
import "time"
|
||||
|
||||
type (
|
||||
// Pipeline being executed.
|
||||
//
|
||||
// Represents the full Drone environment that the plugin is executing in.
|
||||
Pipeline struct {
|
||||
Build Build
|
||||
Repo Repo
|
||||
Commit Commit
|
||||
Stage Stage
|
||||
Step Step
|
||||
SemVer SemVer
|
||||
}
|
||||
|
||||
// Build represents a build of a repository.
|
||||
Build struct {
|
||||
// Action that triggered the build. This value is used to differentiate
|
||||
|
@ -38,6 +38,36 @@ import (
|
||||
"github.com/drone-plugins/drone-plugin-lib/pkg/plugin"
|
||||
)
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
// Pipeline
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
// PipelineFlags has the cli.Flags for the plugin.Pipeline.
|
||||
func PipelineFlags() []cli.Flag {
|
||||
flags := []cli.Flag{}
|
||||
|
||||
flags = append(flags, BuildFlags()...)
|
||||
flags = append(flags, RepoFlags()...)
|
||||
flags = append(flags, CommitFlags()...)
|
||||
flags = append(flags, StageFlags()...)
|
||||
flags = append(flags, StepFlags()...)
|
||||
flags = append(flags, SemVerFlags()...)
|
||||
|
||||
return flags
|
||||
}
|
||||
|
||||
// PipelineFromContext creates a plugin.Pipeline from the cli.Context.
|
||||
func PipelineFromContext(ctx *cli.Context) plugin.Environment {
|
||||
return plugin.Pipeline{
|
||||
Build: BuildFromContext(ctx),
|
||||
Repo: RepoFromContext(ctx),
|
||||
Commit: CommitFromContext(ctx),
|
||||
Stage: StageFromContext(ctx),
|
||||
Step: StepFromContext(ctx),
|
||||
SemVer: SemVerFromContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
// Build Flags
|
||||
//---------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user