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 ¶
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 ¶
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 ¶
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).