mirror of
https://github.com/cupcakearmy/autorestic.git
synced 2024-12-22 08:16:25 +00:00
pass env of backends to restic
This commit is contained in:
parent
b314912821
commit
276c424106
@ -41,6 +41,9 @@ func (b Backend) getEnv() (map[string]string, error) {
|
|||||||
env["RESTIC_PASSWORD"] = b.Key
|
env["RESTIC_PASSWORD"] = b.Key
|
||||||
repo, err := b.generateRepo()
|
repo, err := b.generateRepo()
|
||||||
env["RESTIC_REPOSITORY"] = repo
|
env["RESTIC_REPOSITORY"] = repo
|
||||||
|
for key, value := range b.Env {
|
||||||
|
env[strings.ToUpper(key)] = value
|
||||||
|
}
|
||||||
return env, err
|
return env, err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,8 +91,11 @@ func (b Backend) validate() error {
|
|||||||
return nil
|
return nil
|
||||||
} else {
|
} else {
|
||||||
// If not initialize
|
// If not initialize
|
||||||
|
colors.Body.Printf("Initializing backend \"%s\"...\n", b.name)
|
||||||
out, err := ExecuteResticCommand(options, "init")
|
out, err := ExecuteResticCommand(options, "init")
|
||||||
colors.Faint.Println(out)
|
if VERBOSE {
|
||||||
|
colors.Faint.Println(out)
|
||||||
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -113,7 +113,7 @@ func (c *Config) Describe() {
|
|||||||
if len(b.Env) > 0 {
|
if len(b.Env) > 0 {
|
||||||
tmp := ""
|
tmp := ""
|
||||||
for option, value := range b.Env {
|
for option, value := range b.Env {
|
||||||
tmp += fmt.Sprintf("\n\t%s %s %s", colors.Success.Sprint("✧"), option, colors.Faint.Sprint(value))
|
tmp += fmt.Sprintf("\n\t%s %s %s", colors.Success.Sprint("✧"), strings.ToUpper(option), colors.Faint.Sprint(value))
|
||||||
}
|
}
|
||||||
colors.PrintDescription("Env", tmp)
|
colors.PrintDescription("Env", tmp)
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,8 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
|
||||||
|
"github.com/cupcakearmy/autorestic/internal/colors"
|
||||||
)
|
)
|
||||||
|
|
||||||
func CheckIfCommandIsCallable(cmd string) bool {
|
func CheckIfCommandIsCallable(cmd string) bool {
|
||||||
@ -32,6 +34,10 @@ func ExecuteCommand(options ExecuteOptions, args ...string) (string, error) {
|
|||||||
cmd.Env = env
|
cmd.Env = env
|
||||||
cmd.Dir = options.Dir
|
cmd.Dir = options.Dir
|
||||||
|
|
||||||
|
if VERBOSE {
|
||||||
|
colors.Faint.Printf("> Executing: %s\n", cmd)
|
||||||
|
}
|
||||||
|
|
||||||
var out bytes.Buffer
|
var out bytes.Buffer
|
||||||
var error bytes.Buffer
|
var error bytes.Buffer
|
||||||
cmd.Stdout = &out
|
cmd.Stdout = &out
|
||||||
|
Loading…
Reference in New Issue
Block a user