builder

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: MPL-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package builder handles building email templates

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ApprovalRequestEmail

type ApprovalRequestEmail struct {
	ReleaseVersion    string
	EnvironmentName   string
	PipelineType      models.PipelineType
	TodoTargetType    models.ToDoItemTargetType
	PipelineID        string
	NodePath          *string
	OrgName           string
	ProjectName       string
	EligibleApprovers []string
	ApprovalRules     []ApprovalRule
}

ApprovalRequestEmail is the email builder for approval requests

func (*ApprovalRequestEmail) Build

func (ar *ApprovalRequestEmail) Build(templateCtx *TemplateContext) (string, error)

Build returns the email html

func (*ApprovalRequestEmail) InitFromData

func (ar *ApprovalRequestEmail) InitFromData(data []byte) error

InitFromData creates the builder from raw data

func (*ApprovalRequestEmail) Type

func (ar *ApprovalRequestEmail) Type() EmailType

Type returns the type of email builder

type ApprovalRule

type ApprovalRule struct {
	Name     string
	Required int
}

ApprovalRule contains approval rule fields

type EmailBuilder

type EmailBuilder interface {
	Type() EmailType
	Build(templateCtx *TemplateContext) (string, error)
	InitFromData(data []byte) error
}

EmailBuilder is an interface for building emails

type EmailType

type EmailType string

EmailType is a constant representing the various types of emails

const (
	ApprovalRequestEmailType EmailType = "approval_request"
)

EmailType constant values

func EmailTypes

func EmailTypes() []EmailType

EmailTypes returns a list of email types

func (EmailType) NewBuilder

func (et EmailType) NewBuilder() (EmailBuilder, error)

NewBuilder returns a new builder

func (EmailType) TemplateFilename

func (et EmailType) TemplateFilename() string

TemplateFilename returns the template filename for this type

type MockEmailBuilder

type MockEmailBuilder struct {
	mock.Mock
}

MockEmailBuilder is an autogenerated mock type for the EmailBuilder type

func NewMockEmailBuilder

func NewMockEmailBuilder(t mockConstructorTestingTNewMockEmailBuilder) *MockEmailBuilder

NewMockEmailBuilder creates a new instance of MockEmailBuilder. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.

func (*MockEmailBuilder) Build

func (_m *MockEmailBuilder) Build(templateCtx *TemplateContext) (string, error)

Build provides a mock function with given fields: templateCtx

func (*MockEmailBuilder) InitFromData

func (_m *MockEmailBuilder) InitFromData(data []byte) error

InitFromData provides a mock function with given fields: data

func (*MockEmailBuilder) Type

func (_m *MockEmailBuilder) Type() EmailType

Type provides a mock function with given fields:

type TemplateContext

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

TemplateContext is the context for building templates

func NewTemplateContext

func NewTemplateContext(frontendURL string, footer string) *TemplateContext

NewTemplateContext creates a new template context

func (*TemplateContext) ExecuteTemplate

func (t *TemplateContext) ExecuteTemplate(filename string, data interface{}) (string, error)

ExecuteTemplate executes the template and returns the html

func (*TemplateContext) WrapInBaseTemplate

func (t *TemplateContext) WrapInBaseTemplate(body string) (string, error)

WrapInBaseTemplate wraps the body in the base template html

Jump to

Keyboard shortcuts

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