Files
opentf/internal/command/inspect/ui.go
Diogenes Fernandes 13ada32895 Adding missing .tsx files
Signed-off-by: Diogenes Fernandes <diofeher@gmail.com>
2025-06-06 12:08:23 -03:00

28 lines
599 B
Go

// Copyright (c) The OpenTofu Authors
// SPDX-License-Identifier: MPL-2.0
package inspect
import (
"embed"
"io/fs"
"net/http"
)
// Embed the built React app
var uiFS embed.FS
// GetUIFileSystem returns the embedded UI filesystem
// This strips the "ui/dist" prefix so files can be served from root
func GetUIFileSystem() http.FileSystem {
// Get the subdirectory without the "ui/dist" prefix
sub, err := fs.Sub(uiFS, "ui/dist")
if err != nil {
// If the dist directory doesn't exist (during development),
// return an empty filesystem
return http.Dir(".")
}
return http.FS(sub)
}