2020-12-09 15:31:34 +00:00
|
|
|
package remote
|
|
|
|
|
|
|
|
import (
|
2020-12-16 12:02:02 +00:00
|
|
|
"github.com/cloudskiff/driftctl/pkg/alerter"
|
2021-03-15 17:30:18 +00:00
|
|
|
"github.com/cloudskiff/driftctl/pkg/output"
|
2020-12-09 15:31:34 +00:00
|
|
|
"github.com/cloudskiff/driftctl/pkg/remote/aws"
|
2021-08-24 08:32:56 +00:00
|
|
|
"github.com/cloudskiff/driftctl/pkg/remote/azurerm"
|
2021-06-11 15:10:06 +00:00
|
|
|
"github.com/cloudskiff/driftctl/pkg/remote/common"
|
2021-02-15 13:24:20 +00:00
|
|
|
"github.com/cloudskiff/driftctl/pkg/remote/github"
|
2021-08-04 15:17:27 +00:00
|
|
|
"github.com/cloudskiff/driftctl/pkg/remote/google"
|
2021-01-22 17:06:17 +00:00
|
|
|
"github.com/cloudskiff/driftctl/pkg/resource"
|
|
|
|
"github.com/cloudskiff/driftctl/pkg/terraform"
|
2021-02-09 18:43:39 +00:00
|
|
|
"github.com/pkg/errors"
|
2020-12-09 15:31:34 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
var supportedRemotes = []string{
|
2021-08-03 10:34:36 +00:00
|
|
|
common.RemoteAWSTerraform,
|
|
|
|
common.RemoteGithubTerraform,
|
2021-08-04 15:17:27 +00:00
|
|
|
common.RemoteGoogleTerraform,
|
2021-08-24 08:32:56 +00:00
|
|
|
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,
|
2021-06-11 15:10:06 +00:00
|
|
|
remoteLibrary *common.RemoteLibrary,
|
2021-05-21 14:09:45 +00:00
|
|
|
progress output.Progress,
|
|
|
|
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 {
|
2021-08-03 10:34:36 +00:00
|
|
|
case common.RemoteAWSTerraform:
|
2021-07-26 10:09:52 +00:00
|
|
|
return aws.Init(version, alerter, providerLibrary, remoteLibrary, progress, resourceSchemaRepository, factory, configDir)
|
2021-08-03 10:34:36 +00:00
|
|
|
case common.RemoteGithubTerraform:
|
2021-07-26 10:09:52 +00:00
|
|
|
return github.Init(version, alerter, providerLibrary, remoteLibrary, progress, resourceSchemaRepository, factory, configDir)
|
2021-08-04 15:17:27 +00:00
|
|
|
case common.RemoteGoogleTerraform:
|
|
|
|
return google.Init(version, alerter, providerLibrary, remoteLibrary, progress, resourceSchemaRepository, factory, configDir)
|
2021-08-24 08:32:56 +00:00
|
|
|
case common.RemoteAzureTerraform:
|
|
|
|
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
|
|
|
|
}
|