/
input.go
44 lines (36 loc) · 1.04 KB
/
input.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
package configuration
import (
"log"
)
type input interface {
Hash() []byte
}
func initializeInputs(configurationInputs []configurationInput, componentPath string, rootPath string) []input {
var paths []string
var inputs []input
for _, configurationInput := range configurationInputs {
switch configurationInput.Type {
case "Files":
filePaths := fileInputPatternsToPaths(configurationInput.Paths, rootPath)
paths = append(paths, filePaths...)
case "GitFiles":
filePaths := gitFileInputPatternsToPaths(configurationInput.Paths, componentPath)
paths = append(paths, filePaths...)
case "Component":
componentInput := componentInput{
name: configurationInput.Name,
}
inputs = append(inputs, componentInput)
default:
log.Fatalf("One of the input types does not have a handler, check types on handlers in %s or root config", componentPath)
}
}
uniquePaths := deDuplicateStringSlice(paths)
for _, path := range uniquePaths {
input := fileInput{
path: path,
}
inputs = append(inputs, input)
}
return inputs
}