Skip to content
This repository was archived by the owner on Oct 2, 2023. It is now read-only.

Commit 10a066d

Browse files
committed
source/vault: de-stutter type
1 parent e7f52ae commit 10a066d

File tree

5 files changed

+22
-22
lines changed

5 files changed

+22
-22
lines changed

examples/nsscache-vault/main.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"os"
77

88
nsscache "github.com/MiLk/nsscache-go"
9-
vaultsource "github.com/MiLk/nsscache-go/source/vault"
9+
"github.com/MiLk/nsscache-go/source/vault"
1010
)
1111

1212
func main() {
@@ -33,7 +33,7 @@ func mainE() error {
3333
return err
3434
}
3535

36-
src, err := vaultsource.CreateVaultSource("nsscache_test", file.Name())
36+
src, err := vault.CreateSource("nsscache_test", file.Name())
3737
if err != nil {
3838
return err
3939
}

source/vault/helpers.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ type wrappedData struct {
2020
WrappedAccessor string `json:"wrapped_accessor"`
2121
}
2222

23-
// CreateVaultSource returns a vault source with a client associated to work with
24-
func CreateVaultSource(prefix string, fpath string) (source.Source, error) {
23+
// CreateSource returns a vault source with a client associated to work with
24+
func CreateSource(prefix string, fpath string) (source.Source, error) {
2525
client, err := CreateVaultClient(fpath)
2626
if err != nil {
2727
return nil, err

source/vault/helpers_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ func TestCreateVaultClientWrappedToken(t *testing.T) {
101101
assert.NotNil(t, client)
102102
}
103103

104-
func TestCreateVaultSourceFileInput(t *testing.T) {
104+
func TestCreateSourceFileInput(t *testing.T) {
105105
file, err := ioutil.TempFile("/tmp", "test-token-file")
106106
if err != nil {
107107
t.Fatal(err)
@@ -118,7 +118,7 @@ func TestCreateVaultSourceFileInput(t *testing.T) {
118118
log.Fatal(err)
119119
}
120120

121-
source, err := CreateVaultSource("prefix", file.Name())
121+
source, err := CreateSource("prefix", file.Name())
122122
if err != nil {
123123
t.Fatalf("Unexpected error creating vault source: %s", err.Error())
124124
}

source/vault/vault.go

+12-12
Original file line numberDiff line numberDiff line change
@@ -14,28 +14,28 @@ import (
1414
"github.com/MiLk/nsscache-go/cache"
1515
)
1616

17-
type VaultSource struct {
17+
type Source struct {
1818
client *api.Client
1919
prefix string
2020
mountPath string
2121
}
2222

23-
type Option func(*VaultSource)
23+
type Option func(*Source)
2424

2525
func Client(c *api.Client) Option {
26-
return func(s *VaultSource) { s.client = c }
26+
return func(s *Source) { s.client = c }
2727
}
2828

2929
func Prefix(p string) Option {
30-
return func(s *VaultSource) { s.prefix = p }
30+
return func(s *Source) { s.prefix = p }
3131
}
3232

3333
func MountPath(m string) Option {
34-
return func(s *VaultSource) { s.mountPath = m }
34+
return func(s *Source) { s.mountPath = m }
3535
}
3636

37-
func NewSource(opts ...Option) (*VaultSource, error) {
38-
s := VaultSource{
37+
func NewSource(opts ...Option) (*Source, error) {
38+
s := Source{
3939
prefix: "nsscache",
4040
mountPath: "secret",
4141
}
@@ -55,11 +55,11 @@ func NewSource(opts ...Option) (*VaultSource, error) {
5555
return &s, nil
5656
}
5757

58-
func (s *VaultSource) Client() *api.Client {
58+
func (s *Source) Client() *api.Client {
5959
return s.client
6060
}
6161

62-
func (s *VaultSource) list(name string, c *cache.Cache, createEntry func() cache.Entry) error {
62+
func (s *Source) list(name string, c *cache.Cache, createEntry func() cache.Entry) error {
6363
prefix := fmt.Sprintf("%s/%s", s.prefix, name)
6464
sec, err := s.client.Logical().List(fmt.Sprintf("%s/metadata/%s", s.mountPath, prefix))
6565
if err != nil {
@@ -90,19 +90,19 @@ func (s *VaultSource) list(name string, c *cache.Cache, createEntry func() cache
9090
return nil
9191
}
9292

93-
func (s *VaultSource) FillPasswdCache(c *cache.Cache) error {
93+
func (s *Source) FillPasswdCache(c *cache.Cache) error {
9494
return s.list("passwd", c, func() cache.Entry {
9595
return &cache.PasswdEntry{}
9696
})
9797
}
9898

99-
func (s *VaultSource) FillShadowCache(c *cache.Cache) error {
99+
func (s *Source) FillShadowCache(c *cache.Cache) error {
100100
return s.list("shadow", c, func() cache.Entry {
101101
return &cache.ShadowEntry{}
102102
})
103103
}
104104

105-
func (s *VaultSource) FillGroupCache(c *cache.Cache) error {
105+
func (s *Source) FillGroupCache(c *cache.Cache) error {
106106
return s.list("group", c, func() cache.Entry {
107107
return &cache.GroupEntry{}
108108
})

source/vault/vault_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ func TestNewSource(t *testing.T) {
7777
os.Unsetenv("VAULT_SKIP_VERIFY")
7878
}
7979

80-
func TestVaultSource_FillPasswdCache(t *testing.T) {
80+
func TestSource_FillPasswdCache(t *testing.T) {
8181
dir, err := ioutil.TempDir("/tmp", "nsscache-go-")
8282
assert.Nil(t, err)
8383
defer os.RemoveAll(dir)
@@ -158,7 +158,7 @@ foo:x:1000:1000:Mr Foo:/home/foo:/bin/bash
158158
assert.Equal(t, "", b.String())
159159
}
160160

161-
func TestVaultSource_FillShadowCache(t *testing.T) {
161+
func TestSource_FillShadowCache(t *testing.T) {
162162
dir, err := ioutil.TempDir("/tmp", "nsscache-go-")
163163
assert.Nil(t, err)
164164
defer os.RemoveAll(dir)
@@ -197,7 +197,7 @@ foo:!!:17321::::::
197197
assert.Equal(t, expected, b.String())
198198
}
199199

200-
func TestVaultSource_FillGroupCache(t *testing.T) {
200+
func TestSource_FillGroupCache(t *testing.T) {
201201
dir, err := ioutil.TempDir("/tmp", "nsscache-go-")
202202
assert.Nil(t, err)
203203
defer os.RemoveAll(dir)
@@ -233,7 +233,7 @@ func TestVaultSource_FillGroupCache(t *testing.T) {
233233
assert.Equal(t, expected, b.String())
234234
}
235235

236-
func TestVaultSource_List(t *testing.T) {
236+
func TestSource_List(t *testing.T) {
237237
s, err := NewSource()
238238
assert.Nil(t, err)
239239
err = s.list("name", nil, nil)

0 commit comments

Comments
 (0)