-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
519 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
version: 1 | ||
metadata: | ||
cloud66.com/uuid: ff97e4c6 | ||
cloud66.com/test: 123 | ||
logger: | ||
type: "file" | ||
format: "json" | ||
destination: "logs/{{ if .Step }}{{.Step.Name}}{{ else }}workflow{{ end }}.json" | ||
steps: | ||
- name: list | ||
logger: | ||
type: "stdout" | ||
command: ls -la | ||
metadata: | ||
cloud66.com/uuid: 8e2b4a31 | ||
preflights: | ||
- command: true | ||
message: "Oh nose!" | ||
- name: env | ||
command: echo $USER | ||
- name: false | ||
command: false | ||
continue_on_fail: true | ||
- name: fail | ||
command: fail | ||
metadata: | ||
cloud66.com/uuid: 8e2b4a3e | ||
continue_on_fail: true | ||
- name: sleep | ||
command: sleep 30 | ||
timeout: 1s | ||
metadata: | ||
cloud66.com/uuid: 547c8a3c | ||
continue_on_fail: true | ||
- name: trapper | ||
workdir: "$HOME/work/go/src/github.com/cloud66-oss/trackman/samples" | ||
command: ruby trapper.rb | ||
timeout: 1s | ||
continue_on_fail: true | ||
- name: piper | ||
workdir: "$HOME/work/go/src/github.com/cloud66-oss/trackman/samples" | ||
command: ruby piper.rb | ||
- name: dropcheck | ||
timeout: 3s | ||
workdir: "$HOME/work/go/src/github.com/cloud66-oss/trackman/samples" | ||
command: ruby filer.rb | ||
probe: | ||
command: ruby probe.rb | ||
continue_on_fail: true | ||
- name: arger | ||
metadata: | ||
cloud66.com/uuid: arger-123 | ||
workdir: "$HOME/work/go/src/github.com/cloud66-oss/trackman/samples" | ||
command: "ruby arger.rb hello {{ index .MergedMetadata \"cloud66.com/test\" }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,9 @@ | ||
package utils | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/sirupsen/logrus" | ||
) | ||
|
||
// CtxKey is a context key | ||
type CtxKey struct{ int } | ||
|
||
var ( | ||
// CtxSpinner is the key to a spinner on the context | ||
CtxSpinner = CtxKey{1} | ||
// CtxLogger is the key to a logger on the context | ||
CtxLogger = CtxKey{2} | ||
// CtxLogLevel holds the desired log level on the context | ||
CtxLogLevel = CtxKey{3} | ||
) | ||
|
||
// GetLogger returns a new or existing logger from the context | ||
func getLogger(ctx context.Context) *logrus.Logger { | ||
var logger *logrus.Logger | ||
var logLevel logrus.Level | ||
if ctx.Value(CtxLogLevel) == nil { | ||
logLevel = logrus.DebugLevel | ||
} else { | ||
logLevel = ctx.Value(CtxLogLevel).(logrus.Level) | ||
} | ||
if ctx.Value(CtxLogger) == nil { | ||
logger = logrus.New() | ||
logger.SetLevel(logLevel) | ||
} else { | ||
logger = ctx.Value(CtxLogger).(*logrus.Logger) | ||
} | ||
|
||
return logger | ||
} | ||
|
||
// LoggerContext checks the context for a logger and creates a new one and puts it | ||
// on the context if not there | ||
func LoggerContext(ctx context.Context) (*logrus.Logger, context.Context) { | ||
logger := getLogger(ctx) | ||
ctx = context.WithValue(ctx, CtxLogger, logger) | ||
|
||
return logger, ctx | ||
} |
Oops, something went wrong.