-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from deggja/interactive_ui
Interactive UI
- Loading branch information
Showing
28 changed files
with
12,799 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
"log" | ||
"net/http" | ||
|
||
"github.com/deggja/netfetch/backend/pkg/k8s" | ||
"github.com/rs/cors" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var dashCmd = &cobra.Command{ | ||
Use: "dash", | ||
Short: "Launch the Netfetch interactive dashboard", | ||
Run: func(cmd *cobra.Command, args []string) { | ||
startDashboardServer() | ||
}, | ||
} | ||
|
||
func init() { | ||
rootCmd.AddCommand(dashCmd) | ||
} | ||
|
||
func startDashboardServer() { | ||
// Set up CORS | ||
c := cors.New(cors.Options{ | ||
AllowedOrigins: []string{"http://localhost:8081"}, | ||
AllowedMethods: []string{"GET", "POST", "OPTIONS"}, | ||
AllowedHeaders: []string{"Accept", "Content-Type", "X-CSRF-Token"}, | ||
}) | ||
|
||
// Set up handlers | ||
http.HandleFunc("/", dashboardHandler) | ||
http.HandleFunc("/scan", k8s.HandleScanRequest) | ||
http.HandleFunc("/namespaces", k8s.HandleNamespaceListRequest) | ||
http.HandleFunc("/add-policy", k8s.HandleAddPolicyRequest) | ||
|
||
// Wrap the default serve mux with the CORS middleware | ||
handler := c.Handler(http.DefaultServeMux) | ||
|
||
// Start the server | ||
port := "8080" | ||
fmt.Printf("Starting dashboard server on http://localhost:%s\n", port) | ||
if err := http.ListenAndServe(":"+port, handler); err != nil { | ||
log.Fatalf("Failed to start server: %v\n", err) | ||
} | ||
} | ||
|
||
func dashboardHandler(w http.ResponseWriter, r *http.Request) { | ||
// Serve the Vue.js UI | ||
http.FileServer(http.Dir("netfetch/frontend/dash")).ServeHTTP(w, r) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
package main | ||
|
||
import ( | ||
"github.com/deggja/netfetch/cmd" | ||
"github.com/deggja/netfetch/backend/cmd" | ||
) | ||
|
||
func main() { | ||
|
Binary file not shown.
File renamed without changes.
Oops, something went wrong.