storage

package
v0.0.2-alpha Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package storage store resource information

Package storage store resource information

Package storage store resource information

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Mock

type Mock struct {
	mock.Mock
}

Mock is an autogenerated mock type for the Storage type

func (*Mock) Find

func (_m *Mock) Find(filter ResourceFilter) ([]resource.Resource, error)

Find provides a mock function with given fields: filter

func (*Mock) GetRelations

func (_m *Mock) GetRelations() ([]map[string]string, error)

GetRelations provides a mock function with given fields:

func (*Mock) GetResources

func (_m *Mock) GetResources() ([]resource.Resource, error)

GetResources provides a mock function with given fields:

func (*Mock) Persist

func (_m *Mock) Persist(resources []resource.Resource) error

Persist provides a mock function with given fields: resources

func (*Mock) Prepare

func (_m *Mock) Prepare() error

Prepare provides a mock function with given fields:

func (*Mock) StoreRelations

func (_m *Mock) StoreRelations(relation config.Relation) error

StoreRelations provides a mock function with given fields: criteria

type PostgreSQL

type PostgreSQL struct {
	DB *sql.DB
}

PostgreSQL store storage configuration for PostgreSQL database

func (*PostgreSQL) Find

func (p *PostgreSQL) Find(filter ResourceFilter) ([]resource.Resource, error)

Find resources based on criteria

func (*PostgreSQL) GetRelations

func (p *PostgreSQL) GetRelations() ([]map[string]string, error)

GetRelations fetch all the relations between resources

func (*PostgreSQL) GetResources

func (p *PostgreSQL) GetResources() ([]resource.Resource, error)

GetResources fetch all resources from storage

func (*PostgreSQL) Persist

func (p *PostgreSQL) Persist(resources []resource.Resource) error

Persist store resources

func (*PostgreSQL) Prepare

func (p *PostgreSQL) Prepare() error

Prepare to prepare the database

func (*PostgreSQL) StoreRelations

func (p *PostgreSQL) StoreRelations(relation config.Relation) error

StoreRelations will go through all resources in the database and based on criteria it will insert relationship to "relations" table StoreRelations will go through all resources in the database and based on criteria it will insert relationship to "relations" table

type Query

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

Query build query based on filters

func (*Query) AddFilter

func (q *Query) AddFilter(field, operator string, value interface{})

AddFilter adds filter

func (*Query) Build

func (q *Query) Build() (string, []interface{})

Build builds query

type ResourceFilter

type ResourceFilter struct {
	Kind       string
	UUID       string
	Name       string
	ExternalID string
}

ResourceFilter configure the filter

type Storage

type Storage interface {
	// Prepare to prepare the Storage schema
	Prepare() error

	// Persist Save resources to Storage
	Persist(resources []resource.Resource) error

	// Find will return the resources based on ResourceFilter
	Find(filter ResourceFilter) ([]resource.Resource, error)

	GetResources() ([]resource.Resource, error)
	GetRelations() ([]map[string]string, error)

	// StoreRelations Store Relationship
	StoreRelations(relation config.Relation) error
}

Storage interface helps to build different storage

func BuildStorage

func BuildStorage(appConfig *config.AppConfig) Storage

BuildStorage build storage based on configuration

Jump to

Keyboard shortcuts

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