mirror of
				https://github.com/ClusterCockpit/cc-backend
				synced 2025-10-31 16:05:06 +01:00 
			
		
		
		
	add web init with uiconfig file path, add cli flag
This commit is contained in:
		
							
								
								
									
										15
									
								
								web/web.go
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								web/web.go
									
									
									
									
									
								
							| @@ -11,7 +11,9 @@ import ( | ||||
| 	"encoding/json" | ||||
| 	"html/template" | ||||
| 	"io/fs" | ||||
| 	"log" | ||||
| 	"net/http" | ||||
| 	"os" | ||||
| 	"strings" | ||||
|  | ||||
| 	"github.com/ClusterCockpit/cc-backend/internal/config" | ||||
| @@ -115,9 +117,18 @@ var UIDefaultsMap map[string]any | ||||
| // 	"status_view_selectedTopProjectCategory": "totalJobs", | ||||
| // } | ||||
|  | ||||
| func Init(rawConfig json.RawMessage) error { | ||||
| 	var err error | ||||
| func Init(configFilePath string) error { | ||||
| 	var rawConfig json.RawMessage = nil | ||||
| 	raw, rerr := os.ReadFile(configFilePath) | ||||
| 	if rerr != nil { | ||||
| 		if !os.IsNotExist(rerr) { | ||||
| 			log.Fatalf("UI-CONFIG ERROR: %v", rerr) | ||||
| 		} | ||||
| 	} else { | ||||
| 		rawConfig = json.RawMessage(raw) | ||||
| 	} | ||||
|  | ||||
| 	var err error | ||||
| 	if rawConfig != nil { | ||||
| 		config.Validate(configSchema, rawConfig) | ||||
| 		if err = json.Unmarshal(rawConfig, &UIDefaults); err != nil { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user