Files
fission-src/pkg/storagesvc/localstorage.go
T
Sanket SudakeandGitHub caffed92f4 Remove github.com/pkg/errors with appropriate replacements (#3172)
* errors.Wrap* removal

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

* remove errors.Errorf

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

* Remove remaining calls

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

* Few more errors

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

* Fix golint errors

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

---------

Signed-off-by: Sanket Sudake <sanketsudake@gmail.com>
2025-02-20 08:58:37 +05:30

54 lines
1.1 KiB
Go

package storagesvc
import (
"os"
"github.com/graymeta/stow"
_ "github.com/graymeta/stow/local"
"github.com/fission/fission/pkg/utils/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, error) {
// This is not the item ID (that's returned by Put)
// should we just use handler.Filename? what are the constraints here?
return uuid.NewString(), nil
}
func (ls localStorage) getSubDir() string {
return ""
}
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)
}