Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update X-Terraform-Get error messaging to match v1 #364

Merged
merged 2 commits into from
May 20, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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(), "") {
nywilken marked this conversation as resolved.
Show resolved Hide resolved
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