database

package
v0.0.0-...-ff4b512 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FailedImports = "failed_imports"
	LastImport    = "last_successful_import"
)

Variables

This section is empty.

Functions

func Connect

func Connect(host, user, password, name string) (*gorm.DB, error)

func Persist

func Persist(db *gorm.DB, info map[string]string) error

func Prune

func Prune(db *gorm.DB, keep time.Time) error

func Retrieve

func Retrieve(db *gorm.DB, keys ...string) (info map[string]string, err error)

Types

type ActualState

type ActualState struct {
	Target
	State  string    `gorm:"type:state;not null"`
	ScanID time.Time `gorm:"primaryKey;index"`
}

func CurrentState

func CurrentState(db *gorm.DB) (state []ActualState, err error)

func StateAt

func StateAt(db *gorm.DB, id time.Time) (state []ActualState, err error)

func (ActualState) MarshalJSON

func (s ActualState) MarshalJSON() ([]byte, error)

type Diff

type Diff struct {
	Target
	ExpectedState string
	ActualState   string
	ScanID        time.Time
	Comment       string
}

func DiffExpected

func DiffExpected(db *gorm.DB) (diff []Diff, err error)

func (Diff) MarshalJSON

func (d Diff) MarshalJSON() ([]byte, error)

type DiffAB

type DiffAB struct {
	Target
	StateA string
	StateB string
	ScanA  time.Time
	ScanB  time.Time
}

func DiffOne

func DiffOne(db *gorm.DB, id time.Time) (diff []DiffAB, err error)

func DiffTwo

func DiffTwo(db *gorm.DB, id1, id2 time.Time) (diff []DiffAB, err error)

func (DiffAB) MarshalJSON

func (d DiffAB) MarshalJSON() ([]byte, error)

type ExpectedState

type ExpectedState struct {
	Target
	State   string `gorm:"type:state;not null"`
	Comment string `gorm:"not null"`
}

func Expected

func Expected(db *gorm.DB) (state []ExpectedState, err error)

func (ExpectedState) MarshalJSON

func (s ExpectedState) MarshalJSON() ([]byte, error)

type Info

type Info struct {
	Key   string `gorm:"primaryKey"`
	Value string
}

func (Info) TableName

func (Info) TableName() string

type Scan

type Scan struct {
	ID    time.Time
	Ports []ActualState `gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
}

func Scans

func Scans(db *gorm.DB) (scans []Scan, err error)

func (Scan) MarshalJSON

func (s Scan) MarshalJSON() ([]byte, error)

type Target

type Target struct {
	Address  string `gorm:"type:inet;primaryKey"`
	Port     uint16 `gorm:"check:port > 0 AND port < 65536;primaryKey;autoIncrement:false"`
	Protocol string `gorm:"type:protocol;primaryKey"`
}

Jump to

Keyboard shortcuts

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