github.com/paybyphone/terraform@v0.9.5-0.20170613192930-9706042ddd51/backend/remote-state/inmem/backend.go (about) 1 package inmem 2 3 import ( 4 "context" 5 6 "github.com/hashicorp/terraform/backend" 7 "github.com/hashicorp/terraform/backend/remote-state" 8 "github.com/hashicorp/terraform/helper/schema" 9 "github.com/hashicorp/terraform/state" 10 "github.com/hashicorp/terraform/state/remote" 11 ) 12 13 // New creates a new backend for Inmem remote state. 14 func New() backend.Backend { 15 return &remotestate.Backend{ 16 ConfigureFunc: configure, 17 18 // Set the schema 19 Backend: &schema.Backend{ 20 Schema: map[string]*schema.Schema{ 21 "lock_id": &schema.Schema{ 22 Type: schema.TypeString, 23 Optional: true, 24 Description: "initializes the state in a locked configuration", 25 }, 26 }, 27 }, 28 } 29 } 30 31 func configure(ctx context.Context) (remote.Client, error) { 32 data := schema.FromContextBackendConfig(ctx) 33 if v, ok := data.GetOk("lock_id"); ok && v.(string) != "" { 34 info := state.NewLockInfo() 35 info.ID = v.(string) 36 info.Operation = "test" 37 info.Info = "test config" 38 return &RemoteClient{LockInfo: info}, nil 39 } 40 return &RemoteClient{}, nil 41 }