diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c35690e..2604814 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -82,5 +82,5 @@ jobs: ORG_ID: ${{ secrets.ORG_ID }} TEMBO_HOST: ${{ secrets.TEMBO_HOST }} TEMBO_DATA_HOST: ${{ secrets.TEMBO_DATA_HOST }} - run: go test -v -cover ./internal/provider/ - timeout-minutes: 10 + run: go test -v -cover -timeout 20m ./internal/provider/ + timeout-minutes: 20 diff --git a/internal/provider/provider.go b/internal/provider/provider.go index cba24a5..dfad69b 100644 --- a/internal/provider/provider.go +++ b/internal/provider/provider.go @@ -39,9 +39,11 @@ type temboProvider struct { // temboProviderModel maps provider schema data to a Go type. type temboProviderModel struct { - Host types.String `tfsdk:"host"` - DataHost types.String `tfsdk:"data_host"` - AccessToken types.String `tfsdk:"access_token"` + Host types.String `tfsdk:"host"` + HostURLScheme types.String `tfsdk:"host_url_scheme"` + DataHost types.String `tfsdk:"data_host"` + DataHostURLScheme types.String `tfsdk:"data_host_url_scheme"` + AccessToken types.String `tfsdk:"access_token"` } // Metadata returns the provider type name. @@ -59,10 +61,18 @@ func (p *temboProvider) Schema(_ context.Context, _ provider.SchemaRequest, resp MarkdownDescription: "Tembo API the provider should connect to. By default it connects to Tembo Cloud Production API.", Optional: true, }, + "host_url_scheme": schema.StringAttribute{ + MarkdownDescription: "Url scheme for Tembo API. By default it is https.", + Optional: true, + }, "data_host": schema.StringAttribute{ MarkdownDescription: "Tembo Data API the provider should connect to. By default it connects to Tembo Data Cloud Production API.", Optional: true, }, + "data_host_url_scheme": schema.StringAttribute{ + MarkdownDescription: "Url scheme for Tembo Data API. By default it is https.", + Optional: true, + }, "access_token": schema.StringAttribute{ MarkdownDescription: "Access Token generated using steps [here](https://tembo.io/docs/tembo-cloud/api#create-a-long-lived-api-token).", Optional: true, @@ -119,7 +129,9 @@ func (p *temboProvider) Configure(ctx context.Context, req provider.ConfigureReq // with Terraform configuration value if set. host := os.Getenv("TEMBO_HOST") + host_url_scheme := os.Getenv("TEMBO_HOST_URL_SCHEME") data_host := os.Getenv("TEMBO_DATA_HOST") + data_host_url_scheme := os.Getenv("TEMBO_DATA_HOST_URL_SCHEME") access_token := os.Getenv("TEMBO_ACCESS_TOKEN") if !config.Host.IsNull() { @@ -130,6 +142,14 @@ func (p *temboProvider) Configure(ctx context.Context, req provider.ConfigureReq host = "https://api.coredb.io" } + if !config.HostURLScheme.IsNull() { + host_url_scheme = config.HostURLScheme.ValueString() + } + + if host_url_scheme == "" { + host_url_scheme = "https" + } + if !config.DataHost.IsNull() { data_host = config.DataHost.ValueString() } @@ -138,6 +158,14 @@ func (p *temboProvider) Configure(ctx context.Context, req provider.ConfigureReq data_host = "https://api.data-1.use1.tembo.io" } + if !config.DataHostURLScheme.IsNull() { + data_host_url_scheme = config.DataHostURLScheme.ValueString() + } + + if data_host_url_scheme == "" { + data_host_url_scheme = "https" + } + if !config.AccessToken.IsNull() { access_token = config.AccessToken.ValueString() } @@ -176,7 +204,7 @@ func (p *temboProvider) Configure(ctx context.Context, req provider.ConfigureReq panic(err) } - configuration.Scheme = "https" + configuration.Scheme = host_url_scheme configuration.Host = hostUrl.Host @@ -190,7 +218,7 @@ func (p *temboProvider) Configure(ctx context.Context, req provider.ConfigureReq panic(err) } - data_configuration.Scheme = "https" + data_configuration.Scheme = data_host_url_scheme data_configuration.Host = dataHostUrl.Host