feat: Make STFS API public

Also: Happy new year :)
This commit is contained in:
Felix Pojtinger
2021-12-31 23:57:21 +01:00
parent ef364c836b
commit 67d97ed32b
32 changed files with 214 additions and 222 deletions
+37
View File
@@ -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
}
+19
View File
@@ -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
}
+35
View File
@@ -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
}
+24
View File
@@ -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
}
+19
View File
@@ -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
}