Documentation ¶
Overview ¶
Package stubs provides testable stubs for clients.
Index ¶
- Variables
- type BigQueryStub
- type CloudSQL
- func (s *CloudSQL) InstanceDetails(ctx context.Context, projectID string, instance string) (*sql.DatabaseInstance, error)
- func (s *CloudSQL) PatchInstance(ctx context.Context, projectID, instance string, ...) (*sql.Operation, error)
- func (s *CloudSQL) UpdateUser(ctx context.Context, projectID, instance, host, name string, user *sql.User) (*sql.Operation, error)
- func (s *CloudSQL) WaitSQL(project string, op *sql.Operation) []error
- type ComputeStub
- func (c *ComputeStub) CreateSnapshot(ctx context.Context, _, _, disk string, snapshot *compute.Snapshot) (*compute.Operation, error)
- func (c *ComputeStub) DeleteAccessConfig(ctx context.Context, ...) (*compute.Operation, error)
- func (c *ComputeStub) DeleteDiskSnapshot(_ context.Context, _, _ string) (*compute.Operation, error)
- func (c *ComputeStub) DeleteFirewallRule(ctx context.Context, projectID string, rule string) (*compute.Operation, error)
- func (c *ComputeStub) DeleteInstance(ctx context.Context, projectID, zone, instance string) (*compute.Operation, error)
- func (c *ComputeStub) DiskInsert(ctx context.Context, projectID, zone string, disk *compute.Disk) (*compute.Operation, error)
- func (c *ComputeStub) FirewallRule(ctx context.Context, projectID string, ruleID string) (*compute.Firewall, error)
- func (c *ComputeStub) GetInstance(ctx context.Context, project, zone, instance string) (*compute.Instance, error)
- func (c *ComputeStub) InsertFirewallRule(ctx context.Context, projectID string, fw *compute.Firewall) (*compute.Operation, error)
- func (c *ComputeStub) ListDisks(ctx context.Context, _, _ string) (*compute.DiskList, error)
- func (c *ComputeStub) ListProjectSnapshots(context.Context, string) (*compute.SnapshotList, error)
- func (c *ComputeStub) PatchFirewallRule(ctx context.Context, projectID string, rule string, rb *compute.Firewall) (*compute.Operation, error)
- func (c *ComputeStub) SetLabels(context.Context, string, string, *compute.GlobalSetLabelsRequest) (*compute.Operation, error)
- func (c *ComputeStub) StartInstance(ctx context.Context, projectID, zone, instance string) (*compute.Operation, error)
- func (c *ComputeStub) StopInstance(ctx context.Context, projectID, zone, instance string) (*compute.Operation, error)
- func (c *ComputeStub) WaitGlobal(_ string, _ *compute.Operation) []error
- func (c *ComputeStub) WaitZone(_, _ string, _ *compute.Operation) []error
- type ContainerStub
- type LoggerStub
- type NetworkAccessConfigStub
- type PubSubStub
- type ResourceManagerStub
- func (s *ResourceManagerStub) GetAncestry(context.Context, string) (*crm.GetAncestryResponse, error)
- func (s *ResourceManagerStub) GetOrganization(ctx context.Context, organizationID string) (*crm.Organization, error)
- func (s *ResourceManagerStub) GetPolicyOrganization(ctx context.Context, organizationID string) (*crm.Policy, error)
- func (s *ResourceManagerStub) GetPolicyProject(ctx context.Context, projectID string) (*crm.Policy, error)
- func (s *ResourceManagerStub) SetPolicyOrganization(ctx context.Context, organizationID string, p *crm.Policy) (*crm.Policy, error)
- func (s *ResourceManagerStub) SetPolicyProject(ctx context.Context, projectID string, p *crm.Policy) (*crm.Policy, error)
- func (s *ResourceManagerStub) SetPolicyProjectWithMask(ctx context.Context, projectID string, p *crm.Policy, fields ...string) (*crm.Policy, error)
- type SecurityCommandCenterStub
- type SendGridStub
- type StorageStub
Constants ¶
This section is empty.
Variables ¶
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.
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.
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) 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 ¶
func (c *ComputeStub) SetLabels(context.Context, string, string, *compute.GlobalSetLabelsRequest) (*compute.Operation, error)
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.
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 ¶
NetworkAccessConfigStub tracks deleted AccessConfig's per NetworkInterface.
type PubSubStub ¶
PubSubStub provides a stub for the PubSub client.
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 ¶
func (s *ResourceManagerStub) GetAncestry(context.Context, string) (*crm.GetAncestryResponse, error)
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.
type SecurityCommandCenterStub ¶
type SecurityCommandCenterStub struct {
GetUpdateSecurityMarksRequest *sccpb.UpdateSecurityMarksRequest
}
SecurityCommandCenterStub provides a stub for the Security Command center client.
func (*SecurityCommandCenterStub) AddSecurityMarks ¶
func (s *SecurityCommandCenterStub) AddSecurityMarks(ctx context.Context, request *sccpb.UpdateSecurityMarksRequest) (*sccpb.SecurityMarks, error)
AddSecurityMarks adds Security Marks to a finding or asset.
type SendGridStub ¶
SendGridStub provides a stub for the Email client.
type StorageStub ¶
type StorageStub struct { BucketPolicyResponse *iam.Policy RemoveBucketPolicy *iam.Policy EnabledPolicyOnBucket string }
StorageStub provides a stub for the Storage client.
func (*StorageStub) BucketPolicy ¶
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 ¶
SetBucketPolicy set a policy for the given bucket.