helpers

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

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

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

func ArchiveDiagDirectory added in v0.2.0

func ArchiveDiagDirectory(outputFile, outputDir string) error

archiveDiagDirectory supports .tgz

func GZipDiag added in v0.2.0

func GZipDiag(zipFileName string, _ string, file string) error

func TarDiag added in v0.2.0

func TarDiag(tarFileName string, baseDir string, files []CollectedFile) error

Types

type CollectedFile added in v0.2.0

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

type CopyStrategyHC added in v0.2.0

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)
}

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 added in v0.2.0

func NewHCCopyStrategy(ddcfs Filesystem) *CopyStrategyHC

func (*CopyStrategyHC) ArchiveDiag added in v0.2.0

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

Archive calls out to the main archive function

func (*CopyStrategyHC) ClusterPath added in v0.2.0

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

func (*CopyStrategyHC) CreatePath added in v0.2.0

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

func (*CopyStrategyHC) GetTmpDir added in v0.3.0

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 added in v0.2.0

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
}

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 added in v0.2.0

type RealFileSystem struct {
}

Rea fileSystem wrapper

func NewRealFileSystem added in v0.2.0

func NewRealFileSystem() *RealFileSystem

func (RealFileSystem) Create added in v0.2.0

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

Create

func (RealFileSystem) Mkdir added in v0.2.0

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

Mkdir

func (RealFileSystem) MkdirAll added in v0.2.0

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

MkdirAll

func (RealFileSystem) MkdirTemp added in v0.2.0

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

MkdirTemp

func (RealFileSystem) Remove added in v0.2.0

func (f RealFileSystem) Remove(path string) error

Remove

func (RealFileSystem) RemoveAll added in v0.2.0

func (f RealFileSystem) RemoveAll(path string) error

RemoveAll

func (RealFileSystem) Stat added in v0.2.0

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

Stat

func (RealFileSystem) WriteFile added in v0.2.0

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

WriteFile

Jump to

Keyboard shortcuts

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