di

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2021 License: Apache-2.0 Imports: 36 Imported by: 0

Documentation

Overview

Package di is a package that implements Dependency Injection through methods that create the options needed for structs to be created.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DI

type DI struct {
	Home string

	ExitMode int // Exit mode either exit.None or exit.Panic. See package exit for context

	// No Colour output when running commands.
	NoColour bool
	// Project name, normally supplied by the start sub command.
	ProjectName      string
	PathMetadataDir  string
	PathTemplateConf string
	PathRepoDir      string
	PathTemplateDir  string
	PathUserConf     string
	SqliteDB         string
	ModelDB          string
	Stdin            io.Reader
	Stderr           io.Writer
	Stdout           io.Writer
	// contains filtered or unexported fields
}

DI provides Dependency Injection Container for resources & services.

func New

func New(opts *Options) *DI

New get di using the supplied "home" directory option. Any Dependency Injection (DI) configuration created by di is then contextualized by the home variable. For instance when home is set the paths...

{{home}}/.kick/config.yml
{{home}}/.kick/templates.yml
{{home}}/.kick/metadata/metadata.db
{{home}}/.kick/templates
etc..

are then factored in when creating dependency injections.

If initialization is needed for testing then the initialize package can be used. For example

set := New(&Options{home: "/tmp/tmp_home"});
init := set.MakeInitialize()
init.Init()

will create the structures under "/tmp/tmp_home"

"home" must be explicitly set or a panic will ensue.

func (*DI) CallMakePlumbRepo

func (s *DI) CallMakePlumbRepo() callbacks.MakePlumb

CallMakePlumbRepo dependency injector

func (*DI) CallMakePlumbTemplate

func (s *DI) CallMakePlumbTemplate() callbacks.MakePlumb

CallMakePlumbTemplate dependency injector

func (*DI) ConfigFile

func (s *DI) ConfigFile() *config.File

ConfigFile load di from configuration file

func (*DI) LogLevel

func (s *DI) LogLevel(lvl logger.Level)

LogLevel Sets the log level

func (*DI) MakeCheck

func (s *DI) MakeCheck() *check.Check

MakeCheck dependency injector

func (*DI) MakeCheckVars

func (s *DI) MakeCheckVars() *checkvars.Check

MakeCheckVars inject prompt struct

func (*DI) MakeClient

func (s *DI) MakeClient() *client.Client

MakeClient dependency injector

func (*DI) MakeEnvs

func (s *DI) MakeEnvs() *env.Vars

MakeEnvs dependency injector

func (*DI) MakeErrorHandler

func (s *DI) MakeErrorHandler() *errs.Handler

MakeErrorHandler dependency injector

func (*DI) MakeExitHandler

func (s *DI) MakeExitHandler() *exit.Handler

MakeExitHandler dependency injector

func (*DI) MakeInit

func (s *DI) MakeInit() *initialize.Init

MakeInit dependency injector

func (*DI) MakeInstall

func (s *DI) MakeInstall() *install.Install

MakeInstall dependency injector

func (*DI) MakeList

func (s *DI) MakeList() *list.List

MakeList dependency injector

func (*DI) MakeLogFile

func (s *DI) MakeLogFile(logfile string) *os.File

MakeLogFile create a logfile and return the interface

func (*DI) MakeLoggerOutput

func (s *DI) MakeLoggerOutput(prefix string) *logger.Router

MakeLoggerOutput inject logger.OutputIface.

func (*DI) MakeORM

func (s *DI) MakeORM() *gorm.DB

MakeORM return ORM object.

func (*DI) MakeRemove

func (s *DI) MakeRemove() *remove.Remove

MakeRemove dependency injector

func (*DI) MakeRepo

func (s *DI) MakeRepo() *repo.Repo

MakeRepo dependency injector

func (*DI) MakeSearch

func (s *DI) MakeSearch() *search.Search

MakeSearch dependency injector

func (*DI) MakeSetup

func (s *DI) MakeSetup() *setup.Setup

MakeSetup dependency injector

func (*DI) MakeStart

func (s *DI) MakeStart() *start.Start

MakeStart dependency injector

func (*DI) MakeSync

func (s *DI) MakeSync() *sync.Sync

MakeSync dependency injector

func (*DI) MakeTableWriter

func (s *DI) MakeTableWriter() *tablewriter.Table

MakeTabwritter dependency injector

func (*DI) MakeTemplate

func (s *DI) MakeTemplate() *template.Template

MakeTemplate dependency injector

func (*DI) MakeUpdate

func (s *DI) MakeUpdate() *update.Update

MakeUpdate dependency injector

func (*DI) MakeVCS

func (s *DI) MakeVCS() *vcs.VCS

MakeVCS dependency injector

func (*DI) MakeValidate

func (s *DI) MakeValidate() *validator.Validate

MakeValidate dependency injector

type Options

type Options struct {
	Home     string    // Path to home directory
	DBPath   string    // SQLite DB path
	ExitMode int       // Valid values (exit.MNone, exit.MPanic) defaults to exit.MNone
	Stdin    io.Reader // Stdin injected
	Stdout   io.Writer // Stdout injected
	Stderr   io.Writer // Stderr injected
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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