terraform: some files laying out an API
This commit is contained in:
parent
ab507814b7
commit
1b5dfa043b
|
@ -0,0 +1,16 @@
|
|||
package terraform
|
||||
|
||||
// Diff tracks the differences between resources to apply.
|
||||
type Diff struct {
|
||||
resources map[string]map[string]*resourceDiff
|
||||
}
|
||||
|
||||
// resourceDiff is the diff of a single attribute of a resource.
|
||||
//
|
||||
// This tracks the old value, the new value, and whether the change of this
|
||||
// value actually requires an entirely new resource.
|
||||
type resourceDiff struct {
|
||||
Old string
|
||||
New string
|
||||
RequiresNew bool
|
||||
}
|
|
@ -19,3 +19,7 @@ type ResourceProvider interface {
|
|||
type ResourceType struct {
|
||||
Name string
|
||||
}
|
||||
|
||||
// ResourceProviderFactory is a function type that creates a new instance
|
||||
// of a resource provider.
|
||||
type ResourceProviderFactory func() (ResourceProvider, error)
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
package terraform
|
||||
|
||||
// State keeps track of a snapshot state-of-the-world that Terraform
|
||||
// can use to keep track of what real world resources it is actually
|
||||
// managing.
|
||||
type State struct {
|
||||
resources map[string]resourceState
|
||||
}
|
||||
|
||||
// resourceState is the state of a single resource.
|
||||
//
|
||||
// The ID is required and is some opaque string used to recognize
|
||||
// the realized resource.
|
||||
//
|
||||
// Extra is arbitrary extra metadata that the resource provider returns
|
||||
// that is sent back into the resource provider when it is needed.
|
||||
type resourceState struct {
|
||||
ID string
|
||||
Extra map[string]interface{}
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
package terraform
|
||||
|
||||
import (
|
||||
"github.com/hashicorp/terraform/config"
|
||||
)
|
||||
|
||||
// Terraform is the primary structure that is used to interact with
|
||||
// Terraform from code, and can perform operations such as returning
|
||||
// all resources, a resource tree, a specific resource, etc.
|
||||
type Terraform struct {
|
||||
config *config.Config
|
||||
providers []ResourceProvider
|
||||
}
|
||||
|
||||
// Config is the configuration that must be given to instantiate
|
||||
// a Terraform structure.
|
||||
type Config struct {
|
||||
Config *config.Config
|
||||
Providers map[string]ResourceProviderFactory
|
||||
Variables map[string]string
|
||||
}
|
||||
|
||||
// New creates a new Terraform structure, initializes resource providers
|
||||
// for the given configuration, etc.
|
||||
//
|
||||
// Semantic checks of the entire configuration structure are done at this
|
||||
// time, as well as richer checks such as verifying that the resource providers
|
||||
// can be properly initialized, can be configured, etc.
|
||||
func New(c *Config) (*Terraform, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (t *Terraform) Apply(*State, *Diff) (*State, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (t *Terraform) Diff(*State) (*Diff, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (t *Terraform) Refresh(*State) (*State, error) {
|
||||
return nil, nil
|
||||
}
|
Loading…
Reference in New Issue