storage

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 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 MetadataCount

type MetadataCount struct {
	Source     string
	Kind       string
	Key        string
	Value      string
	TotalCount int
}

MetadataCount count resources by metadata

type Mock

type Mock struct {
	mock.Mock
}

Mock is an autogenerated mock type for the Storage type

func (*Mock) CleanupOldVersion

func (_m *Mock) CleanupOldVersion(source string, kind string) (int64, error)

CleanupOldVersion provides a mock function with given fields: source, kind

func (*Mock) Find

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

Find provides a mock function with given fields: filter

func (*Mock) GetNextVersionForResource

func (_m *Mock) GetNextVersionForResource(source string, kind string) (int, error)

GetNextVersionForResource provides a mock function with given fields: source, kind

func (*Mock) GetRelations

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

GetRelations provides a mock function with given fields:

func (*Mock) GetResourceCount

func (_m *Mock) GetResourceCount() ([]ResourceCount, error)

GetResourceCount provides a mock function with given fields:

func (*Mock) GetResourceCountByMetaData

func (_m *Mock) GetResourceCountByMetaData() ([]MetadataCount, error)

GetResourceCountByMetaData 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) CleanupOldVersion

func (p *PostgreSQL) CleanupOldVersion(source, kind string) (int64, error)

CleanupOldVersion cleanup old version of resources

func (*PostgreSQL) Find

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

Find resources based on criteria

func (*PostgreSQL) GetNextVersionForResource

func (p *PostgreSQL) GetNextVersionForResource(source, kind string) (int, error)

GetNextVersionForResource get next version for a resource

func (*PostgreSQL) GetRelations

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

GetRelations fetch all the relations between resources

func (*PostgreSQL) GetResourceCount

func (p *PostgreSQL) GetResourceCount() ([]ResourceCount, error)

GetResourceCount get resource count

func (*PostgreSQL) GetResourceCountByMetaData

func (p *PostgreSQL) GetResourceCountByMetaData() ([]MetadataCount, error)

GetResourceCountByMetaData get filtered resource count

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 ResourceCount

type ResourceCount struct {
	Source     string
	Kind       string
	TotalCount int
}

ResourceCount count resource

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

	GetNextVersionForResource(source, kind string) (int, error)

	CleanupOldVersion(source, kind string) (int64, error)

	GetResourceCount() ([]ResourceCount, error)

	GetResourceCountByMetaData() ([]MetadataCount, error)
}

Storage interface helps to build different storage

func BuildStorage

func BuildStorage(appConfig *config.AppConfig) (Storage, error)

BuildStorage build storage based on configuration

Jump to

Keyboard shortcuts

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