Skip to content

Commit

Permalink
Update X-Terraform-Get error messaging to match v1 (#364)
Browse files Browse the repository at this point in the history
  • Loading branch information
nywilken authored May 20, 2022
1 parent 38e9738 commit 5ec880f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion get_http.go
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ func (g *HttpGetter) getXTerraformSource(ctx context.Context, req *Request, sour

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

_, err := client.Get(ctx, req)
Expand Down
18 changes: 9 additions & 9 deletions get_http_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func TestHttpGetter_header(t *testing.T) {

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

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

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

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

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

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

0 comments on commit 5ec880f

Please sign in to comment.