mirror of
https://github.com/hanzoai/pack.git
synced 2026-09-30 23:43:13 +00:00
- Migrate module path to github.com/hanzoai/pack across all Go packages - Remove legacy upstream docs and competitor brand references - Modernize LLM.md and mise.toml for pristine Hanzo Pack builder
50 lines
896 B
Go
50 lines
896 B
Go
package build_llb
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/moby/buildkit/client/llb"
|
|
"github.com/hanzoai/pack/core/plan"
|
|
)
|
|
|
|
type BuildKitCache struct {
|
|
cacheKey string
|
|
planCache *plan.Cache
|
|
cacheState *llb.State
|
|
}
|
|
|
|
type BuildKitCacheStore struct {
|
|
uniqueID string
|
|
CacheMap map[string]BuildKitCache
|
|
}
|
|
|
|
func NewBuildKitCacheStore(uniqueID string) *BuildKitCacheStore {
|
|
return &BuildKitCacheStore{
|
|
uniqueID: uniqueID,
|
|
CacheMap: make(map[string]BuildKitCache),
|
|
}
|
|
}
|
|
|
|
func (c *BuildKitCacheStore) GetCache(key string, planCache *plan.Cache) BuildKitCache {
|
|
cacheKey := key
|
|
if c.uniqueID != "" {
|
|
cacheKey = fmt.Sprintf("%s-%s", c.uniqueID, key)
|
|
}
|
|
|
|
if cache, ok := c.CacheMap[cacheKey]; ok {
|
|
return cache
|
|
}
|
|
|
|
cacheState := llb.Scratch()
|
|
|
|
cache := BuildKitCache{
|
|
cacheKey: cacheKey,
|
|
planCache: planCache,
|
|
cacheState: &cacheState,
|
|
}
|
|
|
|
c.CacheMap[cacheKey] = cache
|
|
|
|
return cache
|
|
}
|