forked from snyk/driftctl
/
remote.go
50 lines (44 loc) · 1.71 KB
/
remote.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package remote
import (
"github.com/pkg/errors"
"github.com/snyk/driftctl/enumeration"
"github.com/snyk/driftctl/enumeration/alerter"
"github.com/snyk/driftctl/enumeration/remote/aws"
"github.com/snyk/driftctl/enumeration/remote/azurerm"
"github.com/snyk/driftctl/enumeration/remote/common"
"github.com/snyk/driftctl/enumeration/remote/github"
"github.com/snyk/driftctl/enumeration/remote/google"
"github.com/snyk/driftctl/enumeration/resource"
"github.com/snyk/driftctl/enumeration/terraform"
)
var supportedRemotes = []string{
common.RemoteAWSTerraform,
common.RemoteGithubTerraform,
common.RemoteGoogleTerraform,
common.RemoteAzureTerraform,
}
func IsSupported(remote string) bool {
for _, r := range supportedRemotes {
if r == remote {
return true
}
}
return false
}
func Activate(remote, version string, alerter alerter.AlerterInterface, providerLibrary *terraform.ProviderLibrary, remoteLibrary *common.RemoteLibrary, progress enumeration.ProgressCounter, factory resource.ResourceFactory, configDir string) error {
switch remote {
case common.RemoteAWSTerraform:
return aws.Init(version, alerter, providerLibrary, remoteLibrary, progress, factory, configDir)
case common.RemoteGithubTerraform:
return github.Init(version, alerter, providerLibrary, remoteLibrary, progress, factory, configDir)
case common.RemoteGoogleTerraform:
return google.Init(version, alerter, providerLibrary, remoteLibrary, progress, factory, configDir)
case common.RemoteAzureTerraform:
return azurerm.Init(version, alerter, providerLibrary, remoteLibrary, progress, factory, configDir)
default:
return errors.Errorf("unsupported remote '%s'", remote)
}
}
func GetSupportedRemotes() []string {
return supportedRemotes
}