isUsed returns true if a state key is being used in a variable.
(ctx context.Context, key string)
| 135 | |
| 136 | // isUsed returns true if a state key is being used in a variable. |
| 137 | func (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. |
| 158 | func (s *ShellStateStore) Prune(ctx context.Context) int { |
no test coverage detected