Skip to content

Commit 39969ac

Browse files
authored
Updating comments for cache and config directories to be accurate (#73)
1 parent 4c9e709 commit 39969ac

2 files changed

Lines changed: 20 additions & 5 deletions

File tree

packer/cache.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,20 @@ import (
1010
// When the directory is not absolute, CachePath will try to make a
1111
// a cache depending on the operating system.
1212
//
13-
// TODO: Update this with better examples
1413
// NOTE: cache directory will change depending on operating system dependent
1514
// For Windows:
1615
// PACKER_CACHE_DIR="" CacheDir() => "./packer_cache/
1716
// PACKER_CACHE_DIR="" CacheDir("foo") => "./packer_cache/foo
1817
// PACKER_CACHE_DIR="bar" CacheDir("foo") => "./bar/foo
1918
// PACKER_CACHE_DIR="/home/there" CacheDir("foo", "bar") => "/home/there/foo/bar
2019
// For Unix:
21-
// PACKER_CACHE_DIR="", XDG_CONFIG_HOME="", Default_config CacheDir() => "$HOME/cache/packer"
22-
// PACKER_CACHE_DIR="", XDG_CONFIG_HOME="", Default_config CacheDir("foo") => "$HOME/cache/packer/foo"
23-
// PACKER_CACHE_DIR="bar", XDG_CONFIG_HOME="", Default_config CacheDir("foo") => "./bar/foo
24-
// PACKER_CACHE_DIR="/home/there", XDG_CONFIG_HOME="", Default_config CacheDir("foo", "bar") => "/home/there/foo/bar
20+
// NOTE: PACKER_CACHE_DIR will be used over XDG_CACHE_HOME environment variable
21+
// PACKER_CACHE_DIR="", XDG_CACHE_HOME="", CacheDir() => "$HOME/cache/packer"
22+
// PACKER_CACHE_DIR="", XDG_CACHE_HOME="", CacheDir("foo") => "$HOME/cache/packer/foo"
23+
// PACKER_CACHE_DIR="bar", XDG_CACHE_HOME="", CacheDir("foo") => "./bar/foo"
24+
// PACKER_CACHE_DIR="/home/there", XDG_CACHE_HOME="", CacheDir("foo", "bar") => "/home/there/foo/bar"
25+
// PACKER_CACHE_DIR="", XDG_CACHE_HOME="/home/there", CacheDir("foo", "bar") => "/home/there/foo/bar"
26+
// PACKER_CACHE_DIR="/foo", XDG_CACHE_HOME="/bar", CacheDir("a", "b") => "/foo/a/b"
2527
func CachePath(paths ...string) (path string, err error) {
2628
defer func() {
2729
// create the dir based on return path if it doesn't exist

pathing/config_file.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,19 @@ func ConfigFile() (string, error) {
1919
}
2020

2121
// ConfigDir returns the configuration directory for Packer.
22+
// NOTE: config directory will change depending on operating system dependent
23+
// For Windows:
24+
// PACKER_CONFIG_DIR="" ConfigDir() => "/{homeDir()}/packer.config/
25+
// PACKER_CONFIG_DIR="bar" ConfigDir() => "/bar/packer.config/
26+
//
27+
// NOTE: Default_config_present=TRUE means that there is configuration directory at old location => $HOME/.packer.d
28+
// NOTE: This is not list all permutations, just some examples, view the
29+
// configDir function for your OS for the exact logic
30+
// For Unix:
31+
// PACKER_CONFIG_DIR="" Default_config_present=FALSE XDG_CONFIG_HOME="" ConfigDir() => "$HOME/.config/packer
32+
// PACKER_CONFIG_DIR="bar" Default_config_present=FALSE XDG_CONFIG_HOME="" ConfigDir() => "/bar/.packer.d/
33+
// PACKER_CONFIG_DIR="" Default_config_present=TRUE XDG_CONFIG_HOME="" ConfigDir() => "/$HOME/.packer.d/
34+
// PACKER_CONFIG_DIR="" Default_config_present=TRUE XDG_CONFIG_HOME="bar" ConfigDir() => "/bar/.packer.d/
2235
func ConfigDir() (string, error) {
2336
return configDir()
2437
}

0 commit comments

Comments
 (0)