/
resource_pipeline_material_p4.go
66 lines (58 loc) · 1.68 KB
/
resource_pipeline_material_p4.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
package gocd
import "errors"
func (mp4 MaterialAttributesP4) equal(ma MaterialAttribute) (bool, error) {
var ok bool
mp42, ok := ma.(MaterialAttributesP4)
if !ok {
return false, errors.New("can only compare with same material type")
}
namesEqual := mp4.Name == mp42.Name
portEqual := mp4.Port == mp42.Port
destEqual := mp4.Destination == mp42.Destination
return namesEqual && portEqual && destEqual, nil
}
// GenerateGeneric form (map[string]interface) of the material filter
func (mp4 MaterialAttributesP4) GenerateGeneric() (ma map[string]interface{}) {
ma = make(map[string]interface{})
return
}
// HasFilter in this material attribute
func (mp4 MaterialAttributesP4) HasFilter() bool {
return true
}
// GetFilter from material attribute
func (mp4 MaterialAttributesP4) GetFilter() *MaterialFilter {
return mp4.Filter
}
// UnmarshallInterface from a JSON string to a MaterialAttributesP4 struct
func unmarshallMaterialAttributesP4(mp4 *MaterialAttributesP4, i map[string]interface{}) {
for key, value := range i {
if value == nil {
continue
}
switch key {
case "name":
mp4.Name = value.(string)
case "port":
mp4.Port = value.(string)
case "use_tickets":
mp4.UseTickets = value.(bool)
case "view":
mp4.View = value.(string)
case "username":
mp4.Username = value.(string)
case "password":
mp4.Password = value.(string)
case "encrypted_password":
mp4.EncryptedPassword = value.(string)
case "destination":
mp4.Destination = value.(string)
case "filter":
mp4.Filter = unmarshallMaterialFilter(value.(map[string]interface{}))
case "invert_filter":
mp4.InvertFilter = value.(bool)
case "auto_update":
mp4.AutoUpdate = value.(bool)
}
}
}