Skip to content

Commit 9db58b8

Browse files
committed
Move data store related code in internal/store
1 parent 779c5fb commit 9db58b8

File tree

7 files changed

+15
-11
lines changed

7 files changed

+15
-11
lines changed

internal/trousseau/kv.go internal/store/kv.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package trousseau
1+
package store
22

33
import (
44
"errors"

internal/trousseau/kv_test.go internal/store/kv_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package trousseau
1+
package store
22

33
import (
44
"testing"

internal/trousseau/meta.go internal/store/meta.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package trousseau
1+
package store
22

33
import (
44
"errors"

internal/trousseau/store.go internal/store/store.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package trousseau
1+
package store
22

33
type Store struct {
44
Meta Meta `json:"meta"`

internal/trousseau/actions.go

+5-3
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,19 @@ import (
1010
"os"
1111
"strings"
1212

13+
"github.com/oleiade/trousseau/internal/store"
14+
1315
"github.com/oleiade/trousseau/pkg/dsn"
1416
)
1517

1618
func CreateAction(ct CryptoType, ca CryptoAlgorithm, recipients []string) error {
17-
meta := Meta{
19+
meta := store.Meta{
1820
CreatedAt: time.Now().String(),
1921
LastModifiedAt: time.Now().String(),
2022
Recipients: recipients,
2123
TrousseauVersion: TROUSSEAU_VERSION,
2224
}
23-
store := NewStore(meta)
25+
store := store.NewStore(meta)
2426

2527
tr := Trousseau{
2628
CryptoType: ct,
@@ -182,7 +184,7 @@ func ExportAction(destination io.Writer, plain bool) error {
182184
func ImportAction(source io.Reader, strategy ImportStrategy, plain bool) error {
183185
var data []byte
184186
var err error
185-
var importedStore *Store = &Store{}
187+
var importedStore *store.Store = &store.Store{}
186188
var localFilePath string = InferStorePath()
187189

188190
localTr, err := OpenTrousseau(localFilePath)

internal/trousseau/import.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@ package trousseau
33
import (
44
"fmt"
55

6+
"github.com/oleiade/trousseau/internal/store"
67
"github.com/urfave/cli"
78
)
89

910
type ImportStrategy uint32
1011

1112
// ImportStore imports the src encrypted data store content
1213
// into dest data store, respecting the provided import strategy.
13-
func ImportStore(src, dest *Store, strategy ImportStrategy) error {
14+
func ImportStore(src, dest *store.Store, strategy ImportStrategy) error {
1415
switch strategy {
1516
case IMPORT_YOURS:
1617
for key, value := range src.Data {

internal/trousseau/trousseau.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88

99
"github.com/oleiade/serrure/aes"
1010
"github.com/oleiade/serrure/openpgp"
11+
"github.com/oleiade/trousseau/internal/store"
1112
)
1213

1314
type Trousseau struct {
@@ -70,8 +71,8 @@ func FromBytes(d []byte) (*Trousseau, error) {
7071
return trousseau, err
7172
}
7273

73-
func (t *Trousseau) Decrypt() (*Store, error) {
74-
var store Store
74+
func (t *Trousseau) Decrypt() (*store.Store, error) {
75+
var store store.Store
7576

7677
switch t.CryptoAlgorithm {
7778
case GPG_ENCRYPTION:
@@ -118,7 +119,7 @@ func (t *Trousseau) Decrypt() (*Store, error) {
118119
return &store, nil
119120
}
120121

121-
func (t *Trousseau) Encrypt(store *Store) error {
122+
func (t *Trousseau) Encrypt(store *store.Store) error {
122123
switch t.CryptoAlgorithm {
123124
case GPG_ENCRYPTION:
124125
pd, err := json.Marshal(*store)

0 commit comments

Comments
 (0)