provider

package
Version: v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2020 License: MIT Imports: 2 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

This section is empty.

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) ResourceInOut

func (n NopProvider) ResourceInOut(id, rs string, cfgs map[string]map[string]interface{}) (in, out []string)

ResourceInOut returns the resource In Out from a state config. As an example in AWS this would be an "aws_security_group" "ingress" and "egress"

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)

	// ResourceInOut returns the resource In Out from a
	// state config. As an example in AWS this would be
	// an "aws_security_group" "ingress" and "egress"
	ResourceInOut(id, rs string, cfg map[string]map[string]interface{}) (in, out []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
	AWS
	FlexibleEngine
	OpenStack
	Google
)

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