forked from cloudfoundry/bosh-bootloader
-
Notifications
You must be signed in to change notification settings - Fork 2
/
gcp_client.go
121 lines (111 loc) · 2.78 KB
/
gcp_client.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
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
111
112
113
114
115
116
117
118
119
120
121
package fakes
import compute "google.golang.org/api/compute/v1"
type GCPClient struct {
ProjectIDCall struct {
CallCount int
Returns struct {
ProjectID string
}
}
GetProjectCall struct {
CallCount int
Returns struct {
Project *compute.Project
Error error
}
}
SetCommonInstanceMetadataCall struct {
CallCount int
Receives struct {
Metadata *compute.Metadata
}
Returns struct {
Operation *compute.Operation
Error error
}
}
ListInstancesCall struct {
CallCount int
Returns struct {
InstanceList *compute.InstanceList
Error error
}
}
GetZonesCall struct {
CallCount int
Receives struct {
Region string
}
Returns struct {
Zones []string
Error error
}
}
GetZoneCall struct {
CallCount int
Receives struct {
Zone string
}
Returns struct {
Zone *compute.Zone
Error error
}
}
GetRegionCall struct {
CallCount int
Receives struct {
Region string
}
Returns struct {
Region *compute.Region
Error error
}
}
GetNetworksCall struct {
CallCount int
Receives struct {
Name string
}
Returns struct {
NetworkList *compute.NetworkList
Error error
}
}
}
func (g *GCPClient) ProjectID() string {
g.ProjectIDCall.CallCount++
return g.ProjectIDCall.Returns.ProjectID
}
func (g *GCPClient) GetProject() (*compute.Project, error) {
g.GetProjectCall.CallCount++
return g.GetProjectCall.Returns.Project, g.GetProjectCall.Returns.Error
}
func (g *GCPClient) SetCommonInstanceMetadata(metadata *compute.Metadata) (*compute.Operation, error) {
g.SetCommonInstanceMetadataCall.CallCount++
g.SetCommonInstanceMetadataCall.Receives.Metadata = metadata
return g.SetCommonInstanceMetadataCall.Returns.Operation, g.SetCommonInstanceMetadataCall.Returns.Error
}
func (g *GCPClient) ListInstances() (*compute.InstanceList, error) {
g.ListInstancesCall.CallCount++
return g.ListInstancesCall.Returns.InstanceList, g.ListInstancesCall.Returns.Error
}
func (g *GCPClient) GetZones(region string) ([]string, error) {
g.GetZonesCall.CallCount++
g.GetZonesCall.Receives.Region = region
return g.GetZonesCall.Returns.Zones, g.GetZonesCall.Returns.Error
}
func (g *GCPClient) GetZone(zone string) (*compute.Zone, error) {
g.GetZoneCall.CallCount++
g.GetZoneCall.Receives.Zone = zone
return g.GetZoneCall.Returns.Zone, g.GetZoneCall.Returns.Error
}
func (g *GCPClient) GetRegion(region string) (*compute.Region, error) {
g.GetRegionCall.CallCount++
g.GetRegionCall.Receives.Region = region
return g.GetRegionCall.Returns.Region, g.GetRegionCall.Returns.Error
}
func (g *GCPClient) GetNetworks(name string) (*compute.NetworkList, error) {
g.GetNetworksCall.CallCount++
g.GetNetworksCall.Receives.Name = name
return g.GetNetworksCall.Returns.NetworkList, g.GetNetworksCall.Returns.Error
}