Skip to content

Commit

Permalink
fix: configmap name (#1104)
Browse files Browse the repository at this point in the history
Signed-off-by: zwwhdls <[email protected]>
  • Loading branch information
zwwhdls authored Sep 3, 2024
1 parent 1b9d295 commit 67157a8
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions pkg/dashboard/cm.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,20 @@
package dashboard

import (
"os"

"github.com/gin-gonic/gin"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

func (api *API) getCSIConfig() gin.HandlerFunc {
cmName := os.Getenv("JUICEFS_CONFIG_NAME")
if cmName == "" {
cmName = "juicefs-csi-driver-config"
}
return func(c *gin.Context) {
cm, err := api.client.CoreV1().ConfigMaps(api.sysNamespace).Get(c, "juicefs-csi-driver-config", metav1.GetOptions{})
cm, err := api.client.CoreV1().ConfigMaps(api.sysNamespace).Get(c, cmName, metav1.GetOptions{})
if err != nil {
c.JSON(500, gin.H{"error": err.Error()})
return
Expand All @@ -40,7 +46,11 @@ func (api *API) putCSIConfig() gin.HandlerFunc {
c.JSON(400, gin.H{"error": err.Error()})
return
}
if cm.Name != "juicefs-csi-driver-config" {
cmName := os.Getenv("JUICEFS_CONFIG_NAME")
if cmName == "" {
cmName = "juicefs-csi-driver-config"
}
if cm.Name != cmName {
c.JSON(400, gin.H{"error": "invalid config map name"})
return
}
Expand Down

0 comments on commit 67157a8

Please sign in to comment.