database

package
v0.0.0-...-fa22197 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DB *gorm.DB

Functions

func FetchConfig

func FetchConfig() ([]models.CoreConfig, error)

FetchConfig retrieves all configuration records from the database. It returns a slice of CoreConfig models and an error. The error is non-nil if any issues occur during the database operation.

Example usage:

configs, err := FetchConfig()
if err != nil {
    // Handle the error
}

Returns:

([]models.CoreConfig, error) : A slice of CoreConfig models and an error (if any)

func FetchSSMParams

func FetchSSMParams() ([]models.SSMParameters, error)

func StoreConfig

func StoreConfig(config []models.CoreConfig) ([]models.CoreConfig, error)

StoreConfig stores the given configuration in the database. It uses a transaction to ensure all operations are atomic. If any of the operations fail, it will rollback the transaction and return an error. In case of a conflict on the key field, it updates the existing record's value field with the new value.

The function accepts a slice of CoreConfig models and returns the updated configurations and an error. The error is non-nil if any issues occur during the database operation.

Example usage:

updatedConfigs, err := StoreConfig(configs)
if err != nil {
    // Handle the error
}

Parameters:

config : A slice of CoreConfig models to be stored in the database

Returns:

([]models.CoreConfig, error) : A slice of updated CoreConfig models and error (if any)

Types

type Datastore

type Datastore interface {
	FetchCoreParams() ([]models.CoreConfig, error)
	FetchSSMParams() ([]models.SSMParameters, error)
	StoreSSMParams(p []config.SSMParameter, owner string) error
	StoreDeployment(p models.Deployment) (uint, error)
	UpdateApplicationStatus(deploymentid uint, application string, displayName string, status string) error
	FetchDeploymentIDByName(deploymentname string) (uint, error)
	FetchAllApplicationStatus() ([]models.Deployment, error)
	FetchAllApplicationStatusByDeployment(deploymentid uint) ([]models.Application, error)
	AddToAudit(operation application.AuditLine, owner string) error
	FindLastAuditLineByOperation(operation application.AuditLine) (models.Audit, error)

	FetchDeploymentNames() ([]string, error)
	RemoveDeploymentByName(name string) error
	RemoveApplicationByName(deploymentName string, applicationName string) error
}

func NewGormDatastore

func NewGormDatastore() (Datastore, error)

type GormDatastore

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

func (GormDatastore) AddToAudit

func (g GormDatastore) AddToAudit(operation application.AuditLine, owner string) error

func (GormDatastore) FetchAllApplicationStatus

func (g GormDatastore) FetchAllApplicationStatus() ([]models.Deployment, error)

func (GormDatastore) FetchAllApplicationStatusByDeployment

func (g GormDatastore) FetchAllApplicationStatusByDeployment(deploymentid uint) ([]models.Application, error)

func (GormDatastore) FetchCoreParams

func (g GormDatastore) FetchCoreParams() ([]models.CoreConfig, error)

func (GormDatastore) FetchDeploymentIDByName

func (g GormDatastore) FetchDeploymentIDByName(deploymentID string) (uint, error)

func (GormDatastore) FetchDeploymentNames

func (g GormDatastore) FetchDeploymentNames() ([]string, error)

func (GormDatastore) FetchSSMParams

func (g GormDatastore) FetchSSMParams() ([]models.SSMParameters, error)

func (GormDatastore) FindLastAuditLineByOperation

func (g GormDatastore) FindLastAuditLineByOperation(operation application.AuditLine) (models.Audit, error)

func (GormDatastore) RemoveApplicationByName

func (g GormDatastore) RemoveApplicationByName(deploymentName string, applicationName string) error

func (GormDatastore) RemoveDeploymentByName

func (g GormDatastore) RemoveDeploymentByName(name string) error

func (GormDatastore) StoreDeployment

func (g GormDatastore) StoreDeployment(model models.Deployment) (uint, error)

func (GormDatastore) StoreSSMParams

func (g GormDatastore) StoreSSMParams(p []config.SSMParameter, owner string) error

func (GormDatastore) UpdateApplicationStatus

func (g GormDatastore) UpdateApplicationStatus(deploymentID uint, targetAppName string, displayName string, newStatus string) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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