gcp

package
v0.0.0-...-f99fb5f Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	REQUESTED_CIDR_SIZE          uint8 = 30
	NUMBER_OF_GATEWAY_INTERFACES uint8 = 2
)

Variables

This section is empty.

Functions

func NewConnector

func NewConnector(ctx context.Context, logger *logrus.Entry, config string) (provider.Provider, error)

func NewTransactionState

func NewTransactionState(
	cloudRouterURL string,
	vpnGatewayURL string,
	gatewayName string,
	peerGatewayName string,
	ownInterfaces []string,
) *transactionState

Types

type Config

type Config struct {
	// The GCP Project ID, which will be used for interactions with
	// Google Cloud.
	//
	// If empty, the GCP Client will check the list of projects, which
	// the user has access to - if there is only one project, the script
	// will use that project automatically, otherwise, the user will be
	// instructed to specify the exact project.
	Project string
	// The Region, where GCP resources such as Routers and Subnets
	// will be created.
	Region string
}

type GCPConnector

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

GCPConnector is a structure responsible for preparing GCP side of the connection between providers.

func (*GCPConnector) AttachToExternalGatewayWithBGP

func (c *GCPConnector) AttachToExternalGatewayWithBGP(
	ctx context.Context,
	gateway, peerGateway types.Gateway,
	attachMode types.AttachBGPConnectionMode,
	config types.CreateBGPConnectionConfig,
) (types.OutputForConnectionWithBGP, error)

func (*GCPConnector) AttachToExternalGatewayWithStaticRouting

func (c *GCPConnector) AttachToExternalGatewayWithStaticRouting() error

func (*GCPConnector) Close

func (c *GCPConnector) Close() error

Close closes all internal clients for this client.

The user should call it as soon as the connector is no longer needed

func (*GCPConnector) CreateCloudRouterBGPPeers

func (c *GCPConnector) CreateCloudRouterBGPPeers(ctx context.Context) error

func (*GCPConnector) CreateCloudRouterInterfaces

func (c *GCPConnector) CreateCloudRouterInterfaces(ctx context.Context) error

func (*GCPConnector) CreateExternalVPNGateway

func (c *GCPConnector) CreateExternalVPNGateway(ctx context.Context) error

func (*GCPConnector) CreateVPNTunnels

func (c *GCPConnector) CreateVPNTunnels(ctx context.Context) error

func (*GCPConnector) DeleteConnectionResources

func (c *GCPConnector) DeleteConnectionResources(
	ctx context.Context,
	gateway types.Gateway,
	peerGateway types.Gateway,
) error

func (*GCPConnector) GenerateName

func (c *GCPConnector) GenerateName(id string) string

GenerateName generates a name for the resource in a specific manner, which allows to connect that particular resource with the connection it was created for.

Generate method adds a prefix with encoded string taken from names of both gateways that take place in the connection.

TODO: Design a way to handle possible name collisions with hashing algorithm being used here.

func (*GCPConnector) GetCIDRs

func (c *GCPConnector) GetCIDRs(ctx context.Context, gateway types.Gateway) ([]string, error)

func (*GCPConnector) GetGateway

func (c *GCPConnector) GetGateway(ctx context.Context, gateway types.GatewayIdentifier) (*types.Gateway, error)

GetGateway returns the Cloud Router object, considered as currently selected Gateway, based on the Connection options.

func (*GCPConnector) GetGatewayConnectionSettings

func (c *GCPConnector) GetGatewayConnectionSettings(ctx context.Context, gateway types.Gateway) (
	types.GatewayConnectionSettings, error,
)

func (*GCPConnector) GetInterfaces

func (c *GCPConnector) GetInterfaces(ctx context.Context, routerID string) (
	firstInterface, secondInterface, vpnGateway string, err error,
)

GetInterfaces returns two interfaces that can be used for creating the connection along with the name of VPN Gateway they come from.

The interfaces are picked from the VPN Gateway associated with the GCP Cloud Router that serves the role of the Gateway for creating the connection.

func (*GCPConnector) GetVPCForGateway

func (c *GCPConnector) GetVPCForGateway(ctx context.Context, gateway types.Gateway) (string, error)

func (*GCPConnector) InitializeASN

func (c *GCPConnector) InitializeASN(
	ctx context.Context, gateway, peerGateway types.Gateway,
) (uint64, error)

func (*GCPConnector) InitializeCreation

func (c *GCPConnector) InitializeCreation(
	ctx context.Context, gateway types.Gateway, peerGateway types.Gateway,
) error

func (*GCPConnector) InitializeGatewayInterfaces

func (c *GCPConnector) InitializeGatewayInterfaces(
	ctx context.Context, gateway, peerGateway types.Gateway,
) ([]string, error)

func (*GCPConnector) IsNameOwnedByConnection

func (c *GCPConnector) IsNameOwnedByConnection(name string) bool

Returns true if the name, provided as an argument, indicates that the resource was created while creating a connection between GCP Cloud Router and AWS Transit Gateway from the configuration.

func (*GCPConnector) ListGateways

func (c *GCPConnector) ListGateways(ctx context.Context) ([]types.Gateway, error)

ListGateways returns the slice of abstract Gateway objects that can be used as Edge for connection with other Cloud Providers.

Currently, the GCP Provider considers Cloud Routers as Gateways. However, for the Cloud Router to be an actual Gateway, it needs to have a VPN Gateway and a Network associated to it.

func (*GCPConnector) Name

func (c *GCPConnector) Name() string

func (*GCPConnector) PlanVPNTunnels

func (c *GCPConnector) PlanVPNTunnels(
	cloudRouterURL string,
	vpnGatewayURL string,
	externalVPNGatewayURL string,
	sharedSecrets []string,
) []client.VPNTunnel

PlanVPNTunnels creates objects representing desired VPN Tunnels.

The GCP Provider prepares the number of tunnels equal to the length of sharedSecrets provided as an argument.

Each VPN Tunnel consists of: * Cloud Router URL * VPN Gateway URL * External VPN Gateway

The first two elements come from the GCP Gateway that was selected for connection creation. The latter one is a resource created by the CSP Connector to represent the second side of the connection.

Additionally, each VPN Tunnel has a shared secret which will be picked from the provided slice. The order of secrets is important - to demonstrate, let's visualise situation where VPN Gateway defines 2 interfaces (IF_0 and IF_1) and External VPN gateway defines 4 interfaces (EXT_IF_0, EXT_IF_1, EXT_IF_2, EXT_IF_3). Such scenario would produce following Tunnels:

Tunnel name VPN GW IF EXT IF Shared Secret tunnel-1 IF_0 EXT_IF_0 SECRET_0 tunnel-2 IF_0 EXT_IF_1 SECRET_1 tunnel-3 IF_1 EXT_IF_2 SECRET_2 tunnel-4 IF_1 EXT_IF_3 SECRET_3

type StateOperation

type StateOperation func(ctx context.Context) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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