feat: Make STFS API public
Also: Happy new year :)
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
package check
|
||||
|
||||
import (
|
||||
"github.com/pojntfx/stfs/pkg/config"
|
||||
)
|
||||
|
||||
func CheckCompressionFormat(compressionFormat string) error {
|
||||
compressionFormatIsKnown := false
|
||||
|
||||
for _, candidate := range config.KnownCompressionFormats {
|
||||
if compressionFormat == candidate {
|
||||
compressionFormatIsKnown = true
|
||||
}
|
||||
}
|
||||
|
||||
if !compressionFormatIsKnown {
|
||||
return config.ErrCompressionFormatUnknown
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func CheckCompressionLevel(compressionLevel string) error {
|
||||
compressionLevelIsKnown := false
|
||||
|
||||
for _, candidate := range config.KnownCompressionLevels {
|
||||
if compressionLevel == candidate {
|
||||
compressionLevelIsKnown = true
|
||||
}
|
||||
}
|
||||
|
||||
if !compressionLevelIsKnown {
|
||||
return config.ErrCompressionLevelUnknown
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package check
|
||||
|
||||
import "github.com/pojntfx/stfs/pkg/config"
|
||||
|
||||
func CheckEncryptionFormat(encryptionFormat string) error {
|
||||
encryptionFormatIsKnown := false
|
||||
|
||||
for _, candidate := range config.KnownEncryptionFormats {
|
||||
if encryptionFormat == candidate {
|
||||
encryptionFormatIsKnown = true
|
||||
}
|
||||
}
|
||||
|
||||
if !encryptionFormatIsKnown {
|
||||
return config.ErrEncryptionFormatUnknown
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package check
|
||||
|
||||
import "github.com/pojntfx/stfs/pkg/config"
|
||||
|
||||
func CheckFileSystemCacheType(cacheType string) error {
|
||||
cacheTypeIsKnown := false
|
||||
|
||||
for _, candidate := range config.KnownFileSystemCacheTypes {
|
||||
if cacheType == candidate {
|
||||
cacheTypeIsKnown = true
|
||||
}
|
||||
}
|
||||
|
||||
if !cacheTypeIsKnown {
|
||||
return config.ErrFileSystemCacheTypeUnknown
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func CheckWriteCacheType(cacheType string) error {
|
||||
cacheTypeIsKnown := false
|
||||
|
||||
for _, candidate := range config.KnownWriteCacheTypes {
|
||||
if cacheType == candidate {
|
||||
cacheTypeIsKnown = true
|
||||
}
|
||||
}
|
||||
|
||||
if !cacheTypeIsKnown {
|
||||
return config.ErrWriteCacheTypeUnknown
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package check
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"os"
|
||||
|
||||
"github.com/pojntfx/stfs/pkg/config"
|
||||
)
|
||||
|
||||
var (
|
||||
ErrKeyNotAccessible = errors.New("key not found or accessible")
|
||||
)
|
||||
|
||||
func CheckKeyAccessible(encryptionFormat string, pathToKey string) error {
|
||||
if encryptionFormat == config.NoneKey {
|
||||
return nil
|
||||
}
|
||||
|
||||
if _, err := os.Stat(pathToKey); err != nil {
|
||||
return ErrKeyNotAccessible
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package check
|
||||
|
||||
import "github.com/pojntfx/stfs/pkg/config"
|
||||
|
||||
func CheckSignatureFormat(signatureFormat string) error {
|
||||
signatureFormatIsKnown := false
|
||||
|
||||
for _, candidate := range config.KnownSignatureFormats {
|
||||
if signatureFormat == candidate {
|
||||
signatureFormatIsKnown = true
|
||||
}
|
||||
}
|
||||
|
||||
if !signatureFormatIsKnown {
|
||||
return config.ErrSignatureFormatUnknown
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user