refactor: Split keys and keyext packages, make compression, signature and encryption packages public

This commit is contained in:
Felicitas Pojtinger
2022-01-03 14:56:46 +01:00
parent b0a1b61297
commit 5d5b6ebb96
27 changed files with 65 additions and 55 deletions

View File

@@ -8,9 +8,10 @@ import (
"path/filepath"
"github.com/pojntfx/stfs/internal/check"
"github.com/pojntfx/stfs/internal/keys"
"github.com/pojntfx/stfs/internal/keyext"
"github.com/pojntfx/stfs/internal/logging"
"github.com/pojntfx/stfs/pkg/config"
"github.com/pojntfx/stfs/pkg/keys"
"github.com/pojntfx/stfs/pkg/operations"
"github.com/pojntfx/stfs/pkg/persisters"
"github.com/pojntfx/stfs/pkg/tape"
@@ -48,7 +49,7 @@ var operationArchiveCmd = &cobra.Command{
return check.CheckKeyAccessible(viper.GetString(signatureFlag), viper.GetString(identityFlag))
},
RunE: func(cmd *cobra.Command, args []string) error {
pubkey, err := keys.ReadKey(viper.GetString(encryptionFlag), viper.GetString(recipientFlag))
pubkey, err := keyext.ReadKey(viper.GetString(encryptionFlag), viper.GetString(recipientFlag))
if err != nil {
return err
}
@@ -58,7 +59,7 @@ var operationArchiveCmd = &cobra.Command{
return err
}
privkey, err := keys.ReadKey(viper.GetString(signatureFlag), viper.GetString(identityFlag))
privkey, err := keyext.ReadKey(viper.GetString(signatureFlag), viper.GetString(identityFlag))
if err != nil {
return err
}

View File

@@ -2,9 +2,10 @@ package cmd
import (
"github.com/pojntfx/stfs/internal/check"
"github.com/pojntfx/stfs/internal/keys"
"github.com/pojntfx/stfs/internal/keyext"
"github.com/pojntfx/stfs/internal/logging"
"github.com/pojntfx/stfs/pkg/config"
"github.com/pojntfx/stfs/pkg/keys"
"github.com/pojntfx/stfs/pkg/operations"
"github.com/pojntfx/stfs/pkg/persisters"
"github.com/pojntfx/stfs/pkg/tape"
@@ -32,7 +33,7 @@ var operationDeleteCmd = &cobra.Command{
return check.CheckKeyAccessible(viper.GetString(signatureFlag), viper.GetString(identityFlag))
},
RunE: func(cmd *cobra.Command, args []string) error {
pubkey, err := keys.ReadKey(viper.GetString(encryptionFlag), viper.GetString(recipientFlag))
pubkey, err := keyext.ReadKey(viper.GetString(encryptionFlag), viper.GetString(recipientFlag))
if err != nil {
return err
}
@@ -42,7 +43,7 @@ var operationDeleteCmd = &cobra.Command{
return err
}
privkey, err := keys.ReadKey(viper.GetString(signatureFlag), viper.GetString(identityFlag))
privkey, err := keyext.ReadKey(viper.GetString(signatureFlag), viper.GetString(identityFlag))
if err != nil {
return err
}

View File

@@ -2,9 +2,10 @@ package cmd
import (
"github.com/pojntfx/stfs/internal/check"
"github.com/pojntfx/stfs/internal/keys"
"github.com/pojntfx/stfs/internal/keyext"
"github.com/pojntfx/stfs/internal/logging"
"github.com/pojntfx/stfs/pkg/config"
"github.com/pojntfx/stfs/pkg/keys"
"github.com/pojntfx/stfs/pkg/operations"
"github.com/pojntfx/stfs/pkg/persisters"
"github.com/pojntfx/stfs/pkg/tape"
@@ -28,7 +29,7 @@ var operationMoveCmd = &cobra.Command{
return check.CheckKeyAccessible(viper.GetString(signatureFlag), viper.GetString(identityFlag))
},
RunE: func(cmd *cobra.Command, args []string) error {
pubkey, err := keys.ReadKey(viper.GetString(encryptionFlag), viper.GetString(recipientFlag))
pubkey, err := keyext.ReadKey(viper.GetString(encryptionFlag), viper.GetString(recipientFlag))
if err != nil {
return err
}
@@ -38,7 +39,7 @@ var operationMoveCmd = &cobra.Command{
return err
}
privkey, err := keys.ReadKey(viper.GetString(signatureFlag), viper.GetString(identityFlag))
privkey, err := keyext.ReadKey(viper.GetString(signatureFlag), viper.GetString(identityFlag))
if err != nil {
return err
}

View File

@@ -6,9 +6,10 @@ import (
"os"
"github.com/pojntfx/stfs/internal/check"
"github.com/pojntfx/stfs/internal/keys"
"github.com/pojntfx/stfs/internal/keyext"
"github.com/pojntfx/stfs/internal/logging"
"github.com/pojntfx/stfs/pkg/config"
"github.com/pojntfx/stfs/pkg/keys"
"github.com/pojntfx/stfs/pkg/operations"
"github.com/pojntfx/stfs/pkg/persisters"
"github.com/pojntfx/stfs/pkg/tape"
@@ -36,7 +37,7 @@ var operationRestoreCmd = &cobra.Command{
return check.CheckKeyAccessible(viper.GetString(signatureFlag), viper.GetString(recipientFlag))
},
RunE: func(cmd *cobra.Command, args []string) error {
pubkey, err := keys.ReadKey(viper.GetString(signatureFlag), viper.GetString(recipientFlag))
pubkey, err := keyext.ReadKey(viper.GetString(signatureFlag), viper.GetString(recipientFlag))
if err != nil {
return err
}
@@ -46,7 +47,7 @@ var operationRestoreCmd = &cobra.Command{
return err
}
privkey, err := keys.ReadKey(viper.GetString(encryptionFlag), viper.GetString(identityFlag))
privkey, err := keyext.ReadKey(viper.GetString(encryptionFlag), viper.GetString(identityFlag))
if err != nil {
return err
}

View File

@@ -8,9 +8,10 @@ import (
"path/filepath"
"github.com/pojntfx/stfs/internal/check"
"github.com/pojntfx/stfs/internal/keys"
"github.com/pojntfx/stfs/internal/keyext"
"github.com/pojntfx/stfs/internal/logging"
"github.com/pojntfx/stfs/pkg/config"
"github.com/pojntfx/stfs/pkg/keys"
"github.com/pojntfx/stfs/pkg/operations"
"github.com/pojntfx/stfs/pkg/persisters"
"github.com/pojntfx/stfs/pkg/tape"
@@ -38,7 +39,7 @@ var operationUpdateCmd = &cobra.Command{
return check.CheckKeyAccessible(viper.GetString(signatureFlag), viper.GetString(identityFlag))
},
RunE: func(cmd *cobra.Command, args []string) error {
pubkey, err := keys.ReadKey(viper.GetString(encryptionFlag), viper.GetString(recipientFlag))
pubkey, err := keyext.ReadKey(viper.GetString(encryptionFlag), viper.GetString(recipientFlag))
if err != nil {
return err
}
@@ -48,7 +49,7 @@ var operationUpdateCmd = &cobra.Command{
return err
}
privkey, err := keys.ReadKey(viper.GetString(signatureFlag), viper.GetString(identityFlag))
privkey, err := keyext.ReadKey(viper.GetString(signatureFlag), viper.GetString(identityFlag))
if err != nil {
return err
}

View File

@@ -6,9 +6,10 @@ import (
"os"
"github.com/pojntfx/stfs/internal/check"
"github.com/pojntfx/stfs/internal/keys"
"github.com/pojntfx/stfs/internal/keyext"
"github.com/pojntfx/stfs/internal/logging"
"github.com/pojntfx/stfs/pkg/config"
"github.com/pojntfx/stfs/pkg/keys"
"github.com/pojntfx/stfs/pkg/recovery"
"github.com/pojntfx/stfs/pkg/tape"
"github.com/spf13/cobra"
@@ -37,7 +38,7 @@ var recoveryFetchCmd = &cobra.Command{
return check.CheckKeyAccessible(viper.GetString(signatureFlag), viper.GetString(recipientFlag))
},
RunE: func(cmd *cobra.Command, args []string) error {
pubkey, err := keys.ReadKey(viper.GetString(signatureFlag), viper.GetString(recipientFlag))
pubkey, err := keyext.ReadKey(viper.GetString(signatureFlag), viper.GetString(recipientFlag))
if err != nil {
return err
}
@@ -47,7 +48,7 @@ var recoveryFetchCmd = &cobra.Command{
return err
}
privkey, err := keys.ReadKey(viper.GetString(encryptionFlag), viper.GetString(identityFlag))
privkey, err := keyext.ReadKey(viper.GetString(encryptionFlag), viper.GetString(identityFlag))
if err != nil {
return err
}

View File

@@ -4,13 +4,14 @@ import (
"archive/tar"
"github.com/pojntfx/stfs/internal/check"
"github.com/pojntfx/stfs/internal/encryption"
"github.com/pojntfx/stfs/internal/keys"
"github.com/pojntfx/stfs/internal/keyext"
"github.com/pojntfx/stfs/internal/logging"
"github.com/pojntfx/stfs/internal/signature"
"github.com/pojntfx/stfs/pkg/config"
"github.com/pojntfx/stfs/pkg/encryption"
"github.com/pojntfx/stfs/pkg/keys"
"github.com/pojntfx/stfs/pkg/persisters"
"github.com/pojntfx/stfs/pkg/recovery"
"github.com/pojntfx/stfs/pkg/signature"
"github.com/pojntfx/stfs/pkg/tape"
"github.com/spf13/cobra"
"github.com/spf13/viper"
@@ -31,7 +32,7 @@ var recoveryIndexCmd = &cobra.Command{
return check.CheckKeyAccessible(viper.GetString(signatureFlag), viper.GetString(recipientFlag))
},
RunE: func(cmd *cobra.Command, args []string) error {
pubkey, err := keys.ReadKey(viper.GetString(signatureFlag), viper.GetString(recipientFlag))
pubkey, err := keyext.ReadKey(viper.GetString(signatureFlag), viper.GetString(recipientFlag))
if err != nil {
return err
}
@@ -41,7 +42,7 @@ var recoveryIndexCmd = &cobra.Command{
return err
}
privkey, err := keys.ReadKey(viper.GetString(encryptionFlag), viper.GetString(identityFlag))
privkey, err := keyext.ReadKey(viper.GetString(encryptionFlag), viper.GetString(identityFlag))
if err != nil {
return err
}

View File

@@ -2,9 +2,10 @@ package cmd
import (
"github.com/pojntfx/stfs/internal/check"
"github.com/pojntfx/stfs/internal/keys"
"github.com/pojntfx/stfs/internal/keyext"
"github.com/pojntfx/stfs/internal/logging"
"github.com/pojntfx/stfs/pkg/config"
"github.com/pojntfx/stfs/pkg/keys"
"github.com/pojntfx/stfs/pkg/recovery"
"github.com/pojntfx/stfs/pkg/tape"
"github.com/spf13/cobra"
@@ -26,7 +27,7 @@ var recoveryQueryCmd = &cobra.Command{
return check.CheckKeyAccessible(viper.GetString(signatureFlag), viper.GetString(recipientFlag))
},
RunE: func(cmd *cobra.Command, args []string) error {
pubkey, err := keys.ReadKey(viper.GetString(signatureFlag), viper.GetString(recipientFlag))
pubkey, err := keyext.ReadKey(viper.GetString(signatureFlag), viper.GetString(recipientFlag))
if err != nil {
return err
}
@@ -36,7 +37,7 @@ var recoveryQueryCmd = &cobra.Command{
return err
}
privkey, err := keys.ReadKey(viper.GetString(encryptionFlag), viper.GetString(identityFlag))
privkey, err := keyext.ReadKey(viper.GetString(encryptionFlag), viper.GetString(identityFlag))
if err != nil {
return err
}

View File

@@ -10,17 +10,18 @@ import (
ftpserver "github.com/fclairamb/ftpserverlib"
"github.com/pojntfx/stfs/internal/check"
"github.com/pojntfx/stfs/internal/encryption"
"github.com/pojntfx/stfs/internal/ftp"
"github.com/pojntfx/stfs/internal/keys"
"github.com/pojntfx/stfs/internal/keyext"
"github.com/pojntfx/stfs/internal/logging"
"github.com/pojntfx/stfs/internal/signature"
"github.com/pojntfx/stfs/pkg/cache"
"github.com/pojntfx/stfs/pkg/config"
"github.com/pojntfx/stfs/pkg/encryption"
sfs "github.com/pojntfx/stfs/pkg/fs"
"github.com/pojntfx/stfs/pkg/keys"
"github.com/pojntfx/stfs/pkg/operations"
"github.com/pojntfx/stfs/pkg/persisters"
"github.com/pojntfx/stfs/pkg/recovery"
"github.com/pojntfx/stfs/pkg/signature"
"github.com/pojntfx/stfs/pkg/tape"
"github.com/spf13/cobra"
"github.com/spf13/viper"
@@ -74,22 +75,22 @@ var serveFTPCmd = &cobra.Command{
return check.CheckKeyAccessible(viper.GetString(signatureFlag), viper.GetString(signatureRecipientFlag))
},
RunE: func(cmd *cobra.Command, args []string) error {
signaturePubkey, err := keys.ReadKey(viper.GetString(signatureFlag), viper.GetString(signatureRecipientFlag))
signaturePubkey, err := keyext.ReadKey(viper.GetString(signatureFlag), viper.GetString(signatureRecipientFlag))
if err != nil {
return err
}
signaturePrivkey, err := keys.ReadKey(viper.GetString(signatureFlag), viper.GetString(signatureIdentityFlag))
signaturePrivkey, err := keyext.ReadKey(viper.GetString(signatureFlag), viper.GetString(signatureIdentityFlag))
if err != nil {
return err
}
encryptionPubkey, err := keys.ReadKey(viper.GetString(encryptionFlag), viper.GetString(encryptionRecipientFlag))
encryptionPubkey, err := keyext.ReadKey(viper.GetString(encryptionFlag), viper.GetString(encryptionRecipientFlag))
if err != nil {
return err
}
encryptionPrivkey, err := keys.ReadKey(viper.GetString(encryptionFlag), viper.GetString(encryptionIdentityFlag))
encryptionPrivkey, err := keyext.ReadKey(viper.GetString(encryptionFlag), viper.GetString(encryptionIdentityFlag))
if err != nil {
return err
}

View File

@@ -9,11 +9,12 @@ import (
"github.com/pojntfx/stfs/internal/check"
"github.com/pojntfx/stfs/internal/handlers"
"github.com/pojntfx/stfs/internal/keys"
"github.com/pojntfx/stfs/internal/keyext"
"github.com/pojntfx/stfs/internal/logging"
"github.com/pojntfx/stfs/pkg/cache"
"github.com/pojntfx/stfs/pkg/config"
sfs "github.com/pojntfx/stfs/pkg/fs"
"github.com/pojntfx/stfs/pkg/keys"
"github.com/pojntfx/stfs/pkg/operations"
"github.com/pojntfx/stfs/pkg/persisters"
"github.com/pojntfx/stfs/pkg/tape"
@@ -49,7 +50,7 @@ var serveHTTPCmd = &cobra.Command{
return check.CheckKeyAccessible(viper.GetString(signatureFlag), viper.GetString(recipientFlag))
},
RunE: func(cmd *cobra.Command, args []string) error {
pubkey, err := keys.ReadKey(viper.GetString(signatureFlag), viper.GetString(recipientFlag))
pubkey, err := keyext.ReadKey(viper.GetString(signatureFlag), viper.GetString(recipientFlag))
if err != nil {
return err
}
@@ -59,7 +60,7 @@ var serveHTTPCmd = &cobra.Command{
return err
}
privkey, err := keys.ReadKey(viper.GetString(encryptionFlag), viper.GetString(identityFlag))
privkey, err := keyext.ReadKey(viper.GetString(encryptionFlag), viper.GetString(identityFlag))
if err != nil {
return err
}

View File

@@ -21,7 +21,7 @@ import (
var flagDebugMode = flag.Bool("test.sqldebug", false, "Turns on debug mode for SQL statements")
var flagConfigFile = flag.String("test.config", "", "Overrides the default config")
const outputDirDepth = 5
const outputDirDepth = 7
var (
dbMain tester

View File

@@ -1,4 +1,4 @@
package keys
package keyext
import (
"io/ioutil"

View File

@@ -8,17 +8,17 @@ import (
"strconv"
"strings"
"github.com/pojntfx/stfs/internal/compression"
"github.com/pojntfx/stfs/internal/converters"
"github.com/pojntfx/stfs/internal/encryption"
"github.com/pojntfx/stfs/internal/ioext"
"github.com/pojntfx/stfs/internal/mtio"
"github.com/pojntfx/stfs/internal/records"
"github.com/pojntfx/stfs/internal/signature"
"github.com/pojntfx/stfs/internal/suffix"
"github.com/pojntfx/stfs/internal/tarext"
"github.com/pojntfx/stfs/pkg/compression"
"github.com/pojntfx/stfs/pkg/config"
"github.com/pojntfx/stfs/pkg/encryption"
"github.com/pojntfx/stfs/pkg/recovery"
"github.com/pojntfx/stfs/pkg/signature"
)
var (

View File

@@ -6,12 +6,12 @@ import (
"path/filepath"
"github.com/pojntfx/stfs/internal/converters"
"github.com/pojntfx/stfs/internal/encryption"
"github.com/pojntfx/stfs/internal/records"
"github.com/pojntfx/stfs/internal/signature"
"github.com/pojntfx/stfs/internal/tarext"
"github.com/pojntfx/stfs/pkg/config"
"github.com/pojntfx/stfs/pkg/encryption"
"github.com/pojntfx/stfs/pkg/recovery"
"github.com/pojntfx/stfs/pkg/signature"
)
func (o *Operations) Delete(name string) error {

View File

@@ -8,12 +8,12 @@ import (
"strings"
"github.com/pojntfx/stfs/internal/converters"
"github.com/pojntfx/stfs/internal/encryption"
"github.com/pojntfx/stfs/internal/records"
"github.com/pojntfx/stfs/internal/signature"
"github.com/pojntfx/stfs/internal/tarext"
"github.com/pojntfx/stfs/pkg/config"
"github.com/pojntfx/stfs/pkg/encryption"
"github.com/pojntfx/stfs/pkg/recovery"
"github.com/pojntfx/stfs/pkg/signature"
)
func (o *Operations) Move(from string, to string) error {

View File

@@ -7,17 +7,17 @@ import (
"strconv"
"strings"
"github.com/pojntfx/stfs/internal/compression"
"github.com/pojntfx/stfs/internal/converters"
"github.com/pojntfx/stfs/internal/encryption"
"github.com/pojntfx/stfs/internal/ioext"
"github.com/pojntfx/stfs/internal/mtio"
"github.com/pojntfx/stfs/internal/records"
"github.com/pojntfx/stfs/internal/signature"
"github.com/pojntfx/stfs/internal/suffix"
"github.com/pojntfx/stfs/internal/tarext"
"github.com/pojntfx/stfs/pkg/compression"
"github.com/pojntfx/stfs/pkg/config"
"github.com/pojntfx/stfs/pkg/encryption"
"github.com/pojntfx/stfs/pkg/recovery"
"github.com/pojntfx/stfs/pkg/signature"
)
func (o *Operations) Update(

View File

@@ -1,7 +1,7 @@
package persisters
//go:generate sqlboiler sqlite3 -o ../db/sqlite/models/metadata -c ../../configs/sqlboiler/metadata.yaml
//go:generate go-bindata -pkg metadata -o ../db/sqlite/migrations/metadata/migrations.go ../../db/sqlite/migrations/metadata
//go:generate sqlboiler sqlite3 -o ../../internal/db/sqlite/models/metadata -c ../../configs/sqlboiler/metadata.yaml
//go:generate go-bindata -pkg metadata -o ../../internal/db/sqlite/migrations/metadata/migrations.go ../../db/sqlite/migrations/metadata
import (
"context"

View File

@@ -8,13 +8,13 @@ import (
"path"
"path/filepath"
"github.com/pojntfx/stfs/internal/compression"
"github.com/pojntfx/stfs/internal/converters"
"github.com/pojntfx/stfs/internal/encryption"
"github.com/pojntfx/stfs/internal/mtio"
"github.com/pojntfx/stfs/internal/records"
"github.com/pojntfx/stfs/internal/signature"
"github.com/pojntfx/stfs/pkg/compression"
"github.com/pojntfx/stfs/pkg/config"
"github.com/pojntfx/stfs/pkg/encryption"
"github.com/pojntfx/stfs/pkg/signature"
)
func Fetch(

View File

@@ -8,11 +8,11 @@ import (
"math"
"github.com/pojntfx/stfs/internal/converters"
"github.com/pojntfx/stfs/internal/encryption"
"github.com/pojntfx/stfs/internal/ioext"
"github.com/pojntfx/stfs/internal/mtio"
"github.com/pojntfx/stfs/internal/signature"
"github.com/pojntfx/stfs/pkg/config"
"github.com/pojntfx/stfs/pkg/encryption"
"github.com/pojntfx/stfs/pkg/signature"
)
func Query(