@@ -4,11 +4,6 @@ import (
4
4
"fmt"
5
5
"io/ioutil"
6
6
"os"
7
- "path/filepath"
8
- "runtime"
9
- "strings"
10
-
11
- getter "github.com/hashicorp/go-getter"
12
7
)
13
8
14
9
const subprocessCurrentSigil = "4acd63807899403ca4859f5bb948d2c6"
@@ -85,81 +80,6 @@ func InitHelper(config *Config) (*Helper, error) {
85
80
}, nil
86
81
}
87
82
88
- // symlinkAuxiliaryProviders discovers auxiliary provider binaries, used in
89
- // multi-provider tests, and symlinks them to the plugin directory.
90
- //
91
- // Auxiliary provider binaries should be included in the provider source code
92
- // directory, under the path terraform.d/plugins/$GOOS_$GOARCH/provider-name.
93
- //
94
- // The environment variable TF_ACC_PROVIDER_ROOT_DIR must be set to the path of
95
- // the provider source code directory root in order to use this feature.
96
- func symlinkAuxiliaryProviders (pluginDir string ) error {
97
- providerRootDir := os .Getenv ("TF_ACC_PROVIDER_ROOT_DIR" )
98
- if providerRootDir == "" {
99
- // common case; assume intentional and do not log
100
- return nil
101
- }
102
-
103
- _ , err := os .Stat (filepath .Join (providerRootDir , "terraform.d" , "plugins" ))
104
- if os .IsNotExist (err ) {
105
- fmt .Printf ("No terraform.d/plugins directory found: continuing. Unset TF_ACC_PROVIDER_ROOT_DIR or supply provider binaries in terraform.d/plugins/$GOOS_$GOARCH to disable this message." )
106
- return nil
107
- } else if err != nil {
108
- return fmt .Errorf ("Unexpected error: %s" , err )
109
- }
110
-
111
- auxiliaryProviderDir := filepath .Join (providerRootDir , "terraform.d" , "plugins" , runtime .GOOS + "_" + runtime .GOARCH )
112
-
113
- // If we can't os.Stat() terraform.d/plugins/$GOOS_$GOARCH, however,
114
- // assume the omission was unintentional, and error.
115
- _ , err = os .Stat (auxiliaryProviderDir )
116
- if os .IsNotExist (err ) {
117
- return fmt .Errorf ("error finding auxiliary provider dir %s: %s" , auxiliaryProviderDir , err )
118
- } else if err != nil {
119
- return fmt .Errorf ("Unexpected error: %s" , err )
120
- }
121
-
122
- // now find all the providers in that dir and symlink them to the plugin dir
123
- providers , err := ioutil .ReadDir (auxiliaryProviderDir )
124
- if err != nil {
125
- return fmt .Errorf ("error reading auxiliary providers: %s" , err )
126
- }
127
-
128
- zipDecompressor := new (getter.ZipDecompressor )
129
-
130
- for _ , provider := range providers {
131
- filename := provider .Name ()
132
- filenameExt := filepath .Ext (filename )
133
- name := strings .TrimSuffix (filename , filenameExt )
134
- path := filepath .Join (auxiliaryProviderDir , name )
135
- symlinkPath := filepath .Join (pluginDir , name )
136
-
137
- // exit early if we have already symlinked this provider
138
- _ , err := os .Stat (symlinkPath )
139
- if err == nil {
140
- continue
141
- }
142
-
143
- // if filename ends in .zip, assume it is a zip and extract it
144
- // otherwise assume it is a provider binary
145
- if filenameExt == ".zip" {
146
- _ , err = os .Stat (path )
147
- if os .IsNotExist (err ) {
148
- zipDecompressor .Decompress (path , filepath .Join (auxiliaryProviderDir , filename ), false )
149
- } else if err != nil {
150
- return fmt .Errorf ("Unexpected error: %s" , err )
151
- }
152
- }
153
-
154
- err = symlinkFile (path , symlinkPath )
155
- if err != nil {
156
- return fmt .Errorf ("error symlinking auxiliary provider %s: %s" , name , err )
157
- }
158
- }
159
-
160
- return nil
161
- }
162
-
163
83
// Close cleans up temporary files and directories created to support this
164
84
// helper, returning an error if any of the cleanup fails.
165
85
//
0 commit comments