feat: expose grant schema for UI linting support (#6470)

This commit is contained in:
Bharath Gajjala authored and GitHub committed 2026-03-18 09:49:16 -05:00
1 parent 0f9307c0ae
commit 8dae2ee45b
3 files changed
+188

No files matched your search

+18
View File
@@ -10,6 +10,8 @@ import (
"net/http"
"strings"
"github.com/hashicorp/boundary/internal/event"
"github.com/hashicorp/boundary/internal/perms"
"github.com/hashicorp/boundary/internal/ui"
)
@@ -20,6 +22,19 @@ func init() {
// serveMetadata provides controller metadata to the UI for licensed versions of Boundary.
var serveMetadata = func(ctx context.Context, w http.ResponseWriter) {}
// serveGrantSchema provides the grant schema to the UI for autocomplete and linting support.
var serveGrantSchema = func(ctx context.Context, w http.ResponseWriter) {
const op = "controller.serveGrantSchema"
data, err := perms.BuildGrantSchemaJSON(ctx)
if err != nil {
w.WriteHeader(http.StatusNoContent)
event.WriteError(ctx, op, err)
return
}
w.Header().Set("Content-Type", "application/json")
w.Write(data)
}
func handleUiWithAssets(c *Controller) http.Handler {
var nextHandler http.Handler
if c.conf.RawConfig.DevUiPassthroughDir != "" {
@@ -46,6 +61,9 @@ func handleUiWithAssets(c *Controller) http.Handler {
case "/metadata.json":
serveMetadata(c.baseContext, w)
return
case "/grants-schema.json":
serveGrantSchema(c.baseContext, w)
return
default:
for i := dotIndex + 1; i < len(r.URL.Path); i++ {
intVal := r.URL.Path[i]