refactor: Inject mtio package to allow for remote implementation
This commit is contained in:
@@ -2,6 +2,7 @@ package cmd
|
||||
|
||||
import (
|
||||
"github.com/pojntfx/stfs/pkg/hardware"
|
||||
"github.com/pojntfx/stfs/pkg/mtio"
|
||||
"github.com/pojntfx/stfs/pkg/tape"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
@@ -23,7 +24,10 @@ var driveEjectCmd = &cobra.Command{
|
||||
}
|
||||
defer reader.Close()
|
||||
|
||||
return hardware.Eject(reader.Fd())
|
||||
return hardware.Eject(
|
||||
mtio.MagneticTapeIO{},
|
||||
reader.Fd(),
|
||||
)
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"fmt"
|
||||
|
||||
"github.com/pojntfx/stfs/pkg/hardware"
|
||||
"github.com/pojntfx/stfs/pkg/mtio"
|
||||
"github.com/pojntfx/stfs/pkg/tape"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
@@ -25,7 +26,10 @@ var driveTellCmd = &cobra.Command{
|
||||
}
|
||||
defer reader.Close()
|
||||
|
||||
currentRecord, err := hardware.Tell(reader.Fd())
|
||||
currentRecord, err := hardware.Tell(
|
||||
mtio.MagneticTapeIO{},
|
||||
reader.Fd(),
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import (
|
||||
"github.com/pojntfx/stfs/internal/logging"
|
||||
"github.com/pojntfx/stfs/pkg/config"
|
||||
"github.com/pojntfx/stfs/pkg/keys"
|
||||
"github.com/pojntfx/stfs/pkg/mtio"
|
||||
"github.com/pojntfx/stfs/pkg/operations"
|
||||
"github.com/pojntfx/stfs/pkg/persisters"
|
||||
"github.com/pojntfx/stfs/pkg/tape"
|
||||
@@ -69,8 +70,10 @@ var operationArchiveCmd = &cobra.Command{
|
||||
return err
|
||||
}
|
||||
|
||||
mt := mtio.MagneticTapeIO{}
|
||||
tm := tape.NewTapeManager(
|
||||
viper.GetString(driveFlag),
|
||||
mt,
|
||||
viper.GetInt(recordSizeFlag),
|
||||
viper.GetBool(overwriteFlag),
|
||||
)
|
||||
@@ -87,6 +90,8 @@ var operationArchiveCmd = &cobra.Command{
|
||||
|
||||
GetReader: tm.GetReader,
|
||||
CloseReader: tm.Close,
|
||||
|
||||
MagneticTapeIO: mt,
|
||||
},
|
||||
config.MetadataConfig{
|
||||
Metadata: metadataPersister,
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"github.com/pojntfx/stfs/internal/logging"
|
||||
"github.com/pojntfx/stfs/pkg/config"
|
||||
"github.com/pojntfx/stfs/pkg/keys"
|
||||
"github.com/pojntfx/stfs/pkg/mtio"
|
||||
"github.com/pojntfx/stfs/pkg/operations"
|
||||
"github.com/pojntfx/stfs/pkg/persisters"
|
||||
"github.com/pojntfx/stfs/pkg/tape"
|
||||
@@ -53,8 +54,10 @@ var operationDeleteCmd = &cobra.Command{
|
||||
return err
|
||||
}
|
||||
|
||||
mt := mtio.MagneticTapeIO{}
|
||||
tm := tape.NewTapeManager(
|
||||
viper.GetString(driveFlag),
|
||||
mt,
|
||||
viper.GetInt(recordSizeFlag),
|
||||
false,
|
||||
)
|
||||
@@ -71,6 +74,8 @@ var operationDeleteCmd = &cobra.Command{
|
||||
|
||||
GetReader: tm.GetReader,
|
||||
CloseReader: tm.Close,
|
||||
|
||||
MagneticTapeIO: mt,
|
||||
},
|
||||
config.MetadataConfig{
|
||||
Metadata: metadataPersister,
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"github.com/pojntfx/stfs/internal/logging"
|
||||
"github.com/pojntfx/stfs/pkg/config"
|
||||
"github.com/pojntfx/stfs/pkg/keys"
|
||||
"github.com/pojntfx/stfs/pkg/mtio"
|
||||
"github.com/pojntfx/stfs/pkg/operations"
|
||||
"github.com/pojntfx/stfs/pkg/persisters"
|
||||
"github.com/pojntfx/stfs/pkg/tape"
|
||||
@@ -49,8 +50,10 @@ var operationMoveCmd = &cobra.Command{
|
||||
return err
|
||||
}
|
||||
|
||||
mt := mtio.MagneticTapeIO{}
|
||||
tm := tape.NewTapeManager(
|
||||
viper.GetString(driveFlag),
|
||||
mt,
|
||||
viper.GetInt(recordSizeFlag),
|
||||
false,
|
||||
)
|
||||
@@ -67,6 +70,8 @@ var operationMoveCmd = &cobra.Command{
|
||||
|
||||
GetReader: tm.GetReader,
|
||||
CloseReader: tm.Close,
|
||||
|
||||
MagneticTapeIO: mt,
|
||||
},
|
||||
config.MetadataConfig{
|
||||
Metadata: metadataPersister,
|
||||
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
"github.com/pojntfx/stfs/internal/logging"
|
||||
"github.com/pojntfx/stfs/pkg/config"
|
||||
"github.com/pojntfx/stfs/pkg/keys"
|
||||
"github.com/pojntfx/stfs/pkg/mtio"
|
||||
"github.com/pojntfx/stfs/pkg/operations"
|
||||
"github.com/pojntfx/stfs/pkg/persisters"
|
||||
"github.com/pojntfx/stfs/pkg/tape"
|
||||
@@ -57,8 +58,10 @@ var operationRestoreCmd = &cobra.Command{
|
||||
return err
|
||||
}
|
||||
|
||||
mt := mtio.MagneticTapeIO{}
|
||||
tm := tape.NewTapeManager(
|
||||
viper.GetString(driveFlag),
|
||||
mt,
|
||||
viper.GetInt(recordSizeFlag),
|
||||
false,
|
||||
)
|
||||
@@ -75,6 +78,8 @@ var operationRestoreCmd = &cobra.Command{
|
||||
|
||||
GetReader: tm.GetReader,
|
||||
CloseReader: tm.Close,
|
||||
|
||||
MagneticTapeIO: mt,
|
||||
},
|
||||
config.MetadataConfig{
|
||||
Metadata: metadataPersister,
|
||||
|
||||
@@ -12,6 +12,7 @@ import (
|
||||
"github.com/pojntfx/stfs/internal/logging"
|
||||
"github.com/pojntfx/stfs/pkg/config"
|
||||
"github.com/pojntfx/stfs/pkg/keys"
|
||||
"github.com/pojntfx/stfs/pkg/mtio"
|
||||
"github.com/pojntfx/stfs/pkg/operations"
|
||||
"github.com/pojntfx/stfs/pkg/persisters"
|
||||
"github.com/pojntfx/stfs/pkg/tape"
|
||||
@@ -59,8 +60,10 @@ var operationUpdateCmd = &cobra.Command{
|
||||
return err
|
||||
}
|
||||
|
||||
mt := mtio.MagneticTapeIO{}
|
||||
tm := tape.NewTapeManager(
|
||||
viper.GetString(driveFlag),
|
||||
mt,
|
||||
viper.GetInt(recordSizeFlag),
|
||||
false,
|
||||
)
|
||||
@@ -77,6 +80,8 @@ var operationUpdateCmd = &cobra.Command{
|
||||
|
||||
GetReader: tm.GetReader,
|
||||
CloseReader: tm.Close,
|
||||
|
||||
MagneticTapeIO: mt,
|
||||
},
|
||||
config.MetadataConfig{
|
||||
Metadata: metadataPersister,
|
||||
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
"github.com/pojntfx/stfs/internal/logging"
|
||||
"github.com/pojntfx/stfs/pkg/config"
|
||||
"github.com/pojntfx/stfs/pkg/keys"
|
||||
"github.com/pojntfx/stfs/pkg/mtio"
|
||||
"github.com/pojntfx/stfs/pkg/recovery"
|
||||
"github.com/pojntfx/stfs/pkg/tape"
|
||||
"github.com/spf13/cobra"
|
||||
@@ -71,6 +72,7 @@ var recoveryFetchCmd = &cobra.Command{
|
||||
Drive: reader,
|
||||
DriveIsRegular: readerIsRegular,
|
||||
},
|
||||
mtio.MagneticTapeIO{},
|
||||
config.PipeConfig{
|
||||
Compression: viper.GetString(compressionFlag),
|
||||
Encryption: viper.GetString(encryptionFlag),
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
"github.com/pojntfx/stfs/pkg/config"
|
||||
"github.com/pojntfx/stfs/pkg/encryption"
|
||||
"github.com/pojntfx/stfs/pkg/keys"
|
||||
"github.com/pojntfx/stfs/pkg/mtio"
|
||||
"github.com/pojntfx/stfs/pkg/persisters"
|
||||
"github.com/pojntfx/stfs/pkg/recovery"
|
||||
"github.com/pojntfx/stfs/pkg/signature"
|
||||
@@ -70,6 +71,7 @@ var recoveryIndexCmd = &cobra.Command{
|
||||
Drive: reader,
|
||||
DriveIsRegular: readerIsRegular,
|
||||
},
|
||||
mtio.MagneticTapeIO{},
|
||||
config.MetadataConfig{
|
||||
Metadata: metadataPersister,
|
||||
},
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"github.com/pojntfx/stfs/internal/logging"
|
||||
"github.com/pojntfx/stfs/pkg/config"
|
||||
"github.com/pojntfx/stfs/pkg/keys"
|
||||
"github.com/pojntfx/stfs/pkg/mtio"
|
||||
"github.com/pojntfx/stfs/pkg/recovery"
|
||||
"github.com/pojntfx/stfs/pkg/tape"
|
||||
"github.com/spf13/cobra"
|
||||
@@ -60,6 +61,7 @@ var recoveryQueryCmd = &cobra.Command{
|
||||
Drive: reader,
|
||||
DriveIsRegular: readerIsRegular,
|
||||
},
|
||||
mtio.MagneticTapeIO{},
|
||||
config.PipeConfig{
|
||||
Compression: viper.GetString(compressionFlag),
|
||||
Encryption: viper.GetString(encryptionFlag),
|
||||
|
||||
@@ -15,6 +15,7 @@ import (
|
||||
"github.com/pojntfx/stfs/pkg/config"
|
||||
"github.com/pojntfx/stfs/pkg/fs"
|
||||
"github.com/pojntfx/stfs/pkg/keys"
|
||||
"github.com/pojntfx/stfs/pkg/mtio"
|
||||
"github.com/pojntfx/stfs/pkg/operations"
|
||||
"github.com/pojntfx/stfs/pkg/persisters"
|
||||
"github.com/pojntfx/stfs/pkg/tape"
|
||||
@@ -111,8 +112,10 @@ var serveFTPCmd = &cobra.Command{
|
||||
return err
|
||||
}
|
||||
|
||||
mt := mtio.MagneticTapeIO{}
|
||||
tm := tape.NewTapeManager(
|
||||
viper.GetString(driveFlag),
|
||||
mt,
|
||||
viper.GetInt(recordSizeFlag),
|
||||
false,
|
||||
)
|
||||
@@ -139,6 +142,8 @@ var serveFTPCmd = &cobra.Command{
|
||||
|
||||
GetReader: tm.GetReader,
|
||||
CloseReader: tm.Close,
|
||||
|
||||
MagneticTapeIO: mt,
|
||||
}
|
||||
readCryptoConfig := config.CryptoConfig{
|
||||
Recipient: signatureRecipient,
|
||||
|
||||
@@ -15,6 +15,7 @@ import (
|
||||
"github.com/pojntfx/stfs/pkg/config"
|
||||
"github.com/pojntfx/stfs/pkg/fs"
|
||||
"github.com/pojntfx/stfs/pkg/keys"
|
||||
"github.com/pojntfx/stfs/pkg/mtio"
|
||||
"github.com/pojntfx/stfs/pkg/operations"
|
||||
"github.com/pojntfx/stfs/pkg/persisters"
|
||||
"github.com/pojntfx/stfs/pkg/tape"
|
||||
@@ -70,8 +71,10 @@ var serveHTTPCmd = &cobra.Command{
|
||||
return err
|
||||
}
|
||||
|
||||
mt := mtio.MagneticTapeIO{}
|
||||
tm := tape.NewTapeManager(
|
||||
viper.GetString(driveFlag),
|
||||
mt,
|
||||
viper.GetInt(recordSizeFlag),
|
||||
false,
|
||||
)
|
||||
@@ -95,6 +98,8 @@ var serveHTTPCmd = &cobra.Command{
|
||||
|
||||
GetReader: tm.GetReader,
|
||||
CloseReader: tm.Close,
|
||||
|
||||
MagneticTapeIO: mt,
|
||||
},
|
||||
config.MetadataConfig{
|
||||
Metadata: metadataPersister,
|
||||
|
||||
Reference in New Issue
Block a user