config

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Exists

func Exists(fs Filesystem) (bool, error)

Exists checks if the configuration file exists. It returns a boolean indicating the existence of the file and any error encountered.

func Write

func Write() error

Write writes the default configuration to the configuration file. It returns any error encountered during the operation.

Types

type Config

type Config struct {
	// WhoAmI indicates whether to prepend the user's identity to the output.
	WhoAmI bool `json:"prepend-whoami"`
	// AllowList is a list of allowed entities for the application.
	AllowList []string `json:"allow-list"`
}

Config represents the conditioners configuration. It includes fields for user preferences and settings.

func Read

func Read(fs Filesystem) (*Config, error)

Read is a placeholder function for reading the configuration file.

type FS

type FS struct{}

FS implements the Filesystem interface using the os package.

func (FS) ReadFile

func (f FS) ReadFile(name string) ([]byte, error)

ReadFile reads the file named by `name` and returns the contents. It leverages os.ReadFile to read the file and return its contents along with any error encountered.

func (FS) Stat

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

Stat returns the FileInfo structure describing the file. It uses os.Stat to obtain the FileInfo of the specified file, returning any errors encountered.

func (FS) WriteFile

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

WriteFile writes data to a file named by `name`. It creates or truncates the file named by `name`, writing the provided data with the specified permissions. It uses os.WriteFile to perform the operation, returning any errors encountered.

type Filesystem

type Filesystem interface {
	// ReadFile reads the file named by `name` and returns the contents.
	// It returns the file contents as a byte slice and any error encountered.
	ReadFile(name string) ([]byte, error)

	// Stat returns the FileInfo structure describing the file.
	// If there is an error, it will be of type *PathError.
	Stat(name string) (os.FileInfo, error)

	// WriteFile writes data to a file named by `name`.
	// If the file does not exist, WriteFile creates it with permissions `perm`;
	// otherwise WriteFile truncates it before writing.
	WriteFile(name string, data []byte, perm os.FileMode) error
}

Filesystem defines the operations available for interacting with the filesystem. It provides an abstraction over the standard file operations, allowing for easier testing and mocking.

Jump to

Keyboard shortcuts

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