MCPcopy Index your code
hub / github.com/dagger/dagger / isUsed

Method isUsed

cmd/dagger/shell_state.go:137–155  ·  view source on GitHub ↗

isUsed returns true if a state key is being used in a variable.

(ctx context.Context, key string)

Source from the content-addressed store, hash-verified

135
136// isUsed returns true if a state key is being used in a variable.
137func (s *ShellStateStore) isUsed(ctx context.Context, key string) bool {
138 hctx := HandlerCtx(ctx)
139 if hctx == nil {
140 return true
141 }
142
143 var used bool
144 token := newStateToken(key)
145
146 hctx.Env.Each(func(name string, v expand.Variable) bool {
147 if strings.Contains(v.String(), token) {
148 used = true
149 return false
150 }
151 return true
152 })
153
154 return used
155}
156
157// Prune removes all state instances that are not in use by a variable.
158func (s *ShellStateStore) Prune(ctx context.Context) int {

Callers 1

DeleteMethod · 0.95

Calls 4

HandlerCtxFunction · 0.85
newStateTokenFunction · 0.85
ContainsMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected