driftctl/test/terraform/provider.go

60 lines
1.9 KiB
Go
Raw Normal View History

2021-06-28 09:00:59 +00:00
package terraform
import (
"os"
2021-12-06 13:29:39 +00:00
"github.com/snyk/driftctl/pkg/output"
"github.com/snyk/driftctl/pkg/remote/aws"
"github.com/snyk/driftctl/pkg/remote/azurerm"
"github.com/snyk/driftctl/pkg/remote/github"
"github.com/snyk/driftctl/pkg/remote/google"
"github.com/snyk/driftctl/pkg/terraform"
2021-06-28 09:00:59 +00:00
)
func InitTestAwsProvider(providerLibrary *terraform.ProviderLibrary, version string) (*aws.AWSTerraformProvider, error) {
progress := &output.MockProgress{}
progress.On("Inc").Maybe().Return()
provider, err := aws.NewAWSTerraformProvider(version, progress, os.TempDir())
if err != nil {
return nil, err
}
providerLibrary.AddProvider(terraform.AWS, provider)
return provider, nil
}
2021-06-30 18:42:02 +00:00
func InitTestGithubProvider(providerLibrary *terraform.ProviderLibrary, version string) (*github.GithubTerraformProvider, error) {
progress := &output.MockProgress{}
progress.On("Inc").Maybe().Return()
2021-10-26 09:35:20 +00:00
provider, err := github.NewGithubTerraformProvider(version, progress, os.TempDir())
2021-06-30 18:42:02 +00:00
if err != nil {
return nil, err
}
providerLibrary.AddProvider(terraform.GITHUB, provider)
return provider, nil
}
2021-08-04 15:17:27 +00:00
func InitTestGoogleProvider(providerLibrary *terraform.ProviderLibrary, version string) (*google.GCPTerraformProvider, error) {
progress := &output.MockProgress{}
progress.On("Inc").Maybe().Return()
2021-10-26 09:35:20 +00:00
provider, err := google.NewGCPTerraformProvider(version, progress, os.TempDir())
2021-08-04 15:17:27 +00:00
if err != nil {
return nil, err
}
providerLibrary.AddProvider(terraform.GOOGLE, provider)
return provider, nil
}
2021-08-24 08:32:56 +00:00
func InitTestAzureProvider(providerLibrary *terraform.ProviderLibrary, version string) (*azurerm.AzureTerraformProvider, error) {
progress := &output.MockProgress{}
progress.On("Inc").Maybe().Return()
2021-10-26 09:35:20 +00:00
provider, err := azurerm.NewAzureTerraformProvider(version, progress, os.TempDir())
2021-08-24 08:32:56 +00:00
if err != nil {
return nil, err
}
providerLibrary.AddProvider(terraform.AZURE, provider)
return provider, nil
}