Skip to content

Commit 5ec880f

Browse files
authored
Update X-Terraform-Get error messaging to match v1 (#364)
1 parent 38e9738 commit 5ec880f

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

get_http.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ func (g *HttpGetter) getXTerraformSource(ctx context.Context, req *Request, sour
453453

454454
if !allowed {
455455
protocol := strings.Split(source, ":")[0]
456-
return fmt.Errorf("download not supported for scheme %q", protocol)
456+
return fmt.Errorf("no getter available for X-Terraform-Get source protocol: %q", protocol)
457457
}
458458

459459
_, err := client.Get(ctx, req)

get_http_test.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func TestHttpGetter_header(t *testing.T) {
4848

4949
// Get it, which should error because it uses the file protocol.
5050
err := g.Get(ctx, req)
51-
if !strings.Contains(err.Error(), "download not supported for scheme") {
51+
if !strings.Contains(err.Error(), "no getter available for X-Terraform-Get source protocol") {
5252
t.Fatalf("unexpected error: %v", err)
5353
}
5454
// But, using a wrapper client with a file getter will work.
@@ -127,7 +127,7 @@ func TestHttpGetter_meta(t *testing.T) {
127127

128128
// Get it, which should error because it uses the file protocol.
129129
err := g.Get(ctx, req)
130-
if !strings.Contains(err.Error(), "download not supported for scheme") {
130+
if !strings.Contains(err.Error(), "no getter available for X-Terraform-Get source protocol:") {
131131
t.Fatalf("unexpected error: %v", err)
132132
}
133133
// But, using a wrapper client with a file getter will work.
@@ -427,7 +427,7 @@ func TestHttpGetter_auth(t *testing.T) {
427427

428428
// Get it, which should error because it uses the file protocol.
429429
err := g.Get(ctx, req)
430-
if !strings.Contains(err.Error(), "download not supported for scheme") {
430+
if !strings.Contains(err.Error(), "no getter available for X-Terraform-Get source protocol:") {
431431
t.Fatalf("unexpected error: %v", err)
432432
}
433433
// But, using a wrapper client with a file getter will work.
@@ -477,7 +477,7 @@ func TestHttpGetter_authNetrc(t *testing.T) {
477477

478478
// Get it, which should error because it uses the file protocol.
479479
err := g.Get(ctx, req)
480-
if !strings.Contains(err.Error(), "download not supported for scheme") {
480+
if !strings.Contains(err.Error(), "no getter available for X-Terraform-Get source protocol:") {
481481
t.Fatalf("unexpected error: %v", err)
482482
}
483483
// But, using a wrapper client with a file getter will work.
@@ -536,7 +536,7 @@ func TestHttpGetter_cleanhttp(t *testing.T) {
536536

537537
// Get it, which should error because it uses the file protocol.
538538
err := g.Get(ctx, req)
539-
if !strings.Contains(err.Error(), "download not supported for scheme") {
539+
if !strings.Contains(err.Error(), "no getter available for X-Terraform-Get source protocol:") {
540540
t.Fatalf("unexpected error: %v", err)
541541
}
542542
// But, using a wrapper client with a file getter will work.
@@ -755,8 +755,8 @@ func TestHttpGetter__XTerraformGetConfiguredGettersBypass(t *testing.T) {
755755
}
756756
// We only care about the error messages that indicate that we can download the git header URL
757757
if tt.errExpected && err != nil {
758-
if !strings.Contains(err.Error(), "download not supported for scheme") {
759-
t.Fatalf("expected download not supported for scheme, got: %v", err)
758+
if !strings.Contains(err.Error(), "no getter available for X-Terraform-Get source protocol:") {
759+
t.Fatalf("expected no getter available for X-Terraform-Get source protocol:, got: %v", err)
760760
}
761761
}
762762
})
@@ -978,8 +978,8 @@ func TestHttpGetter_XTerraformWithClientFromContext(t *testing.T) {
978978
}
979979

980980
if err != nil {
981-
if !strings.Contains(err.Error(), "download not supported for scheme") {
982-
t.Fatalf("expected download not supported for scheme, got: %v", err)
981+
if !strings.Contains(err.Error(), "no getter available for X-Terraform-Get source protocol:") {
982+
t.Fatalf("expected no getter available for X-Terraform-Get source protocol:, got: %v", err)
983983
}
984984
return
985985
}

0 commit comments

Comments
 (0)