summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorJulien Dessaux2024-10-14 23:54:49 +0200
committerJulien Dessaux2024-10-14 23:54:49 +0200
commit3319e74279af910523f068a96eea169c7a60d70d (patch)
treef309498f1d09f0549f2a63a5fa5b3aa15d41232a /cmd
parentfeat(logger): implement optional body logging (diff)
downloadtfstated-3319e74279af910523f068a96eea169c7a60d70d.tar.gz
tfstated-3319e74279af910523f068a96eea169c7a60d70d.tar.bz2
tfstated-3319e74279af910523f068a96eea169c7a60d70d.zip
feat(tfstated): implement states versioning
Diffstat (limited to '')
-rw-r--r--cmd/tfstated/get.go9
-rw-r--r--cmd/tfstated/get_test.go2
2 files changed, 2 insertions, 9 deletions
diff --git a/cmd/tfstated/get.go b/cmd/tfstated/get.go
index 7d54970..6bc4466 100644
--- a/cmd/tfstated/get.go
+++ b/cmd/tfstated/get.go
@@ -1,8 +1,6 @@
package main
import (
- "database/sql"
- "errors"
"fmt"
"net/http"
@@ -20,12 +18,7 @@ func handleGet(db *database.DB) http.Handler {
}
if data, err := db.GetState(r.URL.Path); err != nil {
- if errors.Is(err, sql.ErrNoRows) {
- _ = errorResponse(w, http.StatusNotFound,
- fmt.Errorf("state path not found: %s", r.URL.Path))
- } else {
- _ = errorResponse(w, http.StatusInternalServerError, err)
- }
+ _ = errorResponse(w, http.StatusInternalServerError, err)
} else {
w.WriteHeader(http.StatusOK)
_, _ = w.Write(data)
diff --git a/cmd/tfstated/get_test.go b/cmd/tfstated/get_test.go
index a6d9382..aa56026 100644
--- a/cmd/tfstated/get_test.go
+++ b/cmd/tfstated/get_test.go
@@ -18,7 +18,7 @@ func TestGet(t *testing.T) {
msg string
}{
{"GET", &url.URL{Path: "/"}, nil, "", http.StatusBadRequest, "/"},
- {"GET", &url.URL{Path: "/non_existent_get"}, nil, "", http.StatusNotFound, "non existent"},
+ {"GET", &url.URL{Path: "/non_existent_get"}, strings.NewReader(""), "", http.StatusOK, "non existent"},
{"POST", &url.URL{Path: "/test_get"}, strings.NewReader("the_test_get"), "", http.StatusOK, "/test_get"},
{"GET", &url.URL{Path: "/test_get"}, nil, "the_test_get", http.StatusOK, "/test_get"},
}