Skip to content

Commit 43a87cb

Browse files
Match version tags starting with leading v (#2)
* match version tags starting with leading v * added -v to go test
1 parent a9239d9 commit 43a87cb

File tree

3 files changed

+23
-5
lines changed

3 files changed

+23
-5
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ jobs:
2222
run: go build
2323

2424
- name: Check that all tests pass
25-
run: go test
25+
run: go test -v

main.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,20 @@ var (
2323
)
2424

2525
const versionPattern = "[0-9]*.[0-9]*.[0-9]*"
26+
const prefixedVersionPattern = "v[0-9]*.[0-9]*.[0-9]*"
2627
const timeShasumPattern = "[0-9]*-[0-9a-f]*"
2728

2829
func scanForJobs(ctx context.Context, jobs chan<- Job, root string) error {
2930
patterns := []string{
30-
filepath.Join(root, "node-*", "uploads", "*", versionPattern, timeShasumPattern, "data"), // uploads without a namespace
31-
filepath.Join(root, "node-*", "uploads", "*", "latest", timeShasumPattern, "data"), // uploads without a namespace (latest tag)
32-
filepath.Join(root, "node-*", "uploads", "*", "*", versionPattern, timeShasumPattern, "data"), // uploads with a namespace
33-
filepath.Join(root, "node-*", "uploads", "*", "*", "latest", timeShasumPattern, "data"), // uploads with a namespace (latest tag)
31+
// without namespace
32+
filepath.Join(root, "node-*", "uploads", "*", versionPattern, timeShasumPattern, "data"), // version
33+
filepath.Join(root, "node-*", "uploads", "*", prefixedVersionPattern, timeShasumPattern, "data"), // prefixed version
34+
filepath.Join(root, "node-*", "uploads", "*", "latest", timeShasumPattern, "data"), // latest tag
35+
36+
// with namespace
37+
filepath.Join(root, "node-*", "uploads", "*", "*", versionPattern, timeShasumPattern, "data"), // version
38+
filepath.Join(root, "node-*", "uploads", "*", "*", prefixedVersionPattern, timeShasumPattern, "data"), // prefixed version
39+
filepath.Join(root, "node-*", "uploads", "*", "*", "latest", timeShasumPattern, "data"), // latest tag
3440
}
3541

3642
err := filepath.WalkDir(root, func(path string, d fs.DirEntry, err error) error {

worker_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,18 @@ func TestScanAndProcess(t *testing.T) {
8686
data: []byte(`{"ts":1638576647406523064,"labels":{"filename":"wow1.txt"}}`),
8787
},
8888
},
89+
"DefaultSageJobLeadingV": {
90+
{
91+
path: "node-000048b02d15bc7c/uploads/imagesampler-top/v0.2.5/1638576647406523064-9801739daae44ec5293d4e1f53d3f4d2d426d91c/data",
92+
upload: "node-data/sage/sage-imagesampler-top-v0.2.5/000048b02d15bc7c/1638576647406523064-wow1.txt",
93+
data: []byte(`some data`),
94+
},
95+
{
96+
path: "node-000048b02d15bc7c/uploads/imagesampler-top/v0.2.5/1638576647406523064-9801739daae44ec5293d4e1f53d3f4d2d426d91c/meta",
97+
upload: "node-data/sage/sage-imagesampler-top-v0.2.5/000048b02d15bc7c/1638576647406523064-wow1.txt.meta",
98+
data: []byte(`{"ts":1638576647406523064,"labels":{"filename":"wow1.txt"}}`),
99+
},
100+
},
89101
"Job": {
90102
{
91103
path: "node-000048b02d15bc7c/uploads/Pluginctl/imagesampler-top/0.2.5/1638576647406523064-9801739daae44ec5293d4e1f53d3f4d2d426d91c/data",

0 commit comments

Comments
 (0)