Skip to content

Commit

Permalink
Merge branch 'fix/137-file-should-create-the-file-it-adds-if-it-comes…
Browse files Browse the repository at this point in the history
…-from-the-cache' into develop
  • Loading branch information
Gaël Philippe authored and Gaël Philippe committed Jan 18, 2022
2 parents c0d630b + 00d4f5c commit 73489cb
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion cli/cmd/file_add.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package cmd
import (
"errors"
"io/ioutil"
"path"
"path/filepath"

"github.com/spf13/cobra"
Expand Down Expand Up @@ -127,7 +128,8 @@ ks file add -s ./credentials.json`,
Err(),
)
} else {
// just add file to keystone.yaml and keep old content
// add file to keystone.yaml and use the file from the cache
// if the file doesn’t

file := keystonefile.FileKey{
Path: filePath,
Expand All @@ -141,6 +143,16 @@ ks file add -s ./credentials.json`,
Err(); err != nil {
exit(kserrors.FailedToUpdateKeystoneFile(err))
}

if !utils.FileExists(filePath) {
cachePath := ctx.CachedEnvironmentFilesPath(currentEnvironment)
cachedFilePath := path.Join(cachePath, filePath)

exitIfErr(
utils.CopyFile(cachedFilePath, filePath),
)
}

}

display.FileAddSuccess(filePath, len(environments))
Expand Down

0 comments on commit 73489cb

Please sign in to comment.