Skip to content

Commit

Permalink
Match version tags starting with leading v (#2)
Browse files Browse the repository at this point in the history
* match version tags starting with leading v

* added -v to go test
  • Loading branch information
seanshahkarami authored Sep 7, 2022
1 parent a9239d9 commit 43a87cb
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ jobs:
run: go build

- name: Check that all tests pass
run: go test
run: go test -v
14 changes: 10 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,20 @@ var (
)

const versionPattern = "[0-9]*.[0-9]*.[0-9]*"
const prefixedVersionPattern = "v[0-9]*.[0-9]*.[0-9]*"
const timeShasumPattern = "[0-9]*-[0-9a-f]*"

func scanForJobs(ctx context.Context, jobs chan<- Job, root string) error {
patterns := []string{
filepath.Join(root, "node-*", "uploads", "*", versionPattern, timeShasumPattern, "data"), // uploads without a namespace
filepath.Join(root, "node-*", "uploads", "*", "latest", timeShasumPattern, "data"), // uploads without a namespace (latest tag)
filepath.Join(root, "node-*", "uploads", "*", "*", versionPattern, timeShasumPattern, "data"), // uploads with a namespace
filepath.Join(root, "node-*", "uploads", "*", "*", "latest", timeShasumPattern, "data"), // uploads with a namespace (latest tag)
// without namespace
filepath.Join(root, "node-*", "uploads", "*", versionPattern, timeShasumPattern, "data"), // version
filepath.Join(root, "node-*", "uploads", "*", prefixedVersionPattern, timeShasumPattern, "data"), // prefixed version
filepath.Join(root, "node-*", "uploads", "*", "latest", timeShasumPattern, "data"), // latest tag

// with namespace
filepath.Join(root, "node-*", "uploads", "*", "*", versionPattern, timeShasumPattern, "data"), // version
filepath.Join(root, "node-*", "uploads", "*", "*", prefixedVersionPattern, timeShasumPattern, "data"), // prefixed version
filepath.Join(root, "node-*", "uploads", "*", "*", "latest", timeShasumPattern, "data"), // latest tag
}

err := filepath.WalkDir(root, func(path string, d fs.DirEntry, err error) error {
Expand Down
12 changes: 12 additions & 0 deletions worker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,18 @@ func TestScanAndProcess(t *testing.T) {
data: []byte(`{"ts":1638576647406523064,"labels":{"filename":"wow1.txt"}}`),
},
},
"DefaultSageJobLeadingV": {
{
path: "node-000048b02d15bc7c/uploads/imagesampler-top/v0.2.5/1638576647406523064-9801739daae44ec5293d4e1f53d3f4d2d426d91c/data",
upload: "node-data/sage/sage-imagesampler-top-v0.2.5/000048b02d15bc7c/1638576647406523064-wow1.txt",
data: []byte(`some data`),
},
{
path: "node-000048b02d15bc7c/uploads/imagesampler-top/v0.2.5/1638576647406523064-9801739daae44ec5293d4e1f53d3f4d2d426d91c/meta",
upload: "node-data/sage/sage-imagesampler-top-v0.2.5/000048b02d15bc7c/1638576647406523064-wow1.txt.meta",
data: []byte(`{"ts":1638576647406523064,"labels":{"filename":"wow1.txt"}}`),
},
},
"Job": {
{
path: "node-000048b02d15bc7c/uploads/Pluginctl/imagesampler-top/0.2.5/1638576647406523064-9801739daae44ec5293d4e1f53d3f4d2d426d91c/data",
Expand Down

0 comments on commit 43a87cb

Please sign in to comment.