Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions pkg/restic/config.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
package restic

import (
"fmt"
"io/ioutil"
"os"
"path/filepath"

shell "github.com/codeskyblue/go-sh"
ofst "kmodules.xyz/offshoot-api/api/v1"
"stash.appscode.dev/stash/apis/stash/v1alpha1"
Expand Down Expand Up @@ -97,6 +102,24 @@ func (w *ResticWrapper) SetEnv(key, value string) {
}
}

func (w *ResticWrapper) DumpEnv(path string, dumpedFile string) error {
if err := os.MkdirAll(path, 0755); err != nil {
return err
}

var envs string
if w.sh != nil {
for k, v := range w.sh.Env {
envs = envs + fmt.Sprintln(k+"="+v)
}
}

if err := ioutil.WriteFile(filepath.Join(path, dumpedFile), []byte(envs), 0755); err != nil {
return err
}
return nil
}

func (w *ResticWrapper) HideCMD() {
if w.sh != nil {
w.sh.ShowCMD = false
Expand Down