-
Notifications
You must be signed in to change notification settings - Fork 1
/
types.go
63 lines (52 loc) · 2.41 KB
/
types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// Copyright © 2019 Sascha Andres <sascha.andres@outlook.com>
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package flowascode
import "github.com/sirupsen/logrus"
type (
// Error type for constant error definitions
Error string
// Flow represents a complete flow
Flow struct {
// BreakOnError bool `yaml:"break_on_error"` // BreakOnError breaks if a script returns a non zero result
Name string `yaml:"name"` // Name is a name for the flow
Description string `yaml:"description"` // Description is a more descriptive text what the flow does
Steps []Step `yaml:"steps"` // Steps is the collection of steps in the flow
Shell string `yaml:"shell"` // Shell is the path or binary name for the shell to use to execute the script
}
// Step is a single execution point in a flow
Step struct {
Name string `yaml:"name"` // Name of a step, also used to reference from C(Descendant)
Script []string `yaml:"script"` // Script to execute
OnSuccess []Descendant `yaml:"on_success"` // OnSuccess is a list of steps to execute if the script returns with 0
OnFailure []Descendant `yaml:"on_failure"` // OnFailure is a list of steps to execute if the scripts returns not a 0
}
// Descendant represents on step after the current step
// that is it is a reference to a number of other steps
Descendant struct {
Name string `yaml:"name"` // Name is the referenced step
Variables map[string]string `yaml:"variables"` // Variables is a list of variables that are set as environment variables
}
)
var (
logger *logrus.Entry
)
func (e Error) Error() string { return string(e) }
func init() {
logrus.SetLevel(logrus.WarnLevel)
logger = logrus.WithField("package", "flowascode")
}
// SetLogLevel can be used to adjust the log level
func SetLogLevel(level logrus.Level) {
logrus.SetLevel(level)
logger = logrus.WithField("package", "flowascode")
}