db

package
v0.0.0-...-01bf647 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2020 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Database

type Database struct {
	*gorm.DB
}

Database is a wrapping structure to *gorm.DB

func Init

func Init(config config.DBConfig, debug bool) *Database

Init setups up the Database and a pointer to it

func (*Database) DefaultVersion

func (db *Database) DefaultVersion(path string) (version string, err error)

DefaultVersion returns the detault VersionID for a given State path Copied and adapted from github.com/hashicorp/terraform/command/jsonstate/state.go

func (*Database) GetState

func (db *Database) GetState(path, versionID string) (state types.State)

GetState retrieves a State from the database by its path and versionID

func (*Database) GetStateActivity

func (db *Database) GetStateActivity(path string) (states []types.StateStat)

GetStateActivity returns a slice of StateStat from the Database for a given State path representing the State activity over time (Versions)

func (*Database) InsertState

func (db *Database) InsertState(path string, versionID string, sf *statefile.File) error

InsertState inserts a Terraform State in the Database

func (*Database) InsertVersion

func (db *Database) InsertVersion(version *state.Version) error

InsertVersion inserts an AWS S3 Version in the Database

func (*Database) KnownVersions

func (db *Database) KnownVersions() (versions []string)

KnownVersions returns a slice of all known Versions in the Database

func (*Database) ListAttributeKeys

func (db *Database) ListAttributeKeys(resourceType string) (results []string, err error)

ListAttributeKeys lists all Resource Attribute keys for a given Resource type from the Database

func (*Database) ListResourceNames

func (db *Database) ListResourceNames() ([]string, error)

ListResourceNames lists all Resource names from the Database

func (*Database) ListResourceTypes

func (db *Database) ListResourceTypes() ([]string, error)

ListResourceTypes lists all Resource types from the Database

func (*Database) ListResourceTypesWithCount

func (db *Database) ListResourceTypesWithCount() (results []map[string]string, err error)

ListResourceTypesWithCount returns a list of Resource types with associated counts from the Database

func (*Database) ListStateStats

func (db *Database) ListStateStats(query url.Values) (states []types.StateStat, page int, total int)

ListStateStats returns a slice of StateStat, along with paging information

func (*Database) ListStates

func (db *Database) ListStates() (states []string)

ListStates returns a slice of all State paths from the Database

func (*Database) ListStatesVersions

func (db *Database) ListStatesVersions() (statesVersions map[string][]string)

ListStatesVersions returns a map of Version IDs to a slice of State paths from the Database

func (*Database) ListTerraformVersionsWithCount

func (db *Database) ListTerraformVersionsWithCount(query url.Values) (results []map[string]string, err error)

ListTerraformVersionsWithCount returns a slice of maps of Terraform versions mapped to the count of most recent State paths using them. ListTerraformVersionsWithCount also takes a query with possible parameter 'orderBy' to sort results. Default sorting is by descending version number.

func (*Database) ListTfVersions

func (db *Database) ListTfVersions() ([]string, error)

ListTfVersions lists all Terraform versions from the Database

func (*Database) SearchAttribute

func (db *Database) SearchAttribute(query url.Values) (results []types.SearchResult, page int, total int)

SearchAttribute returns a slice of SearchResult given a query The query might contain parameters 'type', 'name', 'key', 'value' and 'tf_version' SearchAttribute also returns paging information: the page number and the total results

Jump to

Keyboard shortcuts

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