storage

package
v0.0.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrKaboom             = errors.New("Implement me! Kaboom!")
	ErrRecordIdOutOfBands = errors.New("Database Id can't be 0 for certs")
)

Functions

This section is empty.

Types

type CertDataService

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

func (*CertDataService) AllByExpiration

func (svc *CertDataService) AllByExpiration() ([]CertificateData, error)

func (*CertDataService) AllForIndexPage

func (svc *CertDataService) AllForIndexPage() ([]DisplayData, error)

func (*CertDataService) AllWCertsThatExpireSoon

func (svc *CertDataService) AllWCertsThatExpireSoon() ([]CertificateData, error)

func (*CertDataService) AllWebCertsThatMightExpireSoon

func (svc *CertDataService) AllWebCertsThatMightExpireSoon() ([]CertificateData, error)

func (*CertDataService) Destroy

func (svc *CertDataService) Destroy(certData *CertificateData) error

func (*CertDataService) FindById

func (svc *CertDataService) FindById(id int) (*CertificateData, error)

func (*CertDataService) Store

func (svc *CertDataService) Store(certData *CreateCertificateData) (*CertificateData, error)

func (*CertDataService) Update

func (svc *CertDataService) Update(certData *CertificateData) error

type CertificateData

type CertificateData struct {
	ID        int       `db:"id" json:"id"`
	Name      string    `db:"name" json:"name"`
	Subject   string    `db:"subject" json:"subject"`
	Type      string    `db:"type" json:"type"`
	NotAfter  time.Time `db:"not_after" json:"not_after"`
	UpdatedAt time.Time `db:"updated_at" json:"updated_at"`
	CreatedAt time.Time `db:"created_at" json:"created_at"`
}

func New

func New(name string, certInfo *certutils.CertInfo) *CertificateData

func (*CertificateData) ExpiresIn

func (cd *CertificateData) ExpiresIn() time.Duration

func (*CertificateData) ExpiresInString

func (cd *CertificateData) ExpiresInString() string

func (*CertificateData) Status

func (cd *CertificateData) Status() string

func (*CertificateData) ToDisplayData

func (cd *CertificateData) ToDisplayData() DisplayData

type CreateCertificateData

type CreateCertificateData struct {
	Name     string
	Subject  string
	Type     string
	NotAfter time.Time
}

CreateCertificateData used to create CertificateData record

type DisplayData

type DisplayData struct {
	ID        int       `json:"id"`
	Name      string    `json:"name"`
	Subject   string    `json:"subject"`
	Type      string    `json:"type"`
	ExpiresIn string    `json:"expires_in"`
	NotAfter  time.Time `json:"not_after"`
	Status    string    `json:"status"`
	Button    string    `json:"status"`
}

DisplayData has all data in final concrete format ready for display in eg. HTML template

type Migrator

type Migrator interface {
	Migrate(databaseURL string) error
}

type Reader

type Reader interface {
	FindById(id int) (*CertificateData, error)
	AllByExpiration() ([]CertificateData, error)
	AllWebCertsThatMightExpireSoon() ([]CertificateData, error)
	AllWCertsThatExpireSoon() ([]CertificateData, error)
}

type Repository

type Repository interface {
	Migrator
	Reader
	Writer
}

type Service

type Service interface {
	FindById(id int) (*CertificateData, error)
	AllByExpiration() ([]CertificateData, error)
	AllForIndexPage() ([]DisplayData, error)
	Store(createCertData *CreateCertificateData) (*CertificateData, error)
	Destroy(certData *CertificateData) error
	Update(certData *CertificateData) error
	AllWebCertsThatMightExpireSoon() ([]CertificateData, error)
	AllWCertsThatExpireSoon() ([]CertificateData, error)
}

func NewService

func NewService(repo Repository) Service

func NewTestMock

func NewTestMock() Service

type SqliteRepository

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

func NewSqliteRepository

func NewSqliteRepository(connectionPool *sqlx.DB) *SqliteRepository

func (*SqliteRepository) AllByExpiration

func (repo *SqliteRepository) AllByExpiration() ([]CertificateData, error)

func (*SqliteRepository) AllWCertsThatExpireSoon

func (repo *SqliteRepository) AllWCertsThatExpireSoon() ([]CertificateData, error)

func (*SqliteRepository) AllWebCertsThatMightExpireSoon

func (repo *SqliteRepository) AllWebCertsThatMightExpireSoon() ([]CertificateData, error)

func (*SqliteRepository) Destroy

func (repo *SqliteRepository) Destroy(certData *CertificateData) error

func (*SqliteRepository) FindById

func (repo *SqliteRepository) FindById(id int) (*CertificateData, error)

func (*SqliteRepository) Migrate

func (repo *SqliteRepository) Migrate(databaseURL string) error

func (*SqliteRepository) Store

func (repo *SqliteRepository) Store(certData *CreateCertificateData) (*CertificateData, error)

func (*SqliteRepository) Update

func (repo *SqliteRepository) Update(certData *CertificateData) error

type StorageTestMockService

type StorageTestMockService struct {
}

func (*StorageTestMockService) AllByExpiration

func (mock *StorageTestMockService) AllByExpiration() ([]CertificateData, error)

func (*StorageTestMockService) AllForIndexPage

func (mock *StorageTestMockService) AllForIndexPage() ([]DisplayData, error)

func (*StorageTestMockService) AllWCertsThatExpireSoon

func (mock *StorageTestMockService) AllWCertsThatExpireSoon() ([]CertificateData, error)

func (*StorageTestMockService) AllWebCertsThatMightExpireSoon

func (mock *StorageTestMockService) AllWebCertsThatMightExpireSoon() ([]CertificateData, error)

func (*StorageTestMockService) Destroy

func (mock *StorageTestMockService) Destroy(certData *CertificateData) error

func (*StorageTestMockService) FindById

func (mock *StorageTestMockService) FindById(id int) (*CertificateData, error)

func (*StorageTestMockService) Store

func (mock *StorageTestMockService) Store(createCertData *CreateCertificateData) (*CertificateData, error)

func (*StorageTestMockService) Update

func (mock *StorageTestMockService) Update(certData *CertificateData) error

type Writer

type Writer interface {
	Store(createCertData *CreateCertificateData) (*CertificateData, error)
	Destroy(certData *CertificateData) error
	Update(certData *CertificateData) error
}

Jump to

Keyboard shortcuts

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