-
Notifications
You must be signed in to change notification settings - Fork 0
/
privateendpoint.go
62 lines (53 loc) · 1.97 KB
/
privateendpoint.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
package testhelpers
import (
"fmt"
capz "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1"
)
type PrivateEndpointBuilder struct {
name string
location string
privateLinkServiceConnections []capz.PrivateLinkServiceConnection
}
func NewPrivateEndpointBuilder(name string) *PrivateEndpointBuilder {
return &PrivateEndpointBuilder{
name: name,
}
}
func (b *PrivateEndpointBuilder) WithLocation(location string) *PrivateEndpointBuilder {
b.location = location
return b
}
func (b *PrivateEndpointBuilder) WithPrivateLinkServiceConnection(subscriptionID, resourceGroup, privateLinkName string) *PrivateEndpointBuilder {
b.privateLinkServiceConnections = append(b.privateLinkServiceConnections, capz.PrivateLinkServiceConnection{
Name: FakePrivateLinkConnectionName(privateLinkName),
PrivateLinkServiceID: fmt.Sprintf(
"/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/privateLinkServices/%s",
subscriptionID,
resourceGroup,
privateLinkName),
})
return b
}
func (b *PrivateEndpointBuilder) WithPrivateLinkServiceConnectionWithName(subscriptionID, resourceGroup, privateLinkName, connectionName string) *PrivateEndpointBuilder {
b.privateLinkServiceConnections = append(b.privateLinkServiceConnections, capz.PrivateLinkServiceConnection{
Name: connectionName,
PrivateLinkServiceID: fmt.Sprintf(
"/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/privateLinkServices/%s",
subscriptionID,
resourceGroup,
privateLinkName),
})
return b
}
func (b *PrivateEndpointBuilder) Build() capz.PrivateEndpointSpec {
privateEndpoint := capz.PrivateEndpointSpec{
Name: b.name,
Location: b.location,
PrivateLinkServiceConnections: b.privateLinkServiceConnections,
ManualApproval: false,
}
return privateEndpoint
}
func FakePrivateLinkConnectionName(privateLinkName string) string {
return fmt.Sprintf("%s-connection", privateLinkName)
}