Skip to content

Commit

Permalink
Make error messages lowercase
Browse files Browse the repository at this point in the history
  • Loading branch information
ma-hartma authored and muesli committed Dec 23, 2021
1 parent 8cdff31 commit 4388cb0
Show file tree
Hide file tree
Showing 17 changed files with 41 additions and 41 deletions.
10 changes: 5 additions & 5 deletions backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ type Backend interface {

// Error declarations.
var (
ErrRepositoryExists = errors.New("Repository seems to already exist")
ErrInvalidRepositoryURL = errors.New("Invalid repository url specified")
ErrAvailableSpaceUnknown = errors.New("Available space is unknown or undefined")
ErrAvailableSpaceUnlimited = errors.New("Available space is unlimited")
ErrInvalidUsername = errors.New("Username wrong or missing")
ErrRepositoryExists = errors.New("repository seems to already exist")
ErrInvalidRepositoryURL = errors.New("invalid repository url specified")
ErrAvailableSpaceUnknown = errors.New("available space is unknown or undefined")
ErrAvailableSpaceUnlimited = errors.New("available space is unlimited")
ErrInvalidUsername = errors.New("username wrong or missing")

backends = []BackendFactory{}
)
Expand Down
18 changes: 9 additions & 9 deletions backendmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ type BackendManager struct {

// Error declarations.
var (
ErrLoadChunkFailed = errors.New("Unable to load chunk from any storage backend")
ErrLoadSnapshotFailed = errors.New("Unable to load snapshot from any storage backend")
ErrLoadChunkIndexFailed = errors.New("Unable to load chunk-index from any storage backend")
ErrLoadRepositoryFailed = errors.New("Unable to load repository from any storage backend")
ErrDeleteChunkFailed = errors.New("Unable to delete chunk from any storage backend")
ErrStoreChunkFailed = errors.New("Storing chunk failed")
ErrStoreSnapshotFailed = errors.New("Storing snapshot failed")
ErrStoreChunkIndexFailed = errors.New("Storing chunk-index failed")
ErrStoreRepositoryFailed = errors.New("Storing repository failed")
ErrLoadChunkFailed = errors.New("unable to load chunk from any storage backend")
ErrLoadSnapshotFailed = errors.New("unable to load snapshot from any storage backend")
ErrLoadChunkIndexFailed = errors.New("unable to load chunk-index from any storage backend")
ErrLoadRepositoryFailed = errors.New("unable to load repository from any storage backend")
ErrDeleteChunkFailed = errors.New("unable to delete chunk from any storage backend")
ErrStoreChunkFailed = errors.New("storing chunk failed")
ErrStoreSnapshotFailed = errors.New("storing snapshot failed")
ErrStoreChunkIndexFailed = errors.New("storing chunk-index failed")
ErrStoreRepositoryFailed = errors.New("storing repository failed")
)

// AddBackend adds a backend.
Expand Down
6 changes: 3 additions & 3 deletions cmd/knoxite/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ func executeConfigSet(option string, values []string) error {
// The first part should be the repos alias
repo, ok := cfg.Repositories[strings.ToLower(parts[0])]
if !ok {
return fmt.Errorf("No alias with name %s found", parts[0])
return fmt.Errorf("no alias with name %s found", parts[0])
}

opt := strings.ToLower(parts[1])
Expand All @@ -164,7 +164,7 @@ func executeConfigSet(option string, values []string) error {
case "tolerance":
tol, err := strconv.Atoi(values[0])
if err != nil {
return fmt.Errorf("Failed to convert %s to uint for the fault tolerance option: %v", opt, err)
return fmt.Errorf("failed to convert %s to uint for the fault tolerance option: %v", opt, err)
}
repo.Tolerance = uint(tol)
case "store_excludes":
Expand All @@ -179,7 +179,7 @@ func executeConfigSet(option string, values []string) error {
repo.Pedantic = b

default:
return fmt.Errorf("Unknown configuration option: %s", opt)
return fmt.Errorf("unknown configuration option: %s", opt)
}
cfg.Repositories[strings.ToLower(parts[0])] = repo

Expand Down
2 changes: 1 addition & 1 deletion cmd/knoxite/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func executeRepoInit() error {

r, err := newRepository(globalOpts.Repo, globalOpts.Password)
if err != nil {
return fmt.Errorf("Creating repository at %s failed: %v", globalOpts.Repo, err)
return fmt.Errorf("creating repository at %s failed: %v", globalOpts.Repo, err)
}

fmt.Printf("Created new repository at %s\n", (*r.BackendManager().Backends[0]).Location())
Expand Down
2 changes: 1 addition & 1 deletion cmd/knoxite/volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func executeVolumeInit(name, description string) error {

err = repository.AddVolume(vol)
if err != nil {
return fmt.Errorf("Creating volume %s failed: %v", name, err)
return fmt.Errorf("creating volume %s failed: %v", name, err)
}

annotation := "Name: " + vol.Name
Expand Down
10 changes: 5 additions & 5 deletions cmd/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,28 @@ func authPath(w http.ResponseWriter, r *http.Request) (string, error) {
auth, _, ok := r.BasicAuth()
if !ok {
w.WriteHeader(http.StatusUnauthorized)
return "", errors.New("Security alert: no auth set")
return "", errors.New("security alert: no auth set")
}

// check for relative path attacks
if strings.Contains(r.URL.Path, ".."+string(os.PathSeparator)) {
w.WriteHeader(http.StatusUnauthorized)
return "", errors.New("Security alert: url path tampering")
return "", errors.New("security alert: url path tampering")
}
if strings.Contains(auth, ".."+string(os.PathSeparator)) {
w.WriteHeader(http.StatusUnauthorized)
return "", errors.New("Security alert: auth code tampering")
return "", errors.New("security alert: auth code tampering")
}

dir := filepath.Join(storagePath, auth)
src, err := os.Stat(dir)
if err != nil {
w.WriteHeader(http.StatusUnauthorized)
return "", errors.New("Invalid auth code: unknown user")
return "", errors.New("invalid auth code: unknown user")
}
if !src.IsDir() {
w.WriteHeader(http.StatusUnauthorized)
return "", errors.New("Invalid auth code: not a dir")
return "", errors.New("invalid auth code: not a dir")
}

return dir, nil
Expand Down
2 changes: 1 addition & 1 deletion compression.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func (c Compressor) Process(data []byte) ([]byte, error) {
return []byte{}, err
}
if n != len(data) {
return []byte{}, fmt.Errorf("Could not write all data to compressor")
return []byte{}, fmt.Errorf("could not write all data to compressor")
}
err = w.Close()
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion encryption.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const (

// Error declarations.
var (
ErrInvalidPassword = errors.New("Empty password not permitted")
ErrInvalidPassword = errors.New("empty password not permitted")
)

// Encryptor is a pipeline processor that encrypts data.
Expand Down
2 changes: 1 addition & 1 deletion progress_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func TestProgressTransferSpeed(t *testing.T) {
}

func TestProgressError(t *testing.T) {
p := newProgressError(errors.New("TestError"))
p := newProgressError(errors.New("testError"))
if p.Error == nil {
t.Errorf("Expected error, got %s", p.Error)
}
Expand Down
10 changes: 5 additions & 5 deletions repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ const (

// Error declarations.
var (
ErrRepositoryIncompatible = errors.New("The repository is not compatible with this version of Knoxite")
ErrOpenRepositoryFailed = errors.New("Wrong password or corrupted repository")
ErrVolumeNotFound = errors.New("Volume not found")
ErrSnapshotNotFound = errors.New("Snapshot not found")
ErrGenerateRandomKeyFailed = errors.New("Failed to generate a random encryption key for new repository")
ErrRepositoryIncompatible = errors.New("the repository is not compatible with this version of Knoxite")
ErrOpenRepositoryFailed = errors.New("wrong password or corrupted repository")
ErrVolumeNotFound = errors.New("volume not found")
ErrSnapshotNotFound = errors.New("snapshot not found")
ErrGenerateRandomKeyFailed = errors.New("failed to generate a random encryption key for new repository")
)

// NewRepository returns a new repository.
Expand Down
2 changes: 1 addition & 1 deletion storage/amazons3/backend_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ var _ = Describe("DeleteFile", func() {
BeforeEach(func() {
backend = &AmazonS3StorageBackend{
service: &mockS3Client{
deleteObjectError: awserr.New("NotFound", "Foobar", fmt.Errorf("NotFound")),
deleteObjectError: awserr.New("NotFound", "Foobar", fmt.Errorf("notFound")),
},
}
err = backend.DeleteFile("asdf")
Expand Down
2 changes: 1 addition & 1 deletion storage/ftp/ftp.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ type FTPStorage struct {

// Error declarations.
var (
ErrInvalidAuthentication = errors.New("Wrong Username or Password")
ErrInvalidAuthentication = errors.New("wrong Username or Password")
)

func init() {
Expand Down
2 changes: 1 addition & 1 deletion storage/googlecloud/gcloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func (*GoogleCloudStorage) NewBackend(URL url.URL) (knoxite.Backend, error) {
var credentialsSet bool
credentialsPath, credentialsSet = os.LookupEnv("GOOGLE_APPLICATION_CREDENTIALS")
if !credentialsSet {
return &GoogleCloudStorage{}, errors.New("No valid JSON credentials file provided.")
return &GoogleCloudStorage{}, errors.New("no valid JSON credentials file provided.")
}
} else {
credentialsPath = URL.User.Username()
Expand Down
2 changes: 1 addition & 1 deletion storage/s3/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func (*S3Storage) NewBackend(URL url.URL) (knoxite.Backend, error) {
case "s3s":
ssl = true
default:
return &S3Storage{}, errors.New("Invalid s3 url scheme")
return &S3Storage{}, errors.New("invalid s3 url scheme")
}

var username, pw string
Expand Down
2 changes: 1 addition & 1 deletion storage/webdav/webdav.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ type WebDAVStorage struct {

// Error declarations.
var (
ErrInvalidAuthentication = errors.New("Wrong Username or Password")
ErrInvalidAuthentication = errors.New("wrong Username or Password")
)

func init() {
Expand Down
2 changes: 1 addition & 1 deletion storage_filesystem.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func (backend StorageFilesystem) InitRepository() error {
return ErrRepositoryExists
/*
if !stat.IsDir() {
return &os.PathError{Op: "create", Path: path, Err: errors.New("Repository path contains an invalid file")}
return &os.PathError{Op: "create", Path: path, Err: errors.New("repository path contains an invalid file")}
}
*/
}
Expand Down
6 changes: 3 additions & 3 deletions verify_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ var verifyTestCases = []struct {
return err
}
if len(layer0) == 0 {
return errors.New("Files expected")
return errors.New("files expected")
}

layer1, err := ioutil.ReadDir(filepath.Join(dir, "chunks", layer0[0].Name()))
Expand All @@ -43,7 +43,7 @@ var verifyTestCases = []struct {
}

if len(layer1) == 0 {
return errors.New("Files expected")
return errors.New("files expected")
}

layer2, err := ioutil.ReadDir(filepath.Join(dir, "chunks", layer0[0].Name(), layer1[0].Name()))
Expand All @@ -52,7 +52,7 @@ var verifyTestCases = []struct {
}

if len(layer2) == 0 {
return errors.New("Files expected")
return errors.New("files expected")
}

os.Remove(filepath.Join(dir, "chunks", layer0[0].Name(), layer1[0].Name(), layer2[0].Name()))
Expand Down

0 comments on commit 4388cb0

Please sign in to comment.