collection

package
v0.10.1 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2024 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PackageManagerRPM    = "rpm"
	PackageManagerDebian = "dpkg"
)
View Source
const (
	ServiceManagerSystemD = "systemd"
	ServiceManagerSysV    = "sysv"
)
View Source
const DefaultTimeout = 5 * time.Second

Variables

View Source
var ErrNoPackageManager = errors.New("could not detect a supported package manager")

ErrNoPackageManager is returned when we could not detect one.

View Source
var ErrNoServiceManager = errors.New("could not detect a supported service manager")

ErrNoServiceManager is returned when we could not detect one.

View Source
var FoundPackageManager string
View Source
var FoundServiceManager string

FoundServiceManager remembers the current service manager found.

Functions

func DetectGitInstalled

func DetectGitInstalled() bool

func DetectPackageManager

func DetectPackageManager() string

func DetectServiceManager

func DetectServiceManager() string

func ExecGitCommand

func ExecGitCommand(dir string, command ...string) ([]byte, error)

func FindServices

func FindServices(pattern string) (map[string]string, error)

func FindServicesSysV

func FindServicesSysV(pattern string) (map[string]string, error)

func FindServicesSystemd

func FindServicesSystemd(pattern string) (map[string]string, error)

func GetServiceStatusRaw

func GetServiceStatusRaw(name string) ([]byte, error)

func IsGitRepository

func IsGitRepository(path string) (string, bool)
func IsSymlink(info os.FileInfo) bool

func ListInstalledPackagesRaw

func ListInstalledPackagesRaw(pattern ...string) ([]byte, error)

func LoadCommandOutput

func LoadCommandOutput(command string, arguments ...string) (output []byte, err error)

func LoadCommandOutputWithTimeout

func LoadCommandOutputWithTimeout(timeout time.Duration, command string, arguments ...string) (
	output []byte, err error)

func ProcessList

func ProcessList() (processList []ps.Process, err error)

ProcessList returns array of type ps.Process. Error returns nil if no error.

func ProcessListFilter

func ProcessListFilter(filter []string) (processList []ps.Process, err error)

ProcessListFilter returns string array of processes with given filter. Error returns nil if no error.

Types

type Collection

type Collection struct {
	Output                 *zip.Writer
	Log                    *logrus.Logger
	LogData                *bytes.Buffer
	ExecTimeout            time.Duration
	Obfuscators            []*obfuscate.Obfuscator
	Detailed               bool
	JournalLoggingInterval string
}

func New

func New(w io.Writer) (c *Collection)

func (*Collection) AddCommandOutput

func (c *Collection) AddCommandOutput(file, command string, arguments ...string)

func (*Collection) AddCommandOutputWithTimeout

func (c *Collection) AddCommandOutputWithTimeout(file string,
	timeout time.Duration, command string, arguments ...string)

func (*Collection) AddFileDataRaw

func (c *Collection) AddFileDataRaw(fileName string, data []byte)

func (*Collection) AddFileFromReaderRaw

func (c *Collection) AddFileFromReaderRaw(name string, r io.Reader) (err error)

func (*Collection) AddFileJSON

func (c *Collection) AddFileJSON(fileName string, data []byte)

func (*Collection) AddFileToOutput

func (c *Collection) AddFileToOutput(file *File) (err error)

AddFileToOutput adds a single file while calling any obfuscator.

func (*Collection) AddFileToOutputRaw

func (c *Collection) AddFileToOutputRaw(file *File) (err error)

AddFileToOutputRaw adds the file directly to ZIP output.

No obfuscation is applied.

func (*Collection) AddFileYAML

func (c *Collection) AddFileYAML(fileName string, data interface{})

func (*Collection) AddFiles

func (c *Collection) AddFiles(prefix, source string)

func (*Collection) AddFilesIfFound

func (c *Collection) AddFilesIfFound(prefix string, sources ...string)

func (*Collection) AddGitRepoInfo

func (c *Collection) AddGitRepoInfo(fileName, path string)

func (*Collection) AddInstalledPackagesRaw

func (c *Collection) AddInstalledPackagesRaw(fileName string, pattern ...string)

func (*Collection) AddJournalLog

func (c *Collection) AddJournalLog(fileName, service string)

func (*Collection) AddLogToOutput

func (c *Collection) AddLogToOutput() (err error)

func (*Collection) AddServiceStatusRaw

func (c *Collection) AddServiceStatusRaw(fileName, name string)

func (*Collection) ClearObfuscators

func (c *Collection) ClearObfuscators()

func (*Collection) Close

func (c *Collection) Close() error

func (*Collection) RegisterObfuscator

func (c *Collection) RegisterObfuscator(o *obfuscate.Obfuscator)

func (*Collection) RegisterObfuscators

func (c *Collection) RegisterObfuscators(list ...*obfuscate.Obfuscator)

type File

type File struct {
	Name     string
	Source   string
	Modified time.Time
	Data     []byte

	io.Writer
}

func LoadFiles

func LoadFiles(prefix, source string) (files []*File, err error)

func LoadFilesFromDirectory

func LoadFilesFromDirectory(prefix, source string) (files []*File, err error)

func LoadFilesFromGlob

func LoadFilesFromGlob(prefix, source string) (files []*File, err error)

func NewFile

func NewFile(name string) *File

func NewFileFromReader

func NewFileFromReader(name string, r io.Reader) (*File, error)

func (*File) Write

func (f *File) Write(p []byte) (n int, err error)

type GitRepoInfo

type GitRepoInfo struct {
	Path       string
	HeadCommit string
	Remotes    string
	Describe   string
	Status     string
}

func LoadGitRepoInfo

func LoadGitRepoInfo(path string) (*GitRepoInfo, error)

type JournalElement

type JournalElement struct {
	Service string
}

Jump to

Keyboard shortcuts

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