Skip to content

Commit

Permalink
check for invalid hardware (nil) before sending to server
Browse files Browse the repository at this point in the history
  • Loading branch information
kqdeng committed Jul 13, 2020
1 parent 12ceff5 commit 17caa6a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion cmd/tink-cli/cmd/hardware/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ package hardware
import (
"encoding/json"
"fmt"
"github.com/tinkerbell/tink/util"
"log"
"os"

"github.com/tinkerbell/tink/util"

"github.com/tinkerbell/tink/protos/hardware"

"github.com/jedib0t/go-pretty/table"
Expand Down
4 changes: 2 additions & 2 deletions http-server/http-handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ func RegisterHardwareServiceHandlerFromEndpoint(ctx context.Context, mux *runtim
return
}

if hw.Id == "" {
writeResponse(w, http.StatusBadRequest, status.Errorf(codes.InvalidArgument, "id must be set to a UUID, got id: %v", hw.Id).Error())
if hw.Hardware == nil || hw.Id == "" {
writeResponse(w, http.StatusBadRequest, status.Errorf(codes.InvalidArgument, "invalid hardware data, must contain an id").Error())
return
}

Expand Down
1 change: 1 addition & 0 deletions http-server/http_handlers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"encoding/json"
"errors"

grpcRuntime "github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/packethost/pkg/log"

Expand Down

0 comments on commit 17caa6a

Please sign in to comment.