utils

package
v0.0.0-...-752702c Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const DefaultLogFormat = "[%Level] [%Date %Time]@%File.%Line %Msg%n"
View Source
const DefaultLogLevel = "info,warn,error"
View Source
const DefaultLogOutput = "/var/log/lastore/daemon.log"

Variables

This section is empty.

Functions

func EnsureBaseDir

func EnsureBaseDir(fpath string) error

EnsureBaseDir make sure the parent directory of fpath exists

func FilterExecOutput

func FilterExecOutput(cmd *exec.Cmd, timeout time.Duration, filter func(line string) bool) ([]string, error)

func OpenURL

func OpenURL(url string) (io.ReadCloser, error)

OpenURL open the url for reading It will reaturn error if open failed or the StatusCode is bigger than 299 NOTE: the return reader need be closed

func RemoteCatLine

func RemoteCatLine(url string) (string, error)

func RunCommand

func RunCommand(prog string, args ...string) (string, error)

func SetLogger

func SetLogger(levels, format, output string) *dbus.Error

func SetSeelogger

func SetSeelogger(levels string, format string, output string) error

func TeeToFile

func TeeToFile(in io.Reader, fpath string, handler func(io.Reader) error) error

TeeToFile invoke the handler with a new io.Reader which created by TeeReader in and the fpath's writer

func ValidURL

func ValidURL(url string) bool

func WriteData

func WriteData(fpath string, data interface{}) error

Types

type OSTree

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

func NewOSTree

func NewOSTree(repo string, remote string) (*OSTree, error)

func (*OSTree) Cat

func (tree *OSTree) Cat(branch string, fpath string) (string, error)

func (*OSTree) Checkout

func (tree *OSTree) Checkout(branch string, target string, force bool) error

func (*OSTree) HasBranch

func (tree *OSTree) HasBranch(branch string) bool

func (*OSTree) List

func (tree *OSTree) List(branch string, root string) (string, error)

func (*OSTree) NeedCheckout

func (tree *OSTree) NeedCheckout(branch string, target string) bool

NeedCheckout check whether the target content by target/.checkout_commit file

func (*OSTree) Pull

func (tree *OSTree) Pull(branch string) error

func (*OSTree) RemoteURL

func (tree *OSTree) RemoteURL() string

Jump to

Keyboard shortcuts

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