pulumi/pkg/resource/resource_goal.go
joeduffy 301739c6b5 Add auto-parenting
This changes a few things about "components":

* Rename what was previously ExternalResource to CustomResource,
  and all of the related fields and parameters that this implies.
  This just seems like a much nicer and expected name for what
  these represent.  I realize I am stealing a name we had thought
  about using elsewhere, but this seems like an appropriate use.

* Introduce ComponentResource, to make initializing resources
  that merely aggregate other resources easier to do correctly.

* Add a withParent and parentScope concept to Resource, to make
  allocating children less error-prone.  Now there's no need to
  explicitly adopt children as they are allocated; instead, any
  children allocated as part of the withParent callback will
  auto-parent to the resource provided.  This is used by
  ComponentResource's initialization function to make initialization
  easier, including the distinction between inputs and outputs.
2017-10-15 04:38:26 -07:00

28 lines
804 B
Go

// Copyright 2016-2017, Pulumi Corporation. All rights reserved.
package resource
import (
"github.com/pulumi/pulumi/pkg/tokens"
)
// Goal is a desired state for a resource object.
type Goal struct {
Type tokens.Type // the type of resource.
Name tokens.QName // the name for the resource's URN.
Custom bool // true if this resource is custom, managed by a plugin.
Properties PropertyMap // the resource's property state.
Children []URN // an optional list of child resource URNs.
}
// NewGoal allocates a new resource goal state.
func NewGoal(t tokens.Type, name tokens.QName, custom bool, props PropertyMap, children []URN) *Goal {
return &Goal{
Type: t,
Name: name,
Custom: custom,
Properties: props,
Children: children,
}
}