Skip to content

Commit

Permalink
fixup cache sharing mode
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Suraci <suraci.alex@gmail.com>
  • Loading branch information
vito committed Jul 18, 2023
1 parent 7768dc3 commit b83b443
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
15 changes: 15 additions & 0 deletions core/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,21 @@ func (mode CacheSharingMode) MarshalJSON() ([]byte, error) {
return json.Marshal(strings.ToLower(string(mode)))
}

// CacheSharingMode marshals to its lowercased value.
//
// NB: as far as I can recall this is purely for ~*aesthetic*~. GraphQL consts
// are so shouty!
func (mode *CacheSharingMode) UnmarshalJSON(payload []byte) error {
var str string
if err := json.Unmarshal(payload, &str); err != nil {
return err
}

*mode = CacheSharingMode(strings.ToUpper(str))

return nil
}

func (cache *CacheVolume) WithKey(key string) *CacheVolume {
cache = cache.Clone()
cache.Keys = append(cache.Keys, key)
Expand Down
4 changes: 4 additions & 0 deletions core/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,10 @@ func (container *Container) WithMountedCache(ctx context.Context, gw bkgw.Client

target = absPath(container.Config.WorkingDir, target)

if sharingMode == "" {
sharingMode = CacheSharingModeShared
}

mount := ContainerMount{
Target: target,
CacheID: cache.Sum(),
Expand Down

0 comments on commit b83b443

Please sign in to comment.