Skip to content

Commit 6a0bf2b

Browse files
committed
feat: Moving to multi-module project architecture
This takes advantage of Golang workspaces: https://go.dev/doc/tutorial/workspaces The idea is that every `plugin/*` is its own submodule, and they contain the strict dependencies needed, instead of having them in the root module. This make the `spelunk/v2` root module extremely lean - almost no dependencies. And yes, as this is a breaking change, pushes us towards a v2 release.
1 parent 9e5d0b7 commit 6a0bf2b

94 files changed

Lines changed: 2169 additions & 885 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

builtin/modifier/base64/base64.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"context"
55
b64 "encoding/base64"
66

7-
"github.com/detro/spelunk/types"
7+
"github.com/detro/spelunk/v2/types"
88
)
99

1010
// SecretModifierBase64 is a modifier that encodes the secret value to a base64 string.

builtin/modifier/base64/base64_test.go

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,10 @@ import (
55
b64 "encoding/base64"
66
"testing"
77

8-
"github.com/detro/spelunk"
9-
b64mod "github.com/detro/spelunk/builtin/modifier/base64"
10-
"github.com/detro/spelunk/internal/testutil"
11-
"github.com/detro/spelunk/plugin/modifier/jsonpath"
12-
"github.com/detro/spelunk/types"
8+
"github.com/detro/spelunk/v2"
9+
b64mod "github.com/detro/spelunk/v2/builtin/modifier/base64"
10+
"github.com/detro/spelunk/v2/types"
11+
"github.com/detro/spelunk/v2/util"
1312
"github.com/stretchr/testify/require"
1413
)
1514

@@ -47,9 +46,9 @@ func TestSecretModifierBase64_Modify(t *testing.T) {
4746
want: "",
4847
},
4948
{
50-
name: "apply jsonpath then base64",
49+
name: "apply mock then base64",
5150
val: `{"key": "mysecret"}`,
52-
coordStr: "test://loc?jp=$.key&b64",
51+
coordStr: "test://loc?mock=key&b64",
5352
want: b64.StdEncoding.EncodeToString([]byte("mysecret")),
5453
},
5554
}
@@ -59,10 +58,14 @@ func TestSecretModifierBase64_Modify(t *testing.T) {
5958
coord, err := types.NewSecretCoord(tt.coordStr)
6059
require.NoError(t, err)
6160

61+
src := util.NewMockSource("test")
62+
src.Val = tt.val
63+
mod := util.NewMockModifier("mock")
64+
6265
spelunker := spelunk.NewSpelunker(
63-
spelunk.WithSource(&testutil.MockSource{Typ: "test", Val: tt.val}),
66+
spelunk.WithSource(src),
6467
spelunk.WithModifier(&b64mod.SecretModifierBase64{}),
65-
jsonpath.WithJSONPath(),
68+
spelunk.WithModifier(mod),
6669
)
6770

6871
got, err := spelunker.DigUp(ctx, coord)

builtin/modifier/base64_decoder/base64_decoder.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
b64 "encoding/base64"
66
"fmt"
77

8-
"github.com/detro/spelunk/types"
8+
"github.com/detro/spelunk/v2/types"
99
)
1010

1111
var ErrSecretModifierBase64DecoderFailedDecoding = fmt.Errorf("failed to decode base64 secret")

builtin/modifier/base64_decoder/base64_decoder_test.go

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,10 @@ import (
55
b64 "encoding/base64"
66
"testing"
77

8-
"github.com/detro/spelunk"
9-
"github.com/detro/spelunk/builtin/modifier/base64_decoder"
10-
"github.com/detro/spelunk/internal/testutil"
11-
"github.com/detro/spelunk/plugin/modifier/jsonpath"
12-
"github.com/detro/spelunk/types"
8+
"github.com/detro/spelunk/v2"
9+
"github.com/detro/spelunk/v2/builtin/modifier/base64_decoder"
10+
"github.com/detro/spelunk/v2/types"
11+
"github.com/detro/spelunk/v2/util"
1312
"github.com/stretchr/testify/require"
1413
)
1514

@@ -47,9 +46,9 @@ func TestSecretModifierBase64Decoder_Modify(t *testing.T) {
4746
want: "",
4847
},
4948
{
50-
name: "apply jsonpath then base64 decode",
49+
name: "apply mock then base64 decode",
5150
val: `{"key": "bXlzZWNyZXQ="}`, // bXlzZWNyZXQ= is "mysecret" in base64
52-
coordStr: "test://loc?jp=$.key&b64d",
51+
coordStr: "test://loc?mock=key&b64d",
5352
want: "mysecret",
5453
},
5554
{
@@ -65,10 +64,15 @@ func TestSecretModifierBase64Decoder_Modify(t *testing.T) {
6564
coord, err := types.NewSecretCoord(tt.coordStr)
6665
require.NoError(t, err)
6766

67+
src := util.NewMockSource("test")
68+
src.Val = tt.val
69+
mod := util.NewMockModifier("mock")
70+
mod.ArgToVal = map[string]string{"key": "bXlzZWNyZXQ="}
71+
6872
spelunker := spelunk.NewSpelunker(
69-
spelunk.WithSource(&testutil.MockSource{Typ: "test", Val: tt.val}),
73+
spelunk.WithSource(src),
7074
spelunk.WithModifier(&base64_decoder.SecretModifierBase64Decoder{}),
71-
jsonpath.WithJSONPath(),
75+
spelunk.WithModifier(mod),
7276
)
7377

7478
got, err := spelunker.DigUp(ctx, coord)

builtin/modifier/base64_encoder/base64_encoder.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package base64_encoder
22

33
import (
4-
"github.com/detro/spelunk/builtin/modifier/base64"
5-
"github.com/detro/spelunk/types"
4+
"github.com/detro/spelunk/v2/builtin/modifier/base64"
5+
"github.com/detro/spelunk/v2/types"
66
)
77

88
// SecretModifierBase64Encoder is a modifier that encodes the secret value to a base64 string.

builtin/source/base64/base64.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"encoding/base64"
66
"fmt"
77

8-
"github.com/detro/spelunk/types"
8+
"github.com/detro/spelunk/v2/types"
99
)
1010

1111
var ErrSecretSourceBase64FailedDecoding = fmt.Errorf("failed to decode base64 secret")

builtin/source/base64/base64_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ import (
55
"encoding/base64"
66
"testing"
77

8-
"github.com/detro/spelunk"
9-
b64 "github.com/detro/spelunk/builtin/source/base64"
10-
"github.com/detro/spelunk/types"
8+
"github.com/detro/spelunk/v2"
9+
b64 "github.com/detro/spelunk/v2/builtin/source/base64"
10+
"github.com/detro/spelunk/v2/types"
1111
"github.com/stretchr/testify/require"
1212
)
1313

builtin/source/env/env.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"fmt"
66
"os"
77

8-
"github.com/detro/spelunk/types"
8+
"github.com/detro/spelunk/v2/types"
99
)
1010

1111
// SecretSourceEnv digs up secrets from environment variables.

builtin/source/env/env_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ import (
55
"os"
66
"testing"
77

8-
"github.com/detro/spelunk"
9-
"github.com/detro/spelunk/builtin/source/env"
10-
"github.com/detro/spelunk/types"
8+
"github.com/detro/spelunk/v2"
9+
"github.com/detro/spelunk/v2/builtin/source/env"
10+
"github.com/detro/spelunk/v2/types"
1111
"github.com/stretchr/testify/require"
1212
)
1313

builtin/source/file/file.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"io"
77
"os"
88

9-
"github.com/detro/spelunk/types"
9+
"github.com/detro/spelunk/v2/types"
1010
)
1111

1212
var (

0 commit comments

Comments
 (0)