util

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2020 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package util is a generated GoMock package.

Index

Constants

This section is empty.

Variables

Log is the shared Lumber Logger logging to console and after calling SetupLogging also to file

Functions

func CheckError

func CheckError(err error, msg string) bool

func CheckProperty

func CheckProperty(properties map[string]string, property string) (string, error)

func FailOnError

func FailOnError(err error, msg string)

func ReplacePathSeparators

func ReplacePathSeparators(path string) (newPath string)

func SetupLogging

func SetupLogging(verbose bool) error

SetupLogging is used to initialize the shared file Logger once the necessary setup config is available

func UnmarshalYaml

func UnmarshalYaml(text string, fileName string) (error, map[string]map[string]string)

UnmarshalYaml takes the contents of a yaml file and converts it to a map[string]map[string]string The yaml file should have the following format:

some-name-1:

  • list-key-1: "list-entry-1"
  • list-key-2: "list-entry-2"

some-name-2:

  • list-key-1: "list-entry-1"

Types

type FileReader

type FileReader interface {
	ReadFile(fileName string) (content []byte, err error)
	ReadDir(fileName string) ([]os.FileInfo, error)
}

A FileReader is an interface which encapsulates io/ioutil to make the code using it testable. Since the reading of the file is now behind an interface, we can easily mock it.

func NewFileReader

func NewFileReader() FileReader

NewFileReader creates a new FileReader. A FileReader is an interface which encapsulates io/ioutil to make the code using it testable. Since the reading of the file is now behind an interface, we can easily mock it.

func NewInMemoryFileReader

func NewInMemoryFileReader(originalDir string, transformers []func(string) string) (FileReader, error)

NewInMemoryFileReader creates a new in-memory file reader which reads all the original files once and stores them internally in-memory. This allows us to perform any modifications on the files later on

type MockFileReader

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

MockFileReader is a mock of FileReader interface

func NewMockFileReader

func NewMockFileReader(ctrl *gomock.Controller) *MockFileReader

NewMockFileReader creates a new mock instance

func (*MockFileReader) EXPECT

EXPECT returns an object that allows the caller to indicate expected use

func (*MockFileReader) ReadDir

func (m *MockFileReader) ReadDir(fileName string) ([]os.FileInfo, error)

ReadDir mocks base method

func (*MockFileReader) ReadFile

func (m *MockFileReader) ReadFile(fileName string) ([]byte, error)

ReadFile mocks base method

type MockFileReaderMockRecorder

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

MockFileReaderMockRecorder is the mock recorder for MockFileReader

func (*MockFileReaderMockRecorder) ReadDir

func (mr *MockFileReaderMockRecorder) ReadDir(fileName interface{}) *gomock.Call

ReadDir indicates an expected call of ReadDir

func (*MockFileReaderMockRecorder) ReadFile

func (mr *MockFileReaderMockRecorder) ReadFile(fileName interface{}) *gomock.Call

ReadFile indicates an expected call of ReadFile

type Template

type Template interface {
	ExecuteTemplate(data map[string]string) (string, error)
}

Template wraps the underlying templating logic and provides a means of setting config values just on one place. It is intended to be language-agnostic, the file type does not matter (yaml, json, ...)

func NewTemplate

func NewTemplate(fileName string) (Template, error)

NewTemplate creates a new template for the given file

func NewTemplateFromString

func NewTemplateFromString(name string, content string) (Template, error)

NewTemplateFromString creates a new template for the given string content

Jump to

Keyboard shortcuts

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