-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
cbiSponsorships.jsonnet
68 lines (59 loc) · 2.31 KB
/
cbiSponsorships.jsonnet
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
67
68
{
local cbi_sp = import 'cbiSponsoredProjects.json',
local filter_by_name(array, name) = std.filter(function(it) it.name == name, array),
//std.sum requires jsonnet version 0.20.0, here is an alternative
local sum(array) = std.foldl(function(x, y) (x + y), array, 0),
local rp_used(name) = sum([
//can resourcePacks be replaced with a variable?
so.resourcePacks
for sp in cbi_sp
for so in filter_by_name(sp.sponsoringOrganizations, name)
]),
local da_used(name) = sum([
//can dedicatedAgents be replaced with a variable?
so.dedicated
for sp in cbi_sp
for so in filter_by_name(sp.sponsoringOrganizations, name)
]),
local ghr_used(name) = sum([
//can ghLargeRunners be replaced with a variable?
so.runners
for sp in cbi_sp
for so in filter_by_name(sp.sponsoringOrganizations, name)
]),
local memberOrgBen(name, id, membership, packs=0, dedicated=0, runners=0) = {
displayName: name,
id: id,
membership: membership,
resourcePacks: packs,
resourcePacks_used: rp_used(name),
dedicatedAgents: dedicated,
dedicatedAgents_used: da_used(name),
ghLargeRunners: runners,
ghLargeRunners_used: ghr_used(name),
},
memberOrganizationsBenefits: [
memberOrgBen(mob["displayName"], mob["id"], mob["membership"], mob["resourcePacks"], mob["dedicatedAgents"], mob["ghLargeRunners"])
for mob in import 'memberOrganizationsBenefits.jsonnet'
],
local sponsoringOrg(name, packs=0, dedicated=0, runners=0, tickets=[], comment="") = {
id: std.filter(function(it) it.displayName == name, $.memberOrganizationsBenefits)[0].id,
displayName: name,
resourcePacks: packs,
dedicatedAgents: dedicated,
ghLargeRunners: runners,
requestTickets: tickets,
comment: comment,
},
local sponsoredProject(project_id, sponsorOrgs) = {
project: {id: project_id},
sponsoringOrganizations: [
//TODO: or just copy content from import?
sponsoringOrg(so["name"], so["resourcePacks"], so["dedicated"], so["runners"], so["tickets"], so["comment"]) for so in sponsorOrgs
]
},
sponsoredProjects: [
sponsoredProject(sponProj["project_id"], sponProj["sponsoringOrganizations"])
for sponProj in import 'cbiSponsoredProjects.json'
],
}