From 047c203c16b53bff830616866954dee7cb276aa5 Mon Sep 17 00:00:00 2001 From: Ethan Dickson Date: Mon, 6 Jan 2025 04:04:34 +0000 Subject: [PATCH 1/2] docs: add URL scheme to example --- docs/index.md | 2 +- examples/provider/provider.tf | 2 +- internal/provider/provider.go | 12 +++++++++++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/docs/index.md b/docs/index.md index 3d9be49..79df017 100644 --- a/docs/index.md +++ b/docs/index.md @@ -27,7 +27,7 @@ terraform { } provider "coderd" { - url = "coder.example.com" + url = "https://coder.example.com" token = "****" } diff --git a/examples/provider/provider.tf b/examples/provider/provider.tf index fe3b9dc..d50d5e7 100644 --- a/examples/provider/provider.tf +++ b/examples/provider/provider.tf @@ -7,7 +7,7 @@ terraform { } provider "coderd" { - url = "coder.example.com" + url = "https://coder.example.com" token = "****" } diff --git a/internal/provider/provider.go b/internal/provider/provider.go index b8b9fa7..b7cfe88 100644 --- a/internal/provider/provider.go +++ b/internal/provider/provider.go @@ -2,6 +2,7 @@ package provider import ( "context" + "fmt" "net/url" "os" "strings" @@ -101,7 +102,16 @@ func (p *CoderdProvider) Configure(ctx context.Context, req provider.ConfigureRe data.Token = types.StringValue(tokenEnv) } - url, err := url.Parse(data.URL.ValueString()) + rawURL := data.URL.ValueString() + if !strings.HasPrefix(rawURL, "http://") && !strings.HasPrefix(rawURL, "https://") { + scheme := "https" + if strings.HasPrefix(rawURL, "localhost") { + scheme = "http" + } + rawURL = fmt.Sprintf("%s://%s", scheme, rawURL) + } + + url, err := url.Parse(rawURL) if err != nil { resp.Diagnostics.AddError("url", "url is not a valid URL: "+err.Error()) return From 3a171a84d084981731fe8d60e58447b6c9afa992 Mon Sep 17 00:00:00 2001 From: Ethan Dickson Date: Mon, 6 Jan 2025 04:13:12 +0000 Subject: [PATCH 2/2] increase startup timeout --- integration/integration.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration/integration.go b/integration/integration.go index f2ed0dd..89b385d 100644 --- a/integration/integration.go +++ b/integration/integration.go @@ -95,7 +95,7 @@ func StartCoder(ctx context.Context, t *testing.T, name string, useLicense bool) t.Logf("not ready yet: %s", err.Error()) } return err == nil - }, 15*time.Second, time.Second, "coder failed to become ready in time") + }, 20*time.Second, time.Second, "coder failed to become ready in time") _, err = client.CreateFirstUser(ctx, codersdk.CreateFirstUserRequest{ Email: testEmail, Username: testUsername,