files_handler

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: May 3, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindResourcesPerFile

func FindResourcesPerFile(dir string) (files map[string][]Resource, err error)

FindResourcesPerFile

@brief:

FindResourcesPerFile parses all the .tf files under a given folder tree recursively in order to get all the Resources
and Data Sources in it

@params:

dir string - the folder to parse

@returns:

resources - map[string][]Resource - map of all resources found in the given folder and its attributes'
error - if exists, else nil

func ScanFileForModules

func ScanFileForModules(fileName string) (filesToResourcesMap map[string][]Resource, err error)

ScanFileForModules

@brief:

ScanFileForModules parses a tf file in order to get the modules defined in it

@params:

filename string - the file to parse

@returns:

resources - map[string][]Resource - all the resources found in the given module
error - if exists, else nil

Types

type Attribute

type Attribute struct {
	Name  string
	Value string
}

Attribute holds the breakdown of an attribute found under a Resource

func (*Attribute) Init

func (a *Attribute) Init(attribute *hclwrite.Attribute, name string)

Init

@brief:

Init initializes the Attribute object in context

@params:

attribute - *hclwrite.Attribute - the attribute to initialize
name - string - the attribute name

type Resource

type Resource struct {
	Type             string
	Name             string
	Alias            string
	FullNameSequence string
	Provider         tfconfig.ProviderRef
	Pos              tfconfig.SourcePos
	Attributes       []Attribute
}

Resource holds all the data scraped from user files for a specific resource

func ScanFileForResources

func ScanFileForResources(fileName string) (resources []Resource, err error)

ScanFileForResources

@brief:

ScanFileForResources parses a tf file in order to get the resources and data source defined in it

@params:

filename string - the file to parse

@returns:

resources - []Resource - all the resource found in the given file
error - if exists, else nil

func ScanFolder

func ScanFolder(dir string) (resources []Resource, err error)

ScanFolder

@brief:

ScanFolder parses a folder which contains tf files in order to get the resources and data source defined in it

@params:

dir string - the folder to parse

@returns:

resources - []*Resource - map of all resources found in the given folder and its attributes'
error - if exists, else nil

func ScanFolderRecursively

func ScanFolderRecursively(dir string) (resources []Resource, err error)

ScanFolderRecursively

@brief:

ScanFolderRecursively parses all the .tf files under a given folder tree recursively in order to get all the Resources
and Data Sources in it

@params:

dir string - the folder to parse

@returns:

resources - []*Resource - map of all resources found in the given folder and its attributes'
error - if exists, else nil

func (Resource) GetAttributesKeys

func (r Resource) GetAttributesKeys() (keys []string)

GetAttributesKeys

@brief:

GetAttributesKeys returns all attributes keys in the Resource in context

@returns:

keys - []string - the keys found

func (Resource) GetRuleset

func (r Resource) GetRuleset(rulebook rules_api.Rulebook, appearances map[string][]string) (rulesetObj rules_api.RuleSet, err error)

GetRuleset

@brief:

GetRuleset checks if the resource in context is inside the given rulebook and returns it if it does.
If no RuleSet is found, will return an empty object and no error.

@params:

rulebook rules_api.Rulebook - the rulebook to search for the ruleset in

@returns:

*gabs.Container - the ruleset to execute
error - if exists

func (*Resource) Init

func (r *Resource) Init(block *hclwrite.Block, metadata *tfconfig.Resource)

Init

@brief:

Init initializes the Resource object in context

@params:

block - *hclwrite.Block - the resource to initialize with
metadata - *tfconfig.Resource - the resource metadata

func (Resource) IsDataSource

func (r Resource) IsDataSource() bool

IsDataSource

@brief:

IsDataSource checks if the resource in context is of type data

@returns:

bool

func (Resource) IsResource

func (r Resource) IsResource() bool

IsResource

@brief:

IsResource checks if the resource in context is of type resource

@returns:

bool

Jump to

Keyboard shortcuts

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