Documentation
¶
Index ¶
- Variables
- type BindingsObject
- type Generator
- func (g *Generator) Generate(data interface{})
- func (g *Generator) GenerateJson(jsonStr []byte) ([]byte, error)
- func (g *Generator) GetBindings() (BindingsObject, error)
- func (g *Generator) GetBindingsJson() ([]byte, error)
- func (g *Generator) InsertBindingsObject(data map[string]interface{}) error
- func (g *Generator) InsertBindingsObjectJson(jsonData []byte) ([]byte, error)
- func (g *Generator) TryBindId(kind Kind, id string) (maybeRef string, didBind bool)
- func (g *Generator) TryBindOid(oidObj oid.OID) (maybeRef string, didBind bool)
- type Kind
- type KindSet
- type Mapping
- type Ref
- type ResourceCache
- type ResourceCacheEntry
- type Target
Constants ¶
This section is empty.
Variables ¶
var ( // must match the data source names, see DataSourcesMap in observe/provider.go KindDataset = addKind("dataset") KindWorksheet = addKind("worksheet") KindWorkspace = addKind("workspace") KindUser = addKind("user") KindDashboard = addKind("dashboard") KindMonitorV2 = addKind("monitor_v2") KindMonitorV2Action = addKind("monitor_v2_action") KindMonitor = addKind("monitor") )
Functions ¶
This section is empty.
Types ¶
type BindingsObject ¶
type BindingsObject struct { Mappings Mapping `json:"mappings"` Kinds []Kind `json:"kinds"` Workspace Target `json:"workspace"` WorkspaceName string `json:"workspace_name"` }
BindingsObject contains all the information necessary to generate terraform data sources and local variable definitions to support the local variable references replacing the raw ids in the resource data.
type Generator ¶
type Generator struct {
// contains filtered or unexported fields
}
func NewGenerator ¶
func NewGenerator(ctx context.Context, resourceType Kind, resourceName string, client *observe.Client, enabledBindings KindSet) (Generator, error)
NewGenerator creates a new binding generator for the given resource type and name, which keeps track of all the bindings generated for raw ids found through later calls to Generate and TryBind.
func (*Generator) Generate ¶
func (g *Generator) Generate(data interface{})
Generate walks the provided data structure and for all ids encountered, generates a binding for it, and replaces the id with a local variable reference
func (*Generator) GenerateJson ¶
GenerateJson does the same as Generate, but accepts a raw json string
func (*Generator) GetBindings ¶ added in v0.14.35
func (g *Generator) GetBindings() (BindingsObject, error)
GetBindings returns the bindings generated so far
func (*Generator) GetBindingsJson ¶ added in v0.14.35
func (*Generator) InsertBindingsObject ¶
InsertBindingsObject inserts the bindings object into the provided map
func (*Generator) InsertBindingsObjectJson ¶
InsertBindingsObjectJson inserts the bindings object into the provided json data, root must be a map
type Mapping ¶
A binding, i.e. mapping of resource kind + label -> terraform local variable name (which the ids have been replaced with)
func NewMapping ¶
func NewMapping() Mapping
type Ref ¶
type Ref struct { Kind Kind Key string // id when used in ResourceCache, label when used in Mapping }
func NewRefFromString ¶
func (Ref) MarshalText ¶
func (*Ref) UnmarshalText ¶
type ResourceCache ¶
type ResourceCache struct {
// contains filtered or unexported fields
}
func NewResourceCache ¶
func NewResourceCache(ctx context.Context, kinds KindSet, client *observe.Client, forResourceKind Kind, forResourceName string) (ResourceCache, error)
NewResourceCache loads all resources of the given kinds and creates a cache of id -> label mappings
func (*ResourceCache) LookupId ¶
func (c *ResourceCache) LookupId(kind Kind, id string) *ResourceCacheEntry
type ResourceCacheEntry ¶
type Target ¶
type Target struct { // Name of the local variable that will be generated for this target, used in place of the raw ids TfLocalBindingVar string `json:"tf_local_binding_var"` // Name of the terraform data source that will be generated for this target TfName string `json:"tf_name"` // When generating locals, used to determine whether we should do ${data_source}.id or ${data_source}.oid IsOid bool `json:"is_oid"` }