-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Expand file tree
/
Copy pathset.go
More file actions
66 lines (56 loc) · 2.39 KB
/
set.go
File metadata and controls
66 lines (56 loc) · 2.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// Copyright IBM Corp. 2014, 2026
// SPDX-License-Identifier: BUSL-1.1
package instances
import (
"github.com/hashicorp/terraform/internal/addrs"
)
// Set is a set of instances, intended mainly for the return value of
// Expander.AllInstances, where it therefore represents all of the module
// and resource instances known to the expander.
type Set struct {
// Set currently really just wraps Expander with a reduced API that
// only supports lookups, to make it clear that a holder of a Set should
// not be modifying the expander any further.
exp *Expander
}
// HasModuleInstance returns true if and only if the set contains the module
// instance with the given address.
func (s Set) HasModuleInstance(want addrs.ModuleInstance) bool {
return s.exp.knowsModuleInstance(want)
}
// HasModuleCall returns true if and only if the set contains the module
// call with the given address, even if that module call has no instances.
func (s Set) HasModuleCall(want addrs.AbsModuleCall) bool {
return s.exp.knowsModuleCall(want)
}
// HasResourceInstance returns true if and only if the set contains the resource
// instance with the given address.
// TODO:
func (s Set) HasResourceInstance(want addrs.AbsResourceInstance) bool {
return s.exp.knowsResourceInstance(want)
}
// HasResource returns true if and only if the set contains the resource with
// the given address, even if that resource has no instances.
// TODO:
func (s Set) HasResource(want addrs.AbsResource) bool {
return s.exp.knowsResource(want)
}
// InstancesForModule returns all of the module instances that correspond with
// the given static module path.
//
// If there are multiple module calls in the path that have repetition enabled
// then the result is the full expansion of all combinations of all of their
// declared instance keys.
func (s Set) InstancesForModule(modAddr addrs.Module, includeDirectOverrides bool) []addrs.ModuleInstance {
return s.exp.expandModule(modAddr, true, includeDirectOverrides)
}
// HasActionInstance returns true if and only if the set contains the actions
// instance with the given address.
func (s Set) HasActionInstance(want addrs.AbsActionInstance) bool {
return s.exp.knowsActionInstance(want)
}
// HasAction returns true if and only if the set contains the actions with
// the given address, even if that action has no instances.
func (s Set) HasAction(want addrs.AbsAction) bool {
return s.exp.knowsAction(want)
}