Files
fission-src/pkg/storagesvc/localstorage.go
T
Sanket SudakeandGitHub cc0400bdd4 Move clientset,listers,informers to pkg/client from pkg/apis (#2090)
* Move clientset,listers,informers to pkg/client from pkg/apis

Signed-off-by: Sanket Sudake <sanketsudake@gmail.com>

* Update golangci-lint version and timeout

Signed-off-by: Sanket Sudake <sanketsudake@gmail.com>
2021-06-24 12:07:14 +05:30

49 lines
1.0 KiB
Go

package storagesvc
import (
"os"
"github.com/graymeta/stow"
_ "github.com/graymeta/stow/local"
uuid "github.com/satori/go.uuid"
)
type localStorage struct {
storageType StorageType
containerName string
localPath string
}
// NewLocalStorage return new local storage struct
func NewLocalStorage(localPath string) Storage {
subdir := os.Getenv("SUBDIR")
if len(subdir) == 0 {
subdir = "fission-functions"
}
return localStorage{
storageType: StorageTypeLocal,
containerName: subdir,
localPath: localPath,
}
}
// Local
func (ls localStorage) getStorageType() StorageType {
return ls.storageType
}
func (ls localStorage) getUploadFileName() string {
// This is not the item ID (that's returned by Put)
// should we just use handler.Filename? what are the constraints here?
return uuid.NewV4().String()
}
func (ls localStorage) getContainerName() string {
return ls.containerName
}
func (ls localStorage) dial() (stow.Location, error) {
cfg := stow.ConfigMap{"path": ls.localPath}
return stow.Dial("local", cfg)
}