client

package
v0.32.3 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2026 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

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

func RegionsForProjects(gcpClient Client, projects []string, logger *slog.Logger) []string

RegionsForProjects fetches and deduplicates regions across all given GCP projects.

func RegionsFromZonesForProjects added in v0.28.1

func RegionsFromZonesForProjects(gcpClient Client, projects []string, logger *slog.Logger) []string

RegionsFromZonesForProjects fetches zones and derives region names (e.g. "us-central1-a" → "us-central1") across all given GCP projects.

Types

type Billing

type Billing struct {
	// contains filtered or unexported fields
}

type Bucket

type Bucket struct {
	// contains filtered or unexported fields
}

func (*Bucket) List

func (b *Bucket) List(ctx context.Context, project string) ([]*storage.BucketAttrs, error)

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 Compute

type Compute struct {
	// contains filtered or unexported fields
}

type Config

type Config struct {
	ProjectId string
	Discount  int
}

type FakeCloudCatalogServer

type FakeCloudCatalogServer struct {
	billingpb.UnimplementedCloudCatalogServer
}

func (*FakeCloudCatalogServer) ListServices

func (*FakeCloudCatalogServer) ListSkus

type FakeCloudCatalogServerSlimResults

type FakeCloudCatalogServerSlimResults struct {
	billingpb.UnimplementedCloudCatalogServer
}

func (*FakeCloudCatalogServerSlimResults) ListServices

func (*FakeCloudCatalogServerSlimResults) ListSkus

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 (*FakeCloudCatalogServerWithSKUs) ListSkus added in v0.20.0

type GCPClient

type GCPClient struct {
	// contains filtered or unexported fields
}

func NewGCPClient

func NewGCPClient(ctx context.Context, cfg Config) (*GCPClient, error)

func (*GCPClient) ExportBucketInfo

func (c *GCPClient) ExportBucketInfo(ctx context.Context, projects []string, m *metrics.Metrics) error

func (*GCPClient) ExportGCPCostData

func (c *GCPClient) ExportGCPCostData(ctx context.Context, serviceName string, m *metrics.Metrics) float64

func (*GCPClient) ExportRegionalDiscounts

func (c *GCPClient) ExportRegionalDiscounts(ctx context.Context, m *metrics.Metrics) error

func (*GCPClient) GetPricing

func (c *GCPClient) GetPricing(ctx context.Context, serviceName string) []*billingpb.Sku

func (*GCPClient) GetRegions added in v0.16.0

func (c *GCPClient) GetRegions(projectId string) ([]*computev1.Region, error)

func (*GCPClient) GetServiceName

func (c *GCPClient) GetServiceName(ctx context.Context, serviceName string) (string, error)

func (*GCPClient) GetZones

func (c *GCPClient) GetZones(projectId string) ([]*computev1.Zone, error)

func (*GCPClient) ListDisks

func (c *GCPClient) ListDisks(ctx context.Context, projectId string, zone string) ([]*computev1.Disk, error)

func (*GCPClient) ListForwardingRules added in v0.16.0

func (c *GCPClient) ListForwardingRules(ctx context.Context, projectId string, region string) ([]*computev1.ForwardingRule, error)

func (*GCPClient) ListInstancesInZone

func (c *GCPClient) ListInstancesInZone(projectId, zone string) ([]*MachineSpec, error)

func (*GCPClient) ListManagedKafkaClusters added in v0.32.0

func (c *GCPClient) ListManagedKafkaClusters(ctx context.Context, projectId string, location string) ([]*managedkafkapb.Cluster, error)

func (*GCPClient) ListManagedKafkaLocations added in v0.32.0

func (c *GCPClient) ListManagedKafkaLocations(ctx context.Context, projectId string) ([]string, error)

func (*GCPClient) ListSQLInstances added in v0.20.0

func (c *GCPClient) ListSQLInstances(ctx context.Context, projectId string) ([]*sqladmin.DatabaseInstance, error)

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 Mock

type Mock struct {
	mock.Mock
	// contains filtered or unexported fields
}

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 (c *Mock) ExportBucketInfo(ctx context.Context, projects []string, m *metrics.Metrics) error

func (*Mock) ExportGCPCostData

func (c *Mock) ExportGCPCostData(ctx context.Context, serviceName string, m *metrics.Metrics) float64

func (*Mock) ExportRegionalDiscounts

func (c *Mock) ExportRegionalDiscounts(ctx context.Context, m *metrics.Metrics) error

func (*Mock) GetPricing

func (c *Mock) GetPricing(ctx context.Context, serviceName string) []*billingpb.Sku

func (*Mock) GetRegions added in v0.16.0

func (c *Mock) GetRegions(project string) ([]*compute.Region, error)

func (*Mock) GetServiceName

func (c *Mock) GetServiceName(ctx context.Context, serviceName string) (string, error)

func (*Mock) GetZones

func (c *Mock) GetZones(projectId string) ([]*compute.Zone, error)

func (*Mock) ListDisks

func (c *Mock) ListDisks(ctx context.Context, projectId string, zone string) ([]*compute.Disk, error)

func (*Mock) ListForwardingRules added in v0.16.0

func (c *Mock) ListForwardingRules(ctx context.Context, project string, region string) ([]*compute.ForwardingRule, error)

func (*Mock) ListInstancesInZone

func (c *Mock) ListInstancesInZone(projectId, zone string) ([]*MachineSpec, error)

func (*Mock) ListManagedKafkaClusters added in v0.32.0

func (c *Mock) ListManagedKafkaClusters(ctx context.Context, projectId string, location string) ([]*managedkafkapb.Cluster, error)

func (*Mock) ListManagedKafkaLocations added in v0.32.0

func (c *Mock) ListManagedKafkaLocations(ctx context.Context, projectId string) ([]string, error)

func (*Mock) ListSQLInstances added in v0.20.0

func (c *Mock) ListSQLInstances(ctx context.Context, projectId string) ([]*sqladmin.DatabaseInstance, error)

type Region

type Region struct {
	// contains filtered or unexported fields
}

type RegionsClient

type RegionsClient interface {
	List(ctx context.Context, req *computepb.ListRegionsRequest, opts ...gax.CallOption) *compute.RegionIterator
}

type SQLAdmin added in v0.20.0

type SQLAdmin struct {
	// contains filtered or unexported fields
}

type StorageClientInterface

type StorageClientInterface interface {
	Buckets(ctx context.Context, projectID string) *storage.BucketIterator
}

Directories

Path Synopsis
Package mock_client is a generated GoMock package.
Package mock_client is a generated GoMock package.

Jump to

Keyboard shortcuts

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