2020-12-09 15:31:34 +00:00
|
|
|
package remote
|
|
|
|
|
|
|
|
import (
|
2021-02-09 18:43:39 +00:00
|
|
|
"github.com/pkg/errors"
|
2022-06-28 07:23:29 +00:00
|
|
|
"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"
|
2022-07-06 08:44:42 +00:00
|
|
|
"github.com/snyk/driftctl/enumeration/remote/common"
|
2022-06-28 07:23:29 +00:00
|
|
|
"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"
|
2020-12-09 15:31:34 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
var supportedRemotes = []string{
|
2022-07-06 08:44:42 +00:00
|
|
|
common.RemoteAWSTerraform,
|
|
|
|
common.RemoteGithubTerraform,
|
|
|
|
common.RemoteGoogleTerraform,
|
|
|
|
common.RemoteAzureTerraform,
|
2020-12-09 15:31:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func IsSupported(remote string) bool {
|
|
|
|
for _, r := range supportedRemotes {
|
|
|
|
if r == remote {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2021-06-03 09:43:15 +00:00
|
|
|
func Activate(remote, version string, alerter *alerter.Alerter,
|
2021-05-21 14:09:45 +00:00
|
|
|
providerLibrary *terraform.ProviderLibrary,
|
2022-07-06 08:44:42 +00:00
|
|
|
remoteLibrary *common.RemoteLibrary,
|
2022-06-28 07:23:29 +00:00
|
|
|
progress enumeration.ProgressCounter,
|
2021-05-21 14:09:45 +00:00
|
|
|
resourceSchemaRepository *resource.SchemaRepository,
|
2021-06-12 14:17:23 +00:00
|
|
|
factory resource.ResourceFactory,
|
|
|
|
configDir string) error {
|
2020-12-09 15:31:34 +00:00
|
|
|
switch remote {
|
2022-07-06 08:44:42 +00:00
|
|
|
case common.RemoteAWSTerraform:
|
2021-07-26 10:09:52 +00:00
|
|
|
return aws.Init(version, alerter, providerLibrary, remoteLibrary, progress, resourceSchemaRepository, factory, configDir)
|
2022-07-06 08:44:42 +00:00
|
|
|
case common.RemoteGithubTerraform:
|
2021-07-26 10:09:52 +00:00
|
|
|
return github.Init(version, alerter, providerLibrary, remoteLibrary, progress, resourceSchemaRepository, factory, configDir)
|
2022-07-06 08:44:42 +00:00
|
|
|
case common.RemoteGoogleTerraform:
|
2021-08-04 15:17:27 +00:00
|
|
|
return google.Init(version, alerter, providerLibrary, remoteLibrary, progress, resourceSchemaRepository, factory, configDir)
|
2022-07-06 08:44:42 +00:00
|
|
|
case common.RemoteAzureTerraform:
|
2021-08-24 08:32:56 +00:00
|
|
|
return azurerm.Init(version, alerter, providerLibrary, remoteLibrary, progress, resourceSchemaRepository, factory, configDir)
|
|
|
|
|
2020-12-09 15:31:34 +00:00
|
|
|
default:
|
2021-02-10 13:37:59 +00:00
|
|
|
return errors.Errorf("unsupported remote '%s'", remote)
|
2020-12-09 15:31:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func GetSupportedRemotes() []string {
|
|
|
|
return supportedRemotes
|
|
|
|
}
|