package activator import "context" // BuildStateLocation is where an instance's build-state.json lives (settings // spec ยง4.2): the bucket and the prefix of the lease's lock.json. With host // claims off that is Config.Bucket and HibernatePrefix(Config.Prefix, host); // with them on, the claim actor's bucket and Holder.Location (never a // g-/ generation prefix). The wake knows which lease it holds, so it // puts the location on the context it hands BeforeExec, and the agent's hook // writes there rather than guessing. type BuildStateLocation struct{ Bucket, Prefix string } type buildStateLocationKey struct{} // WithBuildStateLocation returns ctx carrying l. A location with either part // empty reads back as none, so a caller can mask a location it inherited. func WithBuildStateLocation(ctx context.Context, l BuildStateLocation) context.Context { return context.WithValue(ctx, buildStateLocationKey{}, l) } // BuildStateLocationFrom is the location ctx carries, if a whole one. func BuildStateLocationFrom(ctx context.Context) (BuildStateLocation, bool) { l, ok := ctx.Value(buildStateLocationKey{}).(BuildStateLocation) if !ok || l.Bucket == "" || l.Prefix == "" { return BuildStateLocation{}, false } return l, true }