forked from cvbarros/go-teamcity
/
vcs_root_entry.go
58 lines (47 loc) · 1.62 KB
/
vcs_root_entry.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 teamcity
// VcsRootEntries represents a collection of VCS Roots attached to a resource
type VcsRootEntries struct {
// count
Count int32 `json:"count,omitempty" xml:"count"`
// href
Href string `json:"href,omitempty" xml:"href"`
// property
Items []*VcsRootEntry `json:"vcs-root-entry"`
}
// VcsRootEntry represents a single VCS Root attached to a resource
type VcsRootEntry struct {
// id
ID string `json:"id,omitempty" xmld:"id"`
// inherited
Inherited *bool `json:"inherited,omitempty" xml:"inherited"`
// checkout rules
CheckoutRules string `json:"checkout-rules,omitempty"`
// vcs root
VcsRoot *VcsRootReference `json:"vcs-root,omitempty"`
}
// NewVcsRootEntries returns an instance of VcsRootEntries collection
func NewVcsRootEntries(items ...*VcsRootReference) *VcsRootEntries {
count := len(items)
entries := make([]*VcsRootEntry, count)
for i, item := range items {
entries[i] = NewVcsRootEntry(item)
}
return &VcsRootEntries{
Count: int32(count),
Items: entries,
}
}
// NewVcsRootEntry is a convenience function for attaching a VcsRootReference to a Build configuration, represented as a VcsRootEntry in Teamcity API
func NewVcsRootEntry(vcsRef *VcsRootReference) *VcsRootEntry {
return NewVcsRootEntryWithRules(vcsRef, "")
}
// NewVcsRootEntryWithRules is a convenience function for attaching a VcsRootReference to a Build configuration, represented as a VcsRootEntry in Teamcity API
func NewVcsRootEntryWithRules(vcsRef *VcsRootReference, checkoutRules string) *VcsRootEntry {
out := &VcsRootEntry{
VcsRoot: vcsRef,
}
if checkoutRules != "" {
out.CheckoutRules = checkoutRules
}
return out
}