meltwater / drone-cache

A Drone plugin for caching current workspace files between builds to reduce your build times
https://underthehood.meltwater.com/blog/2019/04/10/making-drone-builds-10-times-faster/
Apache License 2.0
338 stars 81 forks source link

Glob path matching causes panic #242

Open sqsp-rwatkins opened 1 year ago

sqsp-rwatkins commented 1 year ago

Describe the bug Using 2 or more glob paths for the mount paths causes a panic

To Reproduce Steps to reproduce the behavior:

  1. Using the following config in drone:
    image: meltwater/drone-cache
    settings:
    backend: gcs
    cache_key: [REDACTED]/{{ checksum "yarn.lock" }}
    json_key: [REDACTED]
    bucket: [REDACTED]
    region: [REDACTED]
    mount:
    - "packages/**/node_modules"
    - "node_modules"
    - "plugins/**/node_modules"
  2. See Drone console output for error

Expected behavior Expected glob paths to work as described and implemented in https://github.com/meltwater/drone-cache/pull/209

Drone console output

panic: runtime error: index out of range [2] with length 2

goroutine 1 [running]:
github.com/meltwater/drone-cache/internal/plugin.(*Config).HandleMount(0xc0006bf740, {0x142da80, 0xc00011f090})
    /home/runner/work/drone-cache/drone-cache/internal/plugin/config.go:56 +0x345
github.com/meltwater/drone-cache/internal/plugin.(*Plugin).Exec(0xc0006bf5d8)
    /home/runner/work/drone-cache/drone-cache/internal/plugin/plugin.go:134 +0xebc
main.run(0xc0001f9500?)
    /home/runner/work/drone-cache/drone-cache/main.go:613 +0x1706
github.com/urfave/cli/v2.(*App).RunContext(0xc000434700, {0x1433a70?, 0xc00013c030}, {0xc00011e1e0, 0x1, 0x1})
    /home/runner/work/drone-cache/drone-cache/vendor/github.com/urfave/cli/v2/app.go:392 +0xf3f
github.com/urfave/cli/v2.(*App).Run(...)
    /home/runner/work/drone-cache/drone-cache/vendor/github.com/urfave/cli/v2/app.go:253
main.main()
    /home/runner/work/drone-cache/drone-cache/main.go:493 +0x423a

Desktop (please complete the following information): N/A running in drone using meltwater/drone-cache