github.com/rstandt/terraform@v0.12.32-0.20230710220336-b1063613405c/backend/nil.go (about) 1 package backend 2 3 import ( 4 "github.com/hashicorp/terraform/configs/configschema" 5 "github.com/hashicorp/terraform/states/statemgr" 6 "github.com/hashicorp/terraform/tfdiags" 7 "github.com/zclconf/go-cty/cty" 8 ) 9 10 // Nil is a no-op implementation of Backend. 11 // 12 // This is useful to embed within another struct to implement all of the 13 // backend interface for testing. 14 type Nil struct{} 15 16 func (Nil) ConfigSchema() *configschema.Block { 17 return &configschema.Block{} 18 } 19 20 func (Nil) PrepareConfig(v cty.Value) (cty.Value, tfdiags.Diagnostics) { 21 return v, nil 22 } 23 24 func (Nil) Configure(cty.Value) tfdiags.Diagnostics { 25 return nil 26 } 27 28 func (Nil) StateMgr(string) (statemgr.Full, error) { 29 // We must return a non-nil manager to adhere to the interface, so 30 // we'll return an in-memory-only one. 31 return statemgr.NewFullFake(statemgr.NewTransientInMemory(nil), nil), nil 32 } 33 34 func (Nil) StateMgrWithoutCheckVersion(string) (statemgr.Full, error) { 35 return statemgr.NewFullFake(statemgr.NewTransientInMemory(nil), nil), nil 36 } 37 38 func (Nil) DeleteWorkspace(string) error { 39 return nil 40 } 41 42 func (Nil) Workspaces() ([]string, error) { 43 return []string{DefaultStateName}, nil 44 }