refactor: Use consistent naming scheme for config keys

This commit is contained in:
Felicitas Pojtinger
2022-01-08 23:42:32 +01:00
parent 46eef49429
commit f3657dc189
7 changed files with 28 additions and 28 deletions

View File

@@ -169,7 +169,7 @@ func init() {
operationArchiveCmd.PersistentFlags().IntP(recordSizeFlag, "z", 20, "Amount of 512-bit blocks per record")
operationArchiveCmd.PersistentFlags().StringP(fromFlag, "f", ".", "File or directory to archive")
operationArchiveCmd.PersistentFlags().BoolP(overwriteFlag, "o", false, "Start writing from the start instead of from the end of the tape or tar file")
operationArchiveCmd.PersistentFlags().StringP(compressionLevelFlag, "l", config.CompressionLevelBalanced, fmt.Sprintf("Compression level to use (default %v, available are %v)", config.CompressionLevelBalanced, config.KnownCompressionLevels))
operationArchiveCmd.PersistentFlags().StringP(compressionLevelFlag, "l", config.CompressionLevelBalancedKey, fmt.Sprintf("Compression level to use (default %v, available are %v)", config.CompressionLevelBalancedKey, config.KnownCompressionLevels))
operationArchiveCmd.PersistentFlags().StringP(recipientFlag, "r", "", "Path to public key of recipient to encrypt for")
operationArchiveCmd.PersistentFlags().StringP(identityFlag, "i", "", "Path to private key to sign with")
operationArchiveCmd.PersistentFlags().StringP(passwordFlag, "p", "", "Password for the private key")

View File

@@ -160,7 +160,7 @@ func init() {
operationUpdateCmd.PersistentFlags().IntP(recordSizeFlag, "z", 20, "Amount of 512-bit blocks per record")
operationUpdateCmd.PersistentFlags().StringP(fromFlag, "f", "", "Path of the file or directory to update")
operationUpdateCmd.PersistentFlags().BoolP(overwriteFlag, "o", false, "Replace the content on the tape or tar file")
operationUpdateCmd.PersistentFlags().StringP(compressionLevelFlag, "l", config.CompressionLevelBalanced, fmt.Sprintf("Compression level to use (default %v, available are %v)", config.CompressionLevelBalanced, config.KnownCompressionLevels))
operationUpdateCmd.PersistentFlags().StringP(compressionLevelFlag, "l", config.CompressionLevelBalancedKey, fmt.Sprintf("Compression level to use (default %v, available are %v)", config.CompressionLevelBalancedKey, config.KnownCompressionLevels))
operationUpdateCmd.PersistentFlags().StringP(recipientFlag, "r", "", "Path to public key of recipient to encrypt for")
operationUpdateCmd.PersistentFlags().StringP(identityFlag, "i", "", "Path to private key to sign with")
operationUpdateCmd.PersistentFlags().StringP(passwordFlag, "p", "", "Password for the private key")

View File

@@ -247,7 +247,7 @@ func init() {
serveFTPCmd.PersistentFlags().StringP(signaturePasswordFlag, "x", "", "Password for the private key to sign with")
serveFTPCmd.PersistentFlags().StringP(signatureRecipientFlag, "r", "", "Path to the public key to verify with")
serveFTPCmd.PersistentFlags().StringP(compressionLevelFlag, "l", config.CompressionLevelBalanced, fmt.Sprintf("Compression level to use (default %v, available are %v)", config.CompressionLevelBalanced, config.KnownCompressionLevels))
serveFTPCmd.PersistentFlags().StringP(compressionLevelFlag, "l", config.CompressionLevelBalancedKey, fmt.Sprintf("Compression level to use (default %v, available are %v)", config.CompressionLevelBalancedKey, config.KnownCompressionLevels))
serveFTPCmd.PersistentFlags().StringP(laddrFlag, "a", "localhost:1337", "Listen address")
serveFTPCmd.PersistentFlags().StringP(cacheFileSystemFlag, "n", config.NoneKey, fmt.Sprintf("File system cache to use (default %v, available are %v)", config.NoneKey, config.KnownFileSystemCacheTypes))
serveFTPCmd.PersistentFlags().StringP(cacheWriteFlag, "q", config.WriteCacheTypeFile, fmt.Sprintf("Write cache to use (default %v, available are %v)", config.WriteCacheTypeFile, config.KnownWriteCacheTypes))

View File

@@ -214,10 +214,10 @@ func main() {
encryptionPassword := "testEncryptionPassword"
compression := config.CompressionFormatZStandardKey
compressionLevel := config.CompressionLevelFastest
compressionLevel := config.CompressionLevelFastestKey
writeCacheDir := filepath.Join(tmp, "write-cache")
writeCache := config.WriteCacheTypeFile
writeCacheDir := filepath.Join(tmp, "write-cache")
fileSystemCache := config.FileSystemCacheTypeDir
fileSystemCacheDir := filepath.Join(tmp, "filesystem-cache")

View File

@@ -91,7 +91,7 @@ func main() {
Metadata: metadataPersister,
},
config.CompressionLevelFastest,
config.CompressionLevelFastestKey,
func() (cache.WriteCache, func() error, error) {
return cache.NewCacheWrite(
*writeCacheFlag,

View File

@@ -37,11 +37,11 @@ func Compress(
l := gzip.DefaultCompression
switch compressionLevel {
case config.CompressionLevelFastest:
case config.CompressionLevelFastestKey:
l = gzip.BestSpeed
case config.CompressionLevelBalanced:
case config.CompressionLevelBalancedKey:
l = gzip.DefaultCompression
case config.CompressionLevelSmallest:
case config.CompressionLevelSmallestKey:
l = gzip.BestCompression
default:
return nil, config.ErrCompressionLevelUnsupported
@@ -56,11 +56,11 @@ func Compress(
l := pgzip.DefaultCompression
switch compressionLevel {
case config.CompressionLevelFastest:
case config.CompressionLevelFastestKey:
l = pgzip.BestSpeed
case config.CompressionLevelBalanced:
case config.CompressionLevelBalancedKey:
l = pgzip.DefaultCompression
case config.CompressionLevelSmallest:
case config.CompressionLevelSmallestKey:
l = pgzip.BestCompression
default:
return nil, config.ErrCompressionLevelUnsupported
@@ -70,11 +70,11 @@ func Compress(
case config.CompressionFormatLZ4Key:
l := lz4.Level5
switch compressionLevel {
case config.CompressionLevelFastest:
case config.CompressionLevelFastestKey:
l = lz4.Level1
case config.CompressionLevelBalanced:
case config.CompressionLevelBalancedKey:
l = lz4.Level5
case config.CompressionLevelSmallest:
case config.CompressionLevelSmallestKey:
l = lz4.Level9
default:
return nil, config.ErrCompressionLevelUnsupported
@@ -108,11 +108,11 @@ func Compress(
case config.CompressionFormatZStandardKey:
l := zstd.SpeedDefault
switch compressionLevel {
case config.CompressionLevelFastest:
case config.CompressionLevelFastestKey:
l = zstd.SpeedFastest
case config.CompressionLevelBalanced:
case config.CompressionLevelBalancedKey:
l = zstd.SpeedDefault
case config.CompressionLevelSmallest:
case config.CompressionLevelSmallestKey:
l = zstd.SpeedBestCompression
default:
return nil, config.ErrCompressionLevelUnsupported
@@ -136,11 +136,11 @@ func Compress(
l := brotli.DefaultCompression
switch compressionLevel {
case config.CompressionLevelFastest:
case config.CompressionLevelFastestKey:
l = brotli.BestSpeed
case config.CompressionLevelBalanced:
case config.CompressionLevelBalancedKey:
l = brotli.DefaultCompression
case config.CompressionLevelSmallest:
case config.CompressionLevelSmallestKey:
l = brotli.BestCompression
default:
return nil, config.ErrCompressionLevelUnsupported
@@ -154,11 +154,11 @@ func Compress(
case config.CompressionFormatBzip2ParallelKey:
l := bzip2.DefaultCompression
switch compressionLevel {
case config.CompressionLevelFastest:
case config.CompressionLevelFastestKey:
l = bzip2.BestSpeed
case config.CompressionLevelBalanced:
case config.CompressionLevelBalancedKey:
l = bzip2.DefaultCompression
case config.CompressionLevelSmallest:
case config.CompressionLevelSmallestKey:
l = bzip2.BestCompression
default:
return nil, config.ErrCompressionLevelUnsupported

View File

@@ -17,9 +17,9 @@ const (
SignatureFormatMinisignKey = "minisign"
SignatureFormatPGPKey = "pgp"
CompressionLevelFastest = "fastest"
CompressionLevelBalanced = "balanced"
CompressionLevelSmallest = "smallest"
CompressionLevelFastestKey = "fastest"
CompressionLevelBalancedKey = "balanced"
CompressionLevelSmallestKey = "smallest"
HeaderEventTypeArchive = "archive"
HeaderEventTypeDelete = "delete"
@@ -37,7 +37,7 @@ const (
)
var (
KnownCompressionLevels = []string{CompressionLevelFastest, CompressionLevelBalanced, CompressionLevelSmallest}
KnownCompressionLevels = []string{CompressionLevelFastestKey, CompressionLevelBalancedKey, CompressionLevelSmallestKey}
KnownCompressionFormats = []string{NoneKey, CompressionFormatGZipKey, CompressionFormatParallelGZipKey, CompressionFormatLZ4Key, CompressionFormatZStandardKey, CompressionFormatBrotliKey, CompressionFormatBzip2Key, CompressionFormatBzip2ParallelKey}