dumper

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package dumper provides configuration dumper implementations.

The dumper package implements the [Dumper] interface defined in the parent config package. Dumpers write configuration data to various destinations such as files or remote services.

Available Dumpers

  • File: Write configuration to files with various formats

Example

Creating a file dumper:

encoder, _ := codec.GetEncoder(codec.TypeYAML)
fileDumper := dumper.NewFile("output.yaml", encoder)
err := fileDumper.Dump(context.Background(), &configMap)

Creating a file dumper with custom permissions:

fileDumper := dumper.NewFileWithPermissions("output.yaml", encoder, 0600)

Index

Constants

View Source
const (
	// DefaultFilePermissions represents the default file permissions for dumped configuration files.
	// Files are created with read/write permissions for the owner and read permissions for group and others (0644).
	DefaultFilePermissions = 0o644
)

Variables

This section is empty.

Functions

This section is empty.

Types

type File

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

File represents a configuration dumper that writes data to a file. It supports customizable file permissions and uses encoders to convert configuration data to the appropriate format.

func NewFile

func NewFile(path string, encoder codec.Encoder) *File

NewFile creates a new File dumper that writes configuration to the specified file path. It uses default file permissions of 0644. The encoder parameter determines how the configuration data is formatted.

func NewFileWithPermissions

func NewFileWithPermissions(path string, encoder codec.Encoder, permissions os.FileMode) *File

NewFileWithPermissions creates a new File dumper with custom file permissions. This allows control over the file security and access rights. Use this when you need more restrictive permissions (e.g., 0600 for sensitive configuration).

func (*File) Dump

func (f *File) Dump(_ context.Context, values *map[string]any) error

Dump writes the provided configuration values to the file. It encodes the values using the configured encoder and writes them atomically.

Errors:

  • Returns error if encoding fails
  • Returns error if writing to the file fails

Jump to

Keyboard shortcuts

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