1
0
Fork 0

Even better package name

master
Philip O'Toole 1 year ago
parent fd4433ea4b
commit 12f3dd913a

@ -5,17 +5,17 @@ import (
"io/ioutil" "io/ioutil"
"os" "os"
"github.com/rqlite/rqlite/autostate" "github.com/rqlite/rqlite/auto"
"github.com/rqlite/rqlite/aws" "github.com/rqlite/rqlite/aws"
) )
// Config is the config file format for the upload service // Config is the config file format for the upload service
type Config struct { type Config struct {
Version int `json:"version"` Version int `json:"version"`
Type autostate.StorageType `json:"type"` Type auto.StorageType `json:"type"`
NoCompress bool `json:"no_compress,omitempty"` NoCompress bool `json:"no_compress,omitempty"`
Interval autostate.Duration `json:"interval"` Interval auto.Duration `json:"interval"`
Sub json.RawMessage `json:"sub"` Sub json.RawMessage `json:"sub"`
} }
// Unmarshal unmarshals the config file and returns the config and subconfig // Unmarshal unmarshals the config file and returns the config and subconfig
@ -26,8 +26,8 @@ func Unmarshal(data []byte) (*Config, *aws.S3Config, error) {
return nil, nil, err return nil, nil, err
} }
if cfg.Version > autostate.Version { if cfg.Version > auto.Version {
return nil, nil, autostate.ErrInvalidVersion return nil, nil, auto.ErrInvalidVersion
} }
s3cfg := &aws.S3Config{} s3cfg := &aws.S3Config{}

@ -9,7 +9,7 @@ import (
"testing" "testing"
"time" "time"
"github.com/rqlite/rqlite/autostate" "github.com/rqlite/rqlite/auto"
"github.com/rqlite/rqlite/aws" "github.com/rqlite/rqlite/aws"
) )
@ -138,7 +138,7 @@ func TestUnmarshal(t *testing.T) {
Version: 1, Version: 1,
Type: "s3", Type: "s3",
NoCompress: true, NoCompress: true,
Interval: 24 * autostate.Duration(time.Hour), Interval: 24 * auto.Duration(time.Hour),
}, },
expectedS3: &aws.S3Config{ expectedS3: &aws.S3Config{
AccessKeyID: "test_id", AccessKeyID: "test_id",
@ -169,7 +169,7 @@ func TestUnmarshal(t *testing.T) {
Version: 1, Version: 1,
Type: "s3", Type: "s3",
NoCompress: false, NoCompress: false,
Interval: 24 * autostate.Duration(time.Hour), Interval: 24 * auto.Duration(time.Hour),
}, },
expectedS3: &aws.S3Config{ expectedS3: &aws.S3Config{
AccessKeyID: "test_id", AccessKeyID: "test_id",
@ -198,7 +198,7 @@ func TestUnmarshal(t *testing.T) {
} `), } `),
expectedCfg: nil, expectedCfg: nil,
expectedS3: nil, expectedS3: nil,
expectedErr: autostate.ErrInvalidVersion, expectedErr: auto.ErrInvalidVersion,
}, },
{ {
name: "UnsupportedType", name: "UnsupportedType",
@ -218,7 +218,7 @@ func TestUnmarshal(t *testing.T) {
} `), } `),
expectedCfg: nil, expectedCfg: nil,
expectedS3: nil, expectedS3: nil,
expectedErr: autostate.ErrUnsupportedStorageType, expectedErr: auto.ErrUnsupportedStorageType,
}, },
} }

@ -6,17 +6,17 @@ import (
"os" "os"
"time" "time"
"github.com/rqlite/rqlite/autostate" "github.com/rqlite/rqlite/auto"
"github.com/rqlite/rqlite/aws" "github.com/rqlite/rqlite/aws"
) )
// Config is the config file format for the upload service // Config is the config file format for the upload service
type Config struct { type Config struct {
Version int `json:"version"` Version int `json:"version"`
Type autostate.StorageType `json:"type"` Type auto.StorageType `json:"type"`
Timeout autostate.Duration `json:"timeout,omitempty"` Timeout auto.Duration `json:"timeout,omitempty"`
ContinueOnFailure bool `json:"continue_on_failure,omitempty"` ContinueOnFailure bool `json:"continue_on_failure,omitempty"`
Sub json.RawMessage `json:"sub"` Sub json.RawMessage `json:"sub"`
} }
// Unmarshal unmarshals the config file and returns the config and subconfig // Unmarshal unmarshals the config file and returns the config and subconfig
@ -27,12 +27,12 @@ func Unmarshal(data []byte) (*Config, *aws.S3Config, error) {
return nil, nil, err return nil, nil, err
} }
if cfg.Version > autostate.Version { if cfg.Version > auto.Version {
return nil, nil, autostate.ErrInvalidVersion return nil, nil, auto.ErrInvalidVersion
} }
if cfg.Timeout == 0 { if cfg.Timeout == 0 {
cfg.Timeout = autostate.Duration(30 * time.Second) cfg.Timeout = auto.Duration(30 * time.Second)
} }
s3cfg := &aws.S3Config{} s3cfg := &aws.S3Config{}

@ -9,7 +9,7 @@ import (
"testing" "testing"
"time" "time"
"github.com/rqlite/rqlite/autostate" "github.com/rqlite/rqlite/auto"
"github.com/rqlite/rqlite/aws" "github.com/rqlite/rqlite/aws"
) )
@ -136,7 +136,7 @@ func TestUnmarshal(t *testing.T) {
expectedCfg: &Config{ expectedCfg: &Config{
Version: 1, Version: 1,
Type: "s3", Type: "s3",
Timeout: 30 * autostate.Duration(time.Second), Timeout: 30 * auto.Duration(time.Second),
ContinueOnFailure: false, ContinueOnFailure: false,
}, },
expectedS3: &aws.S3Config{ expectedS3: &aws.S3Config{
@ -167,7 +167,7 @@ func TestUnmarshal(t *testing.T) {
expectedCfg: &Config{ expectedCfg: &Config{
Version: 1, Version: 1,
Type: "s3", Type: "s3",
Timeout: autostate.Duration(30 * time.Second), Timeout: auto.Duration(30 * time.Second),
ContinueOnFailure: true, ContinueOnFailure: true,
}, },
expectedS3: &aws.S3Config{ expectedS3: &aws.S3Config{
@ -196,7 +196,7 @@ func TestUnmarshal(t *testing.T) {
} `), } `),
expectedCfg: nil, expectedCfg: nil,
expectedS3: nil, expectedS3: nil,
expectedErr: autostate.ErrInvalidVersion, expectedErr: auto.ErrInvalidVersion,
}, },
{ {
name: "UnsupportedType", name: "UnsupportedType",
@ -215,7 +215,7 @@ func TestUnmarshal(t *testing.T) {
} `), } `),
expectedCfg: nil, expectedCfg: nil,
expectedS3: nil, expectedS3: nil,
expectedErr: autostate.ErrUnsupportedStorageType, expectedErr: auto.ErrUnsupportedStorageType,
}, },
} }

@ -1,4 +1,4 @@
package autostate package auto
import ( import (
"encoding/json" "encoding/json"

@ -19,8 +19,8 @@ import (
"github.com/rqlite/rqlite-disco-clients/dnssrv" "github.com/rqlite/rqlite-disco-clients/dnssrv"
etcd "github.com/rqlite/rqlite-disco-clients/etcd" etcd "github.com/rqlite/rqlite-disco-clients/etcd"
"github.com/rqlite/rqlite/auth" "github.com/rqlite/rqlite/auth"
"github.com/rqlite/rqlite/autostate/backup" "github.com/rqlite/rqlite/auto/backup"
"github.com/rqlite/rqlite/autostate/restore" "github.com/rqlite/rqlite/auto/restore"
"github.com/rqlite/rqlite/aws" "github.com/rqlite/rqlite/aws"
"github.com/rqlite/rqlite/cluster" "github.com/rqlite/rqlite/cluster"
"github.com/rqlite/rqlite/cmd" "github.com/rqlite/rqlite/cmd"

Loading…
Cancel
Save