Skip to content
This repository was archived by the owner on Jan 21, 2020. It is now read-only.

Commit eef7750

Browse files
kaufersthebsdbox
authored andcommitted
Add support for Option Envs parser and use in tf plugin (#694)
* Add plugin `Option` environment parser Generic parser that handles the `Envs` values for a plugin's `Options`; the value is a slice of "key=val" strings that can either be a simple key/value pair or a reference a key in a local JSON file. For example, a value of: ``` "Options": { "Envs": [ "key1=val1", "key2=file:///run/secrets/my-secret:some-key" ] } ``` Parses the the given `/run/secrets/my-secret` file as JSON, gets the `some-key` value, and set the `key2` value in the slice. The parsed slice is: ``` ["key1=val1","key2=<file-value-of-some-key>"] ``` Signed-off-by: Steven Kaufer <[email protected]> * Add support to use custom env vars in terraform plugin The new `Options|Envs` plugin Option is processed to create a slice of env vars to use on the terraform plugin. These env vars are used on all `terraform` execs. The idea is that the env vars would have the specify cloud provider credentials. Signed-off-by: Steven Kaufer <[email protected]> * Cleanup terraform execs to get the working dir from the plugin Since the plugin receiver has the working directory we no longer need to pass it on the function call. Signed-off-by: Steven Kaufer <[email protected]> * Update tf plugin Option.Envs parsing to use native templating Instead of using custom logic with file-uri like values we can simply take advantage of the fact that the plugin configuration file is already templated. Signed-off-by: Steven Kaufer <[email protected]>
1 parent 640723b commit eef7750

File tree

9 files changed

+147
-68
lines changed

9 files changed

+147
-68
lines changed

pkg/provider/terraform/instance/apply.go

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,16 @@ func (p *plugin) terraformApply() error {
4545
if p.shouldApply() {
4646
fns := tfFuncs{
4747
tfRefresh: func() error {
48-
command := exec.Command("terraform refresh").InheritEnvs(true).WithDir(p.Dir)
48+
command := exec.Command("terraform refresh").
49+
InheritEnvs(true).
50+
WithEnvs(p.envs...).
51+
WithDir(p.Dir)
4952
if err := command.WithStdout(os.Stdout).WithStderr(os.Stdout).Start(); err != nil {
5053
return err
5154
}
5255
return command.Wait()
5356
},
54-
tfStateList: doTerraformStateList,
57+
tfStateList: p.doTerraformStateList,
5558
}
5659
// The trigger for an apply is typically from a group commit, sleep for a few seconds so
5760
// that multiple .tf.json.new files have time to be created
@@ -90,7 +93,10 @@ func (p *plugin) terraformApply() error {
9093
// doTerraformApply executes "terraform apply"
9194
func (p *plugin) doTerraformApply() error {
9295
log.Infoln("Applying plan")
93-
command := exec.Command("terraform apply -refresh=false").InheritEnvs(true).WithDir(p.Dir)
96+
command := exec.Command("terraform apply -refresh=false").
97+
InheritEnvs(true).
98+
WithEnvs(p.envs...).
99+
WithDir(p.Dir)
94100
err := command.WithStdout(os.Stdout).WithStderr(os.Stdout).Start()
95101
if err == nil {
96102
return command.Wait()
@@ -127,7 +133,7 @@ func (p *plugin) shouldApply() bool {
127133
// External functions to use during when pruning files; broken out for testing
128134
type tfFuncs struct {
129135
tfRefresh func() error
130-
tfStateList func(string) (map[TResourceType]map[TResourceName]struct{}, error)
136+
tfStateList func() (map[TResourceType]map[TResourceName]struct{}, error)
131137
}
132138

133139
// handleFiles handles resource pruning and new resources via:
@@ -148,7 +154,7 @@ func (p *plugin) handleFiles(fns tfFuncs) error {
148154
if err := fns.tfRefresh(); err != nil {
149155
return err
150156
}
151-
tfStateResources, err := fns.tfStateList(p.Dir)
157+
tfStateResources, err := fns.tfStateList()
152158
if err != nil {
153159
// TODO(kaufers): If it possible that not all of the .new files were moved to
154160
// .tf.json files (NFS connection could be lost) and this could make the refresh
@@ -249,9 +255,12 @@ func (p *plugin) handleFiles(fns tfFuncs) error {
249255
}
250256

251257
// doTerraformStateList shells out to run `terraform state list` and parses the result
252-
func doTerraformStateList(dir string) (map[TResourceType]map[TResourceName]struct{}, error) {
258+
func (p *plugin) doTerraformStateList() (map[TResourceType]map[TResourceName]struct{}, error) {
253259
result := map[TResourceType]map[TResourceName]struct{}{}
254-
command := exec.Command("terraform state list -no-color").InheritEnvs(true).WithDir(dir)
260+
command := exec.Command("terraform state list -no-color").
261+
InheritEnvs(true).
262+
WithEnvs(p.envs...).
263+
WithDir(p.Dir)
255264
command.StartWithHandlers(
256265
nil,
257266
func(r io.Reader) error {

pkg/provider/terraform/instance/apply_test.go

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ func TestRunTerraformApply(t *testing.T) {
2626
dir, err := os.Getwd()
2727
require.NoError(t, err)
2828
dir = path.Join(dir, "aws-two-tier")
29-
terraform := NewTerraformInstancePlugin(dir, 1*time.Second, false, nil)
29+
terraform := NewTerraformInstancePlugin(dir, 1*time.Second, false, []string{}, nil)
3030
p, _ := terraform.(*plugin)
3131
err = p.doTerraformApply()
3232
require.NoError(t, err)
@@ -36,7 +36,7 @@ func TestContinuePollingStandalone(t *testing.T) {
3636
dir, err := ioutil.TempDir("", "infrakit-instance-terraform")
3737
require.NoError(t, err)
3838
defer os.RemoveAll(dir)
39-
terraform := NewTerraformInstancePlugin(dir, 1*time.Second, true, nil)
39+
terraform := NewTerraformInstancePlugin(dir, 1*time.Second, true, []string{}, nil)
4040
p, _ := terraform.(*plugin)
4141
shoudApply := p.shouldApply()
4242
require.True(t, shoudApply)
@@ -156,8 +156,7 @@ func TestHandleFilesStateListFail(t *testing.T) {
156156
refreshInvoked = true
157157
return nil
158158
},
159-
tfStateList: func(dirArg string) (map[TResourceType]map[TResourceName]struct{}, error) {
160-
require.Equal(t, dir, dirArg)
159+
tfStateList: func() (map[TResourceType]map[TResourceName]struct{}, error) {
161160
return nil, fmt.Errorf("Custom state list error")
162161
},
163162
}
@@ -173,7 +172,7 @@ func TestHandleFilesNoFiles(t *testing.T) {
173172

174173
fns := tfFuncs{
175174
tfRefresh: func() error { return nil },
176-
tfStateList: func(dir string) (map[TResourceType]map[TResourceName]struct{}, error) {
175+
tfStateList: func() (map[TResourceType]map[TResourceName]struct{}, error) {
177176
return map[TResourceType]map[TResourceName]struct{}{}, nil
178177
},
179178
}
@@ -205,7 +204,7 @@ func TestHandleFilesNoPruneNoNewFiles(t *testing.T) {
205204

206205
fns := tfFuncs{
207206
tfRefresh: func() error { return nil },
208-
tfStateList: func(dir string) (map[TResourceType]map[TResourceName]struct{}, error) {
207+
tfStateList: func() (map[TResourceType]map[TResourceName]struct{}, error) {
209208
// Return 5 files
210209
result := map[TResourceName]struct{}{}
211210
for i := 100; i < 105; i++ {
@@ -320,7 +319,7 @@ func TestHandleFilesDedicatedGlobalNoPruneNoNewFiles(t *testing.T) {
320319

321320
fns := tfFuncs{
322321
tfRefresh: func() error { return nil },
323-
tfStateList: func(dir string) (map[TResourceType]map[TResourceName]struct{}, error) {
322+
tfStateList: func() (map[TResourceType]map[TResourceName]struct{}, error) {
324323
// Return all VMs
325324
vms := map[TResourceName]struct{}{}
326325
for i := 100; i < 115; i++ {
@@ -395,7 +394,7 @@ func TestHandleFilesNoPruneWithNewFiles(t *testing.T) {
395394

396395
fns := tfFuncs{
397396
tfRefresh: func() error { return nil },
398-
tfStateList: func(dir string) (map[TResourceType]map[TResourceName]struct{}, error) {
397+
tfStateList: func() (map[TResourceType]map[TResourceName]struct{}, error) {
399398
// Return the 5 existing instances
400399
result := map[TResourceName]struct{}{}
401400
for i := 100; i < 105; i++ {
@@ -450,7 +449,7 @@ func TestHandleFilesPruneMultipleVMTypes(t *testing.T) {
450449

451450
fns := tfFuncs{
452451
tfRefresh: func() error { return nil },
453-
tfStateList: func(dir string) (map[TResourceType]map[TResourceName]struct{}, error) {
452+
tfStateList: func() (map[TResourceType]map[TResourceName]struct{}, error) {
454453
// Return all of 1 type, 1 of another type, 0 of the last type
455454
return map[TResourceType]map[TResourceName]struct{}{
456455
VMIBMCloud: {
@@ -504,7 +503,7 @@ func TestHandleFilesPruneWithNewFiles(t *testing.T) {
504503

505504
fns := tfFuncs{
506505
tfRefresh: func() error { return nil },
507-
tfStateList: func(dir string) (map[TResourceType]map[TResourceName]struct{}, error) {
506+
tfStateList: func() (map[TResourceType]map[TResourceName]struct{}, error) {
508507
// Return only 3 of the five existing
509508
result := map[TResourceName]struct{}{
510509
TResourceName("instance-102"): {},
@@ -659,7 +658,7 @@ func TestHandleFilesDedicatedGlobalNoPruneWithNewFiles(t *testing.T) {
659658

660659
fns := tfFuncs{
661660
tfRefresh: func() error { return nil },
662-
tfStateList: func(dir string) (map[TResourceType]map[TResourceName]struct{}, error) {
661+
tfStateList: func() (map[TResourceType]map[TResourceName]struct{}, error) {
663662
// Return only existing instances (ie, only odd ones)
664663
vms := map[TResourceName]struct{}{}
665664
for i := 100; i < 115; i++ {
@@ -842,7 +841,7 @@ func TestHandleFilesDedicatedGlobalPruneWithNewFiles(t *testing.T) {
842841

843842
fns := tfFuncs{
844843
tfRefresh: func() error { return nil },
845-
tfStateList: func(dir string) (map[TResourceType]map[TResourceName]struct{}, error) {
844+
tfStateList: func() (map[TResourceType]map[TResourceName]struct{}, error) {
846845
// Return only existing instances (ie, only odd ones) EXCEPT 1 in each group
847846
vms := map[TResourceName]struct{}{}
848847
for i := 100; i < 115; i++ {
@@ -909,7 +908,7 @@ func TestHandleFilesDuplicates(t *testing.T) {
909908

910909
fns := tfFuncs{
911910
tfRefresh: func() error { return nil },
912-
tfStateList: func(dir string) (map[TResourceType]map[TResourceName]struct{}, error) {
911+
tfStateList: func() (map[TResourceType]map[TResourceName]struct{}, error) {
913912
return map[TResourceType]map[TResourceName]struct{}{}, nil
914913
},
915914
}

pkg/provider/terraform/instance/cmd/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ func main() {
9595
}
9696
cli.SetLogLevel(*logLevel)
9797
run.Plugin(plugin_base.DefaultTransport(*name), instance_plugin.PluginServer(
98-
terraform.NewTerraformInstancePlugin(*dir, *pollInterval, *standalone, &importOpts)),
98+
terraform.NewTerraformInstancePlugin(*dir, *pollInterval, *standalone, []string{}, &importOpts)),
9999
)
100100
}
101101

pkg/provider/terraform/instance/plugin.go

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ type plugin struct {
7070
pollInterval time.Duration
7171
pollChannel chan bool
7272
pluginLookup func() discovery.Plugins
73+
envs []string
7374
}
7475

7576
// ImportResource defines a resource that should be imported
@@ -94,7 +95,7 @@ type ImportOptions struct {
9495
}
9596

9697
// NewTerraformInstancePlugin returns an instance plugin backed by disk files.
97-
func NewTerraformInstancePlugin(dir string, pollInterval time.Duration, standalone bool, importOpts *ImportOptions) instance.Plugin {
98+
func NewTerraformInstancePlugin(dir string, pollInterval time.Duration, standalone bool, envs []string, importOpts *ImportOptions) instance.Plugin {
9899
log.Debugln("terraform instance plugin. dir=", dir)
99100
fsLock, err := lockfile.New(filepath.Join(dir, "tf-apply.lck"))
100101
if err != nil {
@@ -120,6 +121,7 @@ func NewTerraformInstancePlugin(dir string, pollInterval time.Duration, standalo
120121
fsLock: fsLock,
121122
pollInterval: pollInterval,
122123
pluginLookup: pluginLookup,
124+
envs: envs,
123125
}
124126
if err := p.processImport(importOpts); err != nil {
125127
panic(err)
@@ -164,15 +166,18 @@ func (p *plugin) processImport(importOpts *ImportOptions) error {
164166

165167
// Define the functions for import and import the VM
166168
fns := importFns{
167-
tfShow: doTerraformShow,
169+
tfShow: p.doTerraformShow,
168170
tfImport: func(resType TResourceType, resName, id string) error {
169-
command := exec.Command(fmt.Sprintf("terraform import %v.%v %s", resType, resName, id)).InheritEnvs(true).WithDir(p.Dir)
171+
command := exec.Command(fmt.Sprintf("terraform import %v.%v %s", resType, resName, id)).
172+
InheritEnvs(true).
173+
WithEnvs(p.envs...).
174+
WithDir(p.Dir)
170175
if err := command.WithStdout(os.Stdout).WithStderr(os.Stdout).Start(); err != nil {
171176
return err
172177
}
173178
return command.Wait()
174179
},
175-
tfShowInst: doTerraformShowForInstance,
180+
tfShowInst: p.doTerraformShowForInstance,
176181
tfClean: p.cleanupFailedImport,
177182
}
178183
err := p.importResources(fns, importOpts.Resources, importOpts.InstanceSpec)
@@ -1161,7 +1166,7 @@ func (p *plugin) DescribeInstances(tags map[string]string, properties bool) ([]i
11611166
// TODO - not the most efficient, but here we assume we're usually just one vm type
11621167
for vmResourceType := range localSpecs {
11631168

1164-
if result, err := doTerraformShow(p.Dir, []TResourceType{vmResourceType}, nil); err == nil {
1169+
if result, err := p.doTerraformShow([]TResourceType{vmResourceType}, nil); err == nil {
11651170
terraformShowResult = result
11661171
} else {
11671172
// Don't blow up... just do best and show what we can find.
@@ -1282,9 +1287,9 @@ func terraformLogicalID(props TResourceProperties) *instance.LogicalID {
12821287

12831288
// External functions using during import; broken out for testing
12841289
type importFns struct {
1285-
tfShow func(dir string, resTypes []TResourceType, propFilter []string) (map[TResourceType]map[TResourceName]TResourceProperties, error)
1290+
tfShow func(resTypes []TResourceType, propFilter []string) (map[TResourceType]map[TResourceName]TResourceProperties, error)
12861291
tfImport func(resType TResourceType, filename, resID string) error
1287-
tfShowInst func(dir, id string) (TResourceProperties, error)
1292+
tfShowInst func(id string) (TResourceProperties, error)
12881293
tfClean func(resType TResourceType, resName string)
12891294
}
12901295

@@ -1342,7 +1347,7 @@ func (p *plugin) importResources(fns importFns, resources []*ImportResource, spe
13421347
for resType := range showResourceTypesMap {
13431348
showResourceTypes = append(showResourceTypes, resType)
13441349
}
1345-
existingResources, err := fns.tfShow(p.Dir, showResourceTypes, []string{"id"})
1350+
existingResources, err := fns.tfShow(showResourceTypes, []string{"id"})
13461351
if err != nil {
13471352
return err
13481353
}
@@ -1433,7 +1438,7 @@ func (p *plugin) importResources(fns importFns, resources []*ImportResource, spe
14331438
// Parse the terraform show output
14341439
if errorToThrow == nil {
14351440
for _, r := range resources {
1436-
importedProps, err := fns.tfShowInst(p.Dir, fmt.Sprintf("%v.%v", string(*r.ResourceType), r.FinalResourceName))
1441+
importedProps, err := fns.tfShowInst(fmt.Sprintf("%v.%v", string(*r.ResourceType), r.FinalResourceName))
14371442
if err != nil {
14381443
errorToThrow = err
14391444
break
@@ -1493,7 +1498,10 @@ func (p *plugin) importResources(fns importFns, resources []*ImportResource, spe
14931498

14941499
// cleanupFailedImport removes the resource from the terraform state file
14951500
func (p *plugin) cleanupFailedImport(vmType TResourceType, vmName string) {
1496-
command := exec.Command(fmt.Sprintf("terraform state rm %v.%v", vmType, vmName)).InheritEnvs(true).WithDir(p.Dir)
1501+
command := exec.Command(fmt.Sprintf("terraform state rm %v.%v", vmType, vmName)).
1502+
InheritEnvs(true).
1503+
WithEnvs(p.envs...).
1504+
WithDir(p.Dir)
14971505
err := command.WithStdout(os.Stdout).WithStderr(os.Stdout).Start()
14981506
if err == nil {
14991507
command.Wait()

pkg/provider/terraform/instance/plugin_test.go

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ func TestProcessImportOptions(t *testing.T) {
5353
func getPlugin(t *testing.T) (*plugin, string) {
5454
dir, err := ioutil.TempDir("", "infrakit-instance-terraform")
5555
require.NoError(t, err)
56-
tf := NewTerraformInstancePlugin(dir, 120*time.Second, false, nil)
56+
tf := NewTerraformInstancePlugin(dir, 120*time.Second, false, []string{}, nil)
5757
tf.(*plugin).pretend = true
5858
p, is := tf.(*plugin)
5959
require.True(t, is)
@@ -3701,8 +3701,7 @@ func TestImportTfShowError(t *testing.T) {
37013701
defer os.RemoveAll(dir)
37023702

37033703
fns := importFns{
3704-
tfShow: func(dirArg string, types []TResourceType, propFilter []string) (map[TResourceType]map[TResourceName]TResourceProperties, error) {
3705-
require.Equal(t, dir, dirArg)
3704+
tfShow: func(types []TResourceType, propFilter []string) (map[TResourceType]map[TResourceName]TResourceProperties, error) {
37063705
require.Equal(t, []TResourceType{VMAmazon}, types)
37073706
require.Equal(t, []string{"id"}, propFilter)
37083707
return nil, fmt.Errorf("Custom show error")
@@ -3735,8 +3734,7 @@ func TestImportAlreadyExists(t *testing.T) {
37353734
defer os.RemoveAll(dir)
37363735

37373736
fns := importFns{
3738-
tfShow: func(dirArg string, types []TResourceType, propFilter []string) (map[TResourceType]map[TResourceName]TResourceProperties, error) {
3739-
require.Equal(t, dir, dirArg)
3737+
tfShow: func(types []TResourceType, propFilter []string) (map[TResourceType]map[TResourceName]TResourceProperties, error) {
37403738
require.Equal(t, []TResourceType{VMAmazon}, types)
37413739
require.Equal(t, []string{"id"}, propFilter)
37423740
return map[TResourceType]map[TResourceName]TResourceProperties{
@@ -3783,8 +3781,7 @@ func TestImportTfImportError(t *testing.T) {
37833781

37843782
cleanVals := []string{}
37853783
fns := importFns{
3786-
tfShow: func(dirArg string, types []TResourceType, propFilter []string) (map[TResourceType]map[TResourceName]TResourceProperties, error) {
3787-
require.Equal(t, dir, dirArg)
3784+
tfShow: func(types []TResourceType, propFilter []string) (map[TResourceType]map[TResourceName]TResourceProperties, error) {
37883785
require.Equal(t, []TResourceType{VMAmazon}, types)
37893786
require.Equal(t, []string{"id"}, propFilter)
37903787
return map[TResourceType]map[TResourceName]TResourceProperties{}, nil
@@ -3835,8 +3832,7 @@ func TestImportTfShowInstError(t *testing.T) {
38353832

38363833
cleanVals := []string{}
38373834
fns := importFns{
3838-
tfShow: func(dirArg string, types []TResourceType, propFilter []string) (map[TResourceType]map[TResourceName]TResourceProperties, error) {
3839-
require.Equal(t, dir, dirArg)
3835+
tfShow: func(types []TResourceType, propFilter []string) (map[TResourceType]map[TResourceName]TResourceProperties, error) {
38403836
require.Equal(t, []TResourceType{VMAmazon}, types)
38413837
require.Equal(t, []string{"id"}, propFilter)
38423838
return map[TResourceType]map[TResourceName]TResourceProperties{}, nil
@@ -3847,8 +3843,7 @@ func TestImportTfShowInstError(t *testing.T) {
38473843
require.Equal(t, "123", id)
38483844
return nil
38493845
},
3850-
tfShowInst: func(dirArg, id string) (TResourceProperties, error) {
3851-
require.Equal(t, dir, dirArg)
3846+
tfShowInst: func(id string) (TResourceProperties, error) {
38523847
return nil, fmt.Errorf("Custom show inst error")
38533848
},
38543849
tfClean: func(resType TResourceType, name string) {
@@ -3892,8 +3887,7 @@ func TestImportResourceTagMap(t *testing.T) {
38923887
cleanInvoked := false
38933888
resourceName := ""
38943889
fns := importFns{
3895-
tfShow: func(dirArg string, types []TResourceType, propFilter []string) (map[TResourceType]map[TResourceName]TResourceProperties, error) {
3896-
require.Equal(t, dir, dirArg)
3890+
tfShow: func(types []TResourceType, propFilter []string) (map[TResourceType]map[TResourceName]TResourceProperties, error) {
38973891
require.Equal(t, []TResourceType{VMAmazon}, types)
38983892
require.Equal(t, []string{"id"}, propFilter)
38993893
return map[TResourceType]map[TResourceName]TResourceProperties{}, nil
@@ -3905,8 +3899,7 @@ func TestImportResourceTagMap(t *testing.T) {
39053899
require.Equal(t, "123", id)
39063900
return nil
39073901
},
3908-
tfShowInst: func(dirArg, id string) (TResourceProperties, error) {
3909-
require.Equal(t, dir, dirArg)
3902+
tfShowInst: func(id string) (TResourceProperties, error) {
39103903
prefix := "aws_instance.instance-"
39113904
require.True(t, strings.HasPrefix(id, prefix), fmt.Sprintf("'%v' should have prefix '%v'", id, prefix))
39123905
props := TResourceProperties{
@@ -3984,8 +3977,7 @@ func TestImportResourceTagSlice(t *testing.T) {
39843977
cleanInvoked := false
39853978
resourceName := ""
39863979
fns := importFns{
3987-
tfShow: func(dirArg string, types []TResourceType, propFilter []string) (map[TResourceType]map[TResourceName]TResourceProperties, error) {
3988-
require.Equal(t, dir, dirArg)
3980+
tfShow: func(types []TResourceType, propFilter []string) (map[TResourceType]map[TResourceName]TResourceProperties, error) {
39893981
require.Equal(t, []TResourceType{VMIBMCloud}, types)
39903982
require.Equal(t, []string{"id"}, propFilter)
39913983
return map[TResourceType]map[TResourceName]TResourceProperties{
@@ -4003,8 +3995,7 @@ func TestImportResourceTagSlice(t *testing.T) {
40033995
require.Equal(t, "123", id)
40043996
return nil
40053997
},
4006-
tfShowInst: func(dirArg, id string) (TResourceProperties, error) {
4007-
require.Equal(t, dir, dirArg)
3998+
tfShowInst: func(id string) (TResourceProperties, error) {
40083999
require.True(t, strings.HasPrefix(id, "ibm_compute_vm_instance.instance-"))
40094000
props := TResourceProperties{
40104001
"hostname": "actual-hostname",
@@ -4139,8 +4130,7 @@ func internalTestImportResourceDedicatedGlobal(t *testing.T, options importOptio
41394130
cleanInvoked := false
41404131
imports := []string{}
41414132
fns := importFns{
4142-
tfShow: func(dirArg string, types []TResourceType, propFilter []string) (map[TResourceType]map[TResourceName]TResourceProperties, error) {
4143-
require.Equal(t, dir, dirArg)
4133+
tfShow: func(types []TResourceType, propFilter []string) (map[TResourceType]map[TResourceName]TResourceProperties, error) {
41444134
require.Len(t, types, 3)
41454135
require.Contains(t, types, VMIBMCloud)
41464136
require.Contains(t, types, TResourceType("ibm_storage_file"))
@@ -4174,8 +4164,7 @@ func internalTestImportResourceDedicatedGlobal(t *testing.T, options importOptio
41744164
imports = append(imports, fmt.Sprintf("%v.%v.%v", resType, resName, id))
41754165
return nil
41764166
},
4177-
tfShowInst: func(dirArg, id string) (TResourceProperties, error) {
4178-
require.Equal(t, dir, dirArg)
4167+
tfShowInst: func(id string) (TResourceProperties, error) {
41794168
if strings.HasPrefix(id, "ibm_compute_vm_instance.instance-") {
41804169
props := TResourceProperties{
41814170
"hostname": "actual-hostname",

0 commit comments

Comments
 (0)