-
Notifications
You must be signed in to change notification settings - Fork 199
/
raw_mount.go
58 lines (43 loc) · 1.28 KB
/
raw_mount.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
package config
import "github.com/werf/werf/v2/pkg/giterminism_manager"
type rawMount struct {
To string `yaml:"to,omitempty"`
From string `yaml:"from,omitempty"`
FromPath string `yaml:"fromPath,omitempty"`
rawStapelImage *rawStapelImage `yaml:"-"` // parent
UnsupportedAttributes map[string]interface{} `yaml:",inline"`
}
func (c *rawMount) UnmarshalYAML(unmarshal func(interface{}) error) error {
if parent, ok := parentStack.Peek().(*rawStapelImage); ok {
c.rawStapelImage = parent
}
type plain rawMount
if err := unmarshal((*plain)(c)); err != nil {
return err
}
if err := checkOverflow(c.UnsupportedAttributes, c, c.rawStapelImage.doc); err != nil {
return err
}
return nil
}
func (c *rawMount) toDirective(giterminismManager giterminism_manager.Interface) (mount *Mount, err error) {
mount = &Mount{}
mount.To = c.To
mount.From = c.FromPath
if c.From == "" {
mount.Type = "custom_dir"
} else {
mount.Type = c.From
}
mount.raw = c
if err := c.validateDirective(giterminismManager, mount); err != nil {
return nil, err
}
return mount, nil
}
func (c *rawMount) validateDirective(giterminismManager giterminism_manager.Interface, mount *Mount) (err error) {
if err := mount.validate(giterminismManager); err != nil {
return err
}
return nil
}