Minor nits
This commit is contained in:
parent
e8fb164f18
commit
b7ea2ae4df
@ -57,8 +57,8 @@ func addS3Commands(cmd *cobra.Command) *cobra.Command {
|
|||||||
// More generic and more frequently used flags take precedence.
|
// More generic and more frequently used flags take precedence.
|
||||||
fs.StringVar(&bucket, "bucket", "", "Name of S3 bucket for repo. (required)")
|
fs.StringVar(&bucket, "bucket", "", "Name of S3 bucket for repo. (required)")
|
||||||
fs.StringVar(&prefix, "prefix", "", "Repo prefix within bucket.")
|
fs.StringVar(&prefix, "prefix", "", "Repo prefix within bucket.")
|
||||||
fs.StringVar(&endpoint, "endpoint", "127.0.0.1:9000", "S3 service endpoint.")
|
fs.StringVar(&endpoint, "endpoint", "s3.amazonaws.com", "S3 service endpoint.")
|
||||||
fs.BoolVar(&doNotUseTLS, "disable-tls", true, "Disable TLS (HTTPS)")
|
fs.BoolVar(&doNotUseTLS, "disable-tls", false, "Disable TLS (HTTPS)")
|
||||||
fs.BoolVar(&doNotVerifyTLS, "disable-tls-verification", false, "Disable TLS (HTTPS) certificate verification.")
|
fs.BoolVar(&doNotVerifyTLS, "disable-tls-verification", false, "Disable TLS (HTTPS) certificate verification.")
|
||||||
|
|
||||||
// In general, we don't want to expose this flag to users and have them mistake it
|
// In general, we don't want to expose this flag to users and have them mistake it
|
||||||
|
|||||||
@ -22,7 +22,7 @@ type CorsoItemExtensionFactory func(
|
|||||||
*details.ExtensionInfo,
|
*details.ExtensionInfo,
|
||||||
) (CorsoItemExtension, error)
|
) (CorsoItemExtension, error)
|
||||||
|
|
||||||
// Thin wrapper for runtime logging & metrics
|
// Thin wrapper for runtime logging & metrics around extensions
|
||||||
type loggerExtension struct {
|
type loggerExtension struct {
|
||||||
info details.ItemInfo
|
info details.ItemInfo
|
||||||
innerRc io.ReadCloser
|
innerRc io.ReadCloser
|
||||||
@ -84,7 +84,8 @@ var _ AddItemExtensioner = &ItemExtensionHandler{}
|
|||||||
type ItemExtensionHandler struct{}
|
type ItemExtensionHandler struct{}
|
||||||
|
|
||||||
// AddItemExtensions wraps provided readcloser with extensions
|
// AddItemExtensions wraps provided readcloser with extensions
|
||||||
// supplied via factory
|
// supplied via factory, with the first extension in slice being
|
||||||
|
// the innermost one.
|
||||||
func (eh *ItemExtensionHandler) AddItemExtensions(
|
func (eh *ItemExtensionHandler) AddItemExtensions(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
rc io.ReadCloser,
|
rc io.ReadCloser,
|
||||||
|
|||||||
@ -20,9 +20,7 @@ import (
|
|||||||
|
|
||||||
var _ CorsoItemExtension = &MockExtension{}
|
var _ CorsoItemExtension = &MockExtension{}
|
||||||
|
|
||||||
// Temporary, testing purposes only
|
|
||||||
type MockExtension struct {
|
type MockExtension struct {
|
||||||
// TODO: Add cumlulative crc32 checksum
|
|
||||||
numBytes int
|
numBytes int
|
||||||
crc32 uint32
|
crc32 uint32
|
||||||
info details.ItemInfo
|
info details.ItemInfo
|
||||||
@ -48,7 +46,7 @@ func (me *MockExtension) Read(p []byte) (int, error) {
|
|||||||
me.crc32 = crc32.Update(me.crc32, crc32.IEEETable, p[:n])
|
me.crc32 = crc32.Update(me.crc32, crc32.IEEETable, p[:n])
|
||||||
|
|
||||||
if err == io.EOF {
|
if err == io.EOF {
|
||||||
logger.Ctx(me.ctx).Info("mock extension reached EOF")
|
logger.Ctx(me.ctx).Debug("mock extension reached EOF")
|
||||||
me.extInfo.Data["numBytes"] = me.numBytes
|
me.extInfo.Data["numBytes"] = me.numBytes
|
||||||
me.extInfo.Data["crc32"] = me.crc32
|
me.extInfo.Data["crc32"] = me.crc32
|
||||||
}
|
}
|
||||||
@ -97,25 +95,6 @@ func TestExtensionsUnitSuite(t *testing.T) {
|
|||||||
suite.Run(t, &ExtensionsUnitSuite{Suite: tester.NewUnitSuite(t)})
|
suite.Run(t, &ExtensionsUnitSuite{Suite: tester.NewUnitSuite(t)})
|
||||||
}
|
}
|
||||||
|
|
||||||
// func readFrom(rc io.ReadCloser) error {
|
|
||||||
// defer rc.Close()
|
|
||||||
|
|
||||||
// p := make([]byte, 4)
|
|
||||||
|
|
||||||
// for {
|
|
||||||
// _, err := rc.Read(p)
|
|
||||||
// if err == io.EOF {
|
|
||||||
// break
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if err != nil {
|
|
||||||
// return err
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// return nil
|
|
||||||
// }
|
|
||||||
|
|
||||||
func (suite *ExtensionsUnitSuite) TestAddItemExtensions() {
|
func (suite *ExtensionsUnitSuite) TestAddItemExtensions() {
|
||||||
type outputValidationFunc func(
|
type outputValidationFunc func(
|
||||||
extRc io.ReadCloser,
|
extRc io.ReadCloser,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user