Skip to content

Commit

Permalink
Merge pull request #66 from w-h-a/secret-interface
Browse files Browse the repository at this point in the history
refactor: secret interface
  • Loading branch information
w-h-a authored Sep 2, 2024
2 parents d039c6b + 494ca23 commit 30a4efb
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 203 deletions.
95 changes: 0 additions & 95 deletions security/secret/naclbox/naclbox.go

This file was deleted.

45 changes: 0 additions & 45 deletions security/secret/naclbox/naclbox_test.go

This file was deleted.

39 changes: 0 additions & 39 deletions security/secret/naclbox/options.go

This file was deleted.

26 changes: 4 additions & 22 deletions security/secret/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,32 +20,14 @@ func NewSecretOptions(opts ...SecretOption) SecretOptions {
return options
}

type EncryptOption func(o *EncryptOptions)
type GetSecretOption func(o *GetSecretOptions)

type EncryptOptions struct {
type GetSecretOptions struct {
Context context.Context
}

func NewEncryptOptions(opts ...EncryptOption) EncryptOptions {
options := EncryptOptions{
Context: context.Background(),
}

for _, fn := range opts {
fn(&options)
}

return options
}

type DecryptOption func(o *DecryptOptions)

type DecryptOptions struct {
Context context.Context
}

func NewDecryptOptions(opts ...DecryptOption) DecryptOptions {
options := DecryptOptions{
func NewGetSecretOptions(opts ...GetSecretOption) GetSecretOptions {
options := GetSecretOptions{
Context: context.Background(),
}

Expand Down
3 changes: 1 addition & 2 deletions security/secret/secret.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package secret

type Secret interface {
Options() SecretOptions
Encrypt(messageToSend []byte, opts ...EncryptOption) ([]byte, error)
Decrypt(receivedMessage []byte, opts ...DecryptOption) ([]byte, error)
GetSecret(name string, opts ...GetSecretOption) (map[string]string, error)
String() string
}

0 comments on commit 30a4efb

Please sign in to comment.