Skip to content

Commit

Permalink
Fix typos (#209)
Browse files Browse the repository at this point in the history
* Fix typos

* Add changelog entry

---------

Co-authored-by: John Judd <[email protected]>
  • Loading branch information
NathanBaulch and funkyshu authored Nov 3, 2024
1 parent 4c42b46 commit a6121a9
Show file tree
Hide file tree
Showing 59 changed files with 196 additions and 195 deletions.
19 changes: 10 additions & 9 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
### Fixed
- Unit Test improvements: report underlying unit tests errors, always run test cases in a sub-test, always use test suite functions, use more specific assert functions where possible.
- General spelling and grammar corrections everywhere.

## [6.20.0] - 2024-10-15
### Added
Expand Down Expand Up @@ -53,7 +54,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [6.14.1] - 2024-05-28
### Fixed
- Fixed #185 - location.Exists was checking if a list entry was a directory but it was was only checking the first entry.
- Fixed #185 - location.Exists was checking if a list entry was a directory but it was only checking the first entry.

## [6.14.0] - 2024-05-15
### Security
Expand All @@ -62,7 +63,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [6.13.2] - 2024-05-15
### Fixed
- Fixed #182 - location.Exists was checking the wrong dir for existence. Now it checks the file's parent dir for the subdir's existence.
- Corrected where file.Close() occurs then file.Location().NewFile("somefile.txt") but was not repsecting the connection reset. Now it does.
- Corrected where file.Close() occurs then file.Location().NewFile("somefile.txt") but was not respecting the connection reset. Now it does.

## [6.13.1] - 2024-04-24
### Fixed
Expand Down Expand Up @@ -98,7 +99,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [6.11.3] - 2024-02-02
### Fixed
- Fixed #158 bug. Updated sftp backend to to fix issue where some servers return a generic error message when a file is opened for RW on Read().
- Fixed #158 bug. Updated sftp backend to fix issue where some servers return a generic error message when a file is opened for RW on Read().

## [6.11.2] - 2024-01-30
### Fixed
Expand All @@ -116,7 +117,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
- fixed #145 - Remove use of local temp file when reading/seeking from s3 files. This should improve performance by allowing streaming reads from s3 files.
### Added
- fixes #149 - Add overrideable default HostKeyAlgorithms, Ciphers, MACs, and KeyExchanges
- fixes #149 - Add overridable default HostKeyAlgorithms, Ciphers, MACs, and KeyExchanges

## [6.9.1] - 2023-11-21
### Fixed
Expand Down Expand Up @@ -238,7 +239,7 @@ using concurrent go routines to download parts of the file vs. a single request
## [5.9.0] - 2021-09-07
### Added
- Add support (and tests) for Go 1.17. Updated dependencies.
- Updated golanci.yml config.
- Updated golangci.yml config.
### Fixed
- fixed broken backend integration test.

Expand Down Expand Up @@ -324,8 +325,8 @@ https://docs.aws.amazon.com/AmazonS3/latest/dev/acl-overview.html#canned-acl for
## [5.2.3] - 2019-08-07
### Fixed
- The GS implementation of location.List() returned an empty string for files found inside a persistent "folder" object
created in the UI or by createing a zero-length object ending with "/". These objects are now ignored.
- Fixed a gs-to-gs copy bug that became visible with integration tests aded in v5.2.2.
created in the UI or by creating a zero-length object ending with "/". These objects are now ignored.
- Fixed a gs-to-gs copy bug that became visible with integration tests added in v5.2.2.

## [5.2.2] - 2019-07-17
### Fixed
Expand Down Expand Up @@ -358,15 +359,15 @@ created in the UI or by createing a zero-length object ending with "/". These o

## [5.0.0] - 2019-06-18
### Changed
- Defined stricter definitions in interfaces, largely related to input requiements being more
- Defined stricter definitions in interfaces, largely related to input requirements being more
URI compliant.
- FileSystem's NewFile and NewLocation required absolute paths. Locations NewFile and NewLocation require relative paths.
- Added/Updated several new utils functions for URI validation across implementations.
- Ensure native methods are being used for atomic functions like copy or move/rename where possible
- Document expected behavior with empty readers in all copy and move function as well as io.Copy
- ListByPrefix now allows relative paths.
### Added
- Integration test suite for backened developers that ensures expected interface behaviors and tests interactions
- Integration test suite for backend developers that ensures expected interface behaviors and tests interactions
between implementations.
- Examples of io.Copy usage in docs.
### Fixed
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ go install github.com/c2fo/vfs/v6
### Upgrading

#### Upgrading from v5 to v6
With v6.0.0, sftp.Options struct changed to to accept an array of Key Exchange algorithms rather than a string. To update, change the syntax of the auth commands.
With v6.0.0, sftp.Options struct changed to accept an array of Key Exchange algorithms rather than a string. To update, change the syntax of the auth commands.
```
"keyExchanges":"diffie-hellman-group-a256"
```
Expand All @@ -85,7 +85,7 @@ becomes
### Usage

We provide [vfssimple](docs/vfssimple.md) as basic way of initializing file system backends (see each
implementations's docs about authentication). [vfssimple](docs/vfssimple.md) pulls in every c2fo/vfs
implementation's docs about authentication). [vfssimple](docs/vfssimple.md) pulls in every c2fo/vfs
backend. If you need to reduce the backend requirements (and app memory
footprint) or add a third party backend, you'll need to implement your own
"factory". See [backend](docs/backend.md) doc for more info.
Expand Down Expand Up @@ -134,7 +134,7 @@ Note: [io.Copy()](https://godoc.org/io#Copy) doesn't strictly define what happen
will first delegate actual copying in the following:
1. if the io.Reader also implements io.WriterTo, WriteTo() will do the copy
2. if the io.Writer also implements io.ReaderFrom, ReadFrom() will do the copy
3. finally, if neither 1 or 2, io.Copy will do it's own buffered copy
3. finally, if neither 1 or 2, io.Copy will do its own buffered copy

In case 3, and most implementations of cases 1 and 2, if reader is empty, Write() never gets called. What that means for
vfs is there is no way for us to ensure that an empty file does or doesn't get written on an io.Copy(). For instance
Expand Down Expand Up @@ -395,7 +395,7 @@ type Location interface {
// Note: Some file systems may not have a volume and will return "".
Volume() string

// Path returns absolute location path, ie /some/path/to/. An absolute path must be resolved to it's shortest path:
// Path returns absolute location path, ie /some/path/to/. An absolute path must be resolved to its shortest path:
// see path.Clean
Path() string

Expand Down
2 changes: 1 addition & 1 deletion backend/azure/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ func (a *DefaultClient) Copy(srcFile, tgtFile vfs.File) error {
}

// List will return a listing of the contents of the given location. Each item in the list will contain the full key
// as specified by the azure blob (incliding the virtual 'path').
// as specified by the azure blob (including the virtual 'path').
func (a *DefaultClient) List(l vfs.Location) ([]string, error) {
URL, err := url.Parse(l.(*Location).ContainerURL())
if err != nil {
Expand Down
8 changes: 4 additions & 4 deletions backend/azure/client_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ func (s *ClientIntegrationTestSuite) TestProperties() {
err = client.Upload(f, strings.NewReader("Hello world!"))
s.NoError(err, "The file should be successfully uploaded to azure so we shouldn't get an error")
props, err := client.Properties(f.Location().(*Location).ContainerURL(), f.Path())
s.NoError(err, "Tne file exists so we shouldn't get an error")
s.NoError(err, "The file exists so we shouldn't get an error")
s.NotNil(props, "We should get a non-nil BlobProperties pointer back")
s.Greater(props.Size, uint64(0), "The size should be greater than zero")
s.NotNil(props.LastModified, "Should have a non-nil LastModified")
Expand Down Expand Up @@ -204,7 +204,7 @@ func (s *ClientIntegrationTestSuite) TestProperties_NonExistentFile() {
s.NoError(err, "Env variables (AZURE_STORAGE_ACCOUNT, AZURE_STORAGE_ACCESS_KEY) should contain valid azure account credentials")

_, err = client.Properties(f.Location().URI(), f.Path())
s.Error(err, "Tne file does not exist so we expect an error")
s.Error(err, "The file does not exist so we expect an error")
s.Equal(404, err.(azblob.ResponseError).Response().StatusCode)
}

Expand All @@ -216,10 +216,10 @@ func (s *ClientIntegrationTestSuite) TestDelete_NonExistentFile() {
s.NoError(err, "Env variables (AZURE_STORAGE_ACCOUNT, AZURE_STORAGE_ACCESS_KEY) should contain valid azure account credentials")

err = client.Delete(f)
s.Error(err, "Tne file does not exist so we expect an error")
s.Error(err, "The file does not exist so we expect an error")
}

func (s *ClientIntegrationTestSuite) TestTouch_NonexistantContainer() {
func (s *ClientIntegrationTestSuite) TestTouch_NonexistentContainer() {
fs := NewFileSystem()
f, err := fs.NewFile("nosuchcontainer", "/file.txt")
s.NoError(err)
Expand Down
10 changes: 5 additions & 5 deletions backend/azure/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,19 @@ Or call directly:
import "github.com/c2fo/vfs/v6/backend/azure"
func DoSomething() {
fs := azure.NewFilesystem()
fs := azure.NewFileSystem()
...
}
azure can be augmented with the following implementation-specific methods. Backend returns vfs.Filesystem interface so it
would have to be cast as azure.Filesystem to use the following:
azure can be augmented with the following implementation-specific methods. Backend returns vfs.FileSystem interface so it
would have to be cast as azure.FileSystem to use the following:
func DoSomething() {
...
// cast if fs was created using backend.Backend(). Not necessary if created directly from azure.NewFilesystem().
fs = fs.(azure.Filesystem)
// cast if fs was created using backend.Backend(). Not necessary if created directly from azure.NewFileSystem().
fs = fs.(azure.FileSystem)
// to pass in client options
fs = fs.WithOptions(
Expand Down
2 changes: 1 addition & 1 deletion backend/azure/fileSystem_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func (s *FileSystemTestSuite) TestNewFile() {
func (s *FileSystemTestSuite) TestNewFile_NilReceiver() {
var fs *FileSystem
file, err := fs.NewFile("temp", "/foo/bar/test.txt")
s.EqualError(err, "azure.FileSystem receiver pointer must be non-nil", "the receiver pointer is nil so we whould receive an error")
s.EqualError(err, "azure.FileSystem receiver pointer must be non-nil", "the receiver pointer is nil so we would receive an error")
s.Nil(file, "Since there was an error we expect a nil file to be returned")
}

Expand Down
8 changes: 4 additions & 4 deletions backend/azure/file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,14 @@ func (s *FileTestSuite) TestExists() {
s.True(exists)
}

func (s *FileTestSuite) TestExists_NonExistantFile() {
func (s *FileTestSuite) TestExists_NonExistentFile() {
client := MockAzureClient{PropertiesError: MockStorageError{}}
fs := NewFileSystem().WithClient(&client)

f, err := fs.NewFile("test-container", "/foo.txt")
s.NoError(err, "The path is valid so no error should be returned")
exists, err := f.Exists()
s.NoError(err, "no error is returned when the file does not exist")
s.NoError(err, "no error is returned when the file does not exist")
s.False(exists)
}

Expand Down Expand Up @@ -241,7 +241,7 @@ func (s *FileTestSuite) TestSize() {
s.Equal(uint64(5), size, "The size should be 5")
}

func (s *FileTestSuite) TestSize_NonExistantFile() {
func (s *FileTestSuite) TestSize_NonExistentFile() {
client := MockAzureClient{PropertiesError: errors.New("i always error")}
fs := NewFileSystem().WithClient(&client)

Expand Down Expand Up @@ -278,7 +278,7 @@ func (s *FileTestSuite) TestTouch() {
s.NoError(f.Touch())
}

func (s *FileTestSuite) TestTouch_NonexistantContainer() {
func (s *FileTestSuite) TestTouch_NonexistentContainer() {
client := MockAzureClient{ExpectedError: errors.New("i always error")}
fs := NewFileSystem().WithClient(&client)

Expand Down
2 changes: 1 addition & 1 deletion backend/azure/location_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ func (s *LocationTestSuite) TestNewLocation() {
func (s *LocationTestSuite) TestNewLocation_NilReceiver() {
var l *Location
nl, err := l.NewLocation("test-container/")
s.EqualError(err, "azure.Location receiver pointer must be non-nil", "The receiver for NewLocaiton must be non-nil so we expect an error")
s.EqualError(err, "azure.Location receiver pointer must be non-nil", "The receiver for NewLocation must be non-nil so we expect an error")
s.Nil(nl, "An error was returned so we expect a nil location to be returned")
}

Expand Down
2 changes: 1 addition & 1 deletion backend/azure/mock_token.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
// MockTokenCredentialFactory knows how to create a "do-nothing" credential used for unit testing
type MockTokenCredentialFactory struct{}

// New creates a new azblob.TokenCredntial struct
// New creates a new azblob.TokenCredential struct
func (f *MockTokenCredentialFactory) New(tenantID, clientID, clientSecret, azureEnvName string) (azblob.TokenCredential, error) {
return azblob.NewTokenCredential("aaa", func(credential azblob.TokenCredential) time.Duration { return time.Second * 1 }), nil
}
4 changes: 2 additions & 2 deletions backend/azure/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ import (
// TokenCredentialFactory is an interface that provides a single factory method to create azure.TokenCredentials. This
// interface is provided to allow for mocking in unit tests.
type TokenCredentialFactory interface {
// New creates a new azblob.TokenCredntial struct
// New creates a new azblob.TokenCredential struct
New(tenantID, clientID, clientSecret, azureEnvName string) (azblob.TokenCredential, error)
}

// DefaultTokenCredentialFactory knows how to make azblob.TokenCredential structs for OAuth authentication
type DefaultTokenCredentialFactory struct{}

// New creates a new azblob.TokenCredntial struct
// New creates a new azblob.TokenCredential struct
func (f *DefaultTokenCredentialFactory) New(tenantID, clientID, clientSecret, azureEnvName string) (azblob.TokenCredential, error) {
env, err := azure.EnvironmentFromName(azureEnvName)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion backend/backend_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func (s *testSuite) TestBackend() {

// get backend
b := Backend("new mock")
s.IsType(&mocks.FileSystem{}, b, "type is mocks.Filesystem")
s.IsType(&mocks.FileSystem{}, b, "type is mocks.FileSystem")

// check all RegisteredBackends names
s.Len(RegisteredBackends(), 3, "found 3 backends")
Expand Down
2 changes: 1 addition & 1 deletion backend/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Then ensure it registers itself on load:
// register backend
func init() {
backend.Register("exfs", &MyExoticFilesystem{})
backend.Register("exfs", &MyExoticFileSystem{})
}
Then do use it in some other package do
Expand Down
4 changes: 2 additions & 2 deletions backend/ftp/dataconn.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func (dc *dataConn) Rename(from, to string) error {
}

// IsSetTimeSupported will specify whether the ftp
// set time function is availalbe for the connection.
// set time function is available for the connection.
func (dc *dataConn) IsSetTimeSupported() bool {
return dc.c.IsSetTimeSupported()
}
Expand Down Expand Up @@ -125,7 +125,7 @@ func (dc *dataConn) Close() error {
if err := dc.W.Close(); err != nil {
return err
}
// after writer is closed STOR shoud commit - check for error
// after writer is closed STOR should commit - check for error
err := <-dc.errChan
dc.W = nil
dc.R = nil
Expand Down
6 changes: 3 additions & 3 deletions backend/ftp/dataconn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func (s *dataConnSuite) TestGetDataConn_ReadError() {

func (s *dataConnSuite) TestGetDataConn_WriteLocationNotExists() {

// dataconn is nil - opebrewn for write - location doesnt exist - success
// dataconn is nil - open for write - location doesn't exist - success
s.client.EXPECT().
List("/").
Return(nil, errors.New("550")).
Expand All @@ -115,7 +115,7 @@ func (s *dataConnSuite) TestGetDataConn_WriteLocationNotExists() {

func (s *dataConnSuite) TestGetDataConn_WriteLocationNotExistsFails() {
someerr := errors.New("some error")
// dataconn is nil - opebrewn for write - location doesnt exist - success
// dataconn is nil - open for write - location doesn't exist - success
s.client.EXPECT().
List("/").
Return(nil, errors.New("550")).
Expand Down Expand Up @@ -177,7 +177,7 @@ func (s *dataConnSuite) TestGetDataConn_writeSuccess() {
time.Sleep(50 * time.Millisecond)
}

func (s *dataConnSuite) TestGetDataConn_reaedAfterWriteError() {
func (s *dataConnSuite) TestGetDataConn_readAfterWriteError() {

// open dataconn for read after dataconn for write exists - error on dataconn.Close
fakedconn := NewFakeDataConn(types.OpenWrite)
Expand Down
10 changes: 5 additions & 5 deletions backend/ftp/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Or call directly:
import "github.com/c2fo/vfs/v6/backend/ftp"
func DoSomething() {
fs := ftp.NewFilesystem()
fs := ftp.NewFileSystem()
location, err := fs.NewLocation("[email protected]:21", "/some/path/")
if err != nil {
Expand All @@ -29,18 +29,18 @@ Or call directly:
...
}
ftp can be augmented with some implementation-specific methods. Backend returns vfs.Filesystem interface so it
would have to be cast as ftp.Filesystem to use them.
ftp can be augmented with some implementation-specific methods. Backend returns vfs.FileSystem interface so it
would have to be cast as ftp.FileSystem to use them.
These methods are chainable:
(*FileSystem) WithClient(client interface{}) *FileSystem
(*FileSystem) WithOptions(opts vfs.Options) *FileSystem
func DoSomething() {
// cast if fs was created using backend.Backend(). Not necessary if created directly from ftp.NewFilesystem().
// cast if fs was created using backend.Backend(). Not necessary if created directly from ftp.NewFileSystem().
fs := backend.Backend(ftp.Scheme)
fs = fs.(*ftp.Filesystem)
fs = fs.(*ftp.FileSystem)
// to pass specific client implementing types.Client interface (in this case, _ftp github.com/jlaffaye/ftp)
client, _ := _ftp.Dial("server.com:21")
Expand Down
4 changes: 2 additions & 2 deletions backend/ftp/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func (f *File) stat(ctx context.Context) (*_ftp.Entry, error) {
if err != nil {
return nil, err
}
// check if MLSD command is availalbe - if so we'll want to grab file info
// check if MLSD command is available - if so we'll want to grab file info
// via MLST. otherwise we'll need to use LIST.
if dc.IsTimePreciseInList() {
entry, err := dc.GetEntry(f.Path())
Expand Down Expand Up @@ -175,7 +175,7 @@ func (f *File) Location() vfs.Location {
// If the copy succeeds, the source file is deleted. Any errors from the copy or delete are
// returned.
// If the given location is also ftp AND for the same user and host, the ftp Rename method is used, otherwise
// we'll do a an io.Copy to the destination file then delete source file.
// we'll do an io.Copy to the destination file then delete source file.
func (f *File) MoveToFile(t vfs.File) error {
// ftp rename if vfs is ftp and for the same user/host
if f.fileSystem.Scheme() == t.Location().FileSystem().Scheme() &&
Expand Down
4 changes: 2 additions & 2 deletions backend/ftp/fileSystem.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const name = "File Transfer Protocol"
var dataConnGetterFunc func(context.Context, utils.Authority, *FileSystem, *File, types.OpenType) (types.DataConn, error)
var defaultClientGetter func(context.Context, utils.Authority, Options) (client types.Client, err error)

// FileSystem implements vfs.Filesystem for the FTP filesystem.
// FileSystem implements vfs.FileSystem for the FTP filesystem.
type FileSystem struct {
options vfs.Options
ftpclient types.Client
Expand Down Expand Up @@ -146,6 +146,6 @@ func NewFileSystem() *FileSystem {
func init() {
defaultClientGetter = getClient
dataConnGetterFunc = getDataConn
// registers a default Filesystem
// registers a default FileSystem
backend.Register(Scheme, NewFileSystem())
}
Loading

0 comments on commit a6121a9

Please sign in to comment.