mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 05:27:21 +00:00
hooks for updating healthchecks, firewalls, regional backendservices
This commit is contained in:
parent
ebd54ea5e3
commit
fd2bf37d28
@ -331,3 +331,61 @@ func RemoveInstancesHook(ctx context.Context, key *meta.Key, req *ga.InstanceGro
|
|||||||
m.X = attrs
|
m.X = attrs
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// UpdateFirewallHook defines the hook for updating a Firewall. It replaces the
|
||||||
|
// object with the same key in the mock with the updated object.
|
||||||
|
func UpdateFirewallHook(ctx context.Context, key *meta.Key, obj *ga.Firewall, m *cloud.MockFirewalls) error {
|
||||||
|
_, err := m.Get(ctx, key)
|
||||||
|
if err != nil {
|
||||||
|
return &googleapi.Error{
|
||||||
|
Code: http.StatusNotFound,
|
||||||
|
Message: fmt.Sprintf("Key: %s was not found in Firewalls", key.String()),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
obj.Name = key.Name
|
||||||
|
projectID := m.ProjectRouter.ProjectID(ctx, "ga", "firewalls")
|
||||||
|
obj.SelfLink = cloud.SelfLink(meta.VersionGA, projectID, "firewalls", key)
|
||||||
|
|
||||||
|
m.Objects[*key] = &cloud.MockFirewallsObj{obj}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateHealthCheckHook defines the hook for updating a HealthCheck. It
|
||||||
|
// replaces the object with the same key in the mock with the updated object.
|
||||||
|
func UpdateHealthCheckHook(ctx context.Context, key *meta.Key, obj *ga.HealthCheck, m *cloud.MockHealthChecks) error {
|
||||||
|
_, err := m.Get(ctx, key)
|
||||||
|
if err != nil {
|
||||||
|
return &googleapi.Error{
|
||||||
|
Code: http.StatusNotFound,
|
||||||
|
Message: fmt.Sprintf("Key: %s was not found in HealthChecks", key.String()),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
obj.Name = key.Name
|
||||||
|
projectID := m.ProjectRouter.ProjectID(ctx, "ga", "healthChecks")
|
||||||
|
obj.SelfLink = cloud.SelfLink(meta.VersionGA, projectID, "healthChecks", key)
|
||||||
|
|
||||||
|
m.Objects[*key] = &cloud.MockHealthChecksObj{obj}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateRegionBackendServiceHook defines the hook for updating a Region
|
||||||
|
// BackendsService. It replaces the object with the same key in the mock with
|
||||||
|
// the updated object.
|
||||||
|
func UpdateRegionBackendServiceHook(ctx context.Context, key *meta.Key, obj *ga.BackendService, m *cloud.MockRegionBackendServices) error {
|
||||||
|
_, err := m.Get(ctx, key)
|
||||||
|
if err != nil {
|
||||||
|
return &googleapi.Error{
|
||||||
|
Code: http.StatusNotFound,
|
||||||
|
Message: fmt.Sprintf("Key: %s was not found in RegionBackendServices", key.String()),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
obj.Name = key.Name
|
||||||
|
projectID := m.ProjectRouter.ProjectID(ctx, "ga", "backendServices")
|
||||||
|
obj.SelfLink = cloud.SelfLink(meta.VersionGA, projectID, "backendServices", key)
|
||||||
|
|
||||||
|
m.Objects[*key] = &cloud.MockRegionBackendServicesObj{obj}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
@ -88,6 +88,10 @@ func fakeGCECloud(projectID, region, zoneName string) (*GCECloud, error) {
|
|||||||
c.MockInstanceGroups.RemoveInstancesHook = mock.RemoveInstancesHook
|
c.MockInstanceGroups.RemoveInstancesHook = mock.RemoveInstancesHook
|
||||||
c.MockInstanceGroups.ListInstancesHook = mock.ListInstancesHook
|
c.MockInstanceGroups.ListInstancesHook = mock.ListInstancesHook
|
||||||
|
|
||||||
|
c.MockRegionBackendServices.UpdateHook = mock.UpdateRegionBackendServiceHook
|
||||||
|
c.MockHealthChecks.UpdateHook = mock.UpdateHealthCheckHook
|
||||||
|
c.MockFirewalls.UpdateHook = mock.UpdateFirewallHook
|
||||||
|
|
||||||
keyGA := meta.GlobalKey("key-ga")
|
keyGA := meta.GlobalKey("key-ga")
|
||||||
c.MockZones.Objects[*keyGA] = &cloud.MockZonesObj{
|
c.MockZones.Objects[*keyGA] = &cloud.MockZonesObj{
|
||||||
Obj: &compute.Zone{Name: zoneName, Region: gce.getRegionLink(region)},
|
Obj: &compute.Zone{Name: zoneName, Region: gce.getRegionLink(region)},
|
||||||
|
Loading…
Reference in New Issue
Block a user