Documentation ¶
Overview ¶
Package gcp allows interaction with Google Cloud Platform resources.
Index ¶
- func AssertStorageBucketExists(t *testing.T, name string)
- func AssertStorageBucketExistsE(t *testing.T, name string) error
- func CreateStorageBucket(t *testing.T, projectID string, name string, attr *storage.BucketAttrs)
- func CreateStorageBucketE(t *testing.T, projectID string, name string, attr *storage.BucketAttrs) error
- func DeleteStorageBucket(t *testing.T, name string)
- func DeleteStorageBucketE(t *testing.T, name string) error
- func EmptyStorageBucket(t *testing.T, name string)
- func EmptyStorageBucketE(t *testing.T, name string) error
- func GetAllGcpRegions(t *testing.T, projectID string) []string
- func GetAllGcpRegionsE(t *testing.T, projectID string) ([]string, error)
- func GetAllGcpZones(t *testing.T, projectID string) []string
- func GetAllGcpZonesE(t *testing.T, projectID string) ([]string, error)
- func GetGoogleCredentialsFromEnvVar(t *testing.T) string
- func GetGoogleProjectIDFromEnvVar(t *testing.T) string
- func GetGoogleRegionFromEnvVar(t *testing.T) string
- func GetRandomRegion(t *testing.T, projectID string, approvedRegions []string, ...) string
- func GetRandomRegionE(t *testing.T, projectID string, approvedRegions []string, ...) (string, error)
- func GetRandomZone(t *testing.T, projectID string, approvedZones []string, ...) string
- func GetRandomZoneE(t *testing.T, projectID string, approvedZones []string, ...) (string, error)
- func GetRandomZoneForRegion(t *testing.T, projectID string, region string) string
- func GetRandomZoneForRegionE(t *testing.T, projectID string, region string) (string, error)
- func NewComputeService(t *testing.T) *compute.Service
- func NewComputeServiceE(t *testing.T) (*compute.Service, error)
- func NewInstancesService(t *testing.T) *compute.InstancesService
- func NewInstancesServiceE(t *testing.T) (*compute.InstancesService, error)
- func RandomValidGcpName() string
- func ReadBucketObject(t *testing.T, bucketName string, filePath string) io.Reader
- func ReadBucketObjectE(t *testing.T, bucketName string, filePath string) (io.Reader, error)
- func RegionUrlToRegion(zoneUrl string) string
- func WriteBucketObject(t *testing.T, bucketName string, filePath string, body io.Reader, ...) string
- func WriteBucketObjectE(t *testing.T, bucketName string, filePath string, body io.Reader, ...) (string, error)
- func ZoneUrlToZone(zoneUrl string) string
- type Image
- type Instance
- func (i *Instance) AddSshKey(t *testing.T, username string, publicKey string)
- func (i *Instance) AddSshKeyE(t *testing.T, username string, publicKey string) error
- func (i *Instance) GetLabels(t *testing.T) map[string]string
- func (i *Instance) GetMetadata(t *testing.T) []*compute.MetadataItems
- func (i *Instance) GetPublicIp(t *testing.T) string
- func (i *Instance) GetPublicIpE(t *testing.T) (string, error)
- func (i *Instance) GetZone(t *testing.T) string
- func (i *Instance) SetLabels(t *testing.T, labels map[string]string)
- func (i *Instance) SetLabelsE(t *testing.T, labels map[string]string) error
- func (i *Instance) SetMetadata(t *testing.T, metadata map[string]string)
- func (i *Instance) SetMetadataE(t *testing.T, metadata map[string]string) error
- type InstanceGroup
- type RegionalInstanceGroup
- func (ig *RegionalInstanceGroup) GetInstanceIds(t *testing.T) []string
- func (ig *RegionalInstanceGroup) GetInstanceIdsE(t *testing.T) ([]string, error)
- func (ig *RegionalInstanceGroup) GetInstances(t *testing.T, projectId string) []*Instance
- func (ig *RegionalInstanceGroup) GetInstancesE(t *testing.T, projectId string) ([]*Instance, error)
- func (ig *RegionalInstanceGroup) GetPublicIps(t *testing.T, projectId string) []string
- func (ig *RegionalInstanceGroup) GetPublicIpsE(t *testing.T, projectId string) ([]string, error)
- func (ig *RegionalInstanceGroup) GetRandomInstance(t *testing.T) *Instance
- func (ig *RegionalInstanceGroup) GetRandomInstanceE(t *testing.T) (*Instance, error)
- type ZonalInstanceGroup
- func (ig *ZonalInstanceGroup) GetInstanceIds(t *testing.T) []string
- func (ig *ZonalInstanceGroup) GetInstanceIdsE(t *testing.T) ([]string, error)
- func (ig *ZonalInstanceGroup) GetInstances(t *testing.T, projectId string) []*Instance
- func (ig *ZonalInstanceGroup) GetInstancesE(t *testing.T, projectId string) ([]*Instance, error)
- func (ig *ZonalInstanceGroup) GetPublicIps(t *testing.T, projectId string) []string
- func (ig *ZonalInstanceGroup) GetPublicIpsE(t *testing.T, projectId string) ([]string, error)
- func (ig *ZonalInstanceGroup) GetRandomInstance(t *testing.T) *Instance
- func (ig *ZonalInstanceGroup) GetRandomInstanceE(t *testing.T) (*Instance, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertStorageBucketExists ¶
AssertStorageBucketExists checks if the given storage bucket exists and fails the test if it does not.
func AssertStorageBucketExistsE ¶
AssertStorageBucketExistsE checks if the given storage bucket exists and returns an error if it does not.
func CreateStorageBucket ¶
CreateStorageBucket creates a Google Cloud bucket with the given BucketAttrs. Note that Google Storage bucket names must be globally unique.
func CreateStorageBucketE ¶
func CreateStorageBucketE(t *testing.T, projectID string, name string, attr *storage.BucketAttrs) error
CreateStorageBucketE creates a Google Cloud bucket with the given BucketAttrs. Note that Google Storage bucket names must be globally unique.
func DeleteStorageBucket ¶
DeleteStorageBucket destroys the Google Storage bucket.
func DeleteStorageBucketE ¶
DeleteStorageBucketE destroys the S3 bucket in the given region with the given name.
func EmptyStorageBucket ¶
EmptyStorageBucket removes the contents of a storage bucket with the given name.
func EmptyStorageBucketE ¶
EmptyStorageBucketE removes the contents of a storage bucket with the given name.
func GetAllGcpRegions ¶
GetAllGcpRegions gets the list of GCP regions available in this account.
func GetAllGcpRegionsE ¶
GetAllGcpRegionsE gets the list of GCP regions available in this account.
func GetAllGcpZones ¶
GetAllGcpZones gets the list of GCP Zones available in this account.
func GetAllGcpZonesE ¶
GetAllGcpZonesE gets the list of GCP Zones available in this account.
func GetGoogleCredentialsFromEnvVar ¶
GetGoogleCredentialsFromEnvVar returns the Credentials for use with testing.
func GetGoogleProjectIDFromEnvVar ¶
GetGoogleProjectIDFromEnvVar returns the Project Id for use with testing.
func GetGoogleRegionFromEnvVar ¶
GetGoogleRegionFromEnvVar returns the Region for use with testing.
func GetRandomRegion ¶
func GetRandomRegion(t *testing.T, projectID string, approvedRegions []string, forbiddenRegions []string) string
GetRandomRegion gets a randomly chosen GCP Region. If approvedRegions is not empty, this will be a Region from the approvedRegions list; otherwise, this method will fetch the latest list of regions from the GCP APIs and pick one of those. If forbiddenRegions is not empty, this method will make sure the returned Region is not in the forbiddenRegions list.
func GetRandomRegionE ¶
func GetRandomRegionE(t *testing.T, projectID string, approvedRegions []string, forbiddenRegions []string) (string, error)
GetRandomRegionE gets a randomly chosen GCP Region. If approvedRegions is not empty, this will be a Region from the approvedRegions list; otherwise, this method will fetch the latest list of regions from the GCP APIs and pick one of those. If forbiddenRegions is not empty, this method will make sure the returned Region is not in the forbiddenRegions list.
func GetRandomZone ¶
func GetRandomZone(t *testing.T, projectID string, approvedZones []string, forbiddenZones []string, forbiddenRegions []string) string
GetRandomZone gets a randomly chosen GCP Zone. If approvedRegions is not empty, this will be a Zone from the approvedZones list; otherwise, this method will fetch the latest list of Zones from the GCP APIs and pick one of those. If forbiddenZones is not empty, this method will make sure the returned Region is not in the forbiddenZones list.
func GetRandomZoneE ¶
func GetRandomZoneE(t *testing.T, projectID string, approvedZones []string, forbiddenZones []string, forbiddenRegions []string) (string, error)
GetRandomZoneE gets a randomly chosen GCP Zone. If approvedRegions is not empty, this will be a Zone from the approvedZones list; otherwise, this method will fetch the latest list of Zones from the GCP APIs and pick one of those. If forbiddenZones is not empty, this method will make sure the returned Region is not in the forbiddenZones list.
func GetRandomZoneForRegion ¶ added in v0.11.0
GetRandomZoneForRegion gets a randomly chosen GCP Zone in the given Region.
func GetRandomZoneForRegionE ¶ added in v0.11.0
GetRandomZoneForRegionE gets a randomly chosen GCP Zone in the given Region.
func NewComputeService ¶
NewComputeService creates a new Compute service, which is used to make GCE API calls.
func NewComputeServiceE ¶
NewComputeServiceE creates a new Compute service, which is used to make GCE API calls.
func NewInstancesService ¶ added in v0.13.3
NewInstancesService creates a new InstancesService service, which is used to make a subset of GCE API calls.
func NewInstancesServiceE ¶ added in v0.13.3
NewInstancesServiceE creates a new InstancesService service, which is used to make a subset of GCE API calls.
func RandomValidGcpName ¶ added in v0.13.3
func RandomValidGcpName() string
Return a random, valid name for GCP resources. Many resources in GCP requires lowercase letters only.
func ReadBucketObject ¶
ReadBucketObject reads an object from the given Storage Bucket and returns its contents.
func ReadBucketObjectE ¶
ReadBucketObjectE reads an object from the given Storage Bucket and returns its contents.
func RegionUrlToRegion ¶ added in v0.11.0
Given a GCP Zone URL formatted like https://www.googleapis.com/compute/v1/projects/project-123456/regions/southamerica-east1, return "southamerica-east1". Todo: Improve sanity checking on this function by using a RegEx with capture groups
func WriteBucketObject ¶
func WriteBucketObject(t *testing.T, bucketName string, filePath string, body io.Reader, contentType string) string
WriteBucketObject writes an object to the given Storage Bucket and returns its URL.
func WriteBucketObjectE ¶
func WriteBucketObjectE(t *testing.T, bucketName string, filePath string, body io.Reader, contentType string) (string, error)
WriteBucketObjectE writes an object to the given Storage Bucket and returns its URL.
func ZoneUrlToZone ¶ added in v0.11.0
Given a GCP Zone URL formatted like https://www.googleapis.com/compute/v1/projects/project-123456/zones/asia-east1-b, return "asia-east1-b". Todo: Improve sanity checking on this function by using a RegEx with capture groups
Types ¶
type Image ¶ added in v0.11.0
type Image struct { *compute.Image // contains filtered or unexported fields }
Corresponds to a GCP Image (https://cloud.google.com/compute/docs/images)
func FetchImage ¶ added in v0.11.0
FetchImage queries GCP to return a new instance of the (GCP Compute) Image type
func FetchImageE ¶ added in v0.11.0
FetchImage queries GCP to return a new instance of the (GCP Compute) Image type
func (*Image) DeleteImage ¶ added in v0.11.0
DeleteImage deletes the given Compute Image.
type Instance ¶ added in v0.11.0
type Instance struct { *compute.Instance // contains filtered or unexported fields }
Corresponds to a GCP Compute Instance (https://cloud.google.com/compute/docs/instances/)
func FetchInstance ¶ added in v0.11.0
FetchInstance queries GCP to return an instance of the (GCP Compute) Instance type
func FetchInstanceE ¶ added in v0.11.0
FetchInstance queries GCP to return an instance of the (GCP Compute) Instance type
func (*Instance) AddSshKey ¶ added in v0.13.3
Add the given public SSH key to the Compute Instance. Users can SSH in with the given username.
func (*Instance) AddSshKeyE ¶ added in v0.13.3
Add the given public SSH key to the Compute Instance. Users can SSH in with the given username.
func (*Instance) GetLabels ¶ added in v0.11.0
GetLabels returns all the tags for the given Compute Instance.
func (*Instance) GetMetadata ¶ added in v0.13.3
GetMetadata gets the given Compute Instance's metadata
func (*Instance) GetPublicIp ¶ added in v0.11.0
GetPublicIP gets the public IP address of the given Compute Instance.
func (*Instance) GetPublicIpE ¶ added in v0.11.0
GetPublicIpE gets the public IP address of the given Compute Instance.
func (*Instance) GetZone ¶ added in v0.11.0
GetZone returns the Zone in which the Compute Instance is located.
func (*Instance) SetLabels ¶ added in v0.11.0
SetLabels adds the tags to the given Compute Instance.
func (*Instance) SetLabelsE ¶ added in v0.11.0
SetLabelsE adds the tags to the given Compute Instance.
func (*Instance) SetMetadata ¶ added in v0.13.3
SetMetadata sets the given Compute Instance's metadata
type InstanceGroup ¶ added in v0.11.0
type RegionalInstanceGroup ¶ added in v0.11.0
type RegionalInstanceGroup struct { *compute.InstanceGroup // contains filtered or unexported fields }
Corresponds to a GCP Regional Instance Group (https://cloud.google.com/compute/docs/instance-groups/)
func FetchRegionalInstanceGroup ¶ added in v0.11.0
func FetchRegionalInstanceGroup(t *testing.T, projectID string, region string, name string) *RegionalInstanceGroup
FetchRegionalInstanceGroup queries GCP to return a new instance of the Regional Instance Group type
func FetchRegionalInstanceGroupE ¶ added in v0.11.0
func FetchRegionalInstanceGroupE(t *testing.T, projectID string, region string, name string) (*RegionalInstanceGroup, error)
FetchRegionalInstanceGroup queries GCP to return a new instance of the Regional Instance Group type
func (*RegionalInstanceGroup) GetInstanceIds ¶ added in v0.11.0
func (ig *RegionalInstanceGroup) GetInstanceIds(t *testing.T) []string
GetInstanceIds gets the IDs of Instances in the given Regional Instance Group.
func (*RegionalInstanceGroup) GetInstanceIdsE ¶ added in v0.11.0
func (ig *RegionalInstanceGroup) GetInstanceIdsE(t *testing.T) ([]string, error)
GetInstanceIdsE gets the IDs of Instances in the given Regional Instance Group.
func (*RegionalInstanceGroup) GetInstances ¶ added in v0.13.4
func (ig *RegionalInstanceGroup) GetInstances(t *testing.T, projectId string) []*Instance
Return a collection of Instance structs from the given Instance Group
func (*RegionalInstanceGroup) GetInstancesE ¶ added in v0.13.4
Return a collection of Instance structs from the given Instance Group
func (*RegionalInstanceGroup) GetPublicIps ¶ added in v0.13.4
func (ig *RegionalInstanceGroup) GetPublicIps(t *testing.T, projectId string) []string
GetPublicIps returns a slice of the public IPs from the given Instance Group
func (*RegionalInstanceGroup) GetPublicIpsE ¶ added in v0.13.4
GetPublicIpsE returns a slice of the public IPs from the given Instance Group
func (*RegionalInstanceGroup) GetRandomInstance ¶ added in v0.11.0
func (ig *RegionalInstanceGroup) GetRandomInstance(t *testing.T) *Instance
getRandomInstance returns a randomly selected Instance from the Regional Instance Group
func (*RegionalInstanceGroup) GetRandomInstanceE ¶ added in v0.11.0
func (ig *RegionalInstanceGroup) GetRandomInstanceE(t *testing.T) (*Instance, error)
getRandomInstanceE returns a randomly selected Instance from the Regional Instance Group
type ZonalInstanceGroup ¶ added in v0.11.0
type ZonalInstanceGroup struct { *compute.InstanceGroup // contains filtered or unexported fields }
Corresponds to a GCP Zonal Instance Group (https://cloud.google.com/compute/docs/instance-groups/)
func FetchZonalInstanceGroup ¶ added in v0.11.0
func FetchZonalInstanceGroup(t *testing.T, projectID string, zone string, name string) *ZonalInstanceGroup
FetchZonalInstanceGroup queries GCP to return a new instance of the Regional Instance Group type
func FetchZonalInstanceGroupE ¶ added in v0.11.0
func FetchZonalInstanceGroupE(t *testing.T, projectID string, zone string, name string) (*ZonalInstanceGroup, error)
FetchZonalInstanceGroup queries GCP to return a new instance of the Regional Instance Group type
func (*ZonalInstanceGroup) GetInstanceIds ¶ added in v0.11.0
func (ig *ZonalInstanceGroup) GetInstanceIds(t *testing.T) []string
GetInstanceIds gets the IDs of Instances in the given Instance Group.
func (*ZonalInstanceGroup) GetInstanceIdsE ¶ added in v0.11.0
func (ig *ZonalInstanceGroup) GetInstanceIdsE(t *testing.T) ([]string, error)
GetInstanceIdsE gets the IDs of Instances in the given Zonal Instance Group.
func (*ZonalInstanceGroup) GetInstances ¶ added in v0.13.4
func (ig *ZonalInstanceGroup) GetInstances(t *testing.T, projectId string) []*Instance
Return a collection of Instance structs from the given Instance Group
func (*ZonalInstanceGroup) GetInstancesE ¶ added in v0.13.4
Return a collection of Instance structs from the given Instance Group
func (*ZonalInstanceGroup) GetPublicIps ¶ added in v0.13.4
func (ig *ZonalInstanceGroup) GetPublicIps(t *testing.T, projectId string) []string
GetPublicIps returns a slice of the public IPs from the given Instance Group
func (*ZonalInstanceGroup) GetPublicIpsE ¶ added in v0.13.4
GetPublicIpsE returns a slice of the public IPs from the given Instance Group
func (*ZonalInstanceGroup) GetRandomInstance ¶ added in v0.11.0
func (ig *ZonalInstanceGroup) GetRandomInstance(t *testing.T) *Instance
getRandomInstance returns a randomly selected Instance from the Regional Instance Group
func (*ZonalInstanceGroup) GetRandomInstanceE ¶ added in v0.11.0
func (ig *ZonalInstanceGroup) GetRandomInstanceE(t *testing.T) (*Instance, error)
getRandomInstanceE returns a randomly selected Instance from the Regional Instance Group