mirror of
https://github.com/deadc0de6/dotdrop.git
synced 2026-02-11 05:34:17 +00:00
add variables from file doc and refactor to import_variables
This commit is contained in:
38
README.md
38
README.md
@@ -84,6 +84,7 @@ why [dotdrop](https://github.com/deadc0de6/dotdrop) rocks.
|
|||||||
* [Include dotfiles from another profile](#include-dotfiles-from-another-profile)
|
* [Include dotfiles from another profile](#include-dotfiles-from-another-profile)
|
||||||
* [Templating](#templating)
|
* [Templating](#templating)
|
||||||
* [Available variables](#available-variables)
|
* [Available variables](#available-variables)
|
||||||
|
* [Variables from file](#variables-from-file)
|
||||||
* [Available methods](#available-methods)
|
* [Available methods](#available-methods)
|
||||||
* [Dynamic dotfile paths](#dynamic-dotfile-paths)
|
* [Dynamic dotfile paths](#dynamic-dotfile-paths)
|
||||||
* [Dynamic actions](#dynamic-actions)
|
* [Dynamic actions](#dynamic-actions)
|
||||||
@@ -655,6 +656,8 @@ the following entries:
|
|||||||
(absolute path or relative to the config file location, defaults to *~/.config/dotdrop*)
|
(absolute path or relative to the config file location, defaults to *~/.config/dotdrop*)
|
||||||
* `showdiff`: on install show a diff before asking to overwrite (see `--showdiff`) (default *false*)
|
* `showdiff`: on install show a diff before asking to overwrite (see `--showdiff`) (default *false*)
|
||||||
* `ignoreempty`: do not deploy template if empty (default *false*)
|
* `ignoreempty`: do not deploy template if empty (default *false*)
|
||||||
|
* `import_variables`: list of paths to load variables from
|
||||||
|
(absolute path or relative to the config file location).
|
||||||
|
|
||||||
* **dotfiles** entry: a list of dotfiles
|
* **dotfiles** entry: a list of dotfiles
|
||||||
* `dst`: where this dotfile needs to be deployed (can use `variables` and `dynvariables`, make sure to quote).
|
* `dst`: where this dotfile needs to be deployed (can use `variables` and `dynvariables`, make sure to quote).
|
||||||
@@ -834,7 +837,7 @@ will result in the following available variables
|
|||||||
* var4: `echo var1 var2 var3`
|
* var4: `echo var1 var2 var3`
|
||||||
* dvar4: `var1 var2 var3`
|
* dvar4: `var1 var2 var3`
|
||||||
|
|
||||||
## Variables
|
### Variables
|
||||||
|
|
||||||
Variables can be added in the config file under the `variables` entry.
|
Variables can be added in the config file under the `variables` entry.
|
||||||
The variables added there are directly reachable in any templates.
|
The variables added there are directly reachable in any templates.
|
||||||
@@ -871,7 +874,7 @@ profiles:
|
|||||||
- f_gitconfig
|
- f_gitconfig
|
||||||
```
|
```
|
||||||
|
|
||||||
## Interpreted variables
|
### Interpreted variables
|
||||||
|
|
||||||
It is also possible to have *dynamic* variables in the sense that their
|
It is also possible to have *dynamic* variables in the sense that their
|
||||||
content will be interpreted by the shell before being replaced in the templates.
|
content will be interpreted by the shell before being replaced in the templates.
|
||||||
@@ -892,7 +895,7 @@ These can be used as any variables in the templates
|
|||||||
As for variables (see [Variables](#variables)) profile dynvariables will take
|
As for variables (see [Variables](#variables)) profile dynvariables will take
|
||||||
precedence over globally defined dynvariables.
|
precedence over globally defined dynvariables.
|
||||||
|
|
||||||
## Environment variables
|
### Environment variables
|
||||||
|
|
||||||
It's possible to access environment variables inside the templates.
|
It's possible to access environment variables inside the templates.
|
||||||
```
|
```
|
||||||
@@ -924,6 +927,35 @@ alias dotdrop='eval $(grep -v "^#" ~/dotfiles/.env) /usr/bin/dotdrop --cfg=~/dot
|
|||||||
The above aliases load all the variables from `~/dotfiles/.env`
|
The above aliases load all the variables from `~/dotfiles/.env`
|
||||||
(while omitting lines starting with `#`) before calling dotdrop.
|
(while omitting lines starting with `#`) before calling dotdrop.
|
||||||
|
|
||||||
|
## Variables from file
|
||||||
|
|
||||||
|
Variables can be loaded from external files by specifying their
|
||||||
|
paths in the config entry `import_variables`.
|
||||||
|
|
||||||
|
`config.yaml`
|
||||||
|
```yaml
|
||||||
|
config:
|
||||||
|
import_variables:
|
||||||
|
- variables.yaml
|
||||||
|
variables:
|
||||||
|
v1: var2
|
||||||
|
```
|
||||||
|
|
||||||
|
`variables.yaml`
|
||||||
|
```yaml
|
||||||
|
variables:
|
||||||
|
v1: var1
|
||||||
|
v2: var2
|
||||||
|
dynvariables:
|
||||||
|
dv1: "echo test"
|
||||||
|
```
|
||||||
|
|
||||||
|
External variables will take precedence over variables defined within
|
||||||
|
the source config file.
|
||||||
|
|
||||||
|
This can be useful for example if you have sensitive information stored in variables
|
||||||
|
and want those to be encrypted when versioned.
|
||||||
|
|
||||||
## Available methods
|
## Available methods
|
||||||
|
|
||||||
Beside jinja2 global functions
|
Beside jinja2 global functions
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ class Cfg:
|
|||||||
key_showdiff = 'showdiff'
|
key_showdiff = 'showdiff'
|
||||||
key_deflink = 'link_by_default'
|
key_deflink = 'link_by_default'
|
||||||
key_workdir = 'workdir'
|
key_workdir = 'workdir'
|
||||||
key_include_vars = 'include_variables'
|
key_include_vars = 'import_variables'
|
||||||
|
|
||||||
# actions keys
|
# actions keys
|
||||||
key_actions = 'actions'
|
key_actions = 'actions'
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ config:
|
|||||||
backup: true
|
backup: true
|
||||||
create: true
|
create: true
|
||||||
dotpath: dotfiles
|
dotpath: dotfiles
|
||||||
include_variables:
|
import_variables:
|
||||||
- $(basename ${extvars})
|
- $(basename ${extvars})
|
||||||
variables:
|
variables:
|
||||||
var1: "var1"
|
var1: "var1"
|
||||||
@@ -123,7 +123,7 @@ config:
|
|||||||
backup: true
|
backup: true
|
||||||
create: true
|
create: true
|
||||||
dotpath: dotfiles
|
dotpath: dotfiles
|
||||||
include_variables:
|
import_variables:
|
||||||
- $(basename ${extvars})
|
- $(basename ${extvars})
|
||||||
dotfiles:
|
dotfiles:
|
||||||
f_abc:
|
f_abc:
|
||||||
|
|||||||
Reference in New Issue
Block a user