Documentation
¶
Index ¶
- Variables
- func NewTestBillingClient(t *testing.T, server billingpb.CloudCatalogServer) *billingv1.CloudCatalogClient
- func RegionsForProjects(gcpClient Client, projects []string, logger *slog.Logger) []string
- func RegionsFromZonesForProjects(gcpClient Client, projects []string, logger *slog.Logger) []string
- type Billing
- type Bucket
- type Client
- type Compute
- type Config
- type FakeCloudCatalogServer
- type FakeCloudCatalogServerSlimResults
- type FakeCloudCatalogServerWithSKUs
- type GCPClient
- func (c *GCPClient) ExportBucketInfo(ctx context.Context, projects []string, m *metrics.Metrics) error
- func (c *GCPClient) ExportGCPCostData(ctx context.Context, serviceName string, m *metrics.Metrics) float64
- func (c *GCPClient) ExportRegionalDiscounts(ctx context.Context, m *metrics.Metrics) error
- func (c *GCPClient) GetPricing(ctx context.Context, serviceName string) []*billingpb.Sku
- func (c *GCPClient) GetRegions(projectId string) ([]*computev1.Region, error)
- func (c *GCPClient) GetServiceName(ctx context.Context, serviceName string) (string, error)
- func (c *GCPClient) GetZones(projectId string) ([]*computev1.Zone, error)
- func (c *GCPClient) ListDisks(ctx context.Context, projectId string, zone string) ([]*computev1.Disk, error)
- func (c *GCPClient) ListForwardingRules(ctx context.Context, projectId string, region string) ([]*computev1.ForwardingRule, error)
- func (c *GCPClient) ListInstancesInZone(projectId, zone string) ([]*MachineSpec, error)
- func (c *GCPClient) ListManagedKafkaClusters(ctx context.Context, projectId string, location string) ([]*managedkafkapb.Cluster, error)
- func (c *GCPClient) ListManagedKafkaLocations(ctx context.Context, projectId string) ([]string, error)
- func (c *GCPClient) ListSQLInstances(ctx context.Context, projectId string) ([]*sqladmin.DatabaseInstance, error)
- type MachineSpec
- type ManagedKafka
- type ManagedKafkaClient
- type Mock
- func (c *Mock) ExportBucketInfo(ctx context.Context, projects []string, m *metrics.Metrics) error
- func (c *Mock) ExportGCPCostData(ctx context.Context, serviceName string, m *metrics.Metrics) float64
- func (c *Mock) ExportRegionalDiscounts(ctx context.Context, m *metrics.Metrics) error
- func (c *Mock) GetPricing(ctx context.Context, serviceName string) []*billingpb.Sku
- func (c *Mock) GetRegions(project string) ([]*compute.Region, error)
- func (c *Mock) GetServiceName(ctx context.Context, serviceName string) (string, error)
- func (c *Mock) GetZones(projectId string) ([]*compute.Zone, error)
- func (c *Mock) ListDisks(ctx context.Context, projectId string, zone string) ([]*compute.Disk, error)
- func (c *Mock) ListForwardingRules(ctx context.Context, project string, region string) ([]*compute.ForwardingRule, error)
- func (c *Mock) ListInstancesInZone(projectId, zone string) ([]*MachineSpec, error)
- func (c *Mock) ListManagedKafkaClusters(ctx context.Context, projectId string, location string) ([]*managedkafkapb.Cluster, error)
- func (c *Mock) ListManagedKafkaLocations(ctx context.Context, projectId string) ([]string, error)
- func (c *Mock) ListSQLInstances(ctx context.Context, projectId string) ([]*sqladmin.DatabaseInstance, error)
- type Region
- type RegionsClient
- type SQLAdmin
- type StorageClientInterface
Constants ¶
This section is empty.
Variables ¶
View Source
var ( GkeClusterLabel = "goog-k8s-cluster-name" GkeRegionLabel = "goog-k8s-cluster-location" )
View Source
var ErrListInstances = errors.New("no list price was found for the sku")
Functions ¶
func NewTestBillingClient ¶ added in v0.20.0
func NewTestBillingClient(t *testing.T, server billingpb.CloudCatalogServer) *billingv1.CloudCatalogClient
NewTestBillingClient creates a billing client connected to a test gRPC server. The server is registered with the provided fake server implementation and will be cleaned up when the test completes.
func RegionsForProjects ¶ added in v0.28.1
RegionsForProjects fetches and deduplicates regions across all given GCP projects.
Types ¶
type Client ¶
type Client interface {
GetServiceName(ctx context.Context, serviceName string) (string, error)
ExportRegionalDiscounts(ctx context.Context, m *metrics.Metrics) error
ExportGCPCostData(ctx context.Context, serviceName string, m *metrics.Metrics) float64
ExportBucketInfo(ctx context.Context, projects []string, m *metrics.Metrics) error
GetPricing(ctx context.Context, serviceName string) []*billingpb.Sku
GetZones(project string) ([]*compute.Zone, error)
GetRegions(project string) ([]*compute.Region, error)
ListInstancesInZone(projectId, zone string) ([]*MachineSpec, error)
ListDisks(ctx context.Context, project string, zone string) ([]*compute.Disk, error)
ListForwardingRules(ctx context.Context, project string, region string) ([]*compute.ForwardingRule, error)
ListSQLInstances(ctx context.Context, project string) ([]*sqladmin.DatabaseInstance, error)
ListManagedKafkaLocations(ctx context.Context, project string) ([]string, error)
ListManagedKafkaClusters(ctx context.Context, project string, location string) ([]*managedkafkapb.Cluster, error)
}
type FakeCloudCatalogServer ¶
type FakeCloudCatalogServer struct {
billingpb.UnimplementedCloudCatalogServer
}
func (*FakeCloudCatalogServer) ListServices ¶
func (s *FakeCloudCatalogServer) ListServices(_ context.Context, req *billingpb.ListServicesRequest) (*billingpb.ListServicesResponse, error)
func (*FakeCloudCatalogServer) ListSkus ¶
func (s *FakeCloudCatalogServer) ListSkus(_ context.Context, req *billingpb.ListSkusRequest) (*billingpb.ListSkusResponse, error)
type FakeCloudCatalogServerSlimResults ¶
type FakeCloudCatalogServerSlimResults struct {
billingpb.UnimplementedCloudCatalogServer
}
func (*FakeCloudCatalogServerSlimResults) ListServices ¶
func (s *FakeCloudCatalogServerSlimResults) ListServices(_ context.Context, req *billingpb.ListServicesRequest) (*billingpb.ListServicesResponse, error)
func (*FakeCloudCatalogServerSlimResults) ListSkus ¶
func (s *FakeCloudCatalogServerSlimResults) ListSkus(_ context.Context, req *billingpb.ListSkusRequest) (*billingpb.ListSkusResponse, error)
type FakeCloudCatalogServerWithSKUs ¶ added in v0.20.0
type FakeCloudCatalogServerWithSKUs struct {
billingpb.UnimplementedCloudCatalogServer
ServiceName string
ServiceID string
Skus []*billingpb.Sku
}
FakeCloudCatalogServerWithSKUs is a configurable fake billing server that allows customizing the service name and SKUs returned.
func (*FakeCloudCatalogServerWithSKUs) ListServices ¶ added in v0.20.0
func (s *FakeCloudCatalogServerWithSKUs) ListServices(_ context.Context, _ *billingpb.ListServicesRequest) (*billingpb.ListServicesResponse, error)
func (*FakeCloudCatalogServerWithSKUs) ListSkus ¶ added in v0.20.0
func (s *FakeCloudCatalogServerWithSKUs) ListSkus(_ context.Context, _ *billingpb.ListSkusRequest) (*billingpb.ListSkusResponse, error)
type GCPClient ¶
type GCPClient struct {
// contains filtered or unexported fields
}
func (*GCPClient) ExportBucketInfo ¶
func (*GCPClient) ExportGCPCostData ¶
func (*GCPClient) ExportRegionalDiscounts ¶
func (*GCPClient) GetPricing ¶
func (*GCPClient) GetRegions ¶ added in v0.16.0
func (*GCPClient) GetServiceName ¶
func (*GCPClient) ListForwardingRules ¶ added in v0.16.0
func (*GCPClient) ListInstancesInZone ¶
func (c *GCPClient) ListInstancesInZone(projectId, zone string) ([]*MachineSpec, error)
func (*GCPClient) ListManagedKafkaClusters ¶ added in v0.32.0
func (*GCPClient) ListManagedKafkaLocations ¶ added in v0.32.0
func (*GCPClient) ListSQLInstances ¶ added in v0.20.0
type MachineSpec ¶
type MachineSpec struct {
Instance string
Zone string
Region string
Family string
MachineType string
SpotInstance bool
Labels map[string]string
PriceTier string
}
MachineSpec is a slimmed down representation of a google compute.Instance struct
func NewMachineSpec ¶
func NewMachineSpec(instance *compute.Instance) *MachineSpec
NewMachineSpec will create a new MachineSpec from compute.Instance objects. It's responsible for determining the machine family and region that it operates in
func (*MachineSpec) GetClusterName ¶
func (m *MachineSpec) GetClusterName() string
type ManagedKafka ¶ added in v0.32.0
type ManagedKafka struct {
// contains filtered or unexported fields
}
type ManagedKafkaClient ¶ added in v0.32.0
type ManagedKafkaClient interface {
ListClusters(context.Context, *managedkafkapb.ListClustersRequest, ...gax.CallOption) *managedkafka.ClusterIterator
ListLocations(context.Context, *locationpb.ListLocationsRequest, ...gax.CallOption) *managedkafka.LocationIterator
}
type Mock ¶
func NewMock ¶
func NewMock(projectId string, discount int, regionsClient RegionsClient, bucketClient StorageClientInterface, billingClient *billingv1.CloudCatalogClient, computeService *compute.Service, sqladminService *sqladmin.Service, managedKafkaClient ManagedKafkaClient) *Mock
func (*Mock) ExportBucketInfo ¶
func (*Mock) ExportGCPCostData ¶
func (*Mock) ExportRegionalDiscounts ¶
func (*Mock) GetPricing ¶
func (*Mock) GetRegions ¶ added in v0.16.0
func (*Mock) GetServiceName ¶
func (*Mock) ListForwardingRules ¶ added in v0.16.0
func (*Mock) ListInstancesInZone ¶
func (c *Mock) ListInstancesInZone(projectId, zone string) ([]*MachineSpec, error)
func (*Mock) ListManagedKafkaClusters ¶ added in v0.32.0
func (*Mock) ListManagedKafkaLocations ¶ added in v0.32.0
func (*Mock) ListSQLInstances ¶ added in v0.20.0
type RegionsClient ¶
type RegionsClient interface {
List(ctx context.Context, req *computepb.ListRegionsRequest, opts ...gax.CallOption) *compute.RegionIterator
}
type StorageClientInterface ¶
type StorageClientInterface interface {
Buckets(ctx context.Context, projectID string) *storage.BucketIterator
}
Source Files
¶
Click to show internal directories.
Click to hide internal directories.