0
0
mirror of https://github.com/thegeeklab/wp-plugin-go.git synced 2024-11-22 00:20:38 +00:00

Add Pipeline type

This commit is contained in:
Don 2019-10-10 13:05:11 -07:00
parent 99e18f9a03
commit 294ca8c890
2 changed files with 42 additions and 0 deletions

View File

@ -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

View File

@ -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
//---------------------------------------------------------------------