Documentation
¶
Overview ¶
Package gce is a lightweight testable wrapper around GCE compute APIs needed for the gcagent.
Index ¶
- type GCE
- func (g *GCE) AddResourcePolicies(ctx context.Context, project, zone, diskName string, resourcePolicies []string) (*compute.Operation, error)
- func (g *GCE) AttachDisk(ctx context.Context, diskName string, ...) error
- func (g *GCE) CreateSnapshot(ctx context.Context, project string, snapshotReq *compute.Snapshot) (*compute.Operation, error)
- func (g *GCE) DetachDisk(ctx context.Context, ...) error
- func (g *GCE) DiskAttachedToInstance(project, zone, instanceName, diskName string) (string, bool, error)
- func (g *GCE) GetAddress(project, location, name string) (*compute.Address, error)
- func (g *GCE) GetAddressByIP(project, region, subnetwork, ip string) (*compute.Address, error)
- func (g *GCE) GetDisk(project, zone, disk string) (*compute.Disk, error)
- func (g *GCE) GetFilestore(project, zone, name string) (*file.Instance, error)
- func (g *GCE) GetFilestoreByIP(project, location, ip string) (*file.ListInstancesResponse, error)
- func (g *GCE) GetFilestoreInstance(project, location, filestore string) (*file.Instance, error)
- func (g *GCE) GetForwardingRule(project, location, name string) (*compute.ForwardingRule, error)
- func (g *GCE) GetForwardingRuleByIP(project, ip string) (*compute.ForwardingRule, error)
- func (g *GCE) GetHealthCheck(project, name string) (*compute.HealthCheck, error)
- func (g *GCE) GetInstance(project, zone, instance string) (*compute.Instance, error)
- func (g *GCE) GetInstanceByIP(project, ip string) (*compute.Instance, error)
- func (g *GCE) GetInstanceGroup(project, zone, name string) (*compute.InstanceGroup, error)
- func (g *GCE) GetNetwork(name, project string) (*compute.Network, error)
- func (g *GCE) GetRegionalBackendService(project, region, service string) (*compute.BackendService, error)
- func (g *GCE) GetSecret(ctx context.Context, projectID, secretName string) (string, error)
- func (g *GCE) GetSubnetwork(name, project, region string) (*compute.Subnetwork, error)
- func (g *GCE) GetURIForIP(project, ip, region, subnetwork string) (string, error)
- func (g *GCE) ListDisks(project, zone, filter string) (*compute.DiskList, error)
- func (g *GCE) ListInstanceGroupInstances(project, zone, name string) (*compute.InstanceGroupsListInstances, error)
- func (g *GCE) ListSnapshots(ctx context.Context, project string) (*compute.SnapshotList, error)
- func (g *GCE) ListZoneOperations(project, zone, filter string, maxResults int64) (*compute.OperationList, error)
- func (g *GCE) OverrideComputeBasePath(basePath string)
- func (g *GCE) RemoveResourcePolicies(ctx context.Context, project, zone, diskName string, resourcePolicies []string) (*compute.Operation, error)
- func (g *GCE) SetLabels(ctx context.Context, project, zone, diskName, labelFingerprint string, ...) (*compute.Operation, error)
- func (g *GCE) WaitForDiskOpCompletionWithRetry(ctx context.Context, op *compute.Operation, project, dataDiskZone string) error
- func (g *GCE) WaitForInstantSnapshotConversionCompletionWithRetry(ctx context.Context, op *compute.Operation, ...) error
- func (g *GCE) WaitForSnapshotCreationCompletionWithRetry(ctx context.Context, op *compute.Operation, ...) error
- func (g *GCE) WaitForSnapshotUploadCompletionWithRetry(ctx context.Context, op *compute.Operation, ...) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type GCE ¶
type GCE struct {
// contains filtered or unexported fields
}
GCE is a wrapper for Google Compute Engine services.
func NewGCEClient ¶
NewGCEClient creates a new GCE service wrapper.
func (*GCE) AddResourcePolicies ¶
func (g *GCE) AddResourcePolicies(ctx context.Context, project, zone, diskName string, resourcePolicies []string) (*compute.Operation, error)
AddResourcePolicies adds the given resource policies of a disk.
func (*GCE) AttachDisk ¶
func (g *GCE) AttachDisk(ctx context.Context, diskName string, instanceName, project, dataDiskZone string) error
AttachDisk attaches the disk with the given name to the instance.
func (*GCE) CreateSnapshot ¶
func (g *GCE) CreateSnapshot(ctx context.Context, project string, snapshotReq *compute.Snapshot) (*compute.Operation, error)
CreateSnapshot creates a new standard snapshot.
func (*GCE) DetachDisk ¶
func (g *GCE) DetachDisk(ctx context.Context, instanceName, project, dataDiskZone, dataDiskName, dataDiskDeviceName string) error
DetachDisk detaches given disk from the instance.
func (*GCE) DiskAttachedToInstance ¶
func (g *GCE) DiskAttachedToInstance(project, zone, instanceName, diskName string) (string, bool, error)
DiskAttachedToInstance returns the device name of the disk attached to the instance.
func (*GCE) GetAddress ¶
GetAddress retrieves a GCE Address defined by the project, location, and name provided.
func (*GCE) GetAddressByIP ¶
GetAddressByIP attempts to find a ComputeAddress object with a given IP. The string is assumed to be an exact match, so a full IPv4 address is expected. A region should be supplied, or "" to search for a global address.
func (*GCE) GetDisk ¶
GetDisk retrieves a GCE Persistent Disk defined by the project zone and name provided.
func (*GCE) GetFilestore ¶
GetFilestore attempts to retrieve the filestore instance addressed by the provided project, location, and name.
func (*GCE) GetFilestoreByIP ¶
GetFilestoreByIP attempts to locate a GCE Filestore instance defined by the project, location, and IP Address provided.
func (*GCE) GetFilestoreInstance ¶
GetFilestoreInstance retrieves a GCE Filestore Instance defined by the project, location, and name provided.
func (*GCE) GetForwardingRule ¶
GetForwardingRule retrieves a GCE Forwarding rule defined by the project, zone, and name provided.
func (*GCE) GetForwardingRuleByIP ¶
GetForwardingRuleByIP retrieves a GCE Forwarding rule defined by the project, and IP address provided.
func (*GCE) GetHealthCheck ¶
GetHealthCheck attempts to retrieve the compute HealthCheck object addressed by the provided project and name.
func (*GCE) GetInstance ¶
GetInstance retrieves a GCE Instance defined by the project, zone, and name provided.
func (*GCE) GetInstanceByIP ¶
GetInstanceByIP retrieves a GCE Instance defined by the project, and IP provided. May return nil if an instance with the corresponding IP cannot be found.
func (*GCE) GetInstanceGroup ¶
GetInstanceGroup retrieves a GCE Instance Group rule defined by the project, zone, and name provided.
func (*GCE) GetNetwork ¶
GetNetwork retrieves the network with the given name and project.
func (*GCE) GetRegionalBackendService ¶
func (g *GCE) GetRegionalBackendService(project, region, service string) (*compute.BackendService, error)
GetRegionalBackendService retrieves a GCE Backend Service defined by the project, region, and name provided.
func (*GCE) GetSecret ¶
GetSecret accesses the secret manager for the specified project ID and returns the stored password.
func (*GCE) GetSubnetwork ¶
GetSubnetwork retrieves the subnetwork with the given name, project, and region.
func (*GCE) GetURIForIP ¶
GetURIForIP attempts to locate the URI for any object that is related to the IP address provided.
func (*GCE) ListDisks ¶
ListDisks retrieves GCE Persistent Disks defined by the project, sone, and filter provided.
func (*GCE) ListInstanceGroupInstances ¶
func (g *GCE) ListInstanceGroupInstances(project, zone, name string) (*compute.InstanceGroupsListInstances, error)
ListInstanceGroupInstances retrieves a list of GCE Instances in the Instance group defined by the project, zone, and name provided.
func (*GCE) ListSnapshots ¶
ListSnapshots lists the snapshots for a given project.
func (*GCE) ListZoneOperations ¶
func (g *GCE) ListZoneOperations(project, zone, filter string, maxResults int64) (*compute.OperationList, error)
ListZoneOperations retrieves a list of Operations resources defined by the project, and zone provided. Results will be filtered according to the provided filter string, and limit the number of results to maxResults.
func (*GCE) OverrideComputeBasePath ¶
OverrideComputeBasePath overrides the base path of the GCE clients.
func (*GCE) RemoveResourcePolicies ¶
func (g *GCE) RemoveResourcePolicies(ctx context.Context, project, zone, diskName string, resourcePolicies []string) (*compute.Operation, error)
RemoveResourcePolicies removes the given resource policies of a disk.
func (*GCE) SetLabels ¶
func (g *GCE) SetLabels(ctx context.Context, project, zone, diskName, labelFingerprint string, labels map[string]string) (*compute.Operation, error)
SetLabels sets the labels for a given disk.
func (*GCE) WaitForDiskOpCompletionWithRetry ¶
func (g *GCE) WaitForDiskOpCompletionWithRetry(ctx context.Context, op *compute.Operation, project, dataDiskZone string) error
WaitForDiskOpCompletionWithRetry waits for the given compute operation to complete. We sleep for 120s between retries a total 10 times => max_wait_duration = 10*120 = 20 Minutes
func (*GCE) WaitForInstantSnapshotConversionCompletionWithRetry ¶
func (g *GCE) WaitForInstantSnapshotConversionCompletionWithRetry(ctx context.Context, op *compute.Operation, project, diskZone, snapshotName string) error
WaitForInstantSnapshotConversionCompletionWithRetry waits for the given compute operation to complete. We sleep for 30s between retries a total 480 times => max_wait_duration = 30*480 = 4 Hours
func (*GCE) WaitForSnapshotCreationCompletionWithRetry ¶
func (g *GCE) WaitForSnapshotCreationCompletionWithRetry(ctx context.Context, op *compute.Operation, project, diskZone, snapshotName string) error
WaitForSnapshotCreationCompletionWithRetry waits for the given compute operation to complete. We sleep for 1s between retries a total 300 times => max_wait_duration = 5 minutes
func (*GCE) WaitForSnapshotUploadCompletionWithRetry ¶
func (g *GCE) WaitForSnapshotUploadCompletionWithRetry(ctx context.Context, op *compute.Operation, project, diskZone, snapshotName string) error
WaitForSnapshotUploadCompletionWithRetry waits for the given compute operation to complete. We sleep for 30s between retries a total 480 times => max_wait_duration = 30*480 = 4 Hours
Directories
¶
Path | Synopsis |
---|---|
Package fake provides a fake version of the GCE struct to return canned responses in unit tests.
|
Package fake provides a fake version of the GCE struct to return canned responses in unit tests. |
Package fakehttp provides a HTTP server to serve hard-coded responses for unit tests.
|
Package fakehttp provides a HTTP server to serve hard-coded responses for unit tests. |
Package metadataserver performs requests to the metadata server of a GCE instance.
|
Package metadataserver performs requests to the metadata server of a GCE instance. |
Package wlm provides a simple service interface for using the Data Warehouse WriteInsight API.
|
Package wlm provides a simple service interface for using the Data Warehouse WriteInsight API. |