2021-02-15 13:24:20 +00:00
|
|
|
package github
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/cloudskiff/driftctl/pkg/alerter"
|
2021-03-15 17:30:18 +00:00
|
|
|
"github.com/cloudskiff/driftctl/pkg/output"
|
2021-06-04 14:10:00 +00:00
|
|
|
"github.com/cloudskiff/driftctl/pkg/remote/cache"
|
2021-02-15 13:24:20 +00:00
|
|
|
"github.com/cloudskiff/driftctl/pkg/resource"
|
2021-03-26 08:44:55 +00:00
|
|
|
"github.com/cloudskiff/driftctl/pkg/resource/github"
|
2021-02-15 13:24:20 +00:00
|
|
|
"github.com/cloudskiff/driftctl/pkg/terraform"
|
|
|
|
)
|
|
|
|
|
|
|
|
const RemoteGithubTerraform = "github+tf"
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Initialize remote (configure credentials, launch tf providers and start gRPC clients)
|
|
|
|
* Required to use Scanner
|
|
|
|
*/
|
2021-05-21 14:09:45 +00:00
|
|
|
|
2021-06-03 09:43:15 +00:00
|
|
|
func Init(version string, alerter *alerter.Alerter,
|
2021-05-21 14:09:45 +00:00
|
|
|
providerLibrary *terraform.ProviderLibrary,
|
|
|
|
supplierLibrary *resource.SupplierLibrary,
|
|
|
|
progress output.Progress,
|
|
|
|
resourceSchemaRepository *resource.SchemaRepository,
|
|
|
|
factory resource.ResourceFactory) error {
|
|
|
|
|
2021-06-03 09:43:15 +00:00
|
|
|
provider, err := NewGithubTerraformProvider(version, progress)
|
2021-02-15 13:24:20 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
err = provider.Init()
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2021-06-04 14:10:00 +00:00
|
|
|
repositoryCache := cache.New(100)
|
|
|
|
|
|
|
|
repository := NewGithubRepository(provider.GetConfig(), repositoryCache)
|
2021-05-21 14:09:45 +00:00
|
|
|
deserializer := resource.NewDeserializer(factory)
|
2021-02-15 13:24:20 +00:00
|
|
|
providerLibrary.AddProvider(terraform.GITHUB, provider)
|
|
|
|
|
2021-05-21 14:09:45 +00:00
|
|
|
supplierLibrary.AddSupplier(NewGithubRepositorySupplier(provider, repository, deserializer))
|
|
|
|
supplierLibrary.AddSupplier(NewGithubTeamSupplier(provider, repository, deserializer))
|
|
|
|
supplierLibrary.AddSupplier(NewGithubMembershipSupplier(provider, repository, deserializer))
|
|
|
|
supplierLibrary.AddSupplier(NewGithubTeamMembershipSupplier(provider, repository, deserializer))
|
|
|
|
supplierLibrary.AddSupplier(NewGithubBranchProtectionSupplier(provider, repository, deserializer))
|
2021-02-15 13:24:20 +00:00
|
|
|
|
2021-03-26 08:44:55 +00:00
|
|
|
resourceSchemaRepository.Init(provider.Schema())
|
2021-05-07 15:57:31 +00:00
|
|
|
github.InitResourcesMetadata(resourceSchemaRepository)
|
2021-03-26 08:44:55 +00:00
|
|
|
|
2021-02-15 13:24:20 +00:00
|
|
|
return nil
|
|
|
|
}
|