Ks8/Folders: Fix status codes returned on create (#95055)

* Fix status codes returned by k8s folder handler
* Add test for status code when creating duplicate folder
This commit is contained in:
Arati R.
2024-10-21 13:07:11 -03:00
committed by GitHub
parent 9d1f8fbdb0
commit 8abfcdbb78
3 changed files with 75 additions and 1 deletions
+3 -1
View File
@@ -11,6 +11,7 @@ import (
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apiserver/pkg/registry/rest"
"github.com/grafana/grafana/pkg/api/apierrors"
"github.com/grafana/grafana/pkg/apimachinery/identity"
"github.com/grafana/grafana/pkg/apimachinery/utils"
"github.com/grafana/grafana/pkg/apis/folder/v0alpha1"
@@ -186,7 +187,8 @@ func (s *legacyStorage) Create(ctx context.Context,
ParentUID: parent,
})
if err != nil {
return nil, err
statusErr := apierrors.ToFolderStatusError(err)
return nil, &statusErr
}
// #TODO can we directly convert instead of doing a Get? the result of the Create
// has more data than the one of Get so there is more we can include in the k8s resource