db

package
v0.0.0-...-57b77a8 Latest Latest
Warning

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

Go to latest
Published: May 13, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BucketName = "Connections"
)
View Source
const (
	DefaultDBFile = "connections.db"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

func NewClient

func NewClient(filePath string, logger *logrus.Entry) (*Client, error)

func (*Client) Close

func (c *Client) Close() error

func (*Client) DeleteConnection

func (c *Client) DeleteConnection(connID string) error

func (*Client) GetConnection

func (c *Client) GetConnection(connID string) (*Connection, error)

func (*Client) GetConnectionWithGateways

func (c *Client) GetConnectionWithGateways(gatewayA, providerA, gatewayB, providerB string) (*Connection, error)

func (*Client) ListConnections

func (c *Client) ListConnections() ([]Connection, error)

func (*Client) PutConnection

func (c *Client) PutConnection(conn Connection) error

TODO: Handle adding tags and making sure to not clear them.

type Connection

type Connection struct {
	// The Identifier of the connection.
	// The client is supposed to generate valid and unique
	// identifier.
	// TODO: Move this logic to DB.
	ID string `json:"id"`
	// The Source Gateway ID
	SourceID string `json:"source_id"`
	// The Source Cloud Provider (for example AWS)
	SourceProvider string `json:"source_provider"`
	// The region where Source resources will be stored.
	//
	// Region is considered in the context of specified provider.
	SourceRegion string `json:"source_region"`
	// The ID of VPC if the Source Gateway is associated with one.
	// Otherwise this field remains empty.
	SourceVPC string `json:"source_vpc"`
	// The CIDRs that should be reachable from the destination
	// machines.
	SourceCIDRs []string `json:"source_cidr"`
	// The Destination Gateway ID
	DestinationID string `json:"destination_id"`
	// The Destination Cloud Provider (for example GCP)
	DestinationProvider string `json:"destination_provider"`
	// The region where Destination resources will be stored.
	//
	// Region is considered in the context of specified provider.
	DestinationRegion string `json:"destination_region"`
	// The ID of VPC if the Destination Gateway is associated with one.
	// Otherwise this field remains empty.
	DestinationVPC string `json:"destination_vpc"`
	// The CIDRs that should be reachable from the source
	// machines.
	DestinationCIDRs []string `json:"destination_cidr"`
	// The state of the Connection.
	//
	// Describes if the Creation/Deletion is either in
	// progress, was incomplete or completed.
	State ConnectionState
	// If the State reports that not everything was completed
	// and it is no longer in progress - it means there was an
	// issue. Error contains information about the failure so
	// the user may manually fix the issue if it doesn't fix
	// itself alone.
	Error string
	// The time when the entry was created (which means when
	// the creation of the connection has started)
	//
	// TODO: Support it.
	Created time.Time `json:"created"`
	// The time when there was the last update of the given
	// Connection.
	//
	// TODO: Support it.
	LastUpdated time.Time `json:"last_updated"`
	// Tags are the way of providing additional data when writing
	// custom providers that need the exchange of additional
	// information when creating requested resources.
	//
	// Not supported yet.
	Tags map[string]string
}

TODO: Handle regions

type ConnectionState

type ConnectionState string

The state of the Connection

const (
	// The connection was created properly and can be used as a
	// bridge between different Cloud Providers.
	StateActive ConnectionState = "ACTIVE"
	// The connection creation is still in progress.
	//
	// If the script responsible for creating the connection got
	// suddenly interrupted/killed this state may remain for the
	// connection forever and should be treated similarly to
	// StatePartiallyCreated. The biggest difference is that, the
	// StateCreationInProgress will most likely fix itself after
	// restarting the operation.
	StateCreationInProgress ConnectionState = "CREATION_IN_PROGRESS"
	// The connection deletion is still in progress.
	//
	// If the script responsible for deleting the connection got
	// suddenly interrupted/killed this state may remain for the
	// connection forever and should be treated similarly to
	// StatePartiallyDelete. The biggest difference is that, the
	// StateDeletionInProgress will most likely fix itself after
	// restarting the operation.
	StateDeletionInProgress ConnectionState = "DELETION_IN_PROGRESS"
	// StatePartiallyCreated let's us know that some resources could
	// have been created, but there was an error during handling
	// requests and it should be investigated.
	StatePartiallyCreated ConnectionState = "PARTIALLY_CREATED"
	// StatePartiallyDeleted let's us know that some resources could
	// have been deleted, but there was an error during handling
	// requests and it should be investigated.
	StatePartiallyDeleted ConnectionState = "PARTIALLY_DELETED"
)

Jump to

Keyboard shortcuts

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