Documentation
¶
Index ¶
- func CreateExcl(path string, perm os.FileMode) (*os.File, error)
- func CreateNoLinks(path string, perm os.FileMode) (*os.File, error)
- func GetAuthConfig(_ context.Context, optionalCert *x509.Certificate) (*tls.Config, error)
- func GetAuthContext(ctx context.Context, tokenPath string) context.Context
- func GetPerRPCCreds(tokenPath string) oauth.TokenSource
- func NoNullByteString(s string) bool
- func NoNullByteURL(u string) bool
- func OpenNoLinks(path string) (*os.File, error)
- func ParseSizeToMB(sizeStr string) (uint64, error)
- func ReadFileNoLinks(path string) ([]byte, error)
- func ReadFileTrimmed(path string) (string, error)
- func ReadFromCommand(executor CmdExecutor, command string, args ...string) (stdout []byte, err error)
- func TrimPrefix(s, prefix string) string
- func TrimSpace(s string) string
- func TrimSpaceInBytes(b []byte) string
- type CmdExecutor
- type Command
- type ExecCmd
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateExcl ¶
CreateExcl creates a new file at the given path with the specified permissions, failing if the file exists or if the path is a symbolic or hard link.
func CreateNoLinks ¶
CreateNoLinks creates or truncates the file at the given path with the specified permissions, failing if the path is a symbolic or hard link.
func GetAuthConfig ¶
GetAuthConfig returns a TLS configuration for secure communication with the server.
func GetAuthContext ¶
GetAuthContext creates a new context with an authorization header.
func GetPerRPCCreds ¶
func GetPerRPCCreds(tokenPath string) oauth.TokenSource
GetPerRPCCreds returns a PerRPCCredentials object that can be used for gRPC authentication.
func NoNullByteString ¶
NoNullByteString checks if the provided string does not contain any null bytes.
func NoNullByteURL ¶
NoNullByteURL checks if the provided URL string does not contain any null bytes.
func OpenNoLinks ¶
OpenNoLinks opens the file at the given path for reading, failing if the path is a symbolic or hard link.
func ParseSizeToMB ¶ added in v1.7.1
ParseSizeToMB converts a size string (e.g., "16 GB", "1024 MB", "1 TB") to MB.
func ReadFileNoLinks ¶
ReadFileNoLinks reads and returns the contents of the file at the given path, failing if the path is a symbolic or hard link.
func ReadFileTrimmed ¶ added in v1.7.1
ReadFileTrimmed reads a file and returns its content as a string with whitespace trimmed.
func ReadFromCommand ¶ added in v1.7.1
func ReadFromCommand(executor CmdExecutor, command string, args ...string) (stdout []byte, err error)
ReadFromCommand executes a command in the operating system and returns the output, It returns the output from stdout and error if exists.
func TrimPrefix ¶ added in v1.7.1
TrimPrefix removes the specified prefix from the string and trims any leading or trailing whitespace.
func TrimSpaceInBytes ¶ added in v1.7.1
TrimSpaceInBytes converts a byte slice to a string and trims leading and trailing whitespace.
Types ¶
type CmdExecutor ¶ added in v1.7.1
CmdExecutor is a function type that takes a command name and its arguments, and returns a Command interface instance that can execute the command.
type Command ¶ added in v1.7.1
type Command interface {
// Output executes the command and returns its standard output as a byte slice.
Output() ([]byte, error)
// SetStderr sets the standard error output for the command to a provided strings.Builder.
SetStderr(stderr *strings.Builder)
}
Command interface defines the methods required for executing a command and capturing its output.
func ExecCmdExecutor ¶ added in v1.7.1
ExecCmdExecutor is a function that creates an ExecCmd instance for executing commands.
type ExecCmd ¶ added in v1.7.1
type ExecCmd struct {
// contains filtered or unexported fields
}
ExecCmd is a struct that implements the Command interface using the exec package to run commands.