forked from yext/teamcity
-
Notifications
You must be signed in to change notification settings - Fork 0
/
project.go
43 lines (37 loc) · 1.4 KB
/
project.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
package teamcity
// Project is an individual project configured in TeamCity
type Project struct {
Id string `json:"id,omitempty"`
Name string `json:"name,omitempty"`
WebUrl string `json:"webUrl,omitempty"`
Params Params `json:"parameters,omitempty"`
ParentProjectId string `json:"parentProjectId,omitempty"`
ParentProject *Project `json:"parentProject,omitempty"`
}
// Projects is a list of TeamCity projects and aggregate details
type Projects struct {
Projects []Project `json:"project,omitempty"`
}
// Params is a container for the various properties of a project
type Params struct {
Properties []Property `json:"property,omitempty"`
}
// Property is a characteristic of a project (e.g. JOB, OWNER, or SERVICE)
type Property struct {
Name string `json:"name,omitempty"`
Value string `json:"value,omitempty"`
Own bool `json:"own,omitempty"`
}
// PropertyFromName returns the Property of the given Params with the given target name if it exists
func (params Params) PropertyFromName(target string) Property {
for _, property := range params.Properties {
if property.Name == target {
return property
}
}
return Property{}
}
// PropertyFromName returns the Property of the given Project with the given target name if it exists
func (project Project) PropertyFromName(target string) Property {
return project.Params.PropertyFromName(target)
}