2018-06-08 02:27:57 +02:00
|
|
|
package states
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/zclconf/go-cty/cty"
|
|
|
|
)
|
|
|
|
|
|
|
|
// ImportedObject represents an object being imported into Terraform with the
|
|
|
|
// help of a provider. An ImportedObject is a RemoteObject that has been read
|
|
|
|
// by the provider's import handler but hasn't yet been committed to state.
|
|
|
|
type ImportedObject struct {
|
|
|
|
ResourceType string
|
|
|
|
|
|
|
|
// Value is the value (of the object type implied by the associated resource
|
|
|
|
// type schema) that represents this remote object in Terraform Language
|
|
|
|
// expressions and is compared with configuration when producing a diff.
|
|
|
|
Value cty.Value
|
|
|
|
|
|
|
|
// Private corresponds to the field of the same name on
|
|
|
|
// ResourceInstanceObject, where the provider can record private data that
|
|
|
|
// will be available for future operations.
|
2018-08-18 01:11:07 +02:00
|
|
|
Private []byte
|
2018-06-08 02:27:57 +02:00
|
|
|
}
|
terraform: Ugly huge change to weave in new State and Plan types
Due to how often the state and plan types are referenced throughout
Terraform, there isn't a great way to switch them out gradually. As a
consequence, this huge commit gets us from the old world to a _compilable_
new world, but still has a large number of known test failures due to
key functionality being stubbed out.
The stubs here are for anything that interacts with providers, since we
now need to do the follow-up work to similarly replace the old
terraform.ResourceProvider interface with its replacement in the new
"providers" package. That work, along with work to fix the remaining
failing tests, will follow in subsequent commits.
The aim here was to replace all references to terraform.State and its
downstream types with states.State, terraform.Plan with plans.Plan,
state.State with statemgr.State, and switch to the new implementations of
the state and plan file formats. However, due to the number of times those
types are used, this also ended up affecting numerous other parts of core
such as terraform.Hook, the backend.Backend interface, and most of the CLI
commands.
Just as with 5861dbf3fc49b19587a31816eb06f511ab861bb4 before, I apologize
in advance to the person who inevitably just found this huge commit while
spelunking through the commit history.
2018-08-14 23:24:45 +02:00
|
|
|
|
|
|
|
// AsInstanceObject converts the receiving ImportedObject into a
|
|
|
|
// ResourceInstanceObject that has status ObjectReady.
|
|
|
|
//
|
|
|
|
// The returned object does not know its own resource type, so the caller must
|
|
|
|
// retain the ResourceType value from the source object if this information is
|
|
|
|
// needed.
|
|
|
|
//
|
|
|
|
// The returned object also has no dependency addresses, but the caller may
|
|
|
|
// freely modify the direct fields of the returned object without affecting
|
|
|
|
// the receiver.
|
|
|
|
func (io *ImportedObject) AsInstanceObject() *ResourceInstanceObject {
|
|
|
|
return &ResourceInstanceObject{
|
|
|
|
Status: ObjectReady,
|
|
|
|
Value: io.Value,
|
|
|
|
Private: io.Private,
|
|
|
|
}
|
|
|
|
}
|