provider

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2020 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package provider has the abstraction of a Provider which holds the specific logic of that Provider when trying to generate a Graph. The logic to hide/show specific elements and how they should be represented

Index

Constants

View Source
const HCLCanonicalKey = "_im_canonical"

HCLCanonicalKey is used to define a specific key to the config, in this case the HCL config, as it does not have an 'id' we'll add this key with the Canonical of the Resource (ex: _im_canonical => aws_lb.front)

Variables

This section is empty.

Functions

func TypeStrings

func TypeStrings() []string

TypeStrings returns a slice of all String values of the enum

Types

type NopProvider

type NopProvider struct{}

NopProvider holds the default methods for the provider.Interface so if one Provider does not implement one method we do not have to write the method

func (NopProvider) DataSource

func (n NopProvider) DataSource(rsc string) (*resource.Resource, error)

DataSource returns the resource information

func (NopProvider) IsEdge

func (n NopProvider) IsEdge(rsc string) bool

IsEdge checks if the resource should be considered an Edge or not

func (NopProvider) IsNode

func (n NopProvider) IsNode(rsc string) bool

IsNode checks if the resource should be considered a Node or not

func (NopProvider) PreProcess added in v0.2.0

func (n NopProvider) PreProcess(cfg map[string]map[string]interface{}) [][]string

PreProcess defines new edges from the config. each element is an edge and for each edge we have the source and the target. [_][0] is the source of the edge [_][1] is the target of the edge

func (NopProvider) Resource

func (n NopProvider) Resource(rsc string) (*resource.Resource, error)

Resource returns the resource information

func (NopProvider) ResourceInOutNodes added in v0.4.0

func (n NopProvider) ResourceInOutNodes(id, rs string, cfg map[string]map[string]interface{}) (in, out, nodes []string)

ResourceInOutNodes returns the resource In Out and Nodes from a state config. As an example in AWS this would be an "aws_security_group" "ingress" and "egress" In are the incoming connections, Out are the exiting connections and Nodes are fictional Nodes that need to be added, it's basically to represent the internet access

func (NopProvider) Type

func (n NopProvider) Type() Type

Type returns the name of the Provider

func (NopProvider) UsedAttributes

func (n NopProvider) UsedAttributes() []string

UsedAttributes returns all the attributes that are required/used/needed on the providers, so when we have to prune we know what to keep

type Provider

type Provider interface {
	// Type returns the name of the Provider
	Type() Type

	// IsNode checks if the resource should be considered
	// a Node or not
	IsNode(rsc string) bool

	// IsEdge checks if the resource should be considered
	// an Edge or not
	IsEdge(rsc string) bool

	// Resource returns the resource information
	Resource(rsc string) (*resource.Resource, error)

	// DataSource returns the resource information
	DataSource(rsc string) (*resource.Resource, error)

	// ResourceInOutNodes returns the resource In Out and Nodes from a
	// state config. As an example in AWS this would be
	// an "aws_security_group" "ingress" and "egress"
	// In are the incoming connections, Out are the exiting connections
	// and Nodes are fictional Nodes that need to be added, it's basically
	// to represent the internet access
	ResourceInOutNodes(id, rs string, cfg map[string]map[string]interface{}) (in, out, nodes []string)

	// UsedAttributes returns all the attributes that are
	// required/used/needed on the providers, so when we have to
	// prune we know what to keep
	UsedAttributes() []string

	// PreProcess defines new edges from the config.
	// each element is an edge and for each edge we have the source
	// and the target.
	// [_][0] is the source of the edge
	// [_][1] is the target of the edge
	PreProcess(cfg map[string]map[string]interface{}) [][]string
}

Provider is an interface to abstract common functions on all the providers

type RawProvider

type RawProvider struct {
	NopProvider
}

RawProvider is the provider that would be used when we do not have an specific implementation a Provider

func (RawProvider) IsNode

func (n RawProvider) IsNode(rsc string) bool

IsNode checks if the resource should be considered a Node or not For the default one we consider all of the Nodes

func (RawProvider) Resource

func (n RawProvider) Resource(rsc string) (*resource.Resource, error)

Resource returns the resource information

func (RawProvider) Type

func (n RawProvider) Type() Type

Type returns the name of the Provider

type Type

type Type int

Type defines the type of the Provider

const (
	Raw Type = iota
	IM
	AWS
	FlexibleEngine
	OpenStack
	Google
	Azurerm
)

List of all the Providers supported

func TypeString

func TypeString(s string) (Type, error)

TypeString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.

func TypeValues

func TypeValues() []Type

TypeValues returns all values of the enum

func (Type) IsAType

func (i Type) IsAType() bool

IsAType returns "true" if the value is listed in the enum definition. "false" otherwise

func (Type) String

func (i Type) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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