Skip to content

Commit

Permalink
Updating comments for cache and config directories to be accurate (#73)
Browse files Browse the repository at this point in the history
  • Loading branch information
teddylear authored Aug 4, 2021
1 parent 4c9e709 commit 39969ac
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
12 changes: 7 additions & 5 deletions packer/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,20 @@ import (
// When the directory is not absolute, CachePath will try to make a
// a cache depending on the operating system.
//
// TODO: Update this with better examples
// NOTE: cache directory will change depending on operating system dependent
// For Windows:
// PACKER_CACHE_DIR="" CacheDir() => "./packer_cache/
// PACKER_CACHE_DIR="" CacheDir("foo") => "./packer_cache/foo
// PACKER_CACHE_DIR="bar" CacheDir("foo") => "./bar/foo
// PACKER_CACHE_DIR="/home/there" CacheDir("foo", "bar") => "/home/there/foo/bar
// For Unix:
// PACKER_CACHE_DIR="", XDG_CONFIG_HOME="", Default_config CacheDir() => "$HOME/cache/packer"
// PACKER_CACHE_DIR="", XDG_CONFIG_HOME="", Default_config CacheDir("foo") => "$HOME/cache/packer/foo"
// PACKER_CACHE_DIR="bar", XDG_CONFIG_HOME="", Default_config CacheDir("foo") => "./bar/foo
// PACKER_CACHE_DIR="/home/there", XDG_CONFIG_HOME="", Default_config CacheDir("foo", "bar") => "/home/there/foo/bar
// NOTE: PACKER_CACHE_DIR will be used over XDG_CACHE_HOME environment variable
// PACKER_CACHE_DIR="", XDG_CACHE_HOME="", CacheDir() => "$HOME/cache/packer"
// PACKER_CACHE_DIR="", XDG_CACHE_HOME="", CacheDir("foo") => "$HOME/cache/packer/foo"
// PACKER_CACHE_DIR="bar", XDG_CACHE_HOME="", CacheDir("foo") => "./bar/foo"
// PACKER_CACHE_DIR="/home/there", XDG_CACHE_HOME="", CacheDir("foo", "bar") => "/home/there/foo/bar"
// PACKER_CACHE_DIR="", XDG_CACHE_HOME="/home/there", CacheDir("foo", "bar") => "/home/there/foo/bar"
// PACKER_CACHE_DIR="/foo", XDG_CACHE_HOME="/bar", CacheDir("a", "b") => "/foo/a/b"
func CachePath(paths ...string) (path string, err error) {
defer func() {
// create the dir based on return path if it doesn't exist
Expand Down
13 changes: 13 additions & 0 deletions pathing/config_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,19 @@ func ConfigFile() (string, error) {
}

// ConfigDir returns the configuration directory for Packer.
// NOTE: config directory will change depending on operating system dependent
// For Windows:
// PACKER_CONFIG_DIR="" ConfigDir() => "/{homeDir()}/packer.config/
// PACKER_CONFIG_DIR="bar" ConfigDir() => "/bar/packer.config/
//
// NOTE: Default_config_present=TRUE means that there is configuration directory at old location => $HOME/.packer.d
// NOTE: This is not list all permutations, just some examples, view the
// configDir function for your OS for the exact logic
// For Unix:
// PACKER_CONFIG_DIR="" Default_config_present=FALSE XDG_CONFIG_HOME="" ConfigDir() => "$HOME/.config/packer
// PACKER_CONFIG_DIR="bar" Default_config_present=FALSE XDG_CONFIG_HOME="" ConfigDir() => "/bar/.packer.d/
// PACKER_CONFIG_DIR="" Default_config_present=TRUE XDG_CONFIG_HOME="" ConfigDir() => "/$HOME/.packer.d/
// PACKER_CONFIG_DIR="" Default_config_present=TRUE XDG_CONFIG_HOME="bar" ConfigDir() => "/bar/.packer.d/
func ConfigDir() (string, error) {
return configDir()
}
Expand Down

0 comments on commit 39969ac

Please sign in to comment.