gcp

package
v0.0.0-...-73315e9 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2025 License: BSD-3-Clause Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = &ClientError{msg: "not found", status: http.StatusNotFound}

Functions

func BackendServiceFQN

func BackendServiceFQN(project, region, name string) string

func FirewallNeedsUpdate

func FirewallNeedsUpdate(fw *computepb.Firewall, expectedPorts map[int32]struct{}) bool

func ForwardingRuleFQN

func ForwardingRuleFQN(project, region, name string) string

func NEGFQN

func NEGFQN(project, region, name string) string

func NetworkFQN

func NetworkFQN(project, name string) string

func ServiceAttachmentFQN

func ServiceAttachmentFQN(project, region, name string) string

func SubnetFQN

func SubnetFQN(project, region, name string) string

Types

type Client

type Client interface {
	// Accessors
	Project() string
	Region() string
	// NEGs API
	GetNEG(ctx context.Context, name string) (*computepb.NetworkEndpointGroup, error)
	CreatePortmapNEG(ctx context.Context, name string) error
	DeletePortmapNEG(ctx context.Context, name string) error
	ListEndpoints(ctx context.Context, neg string) ([]*PortMapping, error)
	AttachEndpoints(ctx context.Context, neg string, mappings []*PortMapping) error
	DetachEndpoints(ctx context.Context, neg string, mappings []*PortMapping) error
	// Firewalls API
	GetFirewall(ctx context.Context, name string) (*computepb.Firewall, error)
	CreateFirewall(ctx context.Context, name string, ports map[int32]struct{}) error
	UpdateFirewall(ctx context.Context, name string, ports map[int32]struct{}) error
	DeleteFirewall(ctx context.Context, name string) error
	// Backend Services API
	GetBackendService(ctx context.Context, name string) (*computepb.BackendService, error)
	CreateBackendService(ctx context.Context, name string, neg string) error
	DeleteBackendService(ctx context.Context, name string) error
	// Forwarding Rules API
	GetForwardingRule(ctx context.Context, name string) (*computepb.ForwardingRule, error)
	CreateForwardingRule(ctx context.Context, name, backendSvc string, ip *string, globalAccess *bool) error
	DeleteForwardingRule(ctx context.Context, name string) error
	// Service Attachments API
	GetServiceAttachment(ctx context.Context, name string) (*computepb.ServiceAttachment, error)
	CreateServiceAttachment(ctx context.Context, name, fwdRuleFQN string, consumers []*computepb.ServiceAttachmentConsumerProjectLimit, natSubnetFQNs []string) error
	DeleteServiceAttachment(ctx context.Context, name string) error
}

type ClientConfig

type ClientConfig struct {
	Project     string            `env:"PROJECT"`
	Region      string            `env:"REGION"`
	Network     string            `env:"NETWORK"`
	Subnetwork  string            `env:"SUBNET"`
	Annotations map[string]string `env:"ANNOTATIONS"`
}

type ClientError

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

func (*ClientError) Error

func (e *ClientError) Error() string

type GCPClient

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

func NewClient

func NewClient(ctx context.Context, cfg ClientConfig, opts ...option.ClientOption) (*GCPClient, error)

func (*GCPClient) AttachEndpoints

func (c *GCPClient) AttachEndpoints(ctx context.Context, neg string, mappings []*PortMapping) error

func (*GCPClient) CreateBackendService

func (c *GCPClient) CreateBackendService(ctx context.Context, name string, neg string) error

func (*GCPClient) CreateFirewall

func (c *GCPClient) CreateFirewall(ctx context.Context, name string, ports map[int32]struct{}) error

func (*GCPClient) CreateForwardingRule

func (c *GCPClient) CreateForwardingRule(ctx context.Context, name, backendSvc string, ip *string, globalAccess *bool) error

func (*GCPClient) CreatePortmapNEG

func (c *GCPClient) CreatePortmapNEG(ctx context.Context, name string) error

func (*GCPClient) CreateServiceAttachment

func (c *GCPClient) CreateServiceAttachment(
	ctx context.Context,
	name,
	fwdRuleFQN string,
	consumers []*computepb.ServiceAttachmentConsumerProjectLimit,
	natSubnetFQNs []string,
) error

func (*GCPClient) DeleteBackendService

func (c *GCPClient) DeleteBackendService(
	ctx context.Context,
	name string,
) error

func (*GCPClient) DeleteFirewall

func (c *GCPClient) DeleteFirewall(
	ctx context.Context,
	name string,
) error

func (*GCPClient) DeleteForwardingRule

func (c *GCPClient) DeleteForwardingRule(
	ctx context.Context,
	name string,
) error

func (*GCPClient) DeletePortmapNEG

func (c *GCPClient) DeletePortmapNEG(
	ctx context.Context,
	name string,
) error

func (*GCPClient) DeleteServiceAttachment

func (c *GCPClient) DeleteServiceAttachment(
	ctx context.Context,
	name string,
) error

func (*GCPClient) DetachEndpoints

func (c *GCPClient) DetachEndpoints(ctx context.Context, neg string, mappings []*PortMapping) error

func (*GCPClient) GetBackendService

func (c *GCPClient) GetBackendService(ctx context.Context, name string) (*computepb.BackendService, error)

func (*GCPClient) GetFirewall

func (c *GCPClient) GetFirewall(ctx context.Context, name string) (*computepb.Firewall, error)

func (*GCPClient) GetForwardingRule

func (c *GCPClient) GetForwardingRule(ctx context.Context, name string) (*computepb.ForwardingRule, error)

func (*GCPClient) GetNEG

func (*GCPClient) GetServiceAttachment

func (c *GCPClient) GetServiceAttachment(ctx context.Context, name string) (*computepb.ServiceAttachment, error)

func (*GCPClient) ListEndpoints

func (c *GCPClient) ListEndpoints(ctx context.Context, neg string) ([]*PortMapping, error)

func (*GCPClient) Project

func (c *GCPClient) Project() string

func (*GCPClient) Region

func (c *GCPClient) Region() string

func (*GCPClient) UpdateFirewall

func (c *GCPClient) UpdateFirewall(ctx context.Context, name string, ports map[int32]struct{}) error

type PortMapping

type PortMapping struct {
	Port         int32
	Instance     string
	InstancePort int32
}

Directories

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

Jump to

Keyboard shortcuts

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