folders

package
v1.4.2 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Manages the lifecycle of configuration folders for nginx

Index

Constants

View Source
const (
	R_OK = 4
	W_OK = 2
	X_OK = 1
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Available *Folder
	Enabled   *Folder
	Ext       string
	Recursive bool
	DirMode   os.FileMode
}

Config represents the set of files in the available and enabled folders

func New

func New(available, enabled string, ext string, recursive bool) (*Config, error)

Create the set of files

func (*Config) Create

func (c *Config) Create(name string, body []byte) error

Create a new configuration template

func (*Config) Delete

func (c *Config) Delete(name string) error

Delete a configuration template

func (*Config) Disable

func (c *Config) Disable(name string) error

Disable a configuration template

func (*Config) Enable

func (c *Config) Enable(name string) error

Enable a configuration template

func (*Config) Reload

func (c *Config) Reload() error

Reload the configuration

func (*Config) Render

func (c *Config) Render(name string) ([]byte, error)

Render a configuration template

func (Config) String

func (c Config) String() string

func (*Config) Template

func (c *Config) Template(name string) *Template

Return a configuration template by name

func (*Config) Templates

func (c *Config) Templates() []*Template

Return a list of all available configuration templates

func (*Config) Write

func (c *Config) Write(name string, body []byte) error

Write a new body

type File

type File struct {
	// Prefix
	Prefix string

	// Path to the file
	Path string

	// Hash of the file contents
	Hash string
	// contains filtered or unexported fields
}

func NewFile

func NewFile(prefix, path string) (*File, error)

func (*File) Copy

func (f *File) Copy(dest string, perm fs.FileMode) error

Copy a file from a source folder to a destination folder, making directories as needed

func (*File) Remove

func (f *File) Remove() error

Remove a file from a source folder

func (*File) Render

func (f *File) Render() ([]byte, error)

Return the body

func (File) String

func (f File) String() string

func (*File) Write

func (f *File) Write(data []byte) error

Write new body contents to a file. Returns ErrNotModified if the contents are identical

type Folder

type Folder struct {
	// Root path
	Root string

	// Map hash of file contents to files
	Files map[string]*File
}

func NewFolder

func NewFolder(root string, ext string, recursive bool) (*Folder, error)

func (Folder) String

func (f Folder) String() string

type Template

type Template struct {
	Name    string // Name should be unique
	Hash    string // Hash of the file contents
	Enabled bool   // Flag indicating if the template is enabled
}

Template represents a configuration template

func (Template) String

func (t Template) String() string

Jump to

Keyboard shortcuts

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