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

Modify error code for returned errors from SPIRE #368

Merged
merged 1 commit into from
Mar 19, 2024
Merged
Changes from all commits
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
18 changes: 9 additions & 9 deletions api/agent/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func (s *Server) healthcheck(w http.ResponseWriter, r *http.Request) {
ret, err := s.SPIREHealthcheck(input) //nolint:govet //Ignoring mutex (not being used) - sync.Mutex by value is unused for linter govet
if err != nil {
emsg := fmt.Sprintf("Error: %v", err.Error())
retError(w, emsg, http.StatusBadRequest)
retError(w, emsg, http.StatusInternalServerError)
return
}

Expand All @@ -96,7 +96,7 @@ func (s *Server) debugServer(w http.ResponseWriter, r *http.Request) {
ret, err := s.DebugServer(input) //nolint:govet //Ignoring mutex (not being used) - sync.Mutex by value is unused for linter govet
if err != nil {
emsg := fmt.Sprintf("Error: %v", err.Error())
retError(w, emsg, http.StatusBadRequest)
retError(w, emsg, http.StatusInternalServerError)
return
}

Expand Down Expand Up @@ -137,7 +137,7 @@ func (s *Server) agentList(w http.ResponseWriter, r *http.Request) {
ret, err := s.ListAgents(input) //nolint:govet //Ignoring mutex (not being used) - sync.Mutex by value is unused for linter govet
if err != nil {
emsg := fmt.Sprintf("Error: %v", err.Error())
retError(w, emsg, http.StatusBadRequest)
retError(w, emsg, http.StatusInternalServerError)
return
}

Expand Down Expand Up @@ -181,7 +181,7 @@ func (s *Server) agentBan(w http.ResponseWriter, r *http.Request) {
err = s.BanAgent(input) //nolint:govet //Ignoring mutex (not being used) - sync.Mutex by value is unused for linter govet
if err != nil {
emsg := fmt.Sprintf("Error listing agents: %v", err.Error())
retError(w, emsg, http.StatusBadRequest)
retError(w, emsg, http.StatusInternalServerError)
return
}

Expand Down Expand Up @@ -226,7 +226,7 @@ func (s *Server) agentDelete(w http.ResponseWriter, r *http.Request) {
err = s.DeleteAgent(input) //nolint:govet //Ignoring mutex (not being used) - sync.Mutex by value is unused for linter govet
if err != nil {
emsg := fmt.Sprintf("Error listing agents: %v", err.Error())
retError(w, emsg, http.StatusBadRequest)
retError(w, emsg, http.StatusInternalServerError)
return
}

Expand Down Expand Up @@ -267,7 +267,7 @@ func (s *Server) agentCreateJoinToken(w http.ResponseWriter, r *http.Request) {
ret, err := s.CreateJoinToken(input) //nolint:govet //Ignoring mutex (not being used) - sync.Mutex by value is unused for linter govet
if err != nil {
emsg := fmt.Sprintf("Error: %v", err.Error())
retError(w, emsg, http.StatusBadRequest)
retError(w, emsg, http.StatusInternalServerError)
return
}

Expand Down Expand Up @@ -308,7 +308,7 @@ func (s *Server) entryList(w http.ResponseWriter, r *http.Request) {
ret, err := s.ListEntries(input) //nolint:govet //Ignoring mutex (not being used) - sync.Mutex by value is unused for linter govet
if err != nil {
emsg := fmt.Sprintf("Error: %v", err.Error())
retError(w, emsg, http.StatusBadRequest)
retError(w, emsg, http.StatusInternalServerError)
return
}

Expand Down Expand Up @@ -349,7 +349,7 @@ func (s *Server) entryCreate(w http.ResponseWriter, r *http.Request) {
ret, err := s.BatchCreateEntry(input) //nolint:govet //Ignoring mutex (not being used) - sync.Mutex by value is unused for linter govet
if err != nil {
emsg := fmt.Sprintf("Error: %v", err.Error())
retError(w, emsg, http.StatusBadRequest)
retError(w, emsg, http.StatusInternalServerError)
return
}

Expand Down Expand Up @@ -390,7 +390,7 @@ func (s *Server) entryDelete(w http.ResponseWriter, r *http.Request) {
ret, err := s.BatchDeleteEntry(input) //nolint:govet //Ignoring mutex (not being used) - sync.Mutex by value is unused for linter govet
if err != nil {
emsg := fmt.Sprintf("Error: %v", err.Error())
retError(w, emsg, http.StatusBadRequest)
retError(w, emsg, http.StatusInternalServerError)
return
}

Expand Down
Loading