stubs

package
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 13, 2019 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package stubs provides testable stubs for clients.

Index

Constants

This section is empty.

Variables

View Source
var ErrEntityNonExistent = fmt.Errorf("rpc error: code = NotFound desc = Requested entity was not found")

ErrEntityNonExistent is an error throw if the entity was not found.

View Source
var ErrNonexistentVM = fmt.Errorf("googleapi: Error 404: The resource 'projects/test/zones/us-central1-a/instances/nonexistent' was not found, notFound")

ErrNonexistentVM is a stub error returned simulating an error in case of VM not found.

Functions

This section is empty.

Types

type BigQueryStub

type BigQueryStub struct {
	StubbedMetadata      *bigquery.DatasetMetadata
	SavedDatasetMetadata *bigquery.DatasetMetadataToUpdate
}

BigQueryStub provides a stub for the BigQuery client.

func (*BigQueryStub) DatasetMetadata

func (s *BigQueryStub) DatasetMetadata(ctx context.Context, projectID, datasetID string) (*bigquery.DatasetMetadata, error)

DatasetMetadata fetches the metadata for the dataset.

func (*BigQueryStub) OverwriteDatasetMetadata

func (s *BigQueryStub) OverwriteDatasetMetadata(ctx context.Context, projectID, datasetID string, dm bigquery.DatasetMetadataToUpdate) (*bigquery.DatasetMetadata, error)

OverwriteDatasetMetadata modifies specific Dataset metadata fields.

type CloudSQL

type CloudSQL struct {
	SavedInstanceUpdated    *sql.DatabaseInstance
	InstanceDetailsResponse *sql.DatabaseInstance
	UpdatedUser             *sql.User
}

CloudSQL provides a stub for the SQL Admin client.

func (*CloudSQL) InstanceDetails

func (s *CloudSQL) InstanceDetails(ctx context.Context, projectID string, instance string) (*sql.DatabaseInstance, error)

InstanceDetails gets detail from a instance in a project.

func (*CloudSQL) PatchInstance

func (s *CloudSQL) PatchInstance(ctx context.Context, projectID, instance string, databaseInstance *sql.DatabaseInstance) (*sql.Operation, error)

PatchInstance updates partialy a cloud sql instance.

func (*CloudSQL) UpdateUser

func (s *CloudSQL) UpdateUser(ctx context.Context, projectID, instance, host, name string, user *sql.User) (*sql.Operation, error)

UpdateUser updates a given user.

func (*CloudSQL) WaitSQL

func (s *CloudSQL) WaitSQL(project string, op *sql.Operation) []error

WaitSQL waits globally.

type ComputeStub

type ComputeStub struct {
	SavedFirewallRule            *compute.Firewall
	SavedCreateSnapshots         map[string]compute.Snapshot
	DeletedAccessConfigs         []NetworkAccessConfigStub
	DeleteAccessConfigShouldFail bool
	GetInstanceShouldFail        bool
	StubbedListProjectSnapshots  []*compute.SnapshotList
	StubbedListDisks             *compute.DiskList
	StubbedFirewall              *compute.Firewall
	StubbedStopInstance          *compute.Operation
	StubbedStartInstance         *compute.Operation
	StubbedInstance              *compute.Instance
	SavedDiskInsertDst           string
	DiskInsertCalled             bool
}

ComputeStub provides a stub for the compute client.

func (*ComputeStub) CreateSnapshot

func (c *ComputeStub) CreateSnapshot(ctx context.Context, _, _, disk string, snapshot *compute.Snapshot) (*compute.Operation, error)

CreateSnapshot creates a snapshot of a specified persistent disk.

func (*ComputeStub) DeleteAccessConfig

func (c *ComputeStub) DeleteAccessConfig(ctx context.Context, project, zone, instance, accessConfig, networkInterface string) (*compute.Operation, error)

DeleteAccessConfig deletes an access config from an instance's network interface.

func (*ComputeStub) DeleteDiskSnapshot

func (c *ComputeStub) DeleteDiskSnapshot(_ context.Context, _, _ string) (*compute.Operation, error)

DeleteDiskSnapshot deletes a snapshot.

func (*ComputeStub) DeleteFirewallRule

func (c *ComputeStub) DeleteFirewallRule(ctx context.Context, projectID string, rule string) (*compute.Operation, error)

DeleteFirewallRule deletes the firewall rule for the given project.

func (*ComputeStub) DeleteInstance

func (c *ComputeStub) DeleteInstance(ctx context.Context, projectID, zone, instance string) (*compute.Operation, error)

DeleteInstance starts a given instance in given zone.

func (*ComputeStub) DiskInsert

func (c *ComputeStub) DiskInsert(ctx context.Context, projectID, zone string, disk *compute.Disk) (*compute.Operation, error)

DiskInsert creates a new disk in the project.

func (*ComputeStub) FirewallRule

func (c *ComputeStub) FirewallRule(ctx context.Context, projectID string, ruleID string) (*compute.Firewall, error)

FirewallRule get the details of a firewall rule

func (*ComputeStub) GetInstance

func (c *ComputeStub) GetInstance(ctx context.Context, project, zone, instance string) (*compute.Instance, error)

GetInstance returns the specified compute instance resource.

func (*ComputeStub) InsertFirewallRule

func (c *ComputeStub) InsertFirewallRule(ctx context.Context, projectID string, fw *compute.Firewall) (*compute.Operation, error)

InsertFirewallRule inserts a new firewall rule.

func (*ComputeStub) ListDisks

func (c *ComputeStub) ListDisks(ctx context.Context, _, _ string) (*compute.DiskList, error)

ListDisks returns a list of disks.

func (*ComputeStub) ListProjectSnapshots

func (c *ComputeStub) ListProjectSnapshots(context.Context, string) (*compute.SnapshotList, error)

ListProjectSnapshots returns a list of snapshot resources.

func (*ComputeStub) PatchFirewallRule

func (c *ComputeStub) PatchFirewallRule(ctx context.Context, projectID string, rule string, rb *compute.Firewall) (*compute.Operation, error)

PatchFirewallRule updates the firewall rule for the given project.

func (*ComputeStub) SetLabels

SetLabels sets the labels on a snapshot.

func (*ComputeStub) StartInstance

func (c *ComputeStub) StartInstance(ctx context.Context, projectID, zone, instance string) (*compute.Operation, error)

StartInstance starts a given instance in given zone.

func (*ComputeStub) StopInstance

func (c *ComputeStub) StopInstance(ctx context.Context, projectID, zone, instance string) (*compute.Operation, error)

StopInstance stops an instance.

func (*ComputeStub) WaitGlobal

func (c *ComputeStub) WaitGlobal(_ string, _ *compute.Operation) []error

WaitGlobal waits globally.

func (*ComputeStub) WaitZone

func (c *ComputeStub) WaitZone(_, _ string, _ *compute.Operation) []error

WaitZone zone waits at the zone level.

type ContainerStub

type ContainerStub struct {
	UpdatedAddonsConfig *container.SetAddonsConfigRequest
}

ContainerStub provides a stub for the Container client.

func (*ContainerStub) UpdateAddonsConfig

func (c *ContainerStub) UpdateAddonsConfig(ctx context.Context, projectID, zone, clusterID string, conf *container.SetAddonsConfigRequest) (*container.Operation, error)

UpdateAddonsConfig updates the addons configuration of a given cluster.

type LoggerStub

type LoggerStub struct {
}

LoggerStub provides a stub for the Logger client.

func (*LoggerStub) Close

func (l *LoggerStub) Close()

Close buffer and send messages to stackdriver.

func (*LoggerStub) Debug

func (l *LoggerStub) Debug(message string, a ...interface{})

Debug push debug log to buffer.

func (*LoggerStub) Error

func (l *LoggerStub) Error(message string, a ...interface{})

Error push error log to buffer.

func (*LoggerStub) Info

func (l *LoggerStub) Info(message string, a ...interface{})

Info push info log to buffer.

func (*LoggerStub) Warning

func (l *LoggerStub) Warning(message string, a ...interface{})

Warning push warning log to buffer.

type NetworkAccessConfigStub

type NetworkAccessConfigStub struct {
	NetworkInterfaceName string
	AccessConfigName     string
}

NetworkAccessConfigStub tracks deleted AccessConfig's per NetworkInterface.

type PubSubStub

type PubSubStub struct {
	StubbedTopic     *pubsub.Topic
	PublishedMessage *pubsub.Message
}

PubSubStub provides a stub for the PubSub client.

func (*PubSubStub) Publish

func (p *PubSubStub) Publish(ctx context.Context, topic *pubsub.Topic, message *pubsub.Message) (string, error)

Publish will publish a message to a PubSub topic.

func (*PubSubStub) Topic

func (p *PubSubStub) Topic(id string) *pubsub.Topic

Topic returns a reference to a topic.

type ResourceManagerStub

type ResourceManagerStub struct {
	GetPolicyResponse       *crm.Policy
	GetAncestryResponse     *crm.GetAncestryResponse
	SavedSetPolicy          *crm.Policy
	GetOrganizationResponse *crm.Organization
}

ResourceManagerStub provides a stub for the CRM client.

func (*ResourceManagerStub) GetAncestry

GetAncestry is a stub of Cloud Resource Manager's GetAncestry.

func (*ResourceManagerStub) GetOrganization

func (s *ResourceManagerStub) GetOrganization(ctx context.Context, organizationID string) (*crm.Organization, error)

GetOrganization is a stub of Cloud Resource Manager's GetOrganization.

func (*ResourceManagerStub) GetPolicyOrganization

func (s *ResourceManagerStub) GetPolicyOrganization(ctx context.Context, organizationID string) (*crm.Policy, error)

GetPolicyOrganization is a stub of Cloud Resource Manager's GetIamPolicy.

func (*ResourceManagerStub) GetPolicyProject

func (s *ResourceManagerStub) GetPolicyProject(ctx context.Context, projectID string) (*crm.Policy, error)

GetPolicyProject is a stub of Cloud Resource Manager's GetIamPolicy.

func (*ResourceManagerStub) SetPolicyOrganization

func (s *ResourceManagerStub) SetPolicyOrganization(ctx context.Context, organizationID string, p *crm.Policy) (*crm.Policy, error)

SetPolicyOrganization is a stub of Cloud Resource Manager's SetIamPolicy.

func (*ResourceManagerStub) SetPolicyProject

func (s *ResourceManagerStub) SetPolicyProject(ctx context.Context, projectID string, p *crm.Policy) (*crm.Policy, error)

SetPolicyProject is a stub of Cloud Resource Manager's SetIamPolicy.

func (*ResourceManagerStub) SetPolicyProjectWithMask

func (s *ResourceManagerStub) SetPolicyProjectWithMask(ctx context.Context, projectID string, p *crm.Policy, fields ...string) (*crm.Policy, error)

SetPolicyProjectWithMask is a stub of Cloud Resource Manager's SetIamPolicy.

type SecurityCommandCenterStub

type SecurityCommandCenterStub struct {
	GetUpdateSecurityMarksRequest *sccpb.UpdateSecurityMarksRequest
}

SecurityCommandCenterStub provides a stub for the Security Command center client.

func (*SecurityCommandCenterStub) AddSecurityMarks

AddSecurityMarks adds Security Marks to a finding or asset.

type SendGridStub

type SendGridStub struct {
	StubbedSend    *rest.Response
	StubbedSendErr error
}

SendGridStub provides a stub for the Email client.

func (*SendGridStub) Send

func (e *SendGridStub) Send(mail *mail.SGMailV3) (*rest.Response, error)

Send to send email

type StorageStub

type StorageStub struct {
	BucketPolicyResponse  *iam.Policy
	RemoveBucketPolicy    *iam.Policy
	EnabledPolicyOnBucket string
}

StorageStub provides a stub for the Storage client.

func (*StorageStub) BucketPolicy

func (s *StorageStub) BucketPolicy(ctx context.Context, bucketName string) (*iam.Policy, error)

BucketPolicy gets a bucket's policy.

func (*StorageStub) EnableBucketOnlyPolicy

func (s *StorageStub) EnableBucketOnlyPolicy(ctx context.Context, bucketName string) error

EnableBucketOnlyPolicy saves the bucket that receives the request for enabling bucket only policy.

func (*StorageStub) SetBucketPolicy

func (s *StorageStub) SetBucketPolicy(ctx context.Context, bucketName string, p *iam.Policy) error

SetBucketPolicy set a policy for the given bucket.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL