mirror of
https://github.com/thegeeklab/drone-plugin-lib.git
synced 2024-11-05 02:40:40 +00:00
Merge pull request #9 from drone-plugins/better-separation
Better separation of network, logging and pipeline
This commit is contained in:
commit
7d346ea6f4
@ -9,12 +9,11 @@ package drone
|
||||
//
|
||||
// Represents the full Drone environment that the plugin is executing in.
|
||||
type Pipeline struct {
|
||||
Network Network
|
||||
Build Build
|
||||
Repo Repo
|
||||
Commit Commit
|
||||
Stage Stage
|
||||
Step Step
|
||||
SemVer SemVer
|
||||
System System
|
||||
Build Build
|
||||
Repo Repo
|
||||
Commit Commit
|
||||
Stage Stage
|
||||
Step Step
|
||||
SemVer SemVer
|
||||
System System
|
||||
}
|
||||
|
@ -21,8 +21,8 @@ func loggingFlags() []cli.Flag {
|
||||
}
|
||||
}
|
||||
|
||||
// loggingFromContext sets the logrus logging level.
|
||||
func loggingFromContext(ctx *cli.Context) {
|
||||
// LoggingFromContext sets the logrus logging level.
|
||||
func LoggingFromContext(ctx *cli.Context) {
|
||||
lvl, err := logrus.ParseLevel(ctx.String("log-level"))
|
||||
|
||||
if err != nil {
|
||||
|
@ -29,8 +29,8 @@ func networkFlags() []cli.Flag {
|
||||
}
|
||||
}
|
||||
|
||||
// networkFromContext creates a drone.Network from the cli.Context.
|
||||
func networkFromContext(c *cli.Context) drone.Network {
|
||||
// NetworkFromContext creates a drone.Network from the cli.Context.
|
||||
func NetworkFromContext(c *cli.Context) drone.Network {
|
||||
dialer := &net.Dialer{
|
||||
Timeout: 30 * time.Second,
|
||||
KeepAlive: 30 * time.Second,
|
||||
|
@ -27,18 +27,15 @@ func Flags() []cli.Flag {
|
||||
return flags
|
||||
}
|
||||
|
||||
// FromContext creates a drone.Pipeline from the cli.Context.
|
||||
func FromContext(ctx *cli.Context) drone.Pipeline {
|
||||
loggingFromContext(ctx)
|
||||
|
||||
// PipelineFromContext creates a drone.Pipeline from the cli.Context.
|
||||
func PipelineFromContext(ctx *cli.Context) drone.Pipeline {
|
||||
return drone.Pipeline{
|
||||
Network: networkFromContext(ctx),
|
||||
Build: buildFromContext(ctx),
|
||||
Repo: repoFromContext(ctx),
|
||||
Commit: commitFromContext(ctx),
|
||||
Stage: stageFromContext(ctx),
|
||||
Step: stepFromContext(ctx),
|
||||
SemVer: semVerFromContext(ctx),
|
||||
System: systemFromContext(ctx),
|
||||
Build: buildFromContext(ctx),
|
||||
Repo: repoFromContext(ctx),
|
||||
Commit: commitFromContext(ctx),
|
||||
Stage: stageFromContext(ctx),
|
||||
Step: stepFromContext(ctx),
|
||||
SemVer: semVerFromContext(ctx),
|
||||
System: systemFromContext(ctx),
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user