From bb8ef24b7944fb1bbbfd5134e6ad40464df3dfd0 Mon Sep 17 00:00:00 2001 From: Chris Li Date: Mon, 7 Jun 2021 17:52:00 +0800 Subject: [PATCH] fix(installer): allow use empty username and password for es --- cmd/tke-installer/app/installer/installer.go | 8 ++++---- cmd/tke-installer/app/installer/types/types.go | 4 ++-- cmd/tke-upgrade/app/options/options.go | 9 +++++---- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/cmd/tke-installer/app/installer/installer.go b/cmd/tke-installer/app/installer/installer.go index 25c700f3f2..6b50129ae9 100644 --- a/cmd/tke-installer/app/installer/installer.go +++ b/cmd/tke-installer/app/installer/installer.go @@ -1978,14 +1978,14 @@ func (t *TKE) installTKEMonitorAPI(ctx context.Context) error { options["StorageType"] = "es" options["StorageAddress"] = t.Para.Config.Monitor.ESMonitor.URL options["StorageUsername"] = t.Para.Config.Monitor.ESMonitor.Username - options["StoragePassword"] = t.Para.Config.Monitor.ESMonitor.Password + options["StoragePassword"] = string(t.Para.Config.Monitor.ESMonitor.Password) } else if t.Para.Config.Monitor.InfluxDBMonitor != nil { options["StorageType"] = "influxDB" if t.Para.Config.Monitor.InfluxDBMonitor.ExternalInfluxDBMonitor != nil { options["StorageAddress"] = t.Para.Config.Monitor.InfluxDBMonitor.ExternalInfluxDBMonitor.URL options["StorageUsername"] = t.Para.Config.Monitor.InfluxDBMonitor.ExternalInfluxDBMonitor.Username - options["StoragePassword"] = t.Para.Config.Monitor.InfluxDBMonitor.ExternalInfluxDBMonitor.Password + options["StoragePassword"] = string(t.Para.Config.Monitor.InfluxDBMonitor.ExternalInfluxDBMonitor.Password) } else if t.Para.Config.Monitor.InfluxDBMonitor.LocalInfluxDBMonitor != nil { // todo options["StorageAddress"] = fmt.Sprintf("http://%s:8086", t.servers[0]) @@ -2026,7 +2026,7 @@ func (t *TKE) installTKEMonitorController(ctx context.Context) error { params["StorageType"] = "es" params["StorageAddress"] = address params["StorageUsername"] = t.Para.Config.Monitor.ESMonitor.Username - params["StoragePassword"] = t.Para.Config.Monitor.ESMonitor.Password + params["StoragePassword"] = string(t.Para.Config.Monitor.ESMonitor.Password) params["MonitorStorageType"] = "elasticsearch" if t.Para.Config.Monitor.ESMonitor.Username != "" { address = address + "&u=" + t.Para.Config.Monitor.ESMonitor.Username @@ -2042,7 +2042,7 @@ func (t *TKE) installTKEMonitorController(ctx context.Context) error { address := t.Para.Config.Monitor.InfluxDBMonitor.ExternalInfluxDBMonitor.URL params["StorageAddress"] = address params["StorageUsername"] = t.Para.Config.Monitor.InfluxDBMonitor.ExternalInfluxDBMonitor.Username - params["StoragePassword"] = t.Para.Config.Monitor.InfluxDBMonitor.ExternalInfluxDBMonitor.Password + params["StoragePassword"] = string(t.Para.Config.Monitor.InfluxDBMonitor.ExternalInfluxDBMonitor.Password) if t.Para.Config.Monitor.InfluxDBMonitor.ExternalInfluxDBMonitor.Username != "" { address = address + "&u=" + t.Para.Config.Monitor.InfluxDBMonitor.ExternalInfluxDBMonitor.Username } diff --git a/cmd/tke-installer/app/installer/types/types.go b/cmd/tke-installer/app/installer/types/types.go index 73e01610b3..2fe835e3c0 100644 --- a/cmd/tke-installer/app/installer/types/types.go +++ b/cmd/tke-installer/app/installer/types/types.go @@ -189,8 +189,8 @@ type Mesh struct { type ESMonitor struct { URL string `json:"url" validate:"required"` - Username string `json:"username" validate:"required"` - Password []byte `json:"password" validate:"required"` + Username string `json:"username"` + Password []byte `json:"password"` } type InfluxDBMonitor struct { diff --git a/cmd/tke-upgrade/app/options/options.go b/cmd/tke-upgrade/app/options/options.go index 0a256996c2..565d29d49e 100644 --- a/cmd/tke-upgrade/app/options/options.go +++ b/cmd/tke-upgrade/app/options/options.go @@ -4,6 +4,7 @@ import ( "encoding/json" "fmt" "io/ioutil" + platformv1 "tkestack.io/tke/api/platform/v1" v1 "tkestack.io/tke/api/platform/v1" "tkestack.io/tke/cmd/tke-installer/app/config" @@ -236,14 +237,14 @@ func (t *TKE) TKEMonitorAPI() (option Options) { option["StorageType"] = "es" option["StorageAddress"] = t.Para.Config.Monitor.ESMonitor.URL option["StorageUsername"] = t.Para.Config.Monitor.ESMonitor.Username - option["StoragePassword"] = t.Para.Config.Monitor.ESMonitor.Password + option["StoragePassword"] = string(t.Para.Config.Monitor.ESMonitor.Password) } else if t.Para.Config.Monitor.InfluxDBMonitor != nil { option["StorageType"] = "influxDB" if t.Para.Config.Monitor.InfluxDBMonitor.ExternalInfluxDBMonitor != nil { option["StorageAddress"] = t.Para.Config.Monitor.InfluxDBMonitor.ExternalInfluxDBMonitor.URL option["StorageUsername"] = t.Para.Config.Monitor.InfluxDBMonitor.ExternalInfluxDBMonitor.Username - option["StoragePassword"] = t.Para.Config.Monitor.InfluxDBMonitor.ExternalInfluxDBMonitor.Password + option["StoragePassword"] = string(t.Para.Config.Monitor.InfluxDBMonitor.ExternalInfluxDBMonitor.Password) } else if t.Para.Config.Monitor.InfluxDBMonitor.LocalInfluxDBMonitor != nil { // todo option["StorageAddress"] = fmt.Sprintf("http://%s:8086", t.Servers[0]) @@ -265,14 +266,14 @@ func (t *TKE) TKEMonitorController() (option Options) { option["StorageType"] = "es" option["StorageAddress"] = t.Para.Config.Monitor.ESMonitor.URL option["StorageUsername"] = t.Para.Config.Monitor.ESMonitor.Username - option["StoragePassword"] = t.Para.Config.Monitor.ESMonitor.Password + option["StoragePassword"] = string(t.Para.Config.Monitor.ESMonitor.Password) } else if t.Para.Config.Monitor.InfluxDBMonitor != nil { option["StorageType"] = "influxDB" if t.Para.Config.Monitor.InfluxDBMonitor.ExternalInfluxDBMonitor != nil { option["StorageAddress"] = t.Para.Config.Monitor.InfluxDBMonitor.ExternalInfluxDBMonitor.URL option["StorageUsername"] = t.Para.Config.Monitor.InfluxDBMonitor.ExternalInfluxDBMonitor.Username - option["StoragePassword"] = t.Para.Config.Monitor.InfluxDBMonitor.ExternalInfluxDBMonitor.Password + option["StoragePassword"] = string(t.Para.Config.Monitor.InfluxDBMonitor.ExternalInfluxDBMonitor.Password) } else if t.Para.Config.Monitor.InfluxDBMonitor.LocalInfluxDBMonitor != nil { option["StorageAddress"] = fmt.Sprintf("http://%s:8086", t.Servers[0]) }