config

package
v0.0.0-...-c8e4983 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package file provides the capability to parse from disk a configuration file.

Index

Constants

View Source
const (
	CtoldPathToken = "${CTOLD}"
	CtoldTagToken  = "${CTOLD.TAG}"
	CtoldLastToken = "${CTOLD.REV}"
	DateTimeToken  = "${DATETIME.NOW}"
)
View Source
const (
	//CtoldRepoDefault  = "http://rstok3-dev02:3690/svn/FSAS_CTOLD_Source"
	CtoldRepoDefault  = "https://github.com/ardnew/ctoldup"
	CtoldTagDefault   = "trunk"
	CtoldLocalDefault = ".ctoldup"
	CtoldLastDefault  = ""
)

Variables

View Source
var Permissions os.FileMode = 0600

Permissions defines the default permissions of config files written to disk.

Functions

This section is empty.

Types

type CompressConfig

type CompressConfig struct {
	Path      string `yaml:"path"`
	Overwrite bool   `yaml:"overwrite"`
	Method    string `yaml:"method"`
	Level     int    `yaml:"level"`
}

type CompressMap

type CompressMap map[string]CompressConfig

type Config

type Config struct {
	Ctold    CtoldConfig `yaml:"ctold"`
	Merge    MergeMap    `yaml:"merge"`
	Compress CompressMap `yaml:"compress"`
	// contains filtered or unexported fields
}

Config represents a configuration file, containing the CTOLD and destination settings.

func New

func New(filePath string) *Config

New constructs a new config file at the given file path, initialized with all default data. The returned file is stored in-memory only. The Write method must be called to write the file to disk.

func Parse

func Parse(init bool, filePath string) (*Config, error)

Parse parses the configuration file into the returned Config struct, or returns a Config struct with default configuration if the configuration file does not exist. Returns a nil Config and descriptive error if the given path is invalid.

func (*Config) CompressAll

func (cfg *Config) CompressAll() error

func (*Config) MergeAll

func (cfg *Config) MergeAll() error

func (*Config) ReplaceTokens

func (cfg *Config) ReplaceTokens(str string) string

func (*Config) Write

func (cfg *Config) Write() error

Write formats and writes the receiver Config cfg's configuration to disk. Returns an error if formatting or writing fails.

type CtoldConfig

type CtoldConfig struct {
	Repo  string `yaml:"repo"`
	Tag   string `yaml:"tag"`
	Local string `yaml:"local"`
	Last  string `yaml:"last"`
	// contains filtered or unexported fields
}

func (*CtoldConfig) LastValid

func (c *CtoldConfig) LastValid() bool

func (*CtoldConfig) SetPath

func (c *CtoldConfig) SetPath(path string)

func (*CtoldConfig) Url

func (c *CtoldConfig) Url() string

func (*CtoldConfig) Wc

func (c *CtoldConfig) Wc() string

type DirectoryNotFoundError

type DirectoryNotFoundError string

func (DirectoryNotFoundError) Error

func (e DirectoryNotFoundError) Error() string

Error returns the error message for DirectoryNotFoundError.

type FileExistsError

type FileExistsError string

func (FileExistsError) Error

func (e FileExistsError) Error() string

Error returns the error message for FileExistsError.

type InvalidPathError

type InvalidPathError string

func (InvalidPathError) Error

func (e InvalidPathError) Error() string

Error returns the error message for InvalidPathError.

type MergeConfig

type MergeConfig struct {
	Into   string `yaml:"into"`
	Roster bool   `yaml:"roster"`
}

type MergeMap

type MergeMap map[string]MergeConfig

type NotRegularFileError

type NotRegularFileError string

func (NotRegularFileError) Error

func (e NotRegularFileError) Error() string

Error returns the error message for NotRegularFileError.

Jump to

Keyboard shortcuts

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