mirror of
https://github.com/thegeeklab/wp-plugin-go.git
synced 2024-11-22 00:20:38 +00:00
Better separation of network, logging and pipeline
I have reverted some last changes to get logging and network extraction from context separated from the pipeline again as it has been before. Feels much better to have it separated within the generated plugins.
This commit is contained in:
parent
ffc6705536
commit
c46cfdde19
@ -9,12 +9,11 @@ package drone
|
|||||||
//
|
//
|
||||||
// Represents the full Drone environment that the plugin is executing in.
|
// Represents the full Drone environment that the plugin is executing in.
|
||||||
type Pipeline struct {
|
type Pipeline struct {
|
||||||
Network Network
|
Build Build
|
||||||
Build Build
|
Repo Repo
|
||||||
Repo Repo
|
Commit Commit
|
||||||
Commit Commit
|
Stage Stage
|
||||||
Stage Stage
|
Step Step
|
||||||
Step Step
|
SemVer SemVer
|
||||||
SemVer SemVer
|
System System
|
||||||
System System
|
|
||||||
}
|
}
|
||||||
|
@ -21,8 +21,8 @@ func loggingFlags() []cli.Flag {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// loggingFromContext sets the logrus logging level.
|
// LoggingFromContext sets the logrus logging level.
|
||||||
func loggingFromContext(ctx *cli.Context) {
|
func LoggingFromContext(ctx *cli.Context) {
|
||||||
lvl, err := logrus.ParseLevel(ctx.String("log-level"))
|
lvl, err := logrus.ParseLevel(ctx.String("log-level"))
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -29,8 +29,8 @@ func networkFlags() []cli.Flag {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// networkFromContext creates a drone.Network from the cli.Context.
|
// NetworkFromContext creates a drone.Network from the cli.Context.
|
||||||
func networkFromContext(c *cli.Context) drone.Network {
|
func NetworkFromContext(c *cli.Context) drone.Network {
|
||||||
dialer := &net.Dialer{
|
dialer := &net.Dialer{
|
||||||
Timeout: 30 * time.Second,
|
Timeout: 30 * time.Second,
|
||||||
KeepAlive: 30 * time.Second,
|
KeepAlive: 30 * time.Second,
|
||||||
|
@ -27,18 +27,15 @@ func Flags() []cli.Flag {
|
|||||||
return flags
|
return flags
|
||||||
}
|
}
|
||||||
|
|
||||||
// FromContext creates a drone.Pipeline from the cli.Context.
|
// PipelineFromContext creates a drone.Pipeline from the cli.Context.
|
||||||
func FromContext(ctx *cli.Context) drone.Pipeline {
|
func PipelineFromContext(ctx *cli.Context) drone.Pipeline {
|
||||||
loggingFromContext(ctx)
|
|
||||||
|
|
||||||
return drone.Pipeline{
|
return drone.Pipeline{
|
||||||
Network: networkFromContext(ctx),
|
Build: buildFromContext(ctx),
|
||||||
Build: buildFromContext(ctx),
|
Repo: repoFromContext(ctx),
|
||||||
Repo: repoFromContext(ctx),
|
Commit: commitFromContext(ctx),
|
||||||
Commit: commitFromContext(ctx),
|
Stage: stageFromContext(ctx),
|
||||||
Stage: stageFromContext(ctx),
|
Step: stepFromContext(ctx),
|
||||||
Step: stepFromContext(ctx),
|
SemVer: semVerFromContext(ctx),
|
||||||
SemVer: semVerFromContext(ctx),
|
System: systemFromContext(ctx),
|
||||||
System: systemFromContext(ctx),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user