Documentation
¶
Overview ¶
Package gcp allows interaction with Google Cloud Platform resources.
Index ¶
- func AssertStorageBucketExistsContext(t testing.TestingT, ctx context.Context, name string)
- func AssertStorageBucketExistsContextE(t testing.TestingT, ctx context.Context, name string) error
- func AssertStorageBucketExistsWithClient(ctx context.Context, client *storage.Client, name string) error
- func AssertSubscriptionExistsContext(t testing.TestingT, ctx context.Context, projectID string, ...)
- func AssertSubscriptionExistsContextE(t testing.TestingT, ctx context.Context, projectID string, ...) error
- func AssertSubscriptionExistsWithClient(ctx context.Context, client *pubsub.Client, subscriptionName string) error
- func AssertTopicExistsContext(t testing.TestingT, ctx context.Context, projectID string, topicName string)
- func AssertTopicExistsContextE(t testing.TestingT, ctx context.Context, projectID string, topicName string) error
- func AssertTopicExistsWithClient(ctx context.Context, client *pubsub.Client, topicName string) error
- func CreateBuildContext(t testing.TestingT, ctx context.Context, projectID string, ...) *cloudbuildpb.Build
- func CreateBuildContextE(t testing.TestingT, ctx context.Context, projectID string, ...) (*cloudbuildpb.Build, error)
- func CreateBuildWithClient(ctx context.Context, service *cloudbuild.Client, projectID string, ...) (*cloudbuildpb.Build, error)
- func CreateStorageBucketContext(t testing.TestingT, ctx context.Context, projectID string, name string, ...)
- func CreateStorageBucketContextE(t testing.TestingT, ctx context.Context, projectID string, name string, ...) error
- func CreateStorageBucketWithClient(ctx context.Context, client *storage.Client, projectID string, name string, ...) error
- func CreateSubscriptionContext(t testing.TestingT, ctx context.Context, projectID string, ...)
- func CreateSubscriptionContextE(t testing.TestingT, ctx context.Context, projectID string, ...) error
- func CreateSubscriptionWithClient(ctx context.Context, client *pubsub.Client, subscriptionName string, ...) error
- func CreateTopicContext(t testing.TestingT, ctx context.Context, projectID string, topicName string)
- func CreateTopicContextE(t testing.TestingT, ctx context.Context, projectID string, topicName string) error
- func CreateTopicWithClient(ctx context.Context, client *pubsub.Client, topicName string) error
- func DeleteGCRImageRefContext(t testing.TestingT, ctx context.Context, ref string)
- func DeleteGCRImageRefContextE(t testing.TestingT, ctx context.Context, ref string) error
- func DeleteGCRImageRefWithClient(ctx context.Context, client *GCRClient, ref string) error
- func DeleteGCRRepoContext(t testing.TestingT, ctx context.Context, repo string)
- func DeleteGCRRepoContextE(t testing.TestingT, ctx context.Context, repo string) error
- func DeleteGCRRepoWithClient(ctx context.Context, client *GCRClient, repo string) error
- func DeleteSSHKeyContext(t testing.TestingT, ctx context.Context, user, key string)
- func DeleteSSHKeyContextE(t testing.TestingT, ctx context.Context, user, key string) error
- func DeleteSSHKeyWithClient(ctx context.Context, service *oslogin.Service, user, key string) error
- func DeleteStorageBucketContext(t testing.TestingT, ctx context.Context, name string)
- func DeleteStorageBucketContextE(t testing.TestingT, ctx context.Context, name string) error
- func DeleteStorageBucketWithClient(ctx context.Context, client *storage.Client, name string) error
- func DeleteSubscriptionContext(t testing.TestingT, ctx context.Context, projectID string, ...)
- func DeleteSubscriptionContextE(t testing.TestingT, ctx context.Context, projectID string, ...) error
- func DeleteSubscriptionWithClient(ctx context.Context, client *pubsub.Client, subscriptionName string) error
- func DeleteTopicContext(t testing.TestingT, ctx context.Context, projectID string, topicName string)
- func DeleteTopicContextE(t testing.TestingT, ctx context.Context, projectID string, topicName string) error
- func DeleteTopicWithClient(ctx context.Context, client *pubsub.Client, topicName string) error
- func EmptyStorageBucketContext(t testing.TestingT, ctx context.Context, name string)
- func EmptyStorageBucketContextE(t testing.TestingT, ctx context.Context, name string) error
- func EmptyStorageBucketWithClient(ctx context.Context, client *storage.Client, name string) error
- func GetAllGCPRegionsContext(t testing.TestingT, ctx context.Context, projectID string) []string
- func GetAllGCPRegionsContextE(t testing.TestingT, ctx context.Context, projectID string) ([]string, error)
- func GetAllGCPRegionsWithClient(ctx context.Context, service *compute.Service, projectID string) ([]string, error)
- func GetAllGCPZonesContext(t testing.TestingT, ctx context.Context, projectID string) []string
- func GetAllGCPZonesContextE(t testing.TestingT, ctx context.Context, projectID string) ([]string, error)
- func GetAllGCPZonesWithClient(ctx context.Context, service *compute.Service, projectID string) ([]string, error)
- func GetBuildContext(t testing.TestingT, ctx context.Context, projectID string, buildID string) *cloudbuildpb.Build
- func GetBuildContextE(t testing.TestingT, ctx context.Context, projectID string, buildID string) (*cloudbuildpb.Build, error)
- func GetBuildWithClient(ctx context.Context, service *cloudbuild.Client, projectID string, ...) (*cloudbuildpb.Build, error)
- func GetBuildsContext(t testing.TestingT, ctx context.Context, projectID string) []*cloudbuildpb.Build
- func GetBuildsContextE(t testing.TestingT, ctx context.Context, projectID string) ([]*cloudbuildpb.Build, error)
- func GetBuildsForTriggerContext(t testing.TestingT, ctx context.Context, projectID string, triggerID string) []*cloudbuildpb.Build
- func GetBuildsForTriggerContextE(t testing.TestingT, ctx context.Context, projectID string, triggerID string) ([]*cloudbuildpb.Build, error)
- func GetBuildsForTriggerWithClient(ctx context.Context, service *cloudbuild.Client, projectID string, ...) ([]*cloudbuildpb.Build, error)
- func GetBuildsWithClient(ctx context.Context, service *cloudbuild.Client, projectID string) ([]*cloudbuildpb.Build, error)
- func GetGoogleCredentialsFromEnvVar(t testing.TestingT) string
- func GetGoogleIdentityEmailEnvVar(t testing.TestingT) string
- func GetGoogleProjectIDFromEnvVar(t testing.TestingT) string
- func GetGoogleRegionFromEnvVar(t testing.TestingT) string
- func GetLoginProfileContext(t testing.TestingT, ctx context.Context, user string) *oslogin.LoginProfile
- func GetLoginProfileContextE(t testing.TestingT, ctx context.Context, user string) (*oslogin.LoginProfile, error)
- func GetLoginProfileWithClient(ctx context.Context, service *oslogin.Service, user string) (*oslogin.LoginProfile, error)
- func GetRandomRegionContext(t testing.TestingT, ctx context.Context, projectID string, ...) string
- func GetRandomRegionContextE(t testing.TestingT, ctx context.Context, projectID string, ...) (string, error)
- func GetRandomZoneContext(t testing.TestingT, ctx context.Context, projectID string, ...) string
- func GetRandomZoneContextE(t testing.TestingT, ctx context.Context, projectID string, ...) (string, error)
- func GetRandomZoneForRegionContext(t testing.TestingT, ctx context.Context, projectID string, region string) string
- func GetRandomZoneForRegionContextE(t testing.TestingT, ctx context.Context, projectID string, region string) (string, error)
- func ImportProjectSSHKeyContext(t testing.TestingT, ctx context.Context, user, key, projectID string)
- func ImportProjectSSHKeyContextE(t testing.TestingT, ctx context.Context, user, key, projectID string) error
- func ImportProjectSSHKeyWithClient(ctx context.Context, service *oslogin.Service, user, key, projectID string) error
- func ImportSSHKeyContext(t testing.TestingT, ctx context.Context, user, key string)
- func ImportSSHKeyContextE(t testing.TestingT, ctx context.Context, user, key string) error
- func ImportSSHKeyWithClient(ctx context.Context, service *oslogin.Service, user, key string) error
- func NewCloudBuildServiceContext(t testing.TestingT, ctx context.Context) *cloudbuild.Client
- func NewCloudBuildServiceContextE(t testing.TestingT, ctx context.Context) (*cloudbuild.Client, error)
- func NewComputeServiceContext(t testing.TestingT, ctx context.Context) *compute.Service
- func NewComputeServiceContextE(t testing.TestingT, ctx context.Context) (*compute.Service, error)
- func NewInstancesServiceContext(t testing.TestingT, ctx context.Context) *compute.InstancesService
- func NewInstancesServiceContextE(t testing.TestingT, ctx context.Context) (*compute.InstancesService, error)
- func NewMetadata(oldMetadata *compute.Metadata, kvs map[string]string) *compute.Metadata
- func NewOSLoginServiceContextE(t testing.TestingT, ctx context.Context) (*oslogin.Service, error)
- func RandomValidGCPName() string
- func ReadBucketObjectContext(t testing.TestingT, ctx context.Context, bucketName string, filePath string) io.Reader
- func ReadBucketObjectContextE(t testing.TestingT, ctx context.Context, bucketName string, filePath string) (io.Reader, error)
- func ReadBucketObjectWithClient(ctx context.Context, client *storage.Client, bucketName string, ...) (io.Reader, error)
- func RegionURLToRegion(regionURL string) string
- func WriteBucketObjectContext(t testing.TestingT, ctx context.Context, bucketName string, filePath string, ...) string
- func WriteBucketObjectContextE(t testing.TestingT, ctx context.Context, bucketName string, filePath string, ...) (string, error)
- func WriteBucketObjectWithClient(ctx context.Context, client *storage.Client, bucketName string, ...) (string, error)
- func ZoneURLToZone(zoneURL string) string
- type GCRClient
- type Image
- func FetchImageContext(t testing.TestingT, ctx context.Context, projectID string, name string) *Image
- func FetchImageContextE(t testing.TestingT, ctx context.Context, projectID string, name string) (*Image, error)
- func FetchImageWithClient(ctx context.Context, service *compute.Service, projectID string, name string) (*Image, error)
- type Instance
- func FetchInstanceContext(t testing.TestingT, ctx context.Context, projectID string, name string) *Instance
- func FetchInstanceContextE(t testing.TestingT, ctx context.Context, projectID string, name string) (*Instance, error)
- func FetchInstanceWithClient(ctx context.Context, service *compute.Service, projectID string, name string) (*Instance, error)
- func (i *Instance) AddSSHKeyContext(t testing.TestingT, ctx context.Context, username string, publicKey string)
- func (i *Instance) AddSSHKeyContextE(t testing.TestingT, ctx context.Context, username string, publicKey string) error
- func (i *Instance) AddSSHKeyWithClient(ctx context.Context, service *compute.Service, username string, ...) error
- func (i *Instance) GetLabelsContext(t testing.TestingT, ctx context.Context) map[string]string
- func (i *Instance) GetLabelsContextE(t testing.TestingT, ctx context.Context) (map[string]string, error)
- func (i *Instance) GetMetadataContext(t testing.TestingT, ctx context.Context) []*compute.MetadataItems
- func (i *Instance) GetMetadataContextE(t testing.TestingT, ctx context.Context) ([]*compute.MetadataItems, error)
- func (i *Instance) GetPublicIPContext(t testing.TestingT, ctx context.Context) string
- func (i *Instance) GetPublicIPContextE(t testing.TestingT, ctx context.Context) (string, error)
- func (i *Instance) GetZoneContext(t testing.TestingT, ctx context.Context) string
- func (i *Instance) GetZoneContextE(t testing.TestingT, ctx context.Context) (string, error)
- func (i *Instance) SetLabelsContext(t testing.TestingT, ctx context.Context, labels map[string]string)
- func (i *Instance) SetLabelsContextE(t testing.TestingT, ctx context.Context, labels map[string]string) error
- func (i *Instance) SetLabelsWithClient(ctx context.Context, service *compute.Service, labels map[string]string) error
- func (i *Instance) SetMetadataContext(t testing.TestingT, ctx context.Context, metadata map[string]string)
- func (i *Instance) SetMetadataContextE(t testing.TestingT, ctx context.Context, metadata map[string]string) error
- func (i *Instance) SetMetadataWithClient(ctx context.Context, service *compute.Service, metadata map[string]string) error
- type InstanceGroup
- type RegionalInstanceGroup
- func FetchRegionalInstanceGroupContext(t testing.TestingT, ctx context.Context, projectID string, region string, ...) *RegionalInstanceGroup
- func FetchRegionalInstanceGroupContextE(t testing.TestingT, ctx context.Context, projectID string, region string, ...) (*RegionalInstanceGroup, error)
- func FetchRegionalInstanceGroupWithClient(ctx context.Context, service *compute.Service, projectID string, region string, ...) (*RegionalInstanceGroup, error)
- func (ig *RegionalInstanceGroup) GetInstanceIDsContext(t testing.TestingT, ctx context.Context) []string
- func (ig *RegionalInstanceGroup) GetInstanceIDsContextE(t testing.TestingT, ctx context.Context) ([]string, error)
- func (ig *RegionalInstanceGroup) GetInstanceIDsWithClient(ctx context.Context, service *compute.Service) ([]string, error)
- func (ig *RegionalInstanceGroup) GetInstancesContext(t testing.TestingT, ctx context.Context, projectID string) []*Instance
- func (ig *RegionalInstanceGroup) GetInstancesContextE(t testing.TestingT, ctx context.Context, projectID string) ([]*Instance, error)
- func (ig *RegionalInstanceGroup) GetPublicIPsContext(t testing.TestingT, ctx context.Context, projectID string) []string
- func (ig *RegionalInstanceGroup) GetPublicIPsContextE(t testing.TestingT, ctx context.Context, projectID string) ([]string, error)
- func (ig *RegionalInstanceGroup) GetRandomInstanceContext(t testing.TestingT, ctx context.Context) *Instance
- func (ig *RegionalInstanceGroup) GetRandomInstanceContextE(t testing.TestingT, ctx context.Context) (*Instance, error)
- type ZonalInstanceGroup
- func FetchZonalInstanceGroupContext(t testing.TestingT, ctx context.Context, projectID string, zone string, ...) *ZonalInstanceGroup
- func FetchZonalInstanceGroupContextE(t testing.TestingT, ctx context.Context, projectID string, zone string, ...) (*ZonalInstanceGroup, error)
- func FetchZonalInstanceGroupWithClient(ctx context.Context, service *compute.Service, projectID string, zone string, ...) (*ZonalInstanceGroup, error)
- func (ig *ZonalInstanceGroup) GetInstanceIDsContext(t testing.TestingT, ctx context.Context) []string
- func (ig *ZonalInstanceGroup) GetInstanceIDsContextE(t testing.TestingT, ctx context.Context) ([]string, error)
- func (ig *ZonalInstanceGroup) GetInstanceIDsWithClient(ctx context.Context, service *compute.Service) ([]string, error)
- func (ig *ZonalInstanceGroup) GetInstancesContext(t testing.TestingT, ctx context.Context, projectID string) []*Instance
- func (ig *ZonalInstanceGroup) GetInstancesContextE(t testing.TestingT, ctx context.Context, projectID string) ([]*Instance, error)
- func (ig *ZonalInstanceGroup) GetPublicIPsContext(t testing.TestingT, ctx context.Context, projectID string) []string
- func (ig *ZonalInstanceGroup) GetPublicIPsContextE(t testing.TestingT, ctx context.Context, projectID string) ([]string, error)
- func (ig *ZonalInstanceGroup) GetRandomInstanceContext(t testing.TestingT, ctx context.Context) *Instance
- func (ig *ZonalInstanceGroup) GetRandomInstanceContextE(t testing.TestingT, ctx context.Context) (*Instance, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertStorageBucketExistsContext ¶
AssertStorageBucketExistsContext checks if the given storage bucket exists and fails the test if it does not. The ctx parameter supports cancellation and timeouts.
func AssertStorageBucketExistsContextE ¶
AssertStorageBucketExistsContextE checks if the given storage bucket exists and returns an error if it does not. The ctx parameter supports cancellation and timeouts.
func AssertStorageBucketExistsWithClient ¶
func AssertStorageBucketExistsWithClient(ctx context.Context, client *storage.Client, name string) error
AssertStorageBucketExistsWithClient checks if the given storage bucket exists and returns an error if it does not, using the supplied *storage.Client. Prefer this variant in unit tests where the client is backed by an httptest fake server (see storage_unit_test.go for the pattern). The ctx parameter supports cancellation and timeouts.
func AssertSubscriptionExistsContext ¶
func AssertSubscriptionExistsContext(t testing.TestingT, ctx context.Context, projectID string, subscriptionName string)
AssertSubscriptionExistsContext checks if the given Pub/Sub subscription exists and fails the test if it does not. The ctx parameter supports cancellation and timeouts.
func AssertSubscriptionExistsContextE ¶
func AssertSubscriptionExistsContextE(t testing.TestingT, ctx context.Context, projectID string, subscriptionName string) error
AssertSubscriptionExistsContextE checks if the given Pub/Sub subscription exists and returns an error if it does not. The ctx parameter supports cancellation and timeouts.
func AssertSubscriptionExistsWithClient ¶
func AssertSubscriptionExistsWithClient(ctx context.Context, client *pubsub.Client, subscriptionName string) error
AssertSubscriptionExistsWithClient checks if the given Pub/Sub subscription exists using the supplied *pubsub.Client. Prefer this variant in unit tests where the client is backed by a pstest in-memory fake server (see pubsub_unit_test.go for the pattern). The ctx parameter supports cancellation and timeouts.
func AssertTopicExistsContext ¶
func AssertTopicExistsContext(t testing.TestingT, ctx context.Context, projectID string, topicName string)
AssertTopicExistsContext checks if the given Pub/Sub topic exists and fails the test if it does not. The ctx parameter supports cancellation and timeouts.
func AssertTopicExistsContextE ¶
func AssertTopicExistsContextE(t testing.TestingT, ctx context.Context, projectID string, topicName string) error
AssertTopicExistsContextE checks if the given Pub/Sub topic exists and returns an error if it does not. The ctx parameter supports cancellation and timeouts.
func AssertTopicExistsWithClient ¶
func AssertTopicExistsWithClient(ctx context.Context, client *pubsub.Client, topicName string) error
AssertTopicExistsWithClient checks if the given Pub/Sub topic exists using the supplied *pubsub.Client. Prefer this variant in unit tests where the client is backed by a pstest in-memory fake server (see pubsub_unit_test.go for the pattern). The ctx parameter supports cancellation and timeouts.
func CreateBuildContext ¶
func CreateBuildContext(t testing.TestingT, ctx context.Context, projectID string, build *cloudbuildpb.Build) *cloudbuildpb.Build
CreateBuildContext creates a new build blocking until the operation is complete. This will fail the test if there is an error. The ctx parameter supports cancellation and timeouts.
func CreateBuildContextE ¶
func CreateBuildContextE(t testing.TestingT, ctx context.Context, projectID string, build *cloudbuildpb.Build) (*cloudbuildpb.Build, error)
CreateBuildContextE creates a new build blocking until the operation is complete. The ctx parameter supports cancellation and timeouts.
func CreateBuildWithClient ¶
func CreateBuildWithClient(ctx context.Context, service *cloudbuild.Client, projectID string, build *cloudbuildpb.Build) (*cloudbuildpb.Build, error)
CreateBuildWithClient creates a new build blocking until the operation is complete using the supplied *cloudbuild.Client. Prefer this variant in unit tests where the client is backed by a mock gRPC server. The ctx parameter supports cancellation and timeouts.
func CreateStorageBucketContext ¶
func CreateStorageBucketContext(t testing.TestingT, ctx context.Context, projectID string, name string, attr *storage.BucketAttrs)
CreateStorageBucketContext creates a Google Cloud bucket with the given BucketAttrs. Note that Google Storage bucket names must be globally unique. This will fail the test if there is an error. The ctx parameter supports cancellation and timeouts.
func CreateStorageBucketContextE ¶
func CreateStorageBucketContextE(t testing.TestingT, ctx context.Context, projectID string, name string, attr *storage.BucketAttrs) error
CreateStorageBucketContextE creates a Google Cloud bucket with the given BucketAttrs. Note that Google Storage bucket names must be globally unique. The ctx parameter supports cancellation and timeouts.
func CreateStorageBucketWithClient ¶
func CreateStorageBucketWithClient(ctx context.Context, client *storage.Client, projectID string, name string, attr *storage.BucketAttrs) error
CreateStorageBucketWithClient creates a Google Cloud bucket with the given BucketAttrs using the supplied *storage.Client. Prefer this variant in unit tests where the client is backed by an httptest fake server (see storage_unit_test.go for the pattern). The ctx parameter supports cancellation and timeouts.
func CreateSubscriptionContext ¶
func CreateSubscriptionContext(t testing.TestingT, ctx context.Context, projectID string, subscriptionName string, topicName string)
CreateSubscriptionContext creates a new Pub/Sub subscription on the given topic and fails the test if it cannot. The ctx parameter supports cancellation and timeouts.
func CreateSubscriptionContextE ¶
func CreateSubscriptionContextE(t testing.TestingT, ctx context.Context, projectID string, subscriptionName string, topicName string) error
CreateSubscriptionContextE creates a new Pub/Sub subscription on the given topic and returns an error if it fails. The ctx parameter supports cancellation and timeouts.
func CreateSubscriptionWithClient ¶
func CreateSubscriptionWithClient(ctx context.Context, client *pubsub.Client, subscriptionName string, topicName string) error
CreateSubscriptionWithClient creates a new Pub/Sub subscription on the given topic using the supplied *pubsub.Client. Prefer this variant in unit tests where the client is backed by a pstest in-memory fake server (see pubsub_unit_test.go for the pattern). The ctx parameter supports cancellation and timeouts.
func CreateTopicContext ¶
func CreateTopicContext(t testing.TestingT, ctx context.Context, projectID string, topicName string)
CreateTopicContext creates a new Pub/Sub topic and fails the test if it cannot. The ctx parameter supports cancellation and timeouts.
func CreateTopicContextE ¶
func CreateTopicContextE(t testing.TestingT, ctx context.Context, projectID string, topicName string) error
CreateTopicContextE creates a new Pub/Sub topic and returns an error if it fails. The ctx parameter supports cancellation and timeouts.
func CreateTopicWithClient ¶
CreateTopicWithClient creates a new Pub/Sub topic using the supplied *pubsub.Client. Prefer this variant in unit tests where the client is backed by a pstest in-memory fake server (see pubsub_unit_test.go for the pattern). The ctx parameter supports cancellation and timeouts.
func DeleteGCRImageRefContext ¶
DeleteGCRImageRefContext deletes a single repo image ref/digest. This will fail the test if there is an error. The ctx parameter supports cancellation and timeouts.
func DeleteGCRImageRefContextE ¶
DeleteGCRImageRefContextE deletes a single repo image ref/digest. The ctx parameter supports cancellation and timeouts.
func DeleteGCRImageRefWithClient ¶
DeleteGCRImageRefWithClient deletes a single repo image ref/digest using the supplied client. Prefer this variant in unit tests where the client's Transport points at an httptest fake server (see gcr_unit_test.go for the pattern). The ctx parameter supports cancellation and timeouts.
func DeleteGCRRepoContext ¶
DeleteGCRRepoContext deletes a GCR repository including all tagged images. This will fail the test if there is an error. The ctx parameter supports cancellation and timeouts.
func DeleteGCRRepoContextE ¶
DeleteGCRRepoContextE deletes a GCR repository including all tagged images. The ctx parameter supports cancellation and timeouts.
func DeleteGCRRepoWithClient ¶
DeleteGCRRepoWithClient deletes a GCR repository including all tagged images using the supplied client. Prefer this variant in unit tests where the client's Transport points at an httptest fake server (see gcr_unit_test.go for the pattern). The ctx parameter supports cancellation and timeouts.
func DeleteSSHKeyContext ¶
DeleteSSHKeyContext will delete an SSH key attached to the provided user identity. The user parameter should be the email address of the user. The key parameter should be the public key of the SSH key that was uploaded. This will fail the test if there is an error. The ctx parameter supports cancellation and timeouts.
func DeleteSSHKeyContextE ¶
DeleteSSHKeyContextE will delete an SSH key attached to the provided user identity. The user parameter should be the email address of the user. The key parameter should be the public key of the SSH key that was uploaded. The ctx parameter supports cancellation and timeouts.
func DeleteSSHKeyWithClient ¶
DeleteSSHKeyWithClient deletes an SSH key attached to the provided user identity using the supplied *oslogin.Service. Prefer this variant in unit tests where the service is backed by an httptest fake server (see oslogin_unit_test.go for the pattern). The user parameter should be the email address of the user. The key parameter should be the public key of the SSH key that was uploaded. The ctx parameter supports cancellation and timeouts.
func DeleteStorageBucketContext ¶
DeleteStorageBucketContext destroys the Google Storage bucket. This will fail the test if there is an error. The ctx parameter supports cancellation and timeouts.
func DeleteStorageBucketContextE ¶
DeleteStorageBucketContextE destroys the Google Cloud Storage bucket with the given name. The ctx parameter supports cancellation and timeouts.
func DeleteStorageBucketWithClient ¶
DeleteStorageBucketWithClient destroys the Google Cloud Storage bucket with the given name using the supplied *storage.Client. Prefer this variant in unit tests where the client is backed by an httptest fake server (see storage_unit_test.go for the pattern). The ctx parameter supports cancellation and timeouts.
func DeleteSubscriptionContext ¶
func DeleteSubscriptionContext(t testing.TestingT, ctx context.Context, projectID string, subscriptionName string)
DeleteSubscriptionContext deletes the given Pub/Sub subscription and fails the test if it cannot. The ctx parameter supports cancellation and timeouts.
func DeleteSubscriptionContextE ¶
func DeleteSubscriptionContextE(t testing.TestingT, ctx context.Context, projectID string, subscriptionName string) error
DeleteSubscriptionContextE deletes the given Pub/Sub subscription and returns an error if it fails. The ctx parameter supports cancellation and timeouts.
func DeleteSubscriptionWithClient ¶
func DeleteSubscriptionWithClient(ctx context.Context, client *pubsub.Client, subscriptionName string) error
DeleteSubscriptionWithClient deletes the given Pub/Sub subscription using the supplied *pubsub.Client. Prefer this variant in unit tests where the client is backed by a pstest in-memory fake server (see pubsub_unit_test.go for the pattern). The ctx parameter supports cancellation and timeouts.
func DeleteTopicContext ¶
func DeleteTopicContext(t testing.TestingT, ctx context.Context, projectID string, topicName string)
DeleteTopicContext deletes the given Pub/Sub topic and fails the test if it cannot. The ctx parameter supports cancellation and timeouts.
func DeleteTopicContextE ¶
func DeleteTopicContextE(t testing.TestingT, ctx context.Context, projectID string, topicName string) error
DeleteTopicContextE deletes the given Pub/Sub topic and returns an error if it fails. The ctx parameter supports cancellation and timeouts.
func DeleteTopicWithClient ¶
DeleteTopicWithClient deletes the given Pub/Sub topic using the supplied *pubsub.Client. Prefer this variant in unit tests where the client is backed by a pstest in-memory fake server (see pubsub_unit_test.go for the pattern). The ctx parameter supports cancellation and timeouts.
func EmptyStorageBucketContext ¶
EmptyStorageBucketContext removes the contents of a storage bucket with the given name. This will fail the test if there is an error. The ctx parameter supports cancellation and timeouts.
func EmptyStorageBucketContextE ¶
EmptyStorageBucketContextE removes the contents of a storage bucket with the given name. The ctx parameter supports cancellation and timeouts.
func EmptyStorageBucketWithClient ¶
EmptyStorageBucketWithClient removes the contents of a storage bucket with the given name using the supplied *storage.Client. Prefer this variant in unit tests where the client is backed by an httptest fake server (see storage_unit_test.go for the pattern). The ctx parameter supports cancellation and timeouts.
func GetAllGCPRegionsContext ¶
GetAllGCPRegionsContext gets the list of GCP regions available in this account. This will fail the test if there is an error. The ctx parameter supports cancellation and timeouts.
func GetAllGCPRegionsContextE ¶
func GetAllGCPRegionsContextE(t testing.TestingT, ctx context.Context, projectID string) ([]string, error)
GetAllGCPRegionsContextE gets the list of GCP regions available in this account. The ctx parameter supports cancellation and timeouts.
func GetAllGCPRegionsWithClient ¶
func GetAllGCPRegionsWithClient(ctx context.Context, service *compute.Service, projectID string) ([]string, error)
GetAllGCPRegionsWithClient gets the list of GCP regions available in this account using the supplied *compute.Service. Prefer this variant in unit tests where the service is backed by an httptest fake server (see region_unit_test.go for the pattern). The ctx parameter supports cancellation and timeouts.
func GetAllGCPZonesContext ¶
GetAllGCPZonesContext gets the list of GCP Zones available in this account. This will fail the test if there is an error. The ctx parameter supports cancellation and timeouts.
func GetAllGCPZonesContextE ¶
func GetAllGCPZonesContextE(t testing.TestingT, ctx context.Context, projectID string) ([]string, error)
GetAllGCPZonesContextE gets the list of GCP Zones available in this account. The ctx parameter supports cancellation and timeouts.
func GetAllGCPZonesWithClient ¶
func GetAllGCPZonesWithClient(ctx context.Context, service *compute.Service, projectID string) ([]string, error)
GetAllGCPZonesWithClient gets the list of GCP Zones available in this account using the supplied *compute.Service. Prefer this variant in unit tests where the service is backed by an httptest fake server (see region_unit_test.go for the pattern). The ctx parameter supports cancellation and timeouts.
func GetBuildContext ¶
func GetBuildContext(t testing.TestingT, ctx context.Context, projectID string, buildID string) *cloudbuildpb.Build
GetBuildContext gets the given build. This will fail the test if there is an error. The ctx parameter supports cancellation and timeouts.
func GetBuildContextE ¶
func GetBuildContextE(t testing.TestingT, ctx context.Context, projectID string, buildID string) (*cloudbuildpb.Build, error)
GetBuildContextE gets the given build. The ctx parameter supports cancellation and timeouts.
func GetBuildWithClient ¶
func GetBuildWithClient(ctx context.Context, service *cloudbuild.Client, projectID string, buildID string) (*cloudbuildpb.Build, error)
GetBuildWithClient gets the given build using the supplied *cloudbuild.Client. Prefer this variant in unit tests where the client is backed by a mock gRPC server. The ctx parameter supports cancellation and timeouts.
func GetBuildsContext ¶
func GetBuildsContext(t testing.TestingT, ctx context.Context, projectID string) []*cloudbuildpb.Build
GetBuildsContext gets the list of builds for a given project. This will fail the test if there is an error. The ctx parameter supports cancellation and timeouts.
func GetBuildsContextE ¶
func GetBuildsContextE(t testing.TestingT, ctx context.Context, projectID string) ([]*cloudbuildpb.Build, error)
GetBuildsContextE gets the list of builds for a given project. The ctx parameter supports cancellation and timeouts.
func GetBuildsForTriggerContext ¶
func GetBuildsForTriggerContext(t testing.TestingT, ctx context.Context, projectID string, triggerID string) []*cloudbuildpb.Build
GetBuildsForTriggerContext gets a list of builds for a specific cloud build trigger. This will fail the test if there is an error. The ctx parameter supports cancellation and timeouts.
func GetBuildsForTriggerContextE ¶
func GetBuildsForTriggerContextE(t testing.TestingT, ctx context.Context, projectID string, triggerID string) ([]*cloudbuildpb.Build, error)
GetBuildsForTriggerContextE gets a list of builds for a specific cloud build trigger. The ctx parameter supports cancellation and timeouts.
func GetBuildsForTriggerWithClient ¶
func GetBuildsForTriggerWithClient(ctx context.Context, service *cloudbuild.Client, projectID string, triggerID string) ([]*cloudbuildpb.Build, error)
GetBuildsForTriggerWithClient gets a list of builds for a specific cloud build trigger using the supplied *cloudbuild.Client. Prefer this variant in unit tests where the client is backed by a mock gRPC server. The ctx parameter supports cancellation and timeouts.
func GetBuildsWithClient ¶
func GetBuildsWithClient(ctx context.Context, service *cloudbuild.Client, projectID string) ([]*cloudbuildpb.Build, error)
GetBuildsWithClient gets the list of builds for a given project using the supplied *cloudbuild.Client. Prefer this variant in unit tests where the client is backed by a mock gRPC server. The ctx parameter supports cancellation and timeouts.
func GetGoogleCredentialsFromEnvVar ¶
GetGoogleCredentialsFromEnvVar returns the Credentials for use with testing.
func GetGoogleIdentityEmailEnvVar ¶
GetGoogleIdentityEmailEnvVar returns a Google identity (user) 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 GetLoginProfileContext ¶
func GetLoginProfileContext(t testing.TestingT, ctx context.Context, user string) *oslogin.LoginProfile
GetLoginProfileContext will retrieve the login profile for a user's Google identity. The login profile is a combination of OS Login + gcloud SSH keys and POSIX accounts the user will appear as. Generally, this will only be the OS Login key + account, but gcloud compute ssh could create temporary keys and profiles. The user parameter should be the email address of the user. This will fail the test if there is an error. The ctx parameter supports cancellation and timeouts.
func GetLoginProfileContextE ¶
func GetLoginProfileContextE(t testing.TestingT, ctx context.Context, user string) (*oslogin.LoginProfile, error)
GetLoginProfileContextE will retrieve the login profile for a user's Google identity. The login profile is a combination of OS Login + gcloud SSH keys and POSIX accounts the user will appear as. Generally, this will only be the OS Login key + account, but gcloud compute ssh could create temporary keys and profiles. The user parameter should be the email address of the user. The ctx parameter supports cancellation and timeouts.
func GetLoginProfileWithClient ¶
func GetLoginProfileWithClient(ctx context.Context, service *oslogin.Service, user string) (*oslogin.LoginProfile, error)
GetLoginProfileWithClient retrieves the login profile for a user's Google identity using the supplied *oslogin.Service. Prefer this variant in unit tests where the service is backed by an httptest fake server (see oslogin_unit_test.go for the pattern). The user parameter should be the email address of the user. The ctx parameter supports cancellation and timeouts.
func GetRandomRegionContext ¶
func GetRandomRegionContext(t testing.TestingT, ctx context.Context, projectID string, approvedRegions []string, forbiddenRegions []string) string
GetRandomRegionContext 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. This will fail the test if there is an error. The ctx parameter supports cancellation and timeouts.
func GetRandomRegionContextE ¶
func GetRandomRegionContextE(t testing.TestingT, ctx context.Context, projectID string, approvedRegions []string, forbiddenRegions []string) (string, error)
GetRandomRegionContextE 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. The ctx parameter supports cancellation and timeouts.
func GetRandomZoneContext ¶
func GetRandomZoneContext(t testing.TestingT, ctx context.Context, projectID string, approvedZones []string, forbiddenZones []string, forbiddenRegions []string) string
GetRandomZoneContext gets a randomly chosen GCP Zone. If approvedZones 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 Zone is not in the forbiddenZones list. This will fail the test if there is an error. The ctx parameter supports cancellation and timeouts.
func GetRandomZoneContextE ¶
func GetRandomZoneContextE(t testing.TestingT, ctx context.Context, projectID string, approvedZones []string, forbiddenZones []string, forbiddenRegions []string) (string, error)
GetRandomZoneContextE gets a randomly chosen GCP Zone. If approvedZones 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 Zone is not in the forbiddenZones list. The ctx parameter supports cancellation and timeouts.
func GetRandomZoneForRegionContext ¶
func GetRandomZoneForRegionContext(t testing.TestingT, ctx context.Context, projectID string, region string) string
GetRandomZoneForRegionContext gets a randomly chosen GCP Zone in the given Region. This will fail the test if there is an error. The ctx parameter supports cancellation and timeouts.
func GetRandomZoneForRegionContextE ¶
func GetRandomZoneForRegionContextE(t testing.TestingT, ctx context.Context, projectID string, region string) (string, error)
GetRandomZoneForRegionContextE gets a randomly chosen GCP Zone in the given Region. The ctx parameter supports cancellation and timeouts.
func ImportProjectSSHKeyContext ¶
func ImportProjectSSHKeyContext(t testing.TestingT, ctx context.Context, user, key, projectID string)
ImportProjectSSHKeyContext will import an SSH key to GCP under the provided user identity. The user parameter should be the email address of the user. The key parameter should be the public key of the SSH key being uploaded. The projectID parameter should be the chosen project ID. This will fail the test if there is an error. The ctx parameter supports cancellation and timeouts.
func ImportProjectSSHKeyContextE ¶
func ImportProjectSSHKeyContextE(t testing.TestingT, ctx context.Context, user, key, projectID string) error
ImportProjectSSHKeyContextE will import an SSH key to GCP under the provided user identity. The user parameter should be the email address of the user. The key parameter should be the public key of the SSH key being uploaded. The projectID parameter should be the chosen project ID. The ctx parameter supports cancellation and timeouts.
func ImportProjectSSHKeyWithClient ¶
func ImportProjectSSHKeyWithClient(ctx context.Context, service *oslogin.Service, user, key, projectID string) error
ImportProjectSSHKeyWithClient imports an SSH key to GCP under the provided user identity, scoped to projectID, using the supplied *oslogin.Service. The ctx parameter supports cancellation and timeouts.
func ImportSSHKeyContext ¶
ImportSSHKeyContext will import an SSH key to GCP under the provided user identity. The user parameter should be the email address of the user. The key parameter should be the public key of the SSH key being uploaded. This will fail the test if there is an error. The ctx parameter supports cancellation and timeouts.
func ImportSSHKeyContextE ¶
ImportSSHKeyContextE will import an SSH key to GCP under the provided user identity. The user parameter should be the email address of the user. The key parameter should be the public key of the SSH key being uploaded. The ctx parameter supports cancellation and timeouts.
func ImportSSHKeyWithClient ¶
ImportSSHKeyWithClient imports an SSH key to GCP under the provided user identity using the supplied *oslogin.Service. Prefer this variant in unit tests where the service is backed by an httptest fake server (see oslogin_unit_test.go for the pattern). The ctx parameter supports cancellation and timeouts.
func NewCloudBuildServiceContext ¶
NewCloudBuildServiceContext creates a new Cloud Build service, which is used to make Cloud Build API calls. This will fail the test if there is an error. The ctx parameter supports cancellation and timeouts.
func NewCloudBuildServiceContextE ¶
func NewCloudBuildServiceContextE(t testing.TestingT, ctx context.Context) (*cloudbuild.Client, error)
NewCloudBuildServiceContextE creates a new Cloud Build service, which is used to make Cloud Build API calls. The ctx parameter supports cancellation and timeouts.
func NewComputeServiceContext ¶
NewComputeServiceContext creates a new Compute service, which is used to make GCE API calls. This will fail the test if there is an error. The ctx parameter supports cancellation and timeouts.
func NewComputeServiceContextE ¶
NewComputeServiceContextE creates a new Compute service, which is used to make GCE API calls. The ctx parameter supports cancellation and timeouts.
func NewInstancesServiceContext ¶
NewInstancesServiceContext creates a new InstancesService, which is used to make a subset of GCE API calls. This will fail the test if there is an error. The ctx parameter supports cancellation and timeouts.
func NewInstancesServiceContextE ¶
func NewInstancesServiceContextE(t testing.TestingT, ctx context.Context) (*compute.InstancesService, error)
NewInstancesServiceContextE creates a new InstancesService, which is used to make a subset of GCE API calls. The ctx parameter supports cancellation and timeouts.
func NewMetadata ¶
NewMetadata merges new key-value pairs into existing metadata, preserving unmodified items.
func NewOSLoginServiceContextE ¶
NewOSLoginServiceContextE creates a new OS Login service, which is used to make OS Login API calls. The ctx parameter supports cancellation and timeouts.
func RandomValidGCPName ¶
func RandomValidGCPName() string
RandomValidGCPName returns a random, valid name for GCP resources. Many resources in GCP require lowercase letters only.
func ReadBucketObjectContext ¶
func ReadBucketObjectContext(t testing.TestingT, ctx context.Context, bucketName string, filePath string) io.Reader
ReadBucketObjectContext reads an object from the given Storage Bucket and returns its contents. This will fail the test if there is an error. The ctx parameter supports cancellation and timeouts.
func ReadBucketObjectContextE ¶
func ReadBucketObjectContextE(t testing.TestingT, ctx context.Context, bucketName string, filePath string) (io.Reader, error)
ReadBucketObjectContextE reads an object from the given Storage Bucket and returns its contents. The ctx parameter supports cancellation and timeouts.
func ReadBucketObjectWithClient ¶
func ReadBucketObjectWithClient(ctx context.Context, client *storage.Client, bucketName string, filePath string) (io.Reader, error)
ReadBucketObjectWithClient reads an object from the given Storage Bucket and returns its contents using the supplied *storage.Client. Prefer this variant in unit tests where the client is backed by an httptest fake server (see storage_unit_test.go for the pattern). The ctx parameter supports cancellation and timeouts.
func RegionURLToRegion ¶
RegionURLToRegion extracts the region name from a GCP Region URL formatted like https://www.googleapis.com/compute/v1/projects/project-123456/regions/southamerica-east1 and returns "southamerica-east1".
func WriteBucketObjectContext ¶
func WriteBucketObjectContext(t testing.TestingT, ctx context.Context, bucketName string, filePath string, body io.Reader, contentType string) string
WriteBucketObjectContext writes an object to the given Storage Bucket and returns its URL. This will fail the test if there is an error. The ctx parameter supports cancellation and timeouts.
func WriteBucketObjectContextE ¶
func WriteBucketObjectContextE(t testing.TestingT, ctx context.Context, bucketName string, filePath string, body io.Reader, contentType string) (string, error)
WriteBucketObjectContextE writes an object to the given Storage Bucket and returns its URL. The ctx parameter supports cancellation and timeouts.
func WriteBucketObjectWithClient ¶
func WriteBucketObjectWithClient(ctx context.Context, client *storage.Client, bucketName string, filePath string, body io.Reader, contentType string) (string, error)
WriteBucketObjectWithClient writes an object to the given Storage Bucket and returns its URL using the supplied *storage.Client. Prefer this variant in unit tests where the client is backed by an httptest fake server (see storage_unit_test.go for the pattern). The ctx parameter supports cancellation and timeouts.
func ZoneURLToZone ¶
ZoneURLToZone extracts the zone name from a GCP Zone URL formatted like https://www.googleapis.com/compute/v1/projects/project-123456/zones/asia-east1-b and returns "asia-east1-b".
Types ¶
type GCRClient ¶
type GCRClient struct {
Authenticator authn.Authenticator
Transport http.RoundTripper
}
GCRClient bundles the credentials and transport the go-containerregistry library needs. It exists so that GCR helpers can follow terratest's (ctx, client, ...args) WithClient convention instead of exposing the two pieces separately. Transport is optional — nil uses the library default.
type Image ¶
Image represents a GCP Image (https://cloud.google.com/compute/docs/images).
func FetchImageContext ¶
func FetchImageContext(t testing.TestingT, ctx context.Context, projectID string, name string) *Image
FetchImageContext queries GCP to return a new instance of the Compute Image type. This will fail the test if there is an error. The ctx parameter supports cancellation and timeouts.
func FetchImageContextE ¶
func FetchImageContextE(t testing.TestingT, ctx context.Context, projectID string, name string) (*Image, error)
FetchImageContextE queries GCP to return a new instance of the Compute Image type. The ctx parameter supports cancellation and timeouts.
func FetchImageWithClient ¶
func FetchImageWithClient(ctx context.Context, service *compute.Service, projectID string, name string) (*Image, error)
FetchImageWithClient queries GCP to return a new instance of the Compute Image type using the supplied *compute.Service. Prefer this variant in unit tests where the service is backed by an httptest fake server (see compute_unit_test.go for the pattern). The ctx parameter supports cancellation and timeouts.
func (*Image) DeleteImageContext ¶
DeleteImageContext deletes the given Compute Image. This will fail the test if there is an error. The ctx parameter supports cancellation and timeouts.
func (*Image) DeleteImageContextE ¶
DeleteImageContextE deletes the given Compute Image. The ctx parameter supports cancellation and timeouts.
func (*Image) DeleteImageWithClient ¶
DeleteImageWithClient deletes the given Compute Image using the supplied *compute.Service. Prefer this variant in unit tests where the service is backed by an httptest fake server (see compute_unit_test.go for the pattern). The ctx parameter supports cancellation and timeouts.
type Instance ¶
Instance represents a GCP Compute Instance (https://cloud.google.com/compute/docs/instances/).
func FetchInstanceContext ¶
func FetchInstanceContext(t testing.TestingT, ctx context.Context, projectID string, name string) *Instance
FetchInstanceContext queries GCP to return an instance of the Compute Instance type. This will fail the test if there is an error. The ctx parameter supports cancellation and timeouts.
func FetchInstanceContextE ¶
func FetchInstanceContextE(t testing.TestingT, ctx context.Context, projectID string, name string) (*Instance, error)
FetchInstanceContextE queries GCP to return an instance of the Compute Instance type. The ctx parameter supports cancellation and timeouts.
func FetchInstanceWithClient ¶
func FetchInstanceWithClient(ctx context.Context, service *compute.Service, projectID string, name string) (*Instance, error)
FetchInstanceWithClient queries GCP to return an instance of the Compute Instance type using the supplied *compute.Service. Prefer this variant in unit tests where the service is backed by an httptest fake server (see compute_unit_test.go for the pattern). The ctx parameter supports cancellation and timeouts.
func (*Instance) AddSSHKeyContext ¶
func (i *Instance) AddSSHKeyContext(t testing.TestingT, ctx context.Context, username string, publicKey string)
AddSSHKeyContext adds the given public SSH key to the Compute Instance. Users can SSH in with the given username. This will fail the test if there is an error. The ctx parameter supports cancellation and timeouts.
func (*Instance) AddSSHKeyContextE ¶
func (i *Instance) AddSSHKeyContextE(t testing.TestingT, ctx context.Context, username string, publicKey string) error
AddSSHKeyContextE adds the given public SSH key to the Compute Instance. Users can SSH in with the given username. The ctx parameter supports cancellation and timeouts.
func (*Instance) AddSSHKeyWithClient ¶
func (i *Instance) AddSSHKeyWithClient(ctx context.Context, service *compute.Service, username string, publicKey string) error
AddSSHKeyWithClient adds the given public SSH key to the Compute Instance using the supplied *compute.Service. Users can SSH in with the given username. Prefer this variant in unit tests where the service is backed by an httptest fake server (see compute_unit_test.go for the pattern). The ctx parameter supports cancellation and timeouts.
func (*Instance) GetLabelsContext ¶
GetLabelsContext returns all the tags for the given Compute Instance. The ctx parameter supports cancellation and timeouts.
func (*Instance) GetLabelsContextE ¶
func (i *Instance) GetLabelsContextE(t testing.TestingT, ctx context.Context) (map[string]string, error)
GetLabelsContextE returns all the tags for the given Compute Instance. The ctx parameter supports cancellation and timeouts.
func (*Instance) GetMetadataContext ¶
func (i *Instance) GetMetadataContext(t testing.TestingT, ctx context.Context) []*compute.MetadataItems
GetMetadataContext gets the given Compute Instance's metadata. The ctx parameter supports cancellation and timeouts.
func (*Instance) GetMetadataContextE ¶
func (i *Instance) GetMetadataContextE(t testing.TestingT, ctx context.Context) ([]*compute.MetadataItems, error)
GetMetadataContextE gets the given Compute Instance's metadata. The ctx parameter supports cancellation and timeouts.
func (*Instance) GetPublicIPContext ¶
GetPublicIPContext gets the public IP address of the given Compute Instance. This will fail the test if there is an error. The ctx parameter supports cancellation and timeouts.
func (*Instance) GetPublicIPContextE ¶
GetPublicIPContextE gets the public IP address of the given Compute Instance. The ctx parameter supports cancellation and timeouts. Returns an error (rather than panicking) when the instance has no network interfaces or the first interface has no accessConfigs — both indicate the instance has no external internet access (https://cloud.google.com/compute/docs/reference/rest/v1/instances).
func (*Instance) GetZoneContext ¶
GetZoneContext returns the Zone in which the Compute Instance is located. The ctx parameter supports cancellation and timeouts.
func (*Instance) GetZoneContextE ¶
GetZoneContextE returns the Zone in which the Compute Instance is located. The ctx parameter supports cancellation and timeouts.
func (*Instance) SetLabelsContext ¶
func (i *Instance) SetLabelsContext(t testing.TestingT, ctx context.Context, labels map[string]string)
SetLabelsContext adds the tags to the given Compute Instance. This will fail the test if there is an error. The ctx parameter supports cancellation and timeouts.
func (*Instance) SetLabelsContextE ¶
func (i *Instance) SetLabelsContextE(t testing.TestingT, ctx context.Context, labels map[string]string) error
SetLabelsContextE adds the tags to the given Compute Instance. The ctx parameter supports cancellation and timeouts.
func (*Instance) SetLabelsWithClient ¶
func (i *Instance) SetLabelsWithClient(ctx context.Context, service *compute.Service, labels map[string]string) error
SetLabelsWithClient merges the given labels into the instance's existing labels using the supplied *compute.Service. Keys present in labels overwrite existing values; other labels are preserved. Prefer this variant in unit tests where the service is backed by an httptest fake server (see compute_unit_test.go for the pattern). The ctx parameter supports cancellation and timeouts.
func (*Instance) SetMetadataContext ¶
func (i *Instance) SetMetadataContext(t testing.TestingT, ctx context.Context, metadata map[string]string)
SetMetadataContext sets the given Compute Instance's metadata. This will fail the test if there is an error. The ctx parameter supports cancellation and timeouts.
func (*Instance) SetMetadataContextE ¶
func (i *Instance) SetMetadataContextE(t testing.TestingT, ctx context.Context, metadata map[string]string) error
SetMetadataContextE adds the given metadata map to the existing metadata of the given Compute Instance. The ctx parameter supports cancellation and timeouts.
func (*Instance) SetMetadataWithClient ¶
func (i *Instance) SetMetadataWithClient(ctx context.Context, service *compute.Service, metadata map[string]string) error
SetMetadataWithClient adds the given metadata map to the existing metadata of the given Compute Instance using the supplied *compute.Service. Prefer this variant in unit tests where the service is backed by an httptest fake server (see compute_unit_test.go for the pattern). The ctx parameter supports cancellation and timeouts.
type InstanceGroup ¶
type InstanceGroup interface {
// GetInstanceIDsContextE gets the IDs of Instances in the given Instance Group.
// The ctx parameter supports cancellation and timeouts.
GetInstanceIDsContextE(t testing.TestingT, ctx context.Context) ([]string, error)
}
InstanceGroup is an interface for instance groups that can return their instance IDs.
type RegionalInstanceGroup ¶
type RegionalInstanceGroup struct {
*compute.InstanceGroup
// contains filtered or unexported fields
}
RegionalInstanceGroup represents a GCP Regional Instance Group (https://cloud.google.com/compute/docs/instance-groups/).
func FetchRegionalInstanceGroupContext ¶
func FetchRegionalInstanceGroupContext(t testing.TestingT, ctx context.Context, projectID string, region string, name string) *RegionalInstanceGroup
FetchRegionalInstanceGroupContext queries GCP to return a new instance of the Regional Instance Group type. This will fail the test if there is an error. The ctx parameter supports cancellation and timeouts.
func FetchRegionalInstanceGroupContextE ¶
func FetchRegionalInstanceGroupContextE(t testing.TestingT, ctx context.Context, projectID string, region string, name string) (*RegionalInstanceGroup, error)
FetchRegionalInstanceGroupContextE queries GCP to return a new instance of the Regional Instance Group type. The ctx parameter supports cancellation and timeouts.
func FetchRegionalInstanceGroupWithClient ¶
func FetchRegionalInstanceGroupWithClient(ctx context.Context, service *compute.Service, projectID string, region string, name string) (*RegionalInstanceGroup, error)
FetchRegionalInstanceGroupWithClient queries GCP to return a new instance of the Regional Instance Group type using the supplied *compute.Service. Prefer this variant in unit tests where the service is backed by an httptest fake server (see compute_unit_test.go for the pattern). The ctx parameter supports cancellation and timeouts.
func (*RegionalInstanceGroup) GetInstanceIDsContext ¶
func (ig *RegionalInstanceGroup) GetInstanceIDsContext(t testing.TestingT, ctx context.Context) []string
GetInstanceIDsContext gets the IDs of Instances in the given Regional Instance Group. This will fail the test if there is an error. The ctx parameter supports cancellation and timeouts.
func (*RegionalInstanceGroup) GetInstanceIDsContextE ¶
func (ig *RegionalInstanceGroup) GetInstanceIDsContextE(t testing.TestingT, ctx context.Context) ([]string, error)
GetInstanceIDsContextE gets the IDs of Instances in the given Regional Instance Group. The ctx parameter supports cancellation and timeouts.
func (*RegionalInstanceGroup) GetInstanceIDsWithClient ¶
func (ig *RegionalInstanceGroup) GetInstanceIDsWithClient(ctx context.Context, service *compute.Service) ([]string, error)
GetInstanceIDsWithClient gets the IDs of Instances in the given Regional Instance Group using the supplied *compute.Service. Prefer this variant in unit tests where the service is backed by an httptest fake server (see compute_unit_test.go for the pattern). The ctx parameter supports cancellation and timeouts.
func (*RegionalInstanceGroup) GetInstancesContext ¶
func (ig *RegionalInstanceGroup) GetInstancesContext(t testing.TestingT, ctx context.Context, projectID string) []*Instance
GetInstancesContext returns a collection of Instance structs from the given Regional Instance Group. This will fail the test if there is an error. The ctx parameter supports cancellation and timeouts.
func (*RegionalInstanceGroup) GetInstancesContextE ¶
func (ig *RegionalInstanceGroup) GetInstancesContextE(t testing.TestingT, ctx context.Context, projectID string) ([]*Instance, error)
GetInstancesContextE returns a collection of Instance structs from the given Regional Instance Group. The ctx parameter supports cancellation and timeouts.
func (*RegionalInstanceGroup) GetPublicIPsContext ¶
func (ig *RegionalInstanceGroup) GetPublicIPsContext(t testing.TestingT, ctx context.Context, projectID string) []string
GetPublicIPsContext returns a slice of the public IPs from the given Regional Instance Group. This will fail the test if there is an error. The ctx parameter supports cancellation and timeouts.
func (*RegionalInstanceGroup) GetPublicIPsContextE ¶
func (ig *RegionalInstanceGroup) GetPublicIPsContextE(t testing.TestingT, ctx context.Context, projectID string) ([]string, error)
GetPublicIPsContextE returns a slice of the public IPs from the given Regional Instance Group. The ctx parameter supports cancellation and timeouts.
func (*RegionalInstanceGroup) GetRandomInstanceContext ¶
func (ig *RegionalInstanceGroup) GetRandomInstanceContext(t testing.TestingT, ctx context.Context) *Instance
GetRandomInstanceContext returns a randomly selected Instance from the Regional Instance Group. This will fail the test if there is an error. The ctx parameter supports cancellation and timeouts.
func (*RegionalInstanceGroup) GetRandomInstanceContextE ¶
func (ig *RegionalInstanceGroup) GetRandomInstanceContextE(t testing.TestingT, ctx context.Context) (*Instance, error)
GetRandomInstanceContextE returns a randomly selected Instance from the Regional Instance Group. The ctx parameter supports cancellation and timeouts.
type ZonalInstanceGroup ¶
type ZonalInstanceGroup struct {
*compute.InstanceGroup
// contains filtered or unexported fields
}
ZonalInstanceGroup represents a GCP Zonal Instance Group (https://cloud.google.com/compute/docs/instance-groups/).
func FetchZonalInstanceGroupContext ¶
func FetchZonalInstanceGroupContext(t testing.TestingT, ctx context.Context, projectID string, zone string, name string) *ZonalInstanceGroup
FetchZonalInstanceGroupContext queries GCP to return a new instance of the Zonal Instance Group type. This will fail the test if there is an error. The ctx parameter supports cancellation and timeouts.
func FetchZonalInstanceGroupContextE ¶
func FetchZonalInstanceGroupContextE(t testing.TestingT, ctx context.Context, projectID string, zone string, name string) (*ZonalInstanceGroup, error)
FetchZonalInstanceGroupContextE queries GCP to return a new instance of the Zonal Instance Group type. The ctx parameter supports cancellation and timeouts.
func FetchZonalInstanceGroupWithClient ¶
func FetchZonalInstanceGroupWithClient(ctx context.Context, service *compute.Service, projectID string, zone string, name string) (*ZonalInstanceGroup, error)
FetchZonalInstanceGroupWithClient queries GCP to return a new instance of the Zonal Instance Group type using the supplied *compute.Service. Prefer this variant in unit tests where the service is backed by an httptest fake server (see compute_unit_test.go for the pattern). The ctx parameter supports cancellation and timeouts.
func (*ZonalInstanceGroup) GetInstanceIDsContext ¶
func (ig *ZonalInstanceGroup) GetInstanceIDsContext(t testing.TestingT, ctx context.Context) []string
GetInstanceIDsContext gets the IDs of Instances in the given Zonal Instance Group. This will fail the test if there is an error. The ctx parameter supports cancellation and timeouts.
func (*ZonalInstanceGroup) GetInstanceIDsContextE ¶
func (ig *ZonalInstanceGroup) GetInstanceIDsContextE(t testing.TestingT, ctx context.Context) ([]string, error)
GetInstanceIDsContextE gets the IDs of Instances in the given Zonal Instance Group. The ctx parameter supports cancellation and timeouts.
func (*ZonalInstanceGroup) GetInstanceIDsWithClient ¶
func (ig *ZonalInstanceGroup) GetInstanceIDsWithClient(ctx context.Context, service *compute.Service) ([]string, error)
GetInstanceIDsWithClient gets the IDs of Instances in the given Zonal Instance Group using the supplied *compute.Service. Prefer this variant in unit tests where the service is backed by an httptest fake server (see compute_unit_test.go for the pattern). The ctx parameter supports cancellation and timeouts.
func (*ZonalInstanceGroup) GetInstancesContext ¶
func (ig *ZonalInstanceGroup) GetInstancesContext(t testing.TestingT, ctx context.Context, projectID string) []*Instance
GetInstancesContext returns a collection of Instance structs from the given Zonal Instance Group. This will fail the test if there is an error. The ctx parameter supports cancellation and timeouts.
func (*ZonalInstanceGroup) GetInstancesContextE ¶
func (ig *ZonalInstanceGroup) GetInstancesContextE(t testing.TestingT, ctx context.Context, projectID string) ([]*Instance, error)
GetInstancesContextE returns a collection of Instance structs from the given Zonal Instance Group. The ctx parameter supports cancellation and timeouts.
func (*ZonalInstanceGroup) GetPublicIPsContext ¶
func (ig *ZonalInstanceGroup) GetPublicIPsContext(t testing.TestingT, ctx context.Context, projectID string) []string
GetPublicIPsContext returns a slice of the public IPs from the given Zonal Instance Group. This will fail the test if there is an error. The ctx parameter supports cancellation and timeouts.
func (*ZonalInstanceGroup) GetPublicIPsContextE ¶
func (ig *ZonalInstanceGroup) GetPublicIPsContextE(t testing.TestingT, ctx context.Context, projectID string) ([]string, error)
GetPublicIPsContextE returns a slice of the public IPs from the given Zonal Instance Group. The ctx parameter supports cancellation and timeouts.
func (*ZonalInstanceGroup) GetRandomInstanceContext ¶
func (ig *ZonalInstanceGroup) GetRandomInstanceContext(t testing.TestingT, ctx context.Context) *Instance
GetRandomInstanceContext returns a randomly selected Instance from the Zonal Instance Group. This will fail the test if there is an error. The ctx parameter supports cancellation and timeouts.
func (*ZonalInstanceGroup) GetRandomInstanceContextE ¶
func (ig *ZonalInstanceGroup) GetRandomInstanceContextE(t testing.TestingT, ctx context.Context) (*Instance, error)
GetRandomInstanceContextE returns a randomly selected Instance from the Zonal Instance Group. The ctx parameter supports cancellation and timeouts.