-
Notifications
You must be signed in to change notification settings - Fork 0
/
pathlink.go
67 lines (53 loc) · 1.51 KB
/
pathlink.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
64
65
66
67
// Copyright 2021 The Tiyo authors
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
package pipeline
// A PathLink specifies how to connect files, directories and sockets between
// components in the pipeline.
// PathLink : Socket / Path connections
type PathLink struct {
// Common Link details
Link
// The path this link will listen against
// If link type is Path, this is mutually exclusive with Pattern
Path string
// Regex pattern to match when reading paths
// ignored if link type is socket
Pattern string
// If link type is path sets up inotify watchers for the path
Watch bool
}
// GetType : Get the type of link
func (path *PathLink) GetType() string {
return path.Link.Type
}
// GetLink : Get common link details
func (path *PathLink) GetLink() Link {
return path.Link
}
// NewPathLink : Convert a map[string]interface into a PathLink type
func NewPathLink(cell map[string]interface{}) *PathLink {
link := GetLink(cell)
path := PathLink{
Link{
ID: link.ID,
Type: link.Type,
Source: link.Source,
Target: link.Target,
},
"", "", false,
}
attrib := cell["attributes"].(map[string]interface{})
if attrib["path"] != nil {
path.Path = attrib["path"].(string)
}
if attrib["pattern"] != nil {
path.Pattern = attrib["pattern"].(string)
}
if attrib["watch"] != nil {
path.Watch = attrib["watch"].(bool)
}
return &path
}