templates

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: May 17, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewService

func NewService(db *gorm.DB) domain.TemplatesService

NewService returns repository struct

Types

type Repository

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

Repository talks to the store to read or insert data

func NewRepository

func NewRepository(db *gorm.DB) *Repository

NewRepository returns repository struct

func (Repository) Delete

func (r Repository) Delete(name string) error

func (Repository) GetByName

func (r Repository) GetByName(name string) (*Template, error)

func (Repository) Index

func (r Repository) Index(tag string) ([]Template, error)

func (Repository) Migrate

func (r Repository) Migrate() error

func (Repository) Render

func (r Repository) Render(name string, requestVariables map[string]string) (string, error)

func (Repository) Upsert

func (r Repository) Upsert(template *Template) (*Template, error)

type Service

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

Service handles business logic

func (Service) Delete

func (service Service) Delete(name string) error

func (Service) GetByName

func (service Service) GetByName(name string) (*domain.Template, error)

func (Service) Index

func (service Service) Index(tag string) ([]domain.Template, error)

func (Service) Migrate

func (service Service) Migrate() error

func (Service) Render

func (service Service) Render(name string, body map[string]string) (string, error)

func (Service) Upsert

func (service Service) Upsert(template *domain.Template) (*domain.Template, error)

type Template

type Template struct {
	ID        uint `gorm:"primarykey"`
	CreatedAt time.Time
	UpdatedAt time.Time
	Name      string `gorm:"index:idx_template_name,unique"`
	Body      string
	Tags      pq.StringArray `gorm:"type:text[];index:idx_tags,type:gin"`
	Variables string         `gorm:"type:jsonb" sql:"type:jsonb" `
}

type TemplatesRepository

type TemplatesRepository interface {
	Upsert(*Template) (*Template, error)
	Index(string) ([]Template, error)
	GetByName(string) (*Template, error)
	Delete(string) error
	Render(string, map[string]string) (string, error)
	Migrate() error
}

TemplatesRepositoryMock interface

type TemplatesRepositoryMock

type TemplatesRepositoryMock struct {
	mock.Mock
}

TemplatesRepositoryMock is an autogenerated mock type for the TemplatesRepositoryMock type

func (*TemplatesRepositoryMock) Delete

func (_m *TemplatesRepositoryMock) Delete(_a0 string) error

Delete provides a mock function with given fields: _a0

func (*TemplatesRepositoryMock) GetByName

func (_m *TemplatesRepositoryMock) GetByName(_a0 string) (*Template, error)

GetByName provides a mock function with given fields: _a0

func (*TemplatesRepositoryMock) Index

func (_m *TemplatesRepositoryMock) Index(_a0 string) ([]Template, error)

Index provides a mock function with given fields: _a0

func (*TemplatesRepositoryMock) Migrate

func (_m *TemplatesRepositoryMock) Migrate() error

Migrate provides a mock function with given fields:

func (*TemplatesRepositoryMock) Render

func (_m *TemplatesRepositoryMock) Render(_a0 string, _a1 map[string]string) (string, error)

Render provides a mock function with given fields: _a0, _a1

func (*TemplatesRepositoryMock) Upsert

func (_m *TemplatesRepositoryMock) Upsert(_a0 *Template) (*Template, error)

Upsert provides a mock function with given fields: _a0

Jump to

Keyboard shortcuts

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