helpers

package
v1.0.1 Latest Latest
Warning

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

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

Documentation

Overview

helpers package provides some general functions that do not have a good home

helpers package provides different functionality

helpers module creates a strategy to determine, where to put the files we copy from the cluster.

Index

Constants

View Source
const DirPerms fs.FileMode = 0750

Variables

This section is empty.

Functions

This section is empty.

Types

type CollectedFile

type CollectedFile struct {
	Path string `json:"path"`
	Size int64  `json:"size"`
}

type CopyStrategyHC

type CopyStrategyHC struct {
	StrategyName string     // the name of the output strategy (defasult, healthcheck etc)
	TmpDir       string     // tmp dir used for staging files
	BaseDir      string     // the base dir of where the output is routed
	Fs           Filesystem // filesystem interface (so we can pass in realof fake filesystem, assists testing)
	TimeService  TimeService
}

This struct holds the details we need to copy files. The strategy is used to determine where and in what format we copy the files

func NewHCCopyStrategy

func NewHCCopyStrategy(ddcfs Filesystem, timeService TimeService, tmpDir string) *CopyStrategyHC

func (*CopyStrategyHC) ArchiveDiag

func (s *CopyStrategyHC) ArchiveDiag(o string, outputLoc string) error

Archive calls out to the main archive function

func (*CopyStrategyHC) Close added in v0.9.0

func (s *CopyStrategyHC) Close()

func (*CopyStrategyHC) ClusterPath

func (s *CopyStrategyHC) ClusterPath() (path string, err error)

func (*CopyStrategyHC) CreatePath

func (s *CopyStrategyHC) CreatePath(fileType, source, nodeType string) (path string, err error)

func (*CopyStrategyHC) GetTmpDir

func (s *CopyStrategyHC) GetTmpDir() string

type FakeFile

type FakeFile struct {
}

Fake File

func (*FakeFile) Close

func (f *FakeFile) Close() error

Close

func (*FakeFile) Name

func (f *FakeFile) Name() string

Name

func (*FakeFile) Sync

func (f *FakeFile) Sync() error

Sync

func (*FakeFile) Write

func (f *FakeFile) Write(b []byte) (n int, err error)

Write

type FakeFileSystem

type FakeFileSystem struct {
}

Fake filesystem wrapper

func NewFakeFileSystem

func NewFakeFileSystem() *FakeFileSystem

func (FakeFileSystem) Create

func (f FakeFileSystem) Create(_ string) (File, error)

Create

func (FakeFileSystem) Mkdir

func (f FakeFileSystem) Mkdir(_ string, _ os.FileMode) error

Mkdir

func (FakeFileSystem) MkdirAll

func (f FakeFileSystem) MkdirAll(_ string, _ os.FileMode) error

MkdirAll

func (FakeFileSystem) MkdirTemp

func (f FakeFileSystem) MkdirTemp(name string, pattern string) (string, error)

MkdirTemp

func (FakeFileSystem) Remove

func (f FakeFileSystem) Remove(_ string) error

Remove

func (FakeFileSystem) RemoveAll

func (f FakeFileSystem) RemoveAll(_ string) error

RemoveAll

func (FakeFileSystem) Stat

func (f FakeFileSystem) Stat(name string) (os.FileInfo, error)

Stat

func (FakeFileSystem) WriteFile

func (f FakeFileSystem) WriteFile(_ string, _ []byte, _ os.FileMode) error

Writefile

type File

type File interface {
	Name() string
	Write(b []byte) (n int, err error)
	Sync() error
	Close() error
}

type Filesystem

type Filesystem interface {
	Stat(name string) (os.FileInfo, error)
	Create(name string) (File, error)
	MkdirAll(path string, perm os.FileMode) error
	Mkdir(path string, perm os.FileMode) error
	MkdirTemp(name string, pattern string) (string, error)
	RemoveAll(path string) error
	Remove(name string) error
	WriteFile(name string, data []byte, perms os.FileMode) error
}

fshelper provides functions to wrapper os file system calls to better facilitate testing

type RealFile

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

Real file

func (*RealFile) Close

func (f *RealFile) Close() error

Close

func (*RealFile) Name

func (f *RealFile) Name() string

Name

func (*RealFile) Sync

func (f *RealFile) Sync() error

Sync

func (*RealFile) Write

func (f *RealFile) Write(b []byte) (n int, err error)

Write

type RealFileSystem

type RealFileSystem struct {
}

Rea fileSystem wrapper

func NewRealFileSystem

func NewRealFileSystem() *RealFileSystem

func (RealFileSystem) Create

func (f RealFileSystem) Create(name string) (File, error)

Create

func (RealFileSystem) Mkdir

func (f RealFileSystem) Mkdir(name string, perms os.FileMode) error

Mkdir

func (RealFileSystem) MkdirAll

func (f RealFileSystem) MkdirAll(name string, perms os.FileMode) error

MkdirAll

func (RealFileSystem) MkdirTemp

func (f RealFileSystem) MkdirTemp(name string, pattern string) (dir string, err error)

MkdirTemp

func (RealFileSystem) Remove

func (f RealFileSystem) Remove(path string) error

Remove

func (RealFileSystem) RemoveAll

func (f RealFileSystem) RemoveAll(path string) error

RemoveAll

func (RealFileSystem) Stat

func (f RealFileSystem) Stat(name string) (os.FileInfo, error)

Stat

func (RealFileSystem) WriteFile

func (f RealFileSystem) WriteFile(name string, data []byte, perms os.FileMode) error

WriteFile

type RealTimeService added in v0.6.0

type RealTimeService struct {
}

func (*RealTimeService) GetNow added in v0.6.0

func (r *RealTimeService) GetNow() time.Time

type TimeService added in v0.6.0

type TimeService interface {
	GetNow() time.Time
}

Jump to

Keyboard shortcuts

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