|
|
|
|
@ -2639,107 +2639,105 @@ module.child:
|
|
|
|
|
`)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//// FIXME: how do we handle this one?
|
|
|
|
|
//func TestContext2Apply_moduleOrphanProvider(t *testing.T) {
|
|
|
|
|
// m := testModule(t, "apply-module-orphan-provider-inherit")
|
|
|
|
|
// p := testProvider("aws")
|
|
|
|
|
// p.ApplyFn = testApplyFn
|
|
|
|
|
// p.DiffFn = testDiffFn
|
|
|
|
|
|
|
|
|
|
// p.ConfigureFn = func(c *ResourceConfig) error {
|
|
|
|
|
// if _, ok := c.Get("value"); !ok {
|
|
|
|
|
// return fmt.Errorf("value is not found")
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// return nil
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// // Create a state with an orphan module
|
|
|
|
|
// state := &State{
|
|
|
|
|
// Modules: []*ModuleState{
|
|
|
|
|
// &ModuleState{
|
|
|
|
|
// Path: []string{"root", "child"},
|
|
|
|
|
// Resources: map[string]*ResourceState{
|
|
|
|
|
// "aws_instance.bar": &ResourceState{
|
|
|
|
|
// Type: "aws_instance",
|
|
|
|
|
// Primary: &InstanceState{
|
|
|
|
|
// ID: "bar",
|
|
|
|
|
// },
|
|
|
|
|
// },
|
|
|
|
|
// },
|
|
|
|
|
// },
|
|
|
|
|
// },
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// ctx := testContext2(t, &ContextOpts{
|
|
|
|
|
// Module: m,
|
|
|
|
|
// State: state,
|
|
|
|
|
// ProviderResolver: ResourceProviderResolverFixed(
|
|
|
|
|
// map[string]ResourceProviderFactory{
|
|
|
|
|
// "aws": testProviderFuncFixed(p),
|
|
|
|
|
// },
|
|
|
|
|
// ),
|
|
|
|
|
// })
|
|
|
|
|
|
|
|
|
|
// if _, err := ctx.Plan(); err != nil {
|
|
|
|
|
// t.Fatalf("err: %s", err)
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// if _, err := ctx.Apply(); err != nil {
|
|
|
|
|
// t.Fatalf("err: %s", err)
|
|
|
|
|
// }
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
//// FIXME: how do we handle this one?
|
|
|
|
|
//func TestContext2Apply_moduleOrphanGrandchildProvider(t *testing.T) {
|
|
|
|
|
// m := testModule(t, "apply-module-orphan-provider-inherit")
|
|
|
|
|
// p := testProvider("aws")
|
|
|
|
|
// p.ApplyFn = testApplyFn
|
|
|
|
|
// p.DiffFn = testDiffFn
|
|
|
|
|
|
|
|
|
|
// p.ConfigureFn = func(c *ResourceConfig) error {
|
|
|
|
|
// if _, ok := c.Get("value"); !ok {
|
|
|
|
|
// return fmt.Errorf("value is not found")
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// return nil
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// // Create a state with an orphan module that is nested (grandchild)
|
|
|
|
|
// state := &State{
|
|
|
|
|
// Modules: []*ModuleState{
|
|
|
|
|
// &ModuleState{
|
|
|
|
|
// Path: []string{"root", "parent", "child"},
|
|
|
|
|
// Resources: map[string]*ResourceState{
|
|
|
|
|
// "aws_instance.bar": &ResourceState{
|
|
|
|
|
// Type: "aws_instance",
|
|
|
|
|
// Primary: &InstanceState{
|
|
|
|
|
// ID: "bar",
|
|
|
|
|
// },
|
|
|
|
|
// },
|
|
|
|
|
// },
|
|
|
|
|
// },
|
|
|
|
|
// },
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// ctx := testContext2(t, &ContextOpts{
|
|
|
|
|
// Module: m,
|
|
|
|
|
// State: state,
|
|
|
|
|
// ProviderResolver: ResourceProviderResolverFixed(
|
|
|
|
|
// map[string]ResourceProviderFactory{
|
|
|
|
|
// "aws": testProviderFuncFixed(p),
|
|
|
|
|
// },
|
|
|
|
|
// ),
|
|
|
|
|
// })
|
|
|
|
|
|
|
|
|
|
// if _, err := ctx.Plan(); err != nil {
|
|
|
|
|
// t.Fatalf("err: %s", err)
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// if _, err := ctx.Apply(); err != nil {
|
|
|
|
|
// t.Fatalf("err: %s", err)
|
|
|
|
|
// }
|
|
|
|
|
//}
|
|
|
|
|
func TestContext2Apply_moduleOrphanProvider(t *testing.T) {
|
|
|
|
|
m := testModule(t, "apply-module-orphan-provider-inherit")
|
|
|
|
|
p := testProvider("aws")
|
|
|
|
|
p.ApplyFn = testApplyFn
|
|
|
|
|
p.DiffFn = testDiffFn
|
|
|
|
|
|
|
|
|
|
p.ConfigureFn = func(c *ResourceConfig) error {
|
|
|
|
|
if _, ok := c.Get("value"); !ok {
|
|
|
|
|
return fmt.Errorf("value is not found")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Create a state with an orphan module
|
|
|
|
|
state := &State{
|
|
|
|
|
Modules: []*ModuleState{
|
|
|
|
|
&ModuleState{
|
|
|
|
|
Path: []string{"root", "child"},
|
|
|
|
|
Resources: map[string]*ResourceState{
|
|
|
|
|
"aws_instance.bar": &ResourceState{
|
|
|
|
|
Type: "aws_instance",
|
|
|
|
|
Primary: &InstanceState{
|
|
|
|
|
ID: "bar",
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ctx := testContext2(t, &ContextOpts{
|
|
|
|
|
Module: m,
|
|
|
|
|
State: state,
|
|
|
|
|
ProviderResolver: ResourceProviderResolverFixed(
|
|
|
|
|
map[string]ResourceProviderFactory{
|
|
|
|
|
"aws": testProviderFuncFixed(p),
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
if _, err := ctx.Plan(); err != nil {
|
|
|
|
|
t.Fatalf("err: %s", err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if _, err := ctx.Apply(); err != nil {
|
|
|
|
|
t.Fatalf("err: %s", err)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestContext2Apply_moduleOrphanGrandchildProvider(t *testing.T) {
|
|
|
|
|
m := testModule(t, "apply-module-orphan-provider-inherit")
|
|
|
|
|
p := testProvider("aws")
|
|
|
|
|
p.ApplyFn = testApplyFn
|
|
|
|
|
p.DiffFn = testDiffFn
|
|
|
|
|
|
|
|
|
|
p.ConfigureFn = func(c *ResourceConfig) error {
|
|
|
|
|
if _, ok := c.Get("value"); !ok {
|
|
|
|
|
return fmt.Errorf("value is not found")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Create a state with an orphan module that is nested (grandchild)
|
|
|
|
|
state := &State{
|
|
|
|
|
Modules: []*ModuleState{
|
|
|
|
|
&ModuleState{
|
|
|
|
|
Path: []string{"root", "parent", "child"},
|
|
|
|
|
Resources: map[string]*ResourceState{
|
|
|
|
|
"aws_instance.bar": &ResourceState{
|
|
|
|
|
Type: "aws_instance",
|
|
|
|
|
Primary: &InstanceState{
|
|
|
|
|
ID: "bar",
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ctx := testContext2(t, &ContextOpts{
|
|
|
|
|
Module: m,
|
|
|
|
|
State: state,
|
|
|
|
|
ProviderResolver: ResourceProviderResolverFixed(
|
|
|
|
|
map[string]ResourceProviderFactory{
|
|
|
|
|
"aws": testProviderFuncFixed(p),
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
if _, err := ctx.Plan(); err != nil {
|
|
|
|
|
t.Fatalf("err: %s", err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if _, err := ctx.Apply(); err != nil {
|
|
|
|
|
t.Fatalf("err: %s", err)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestContext2Apply_moduleGrandchildProvider(t *testing.T) {
|
|
|
|
|
m := testModule(t, "apply-module-grandchild-provider-inherit")
|
|
|
|
|
|