-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathistio.libsonnet
110 lines (110 loc) · 4.27 KB
/
istio.libsonnet
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
{
networking:: {
v1alpha3:: {
local apiVersion = { apiVersion: 'networking.istio.io/v1alpha3' },
gateway:: {
local kind = { kind: 'Gateway' },
new(name):: apiVersion + kind + self.mixin.metadata.withName(name),
mixin:: {
metadata:: {
local __metadataMixin(metadata) = { metadata+: metadata },
withName(name):: self + __metadataMixin({ name: name }),
},
spec:: {
local __specMixin(spec) = { spec+: spec },
withSelector(selector):: self + __specMixin({selector: selector}),
withServers(servers):: self + if std.type(servers) == 'array' then __specMixin({servers: servers}) else __specMixin({servers: [servers]}),
Server:: hidden.networking.v1alpha3.Server,
},
},
},
virtualservice:: {
local kind = { kind: 'VirtualService' },
new(name):: apiVersion + kind + self.mixin.metadata.withName(name),
mixin:: {
metadata:: {
local __metadataMixin(metadata) = { metadata+: metadata },
withName(name):: self + __metadataMixin({ name: name }),
},
spec:: {
local __specMixin(spec) = { spec+: spec },
withHosts(hosts):: self + __specMixin({hosts: hosts}),
withGateways(gateways):: self + if std.type(gateways) == 'array' then __specMixin({gateways: gateways}) else __specMixin({gateways: [gateways]}),
withHTTP(http):: self + if std.type(http) == 'array' then __specMixin({http: http}) else __specMixin({http: [http]}),
HTTPRoute:: hidden.networking.v1alpha3.HTTPRoute,
},
},
},
destinationrule:: {
local kind = { kind: 'DestinationRule' },
new(name, host):: apiVersion + kind + self.mixin.metadata.withName(name) + self.mixin.spec.withHost(host),
mixin:: {
metadata:: {
local __metadataMixin(metadata) = { metadata+: metadata },
withName(name):: self + __metadataMixin({ name: name }),
},
spec:: {
local __specMixin(spec) = { spec+: spec },
withHost(host):: self + __specMixin({host: host}),
withSubsets(subsets):: self + __specMixin({subsets: subsets}),
Subset:: hidden.networking.v1alpha3.Subset,
},
},
},
},
},
local hidden = {
networking:: {
v1alpha3:: {
Server:: {
new():: self,
withPort(port):: self + {port: port},
withHosts(hosts):: self + {hosts: hosts},
Port:: hidden.networking.v1alpha3.Port,
},
Port:: {
new(number, protocol):: self + {number: number, protocol: protocol},
withName(name):: self + {name: name},
},
HTTPRoute:: {
new():: self,
withRoute(route):: self + {route: route},
withMatch(match):: self + {match: match},
HTTPMatchRequest:: hidden.networking.v1alpha3.HTTPMatchRequest,
DestinationWeight:: hidden.networking.v1alpha3.DestinationWeight,
},
HTTPMatchRequest:: {
new():: self,
withUri(match):: self + {uri: match},
withScheme(match):: self + {scheme: match},
withMethod(match):: self + {method: match},
withAuthority(match):: self + {authority: match},
withHeader(name, match):: self + {[name]: match},
withPort(port):: self + {port: port},
StringMatch:: hidden.networking.v1alpha3.StringMatch,
},
DestinationWeight:: {
new(destination, weight=100):: {weight: weight, destination: destination},
Destination:: hidden.networking.v1alpha3.Destination,
},
Destination:: {
new(host):: self + {host: host},
withSubset(subset):: self + {subset: subset},
withPortSelector(port):: self + {port: port},
PortSelector:: hidden.networking.v1alpha3.PortSelector,
},
PortSelector:: {
new(number):: {number: number},
},
Subset:: {
new(name, labels):: {name: name, labels: labels},
},
StringMatch:: {
exact(value):: {exact: value},
prefix(value):: {prefix: value},
regex(value):: {regex: value},
},
},
},
},
}