provider

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

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccessControl

type AccessControl interface {
	// AddInboundAllowRuleInVPC allows given cidrs in all VPC instances. Security rules are created with name ruleName
	// and tags if they are allowed in given cloud.
	AddInboundAllowRuleInVPC(ctx context.Context, account, region string, destinationVpcID string, cidrsToAllow []string, ruleName string,
		tags map[string]string) error
	// AddInboundAllowRuleByLabelsMatch allows cidrsToAllow with protocolsAndPorts to all instances which match to labels
	AddInboundAllowRuleByLabelsMatch(ctx context.Context, account, region string,
		vpcID string, ruleName string, labels map[string]string, cidrsToAllow []string,
		protocolsAndPorts types.ProtocolsAndPorts) (ruleId string, instances []types.Instance, err error)
	// AddInboundAllowRuleBySubnetMatch allows cidrsToAllow with protocolsAndPorts to all instances which are within provided cloud subnets
	AddInboundAllowRuleBySubnetMatch(ctx context.Context, account, region string,
		vpcID string, ruleName string, subnetCidrs []string, cidrsToAllow []string,
		protocolsAndPorts types.ProtocolsAndPorts) (ruleId string, instances []types.Instance, subnets []types.Subnet, err error)
	// AddInboundAllowRuleByInstanceIPMatch allows cidrsToAllow with protocolsAndPorts to all instances which have provided instancesIPs
	AddInboundAllowRuleByInstanceIPMatch(ctx context.Context, account, region string,
		vpcID string, ruleName string, instancesIPs []string, cidrsToAllow []string,
		protocolsAndPorts types.ProtocolsAndPorts) (ruleId string, instances []types.Instance, err error)
	// AddInboundAllowRuleForLoadBalancerByDNS allows cidrsToAllow with protocolsAndPorts to load balancer with given DNS
	AddInboundAllowRuleForLoadBalancerByDNS(ctx context.Context, account, region string, loadBalancerDNS string, vpcID string,
		ruleName string, cidrsToAllow []string, protocolsAndPorts types.ProtocolsAndPorts,
	) (loadBalancerId, ruleId string, err error)
	RemoveInboundAllowRuleFromVPCByName(ctx context.Context, account, region string, vpcID string, ruleName string) error
	RemoveInboundAllowRulesFromVPCById(ctx context.Context, account, region string, vpcID string, instanceIDs []string,
		loadBalancersIDs []string, ruleId string) error
	RemoveInboundAllowRuleRulesByTags(ctx context.Context, account, region string, vpcID string, ruleName string, tags map[string]string) error
	// RefreshInboundAllowRule adds and removes CIDRs in rule rules and applies rule in instances matching
	// to destinationLabels or destinationPrefixes
	RefreshInboundAllowRule(ctx context.Context, account, region string, ruleId string, cidrsToAdd []string, cidrsToRemove []string,
		destinationLabels map[string]string, destinationPrefixes []string, destinationVPCId string,
		protocolsAndPorts types.ProtocolsAndPorts) (instances []types.Instance, subnets []types.Subnet, err error)
}

type CloudProvider

type CloudProvider interface {
	GetName() string
	ListAccounts() []types.Account
	// ListVPC returns cloud instances based on provided filters, empty filter means no filtering by this parameter.
	ListVPC(ctx context.Context, input *infrapb.ListVPCRequest) ([]types.VPC, error)
	// ListInstances returns cloud instances based on provided filters, empty filter means no filtering by this parameter.
	ListInstances(ctx context.Context, input *infrapb.ListInstancesRequest) ([]types.Instance, error)
	// ListSubnets returns cloud instances based on provided filters, empty filter means no filtering by this parameter.
	// Scope of subnet is regional in some clouds (e.g. GCP, Azure) and zonal in others (e.g. AWS), filtering is done by
	// this scope.
	ListSubnets(ctx context.Context, input *infrapb.ListSubnetsRequest) ([]types.Subnet, error)
	ListACLs(ctx context.Context, input *infrapb.ListACLsRequest) ([]types.ACL, error)
	ListSecurityGroups(ctx context.Context, input *infrapb.ListSecurityGroupsRequest) ([]types.SecurityGroup, error)
	ListRouteTables(ctx context.Context, input *infrapb.ListRouteTablesRequest) ([]types.RouteTable, error)
	ListNATGateways(ctx context.Context, input *infrapb.ListNATGatewaysRequest) ([]types.NATGateway, error)
	ListRouters(ctx context.Context, input *infrapb.ListRoutersRequest) ([]types.Router, error)
	ListInternetGateways(ctx context.Context, input *infrapb.ListInternetGatewaysRequest) ([]types.IGW, error)

	// GetSubnet returns single subnet based on it's ID
	GetSubnet(ctx context.Context, input *infrapb.GetSubnetRequest) (types.Subnet, error)
	// GetVPCIDForCIDR returns ID of VPC which have subnet with given CIDR.
	GetVPCIDForCIDR(ctx context.Context, input *infrapb.GetVPCIDForCIDRRequest) (string, error)
	// GetCIDRsForLabels returns CIDRs of subnets with given labels.
	GetCIDRsForLabels(ctx context.Context, input *infrapb.GetCIDRsForLabelsRequest) ([]string, error)
	// GetIPsForLabels returns IPs of instances with given labels.
	GetIPsForLabels(ctx context.Context, input *infrapb.GetIPsForLabelsRequest) ([]string, error)
	// GetInstancesForLabels returns instances with given labels.
	GetInstancesForLabels(ctx context.Context, input *infrapb.GetInstancesForLabelsRequest) ([]types.Instance, error)
	GetVPCIDWithTag(ctx context.Context, input *infrapb.GetVPCIDWithTagRequest) (string, error)
	ListClusters(ctx context.Context, input *infrapb.ListCloudClustersRequest) ([]types.Cluster, error)
	RetrieveClustersData(ctx context.Context) ([]cluster.DiscoveredCluster, error)
	AccessControl
	DBMetadata
	VPCConnector
}

type DBMetadata

type DBMetadata interface {
	GetSyncTime(id string) (types.SyncTime, error)
}

type Kubernetes

type Kubernetes interface {
	ListClusters(ctx context.Context) (clusters []types.Cluster, err error)
	ListNamespaces(ctx context.Context, clusterName string, labels map[string]string) (namespaces []types.Namespace, err error)
	ListPods(ctx context.Context, clusterName string, labels map[string]string) (pods []types.Pod, err error)
	ListServices(ctx context.Context, clusterName string, labels map[string]string) (services []types.K8SService, err error)
	ListNodes(ctx context.Context, clusterName string, labels map[string]string) (nodes []types.K8sNode, err error)
	ListPodsCIDRs(ctx context.Context, clusterName string) ([]string, error)
	ListServicesCIDRs(ctx context.Context, clusterName string) (string, error)
	UpdateServiceSourceRanges(ctx context.Context, clusterName, namespace, name string, cidrsToAdd []string, cidrsToRemove []string) error
	DBMetadata
}

type RealProviderStrategy

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

func NewRealProviderStrategy

func NewRealProviderStrategy(ctx context.Context, logger *logrus.Logger, kubeConfigFileName string) *RealProviderStrategy

func (*RealProviderStrategy) GetAllProviders

func (s *RealProviderStrategy) GetAllProviders() []CloudProvider

func (*RealProviderStrategy) GetKubernetesProvider

func (s *RealProviderStrategy) GetKubernetesProvider() (Kubernetes, error)

func (*RealProviderStrategy) GetProvider

func (s *RealProviderStrategy) GetProvider(ctx context.Context, cloud string) (CloudProvider, error)

func (*RealProviderStrategy) RefreshState

func (s *RealProviderStrategy) RefreshState(ctx context.Context) error

func (*RealProviderStrategy) RetrieveClusters

func (s *RealProviderStrategy) RetrieveClusters(ctx context.Context)

type Strategy

type Strategy interface {
	GetProvider(ctx context.Context, cloud string) (CloudProvider, error)
	GetAllProviders() []CloudProvider
	GetKubernetesProvider() (Kubernetes, error)
	RefreshState(ctx context.Context) error
}

Jump to

Keyboard shortcuts

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