add all the new files
This commit is contained in:
parent
d689e6b4d3
commit
4d19f4f8b6
|
@ -0,0 +1,31 @@
|
|||
package common
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
// Used to set variables which we need to access later in the build, where
|
||||
// state bag and config information won't work
|
||||
func sharedStateFilename(suffix string) string {
|
||||
uuid := os.Getenv("PACKER_RUN_UUID")
|
||||
return filepath.Join(os.TempDir(), fmt.Sprintf("packer-%s-%s", uuid, suffix))
|
||||
}
|
||||
|
||||
func SetSharedState(key string, value string) error {
|
||||
return ioutil.WriteFile(sharedStateFilename(key), []byte(value), 0644)
|
||||
}
|
||||
|
||||
func RetrieveSharedState(key string) (string, error) {
|
||||
value, err := ioutil.ReadFile(sharedStateFilename(key))
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return string(value), nil
|
||||
}
|
||||
|
||||
func RemoveSharedStateFile(key string) {
|
||||
os.Remove(sharedStateFilename(key))
|
||||
}
|
Loading…
Reference in New Issue