tvl-depot/tools/nixery/server/builder/state.go
Vincent Ambo 61269175c0 refactor(server): Introduce a state type to carry runtime state
The state type contains things such as the bucket handle and Nixery's
configuration which need to be passed around in the builder.

This is only added for convenience.
2019-10-03 13:21:04 +01:00

24 lines
498 B
Go

package builder
import (
"cloud.google.com/go/storage"
"github.com/google/nixery/config"
"github.com/google/nixery/layers"
)
// State holds the runtime state that is carried around in Nixery and
// passed to builder functions.
type State struct {
Bucket *storage.BucketHandle
Cache LocalCache
Cfg config.Config
Pop layers.Popularity
}
func NewState(bucket *storage.BucketHandle, cfg config.Config) State {
return State{
Bucket: bucket,
Cfg: cfg,
Cache: NewCache(),
}
}