-
Notifications
You must be signed in to change notification settings - Fork 386
/
parsefeatures.go
46 lines (37 loc) · 1.06 KB
/
parsefeatures.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
package buildcontext
import (
"fmt"
"strings"
"github.com/earthly/earthly/ast"
"github.com/earthly/earthly/conslogging"
"github.com/earthly/earthly/features"
)
type buildFile struct {
path string
ftrs *features.Features
}
func parseFeatures(buildFilePath string, featureFlagOverrides string, projectRef string, console conslogging.ConsoleLogger) (*features.Features, error) {
version, err := ast.ParseVersion(buildFilePath, false)
if err != nil {
return nil, err
}
ftrs, hasVersion, err := features.Get(version)
if err != nil {
return nil, err
}
if !hasVersion {
return nil, fmt.Errorf("No version specified in %s/Earthfile", projectRef)
}
warningStrs, err := ftrs.ProcessFlags()
if err != nil {
return nil, err
}
if len(warningStrs) > 0 {
console.Printf("NOTE: The %s feature is enabled by default under VERSION %s, and can be safely removed from the VERSION command", strings.Join(warningStrs, ", "), ftrs.Version())
}
err = features.ApplyFlagOverrides(ftrs, featureFlagOverrides)
if err != nil {
return nil, err
}
return ftrs, nil
}