<commit_before>// Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved.
// Licensed under the Mozilla Public License v2.0

package provider

import (
	"crypto/rsa"
	"fmt"
	"io/ioutil"
	"log"
	"math"
	"os"
	"path"
	"path/filepath"
	"regexp"
	"strconv"
	"strings"
	"time"

	"github.com/terraform-providers/terraform-provider-oci/internal/globalvar"

	"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
	"github.com/hashicorp/terraform-plugin-sdk/helper/validation"
	sdkMeta "github.com/hashicorp/terraform-plugin-sdk/meta"
	"github.com/hashicorp/terraform-plugin-sdk/terraform"

	"crypto/tls"
	"crypto/x509"
	"net"
	"net/http"
	"runtime"

	oci_common "github.com/oracle/oci-go-sdk/v54/common"
	oci_common_auth "github.com/oracle/oci-go-sdk/v54/common/auth"

	"github.com/terraform-providers/terraform-provider-oci/httpreplay"
	tf_client "github.com/terraform-providers/terraform-provider-oci/internal/client"
	tf_resource "github.com/terraform-providers/terraform-provider-oci/internal/tfresource"
	"github.com/terraform-providers/terraform-provider-oci/internal/utils"
)

var descriptions map[string]string
var ApiKeyConfigAttributes = [5]string{globalvar.UserOcidAttrName, globalvar.FingerprintAttrName, globalvar.PrivateKeyAttrName, globalvar.PrivateKeyPathAttrName, globalvar.PrivateKeyPasswordAttrName}
var ociProvider *schema.Provider

var TerraformCLIVersion = globalvar.UnknownTerraformCLIVersion
var avoidWaitingForDeleteTarget bool

var OciResources map[string]*schema.Resource
var OciDatasources map[string]*schema.Resource

// OboTokenProvider interface that wraps information about auth tokens so the sdk client can make calls
// on behalf of a different authorized user
type OboTokenProvider interface {
	OboToken() (string, error)
}

//EmptyOboTokenProvider always provides an empty obo token
type emptyOboTokenProvider struct{}

//OboToken provides the obo token
func (provider emptyOboTokenProvider) OboToken() (string, error) {
	return "", nil
}

type oboTokenProviderFromEnv struct{}

func (p oboTokenProviderFromEnv) OboToken() (string, error) {
	// priority token from path than token from environment
	if path := utils.GetEnvSettingWithBlankDefault(globalvar.OboTokenPath); path != "" {
		token, err := utils.GetTokenFromFile(path)
		if err != nil {
			return "", err
		}
		return token, nil
	}
	return utils.GetEnvSettingWithBlankDefault(globalvar.OboTokenAttrName), nil
}

func tfVarName(attrName string) string {
	return utils.TfEnvPrefix + attrName
}

func ociVarName(attrName string) string {
	return utils.OciEnvPrefix + strings.ToUpper(attrName)
}

func init() {
	descriptions = map[string]string{
		globalvar.AuthAttrName:        fmt.Sprintf("(Optional) The type of auth to use. Options are '%s', '%s' and '%s'. By default, '%s' will be used.", globalvar.AuthAPIKeySetting, globalvar.AuthSecurityToken, globalvar.AuthInstancePrincipalSetting, globalvar.AuthAPIKeySetting),
		globalvar.TenancyOcidAttrName: fmt.Sprintf("(Optional) The tenancy OCID for a user. The tenancy OCID can be found at the bottom of user settings in the Oracle Cloud Infrastructure console. Required if auth is set to '%s', ignored otherwise.", globalvar.AuthAPIKeySetting),
		globalvar.UserOcidAttrName:    fmt.Sprintf("(Optional) The user OCID. This can be found in user settings in the Oracle Cloud Infrastructure console. Required if auth is set to '%s', ignored otherwise.", globalvar.AuthAPIKeySetting),
		globalvar.FingerprintAttrName: fmt.Sprintf("(Optional) The fingerprint for the user's RSA key. This can be found in user settings in the Oracle Cloud Infrastructure console. Required if auth is set to '%s', ignored otherwise.", globalvar.AuthAPIKeySetting),
		globalvar.RegionAttrName:      "(Required) The region for API connections (e.g. us-ashburn-1).",
		globalvar.PrivateKeyAttrName: "(Optional) A PEM formatted RSA private key for the user.\n" +
			fmt.Sprintf("A private_key or a private_key_path must be provided if auth is set to '%s', ignored otherwise.", globalvar.AuthAPIKeySetting),
		globalvar.PrivateKeyPathAttrName: "(Optional) The path to the user's PEM formatted private key.\n" +
			fmt.Sprintf("A private_key or a private_key_path must be provided if auth is set to '%s', ignored otherwise.", globalvar.AuthAPIKeySetting),
		globalvar.PrivateKeyPasswordAttrName: "(Optional) The password used to secure the private key.",
		globalvar.DisableAutoRetriesAttrName: "(Optional) Disable automatic retries for retriable errors.\n" +
			"Automatic retries were introduced to solve some eventual consistency problems but it also introduced performance issues on destroy operations.",
		globalvar.RetryDurationSecondsAttrName: "(Optional) The minimum duration (in seconds) to retry a resource operation in response to an error.\n" +
			"The actual retry duration may be longer due to jittering of retry operations. This value is ignored if the `disable_auto_retries` field is set to true.",
		globalvar.ConfigFileProfileAttrName: "(Optional) The profile name to be used from config file, if not set it will be DEFAULT.",
	}
}

func Provider() terraform.ResourceProvider {
	ociProvider = &schema.Provider{
		DataSourcesMap: DataSourcesMap(),
		Schema:         SchemaMap(),
		ResourcesMap:   ResourcesMap(),
		ConfigureFunc:  ProviderConfig,
	}
	return ociProvider
}

func SchemaMap() map[string]*schema.Schema {
	return map[string]*schema.Schema{
		globalvar.AuthAttrName: {
			Type:         schema.TypeString,
			Optional:     true,
			Description:  descriptions[globalvar.AuthAttrName],
			DefaultFunc:  schema.MultiEnvDefaultFunc([]string{tfVarName(globalvar.AuthAttrName), ociVarName(globalvar.AuthAttrName)}, globalvar.AuthAPIKeySetting),
			ValidateFunc: validation.StringInSlice([]string{globalvar.AuthAPIKeySetting, globalvar.AuthInstancePrincipalSetting, globalvar.AuthInstancePrincipalWithCertsSetting, globalvar.AuthSecurityToken}, true),
		},
		globalvar.TenancyOcidAttrName: {
			Type:        schema.TypeString,
			Optional:    true,
			Description: descriptions[globalvar.TenancyOcidAttrName],
			DefaultFunc: schema.MultiEnvDefaultFunc([]string{tfVarName(globalvar.TenancyOcidAttrName), ociVarName(globalvar.TenancyOcidAttrName)}, nil),
		},
		globalvar.UserOcidAttrName: {
			Type:        schema.TypeString,
			Optional:    true,
			Description: descriptions[globalvar.UserOcidAttrName],
			DefaultFunc: schema.MultiEnvDefaultFunc([]string{tfVarName(globalvar.UserOcidAttrName), ociVarName(globalvar.UserOcidAttrName)}, nil),
		},
		globalvar.FingerprintAttrName: {
			Type:        schema.TypeString,
			Optional:    true,
			Description: descriptions[globalvar.FingerprintAttrName],
			DefaultFunc: schema.MultiEnvDefaultFunc([]string{tfVarName(globalvar.FingerprintAttrName), ociVarName(globalvar.FingerprintAttrName)}, nil),
		},
		// Mostly used for testing. Don't put keys in your .tf files
		globalvar.PrivateKeyAttrName: {
			Type:        schema.TypeString,
			Optional:    true,
			Default:     "",
			Sensitive:   true,
			Description: descriptions[globalvar.PrivateKeyAttrName],
			DefaultFunc: schema.MultiEnvDefaultFunc([]string{tfVarName(globalvar.PrivateKeyAttrName), ociVarName(globalvar.PrivateKeyAttrName)}, nil),
		},
		globalvar.PrivateKeyPathAttrName: {
			Type:        schema.TypeString,
			Optional:    true,
			Description: descriptions[globalvar.PrivateKeyPathAttrName],
			DefaultFunc: schema.MultiEnvDefaultFunc([]string{tfVarName(globalvar.PrivateKeyPathAttrName), ociVarName(globalvar.PrivateKeyPathAttrName)}, nil),
		},
		globalvar.PrivateKeyPasswordAttrName: {
			Type:        schema.TypeString,
			Optional:    true,
			Sensitive:   true,
			Default:     "",
			Description: descriptions[globalvar.PrivateKeyPasswordAttrName],
			DefaultFunc: schema.MultiEnvDefaultFunc([]string{tfVarName(globalvar.PrivateKeyPasswordAttrName), ociVarName(globalvar.PrivateKeyPasswordAttrName)}, nil),
		},
		globalvar.RegionAttrName: {
			Type:        schema.TypeString,
			Optional:    true,
			Description: descriptions[globalvar.RegionAttrName],
			DefaultFunc: schema.MultiEnvDefaultFunc([]string{tfVarName(globalvar.RegionAttrName), ociVarName(globalvar.RegionAttrName)}, nil),
		},
		globalvar.DisableAutoRetriesAttrName: {
			Type:        schema.TypeBool,
			Optional:    true,
			Default:     false,
			Description: descriptions[globalvar.DisableAutoRetriesAttrName],
			DefaultFunc: schema.MultiEnvDefaultFunc([]string{tfVarName(globalvar.DisableAutoRetriesAttrName), ociVarName(globalvar.DisableAutoRetriesAttrName)}, nil),
		},
		globalvar.RetryDurationSecondsAttrName: {
			Type:        schema.TypeInt,
			Optional:    true,
			Description: descriptions[globalvar.RetryDurationSecondsAttrName],
			DefaultFunc: schema.MultiEnvDefaultFunc([]string{tfVarName(globalvar.RetryDurationSecondsAttrName), ociVarName(globalvar.RetryDurationSecondsAttrName)}, nil),
		},
		globalvar.ConfigFileProfileAttrName: {
			Type:        schema.TypeString,
			Optional:    true,
			Description: descriptions[globalvar.ConfigFileProfileAttrName],
			DefaultFunc: schema.MultiEnvDefaultFunc([]string{tfVarName(globalvar.ConfigFileProfileAttrName), ociVarName(globalvar.ConfigFileProfileAttrName)}, nil),
		},
	}
}

func RegisterResource(name string, resourceSchema *schema.Resource) {
	if OciResources == nil {
		OciResources = make(map[string]*schema.Resource)
	}
	OciResources[name] = resourceSchema
}

func RegisterDatasource(name string, datasourceSchema *schema.Resource) {
	if OciDatasources == nil {
		OciDatasources = make(map[string]*schema.Resource)
	}
	OciDatasources[name] = datasourceSchema
}

// This returns a map of all data sources to register with Terraform
// The OciDatasources map is populated by each datasource's init function being invoked before it gets here
func DataSourcesMap() map[string]*schema.Resource {
	// Register some aliases of registered datasources. These are registered for convenience and legacy reasons.
	/*RegisterDatasource("oci_core_listing_resource_version", CoreAppCatalogListingResourceVersionDataSource())
	RegisterDatasource("oci_core_listing_resource_versions", CoreAppCatalogListingResourceVersionsDataSource())
	RegisterDatasource("oci_core_shape", CoreShapesDataSource())
	RegisterDatasource("oci_core_virtual_networks", CoreVcnsDataSource())
	RegisterDatasource("oci_load_balancers", LoadBalancerLoadBalancersDataSource())
	RegisterDatasource("oci_load_balancer_backendsets", LoadBalancerBackendSetsDataSource())*/
	return OciDatasources
}

// This returns a map of all resources to register with Terraform
// The OciResource map is populated by each resource's init function being invoked before it gets here
func ResourcesMap() map[string]*schema.Resource {
	// Register some aliases of registered resources. These are registered for convenience and legacy reasons.
	/*RegisterResource("oci_core_virtual_network", CoreVcnResource())
	RegisterResource("oci_load_balancer", LoadBalancerLoadBalancerResource())
	RegisterResource("oci_load_balancer_backendset", LoadBalancerBackendSetResource())*/
	return OciResources
}

func ProviderConfig(d *schema.ResourceData) (interface{}, error) {
	clients := &tf_client.OracleClients{
		SdkClientMap:  make(map[string]interface{}, len(tf_client.OracleClientRegistrationsVar.RegisteredClients)),
		Configuration: make(map[string]string),
	}

	if d.Get(globalvar.DisableAutoRetriesAttrName).(bool) {
		tf_resource.ShortRetryTime = 0
		tf_resource.LongRetryTime = 0
	} else if retryDurationSeconds, exists := d.GetOkExists(globalvar.RetryDurationSecondsAttrName); exists {
		val := time.Duration(retryDurationSeconds.(int)) * time.Second
		if retryDurationSeconds.(int) < 0 {
			// Retry for maximum amount of time, if a negative value was specified
			val = time.Duration(math.MaxInt64)
		}
		tf_resource.ConfiguredRetryDuration = &val
	}

	sdkConfigProvider, err := GetSdkConfigProvider(d, clients)<commit_msg>uncomment core, lb register resources<commit_after>// Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved.
// Licensed under the Mozilla Public License v2.0

package provider

import (
	"crypto/rsa"
	"fmt"
	tf_core "github.com/terraform-providers/terraform-provider-oci/internal/service/core"
	tf_load_balancer "github.com/terraform-providers/terraform-provider-oci/internal/service/load_balancer"
	"io/ioutil"
	"log"
	"math"
	"os"
	"path"
	"path/filepath"
	"regexp"
	"strconv"
	"strings"
	"time"

	"github.com/terraform-providers/terraform-provider-oci/internal/globalvar"

	"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
	"github.com/hashicorp/terraform-plugin-sdk/helper/validation"
	sdkMeta "github.com/hashicorp/terraform-plugin-sdk/meta"
	"github.com/hashicorp/terraform-plugin-sdk/terraform"

	"crypto/tls"
	"crypto/x509"
	"net"
	"net/http"
	"runtime"

	oci_common "github.com/oracle/oci-go-sdk/v54/common"
	oci_common_auth "github.com/oracle/oci-go-sdk/v54/common/auth"

	"github.com/terraform-providers/terraform-provider-oci/httpreplay"
	tf_client "github.com/terraform-providers/terraform-provider-oci/internal/client"
	tf_resource "github.com/terraform-providers/terraform-provider-oci/internal/tfresource"
	"github.com/terraform-providers/terraform-provider-oci/internal/utils"
)

var descriptions map[string]string
var ApiKeyConfigAttributes = [5]string{globalvar.UserOcidAttrName, globalvar.FingerprintAttrName, globalvar.PrivateKeyAttrName, globalvar.PrivateKeyPathAttrName, globalvar.PrivateKeyPasswordAttrName}
var ociProvider *schema.Provider

var TerraformCLIVersion = globalvar.UnknownTerraformCLIVersion
var avoidWaitingForDeleteTarget bool

var OciResources map[string]*schema.Resource
var OciDatasources map[string]*schema.Resource

// OboTokenProvider interface that wraps information about auth tokens so the sdk client can make calls
// on behalf of a different authorized user
type OboTokenProvider interface {
	OboToken() (string, error)
}

//EmptyOboTokenProvider always provides an empty obo token
type emptyOboTokenProvider struct{}

//OboToken provides the obo token
func (provider emptyOboTokenProvider) OboToken() (string, error) {
	return "", nil
}

type oboTokenProviderFromEnv struct{}

func (p oboTokenProviderFromEnv) OboToken() (string, error) {
	// priority token from path than token from environment
	if path := utils.GetEnvSettingWithBlankDefault(globalvar.OboTokenPath); path != "" {
		token, err := utils.GetTokenFromFile(path)
		if err != nil {
			return "", err
		}
		return token, nil
	}
	return utils.GetEnvSettingWithBlankDefault(globalvar.OboTokenAttrName), nil
}

func tfVarName(attrName string) string {
	return utils.TfEnvPrefix + attrName
}

func ociVarName(attrName string) string {
	return utils.OciEnvPrefix + strings.ToUpper(attrName)
}

func init() {
	descriptions = map[string]string{
		globalvar.AuthAttrName:        fmt.Sprintf("(Optional) The type of auth to use. Options are '%s', '%s' and '%s'. By default, '%s' will be used.", globalvar.AuthAPIKeySetting, globalvar.AuthSecurityToken, globalvar.AuthInstancePrincipalSetting, globalvar.AuthAPIKeySetting),
		globalvar.TenancyOcidAttrName: fmt.Sprintf("(Optional) The tenancy OCID for a user. The tenancy OCID can be found at the bottom of user settings in the Oracle Cloud Infrastructure console. Required if auth is set to '%s', ignored otherwise.", globalvar.AuthAPIKeySetting),
		globalvar.UserOcidAttrName:    fmt.Sprintf("(Optional) The user OCID. This can be found in user settings in the Oracle Cloud Infrastructure console. Required if auth is set to '%s', ignored otherwise.", globalvar.AuthAPIKeySetting),
		globalvar.FingerprintAttrName: fmt.Sprintf("(Optional) The fingerprint for the user's RSA key. This can be found in user settings in the Oracle Cloud Infrastructure console. Required if auth is set to '%s', ignored otherwise.", globalvar.AuthAPIKeySetting),
		globalvar.RegionAttrName:      "(Required) The region for API connections (e.g. us-ashburn-1).",
		globalvar.PrivateKeyAttrName: "(Optional) A PEM formatted RSA private key for the user.\n" +
			fmt.Sprintf("A private_key or a private_key_path must be provided if auth is set to '%s', ignored otherwise.", globalvar.AuthAPIKeySetting),
		globalvar.PrivateKeyPathAttrName: "(Optional) The path to the user's PEM formatted private key.\n" +
			fmt.Sprintf("A private_key or a private_key_path must be provided if auth is set to '%s', ignored otherwise.", globalvar.AuthAPIKeySetting),
		globalvar.PrivateKeyPasswordAttrName: "(Optional) The password used to secure the private key.",
		globalvar.DisableAutoRetriesAttrName: "(Optional) Disable automatic retries for retriable errors.\n" +
			"Automatic retries were introduced to solve some eventual consistency problems but it also introduced performance issues on destroy operations.",
		globalvar.RetryDurationSecondsAttrName: "(Optional) The minimum duration (in seconds) to retry a resource operation in response to an error.\n" +
			"The actual retry duration may be longer due to jittering of retry operations. This value is ignored if the `disable_auto_retries` field is set to true.",
		globalvar.ConfigFileProfileAttrName: "(Optional) The profile name to be used from config file, if not set it will be DEFAULT.",
	}
}

func Provider() terraform.ResourceProvider {
	ociProvider = &schema.Provider{
		DataSourcesMap: DataSourcesMap(),
		Schema:         SchemaMap(),
		ResourcesMap:   ResourcesMap(),
		ConfigureFunc:  ProviderConfig,
	}
	return ociProvider
}

func SchemaMap() map[string]*schema.Schema {
	return map[string]*schema.Schema{
		globalvar.AuthAttrName: {
			Type:         schema.TypeString,
			Optional:     true,
			Description:  descriptions[globalvar.AuthAttrName],
			DefaultFunc:  schema.MultiEnvDefaultFunc([]string{tfVarName(globalvar.AuthAttrName), ociVarName(globalvar.AuthAttrName)}, globalvar.AuthAPIKeySetting),
			ValidateFunc: validation.StringInSlice([]string{globalvar.AuthAPIKeySetting, globalvar.AuthInstancePrincipalSetting, globalvar.AuthInstancePrincipalWithCertsSetting, globalvar.AuthSecurityToken}, true),
		},
		globalvar.TenancyOcidAttrName: {
			Type:        schema.TypeString,
			Optional:    true,
			Description: descriptions[globalvar.TenancyOcidAttrName],
			DefaultFunc: schema.MultiEnvDefaultFunc([]string{tfVarName(globalvar.TenancyOcidAttrName), ociVarName(globalvar.TenancyOcidAttrName)}, nil),
		},
		globalvar.UserOcidAttrName: {
			Type:        schema.TypeString,
			Optional:    true,
			Description: descriptions[globalvar.UserOcidAttrName],
			DefaultFunc: schema.MultiEnvDefaultFunc([]string{tfVarName(globalvar.UserOcidAttrName), ociVarName(globalvar.UserOcidAttrName)}, nil),
		},
		globalvar.FingerprintAttrName: {
			Type:        schema.TypeString,
			Optional:    true,
			Description: descriptions[globalvar.FingerprintAttrName],
			DefaultFunc: schema.MultiEnvDefaultFunc([]string{tfVarName(globalvar.FingerprintAttrName), ociVarName(globalvar.FingerprintAttrName)}, nil),
		},
		// Mostly used for testing. Don't put keys in your .tf files
		globalvar.PrivateKeyAttrName: {
			Type:        schema.TypeString,
			Optional:    true,
			Default:     "",
			Sensitive:   true,
			Description: descriptions[globalvar.PrivateKeyAttrName],
			DefaultFunc: schema.MultiEnvDefaultFunc([]string{tfVarName(globalvar.PrivateKeyAttrName), ociVarName(globalvar.PrivateKeyAttrName)}, nil),
		},
		globalvar.PrivateKeyPathAttrName: {
			Type:        schema.TypeString,
			Optional:    true,
			Description: descriptions[globalvar.PrivateKeyPathAttrName],
			DefaultFunc: schema.MultiEnvDefaultFunc([]string{tfVarName(globalvar.PrivateKeyPathAttrName), ociVarName(globalvar.PrivateKeyPathAttrName)}, nil),
		},
		globalvar.PrivateKeyPasswordAttrName: {
			Type:        schema.TypeString,
			Optional:    true,
			Sensitive:   true,
			Default:     "",
			Description: descriptions[globalvar.PrivateKeyPasswordAttrName],
			DefaultFunc: schema.MultiEnvDefaultFunc([]string{tfVarName(globalvar.PrivateKeyPasswordAttrName), ociVarName(globalvar.PrivateKeyPasswordAttrName)}, nil),
		},
		globalvar.RegionAttrName: {
			Type:        schema.TypeString,
			Optional:    true,
			Description: descriptions[globalvar.RegionAttrName],
			DefaultFunc: schema.MultiEnvDefaultFunc([]string{tfVarName(globalvar.RegionAttrName), ociVarName(globalvar.RegionAttrName)}, nil),
		},
		globalvar.DisableAutoRetriesAttrName: {
			Type:        schema.TypeBool,
			Optional:    true,
			Default:     false,
			Description: descriptions[globalvar.DisableAutoRetriesAttrName],
			DefaultFunc: schema.MultiEnvDefaultFunc([]string{tfVarName(globalvar.DisableAutoRetriesAttrName), ociVarName(globalvar.DisableAutoRetriesAttrName)}, nil),
		},
		globalvar.RetryDurationSecondsAttrName: {
			Type:        schema.TypeInt,
			Optional:    true,
			Description: descriptions[globalvar.RetryDurationSecondsAttrName],
			DefaultFunc: schema.MultiEnvDefaultFunc([]string{tfVarName(globalvar.RetryDurationSecondsAttrName), ociVarName(globalvar.RetryDurationSecondsAttrName)}, nil),
		},
		globalvar.ConfigFileProfileAttrName: {
			Type:        schema.TypeString,
			Optional:    true,
			Description: descriptions[globalvar.ConfigFileProfileAttrName],
			DefaultFunc: schema.MultiEnvDefaultFunc([]string{tfVarName(globalvar.ConfigFileProfileAttrName), ociVarName(globalvar.ConfigFileProfileAttrName)}, nil),
		},
	}
}

func RegisterResource(name string, resourceSchema *schema.Resource) {
	if OciResources == nil {
		OciResources = make(map[string]*schema.Resource)
	}
	OciResources[name] = resourceSchema
}

func RegisterDatasource(name string, datasourceSchema *schema.Resource) {
	if OciDatasources == nil {
		OciDatasources = make(map[string]*schema.Resource)
	}
	OciDatasources[name] = datasourceSchema
}

// This returns a map of all data sources to register with Terraform
// The OciDatasources map is populated by each datasource's init function being invoked before it gets here
func DataSourcesMap() map[string]*schema.Resource {
	// Register some aliases of registered datasources. These are registered for convenience and legacy reasons.
	RegisterDatasource("oci_core_listing_resource_version", tf_core.CoreAppCatalogListingResourceVersionDataSource())
	RegisterDatasource("oci_core_listing_resource_versions", tf_core.CoreAppCatalogListingResourceVersionsDataSource())
	RegisterDatasource("oci_core_shape", tf_core.CoreShapesDataSource())
	RegisterDatasource("oci_core_virtual_networks", tf_core.CoreVcnsDataSource())
	RegisterDatasource("oci_load_balancers", tf_load_balancer.LoadBalancerLoadBalancersDataSource())
	RegisterDatasource("oci_load_balancer_backendsets", tf_load_balancer.LoadBalancerBackendSetsDataSource())
	return OciDatasources
}

// This returns a map of all resources to register with Terraform
// The OciResource map is populated by each resource's init function being invoked before it gets here
func ResourcesMap() map[string]*schema.Resource {
	// Register some aliases of registered resources. These are registered for convenience and legacy reasons.
	RegisterResource("oci_core_virtual_network", tf_core.CoreVcnResource())
	RegisterResource("oci_load_balancer", tf_load_balancer.LoadBalancerLoadBalancerResource())
	RegisterResource("oci_load_balancer_backendset", tf_load_balancer.LoadBalancerBackendSetResource())
	return OciResources
}

func ProviderConfig(d *schema.ResourceData) (interface{}, error) {
	clients := &tf_client.OracleClients{
		SdkClientMap:  make(map[string]interface{}, len(tf_client.OracleClientRegistrationsVar.RegisteredClients)),
		Configuration: make(map[string]string),
	}

	if d.Get(globalvar.DisableAutoRetriesAttrName).(bool) {
		tf_resource.ShortRetryTime = 0
		tf_resource.LongRetryTime = 0
	} else if retryDurationSeconds, exists := d.GetOkExists(globalvar.RetryDurationSecondsAttrName); exists {
		val := time.Duration(retryDurationSeconds.(int)) * time.Second
		if retryDurationSeconds.(int) < 0 {
			// Retry for maximum amount of time, if a negative value was specified
			val = time.Duration(math.MaxInt64)
		}
		tf_resource.ConfiguredRetryDuration = &val
	}

	sdkConfigProvider, err := GetSdkConfigProvider(d, clients)
{'fraction_non_alphanumeric': 0.09652766240239243, 'fraction_numerical': 0.001993686658913441, 'mean_word_length': 5.767003934794829, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '640299', 'n_tokens_mistral': 7417, 'n_tokens_neox': 7075, 'n_words': 1641}