Documentation
¶
Overview ¶
Package config handles configuration files. Files are stored in a directory inside user's HOME. HOME is identified by using github.com/mitchellh/go-homedir.
Index ¶
- func Backup(filename string) error
- func BackupFiles() (fi []string, err error)
- func ConfigDir() (string, error)
- func ConfigFilePath() (string, error)
- func CreateDefault() error
- func Deploy() error
- func Edit(editor string) error
- func FileTemplates() (mp map[string]string, err error)
- func ProjectTemplates() (mp map[string]string, err error)
- func Reset(createBackup bool, backupFile string) error
- func Restore(filename string) error
- func TemplatePath(name string) (string, error)
- func Write(cfg ConfigMap) error
- type ConfigMap
- type Template
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Backup ¶
Backup creates a zip file from the "homedir/borrowedtime/templates" directory and stores it in the "homedir/borrowedtime/backups" directory. Go's zip directory is very basic so we use: https://github.com/mholt/archiver. If input is empty, file name will be timestamp.
func BackupFiles ¶
BackupFiles returns all files in the backup directory.
func ConfigFilePath ¶
ConfigFilePath returns the path of the config file.
func CreateDefault ¶
func CreateDefault() error
CreateDefault creates the default config file and overwrites whatever is at "borrowedtime/config.json", finally opens it with OS default editor.
func Deploy ¶
func Deploy() error
Deploy calls initiateConfig() to create the configuration structure and file. Returns an error if config already exists.
func FileTemplates ¶
FileTemplates returns returns map[filename]fullpath of all files inside the file template directory.
func ProjectTemplates ¶
ProjectTemplates returns returns map[filename]fullpath of all files inside the project template directory.
func Reset ¶
Reset creates a backup and then calls initiateConfig(overwrite=true) and overwrites deployment. If no backup filename is provided, it will create one based on timestamp.
func Restore ¶
Restore restores config.json and the templates directory from a backup file. Don't provide fullpath, just filename and extension.
func TemplatePath ¶
TemplatePath returns template path. Returns "" if the template does not exist. Template names should be passed without the extension. TODO: Make private.
Types ¶
type ConfigMap ¶
ConfigMap represents the contents of the config file.
func Read ¶
Read reads the configuration file at "homedir/borrowedtime/config.json" and returns a populated map[string]string of keys.