driftctl/enumeration/remote/remote.go

57 lines
1.9 KiB
Go
Raw Normal View History

package remote
import (
2021-02-09 18:43:39 +00:00
"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"
2022-07-06 08:44:42 +00:00
"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{
2022-07-06 08:44:42 +00:00
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.Alerter,
2021-05-21 14:09:45 +00:00
providerLibrary *terraform.ProviderLibrary,
2022-07-06 08:44:42 +00:00
remoteLibrary *common.RemoteLibrary,
progress enumeration.ProgressCounter,
2021-05-21 14:09:45 +00:00
resourceSchemaRepository *resource.SchemaRepository,
factory resource.ResourceFactory,
configDir string) error {
switch remote {
2022-07-06 08:44:42 +00:00
case common.RemoteAWSTerraform:
return aws.Init(version, alerter, providerLibrary, remoteLibrary, progress, resourceSchemaRepository, factory, configDir)
2022-07-06 08:44:42 +00:00
case common.RemoteGithubTerraform:
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)
default:
2021-02-10 13:37:59 +00:00
return errors.Errorf("unsupported remote '%s'", remote)
}
}
func GetSupportedRemotes() []string {
return supportedRemotes
}