Skip to content

Commit

Permalink
make fix
Browse files Browse the repository at this point in the history
  • Loading branch information
floreks committed Mar 4, 2024
1 parent 3b927f0 commit a258450
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 29 deletions.
8 changes: 7 additions & 1 deletion modules/web/pkg/settings/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (

"github.com/gin-gonic/gin"
v1 "k8s.io/api/authorization/v1"

"k8s.io/dashboard/web/pkg/args"

"k8s.io/dashboard/client"
Expand Down Expand Up @@ -82,7 +83,12 @@ func handleGetSettingGlobal(c *gin.Context) {
}

func handleSettingsGlobalSave(c *gin.Context) {
k8sClient := client.InClusterClient()
k8sClient, err := client.Client(c.Request)
if err != nil {
c.JSON(http.StatusInternalServerError, err)
return
}

settings := new(Settings)
if err := c.Bind(settings); err != nil {
c.JSON(http.StatusBadRequest, err)
Expand Down
29 changes: 1 addition & 28 deletions modules/web/pkg/settings/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,7 @@ func (sm *SettingsManager) load(client kubernetes.Interface) (changed bool) {
configMap, err := client.CoreV1().ConfigMaps(args.Namespace()).
Get(context.Background(), args.SettingsConfigMapName(), metav1.GetOptions{})
if err != nil {
klog.Errorf("Cannot find settings config map: %s", err.Error())
//err = sm.restoreConfigMap(client)
//if err != nil {
// log.Printf("Cannot restore settings config map: %s", err.Error())
//}
klog.V(1).Infof("Could not get settings config map: %s", err.Error())
return
}

Expand Down Expand Up @@ -117,29 +113,6 @@ func (sm *SettingsManager) load(client kubernetes.Interface) (changed bool) {
return
}

func (sm *SettingsManager) restoreConfigMap(client kubernetes.Interface) error {
configMap := &v1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Name: args.SettingsConfigMapName(),
Namespace: args.Namespace(),
},
Data: map[string]string{
ConfigMapSettingsKey: defaultSettings.Marshal(),
},
}

restoredConfigMap, err := client.CoreV1().ConfigMaps(args.Namespace()).
Create(context.Background(), configMap, metav1.CreateOptions{})
if err != nil {
return err
}

sm.settings = &defaultSettings
sm.rawSettings = restoredConfigMap.Data

return nil
}

func (sm *SettingsManager) GetGlobalSettings(client kubernetes.Interface) *Settings {
_ = sm.load(client)

Expand Down

0 comments on commit a258450

Please sign in to comment.