diff --git a/.golangci.yml b/.golangci.yml index 3322f29e..b7f7b37d 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -36,6 +36,7 @@ linters: issues: exclude: - G101 # gosec: Potential hardcoded credentials + - G115 # gosec: integer overflow conversion int max-same-issues: 0 # Excluding configuration per-path, per-linter, per-text and per-source exclude-rules: diff --git a/internal/app/config/config.go b/internal/app/config/config.go index 4c1684ae..12a3a2bb 100644 --- a/internal/app/config/config.go +++ b/internal/app/config/config.go @@ -48,8 +48,9 @@ type Storage struct { } type Install struct { - Type string `yaml:"type" json:"type"` - Pkg string `yaml:"pkg" json:"pkg"` + Type string `yaml:"type" json:"type"` + Pkg string `yaml:"pkg" json:"pkg"` + Version string `yaml:"version" json:"version"` } type Quickon struct { diff --git a/internal/pkg/util/kutil/kutil.go b/internal/pkg/util/kutil/kutil.go index 5e63de84..c7c91988 100644 --- a/internal/pkg/util/kutil/kutil.go +++ b/internal/pkg/util/kutil/kutil.go @@ -14,6 +14,7 @@ import ( "github.com/ergoapi/util/exstr" "github.com/ergoapi/util/file" + "github.com/ergoapi/util/version" "github.com/ergoapi/util/ztime" "github.com/easysoft/qcadmin/common" @@ -72,12 +73,15 @@ func SplitDomain(domain string) (string, string) { func GetConsoleURL(cfg *config.Config) string { domain := cfg.Domain if len(domain) > 0 { - prekey := "console" + prekey := "console." if cfg.Quickon.DevOps { - prekey = "zentao" + prekey = "" + if len(cfg.Install.Version) == 0 || version.LTv2(cfg.Install.Version, common.Version) { + prekey = "zentao." + } } if !IsLegalDomain(cfg.Domain) || cfg.Quickon.Domain.Type != "api" { - domain = fmt.Sprintf("http://%s.%s", prekey, cfg.Domain) + domain = fmt.Sprintf("http://%s%s", prekey, cfg.Domain) } else { domain = fmt.Sprintf("https://%s", cfg.Domain) } diff --git a/pkg/cluster/cluster.go b/pkg/cluster/cluster.go index 0a2cb4f9..7dcc8dac 100644 --- a/pkg/cluster/cluster.go +++ b/pkg/cluster/cluster.go @@ -306,6 +306,7 @@ func (c *Cluster) initMaster0(cfg *config.Config, sshClient ssh.Interface) error } else { cfg.Install.Type = "online" } + cfg.Install.Version = common.Version return cfg.SaveConfig() } diff --git a/pkg/providers/devops/devops.go b/pkg/providers/devops/devops.go index 7dc7965e..0356e8ed 100644 --- a/pkg/providers/devops/devops.go +++ b/pkg/providers/devops/devops.go @@ -11,6 +11,7 @@ import ( "github.com/ergoapi/util/color" "github.com/ergoapi/util/exnet" + "github.com/ergoapi/util/version" "k8s.io/kubectl/pkg/util/i18n" "k8s.io/kubectl/pkg/util/templates" @@ -85,7 +86,11 @@ func (q *Devops) Show() { q.MetaData.Log.Info("----------------------------\t") if len(domain) > 0 { if !kutil.IsLegalDomain(cfg.Domain) || cfg.Quickon.Domain.Type != "api" { - domain = fmt.Sprintf("http://zentao.%s", cfg.Domain) + if len(cfg.Install.Version) == 0 || version.LTv2(cfg.Install.Version, common.Version) { + domain = fmt.Sprintf("http://zentao.%s", cfg.Domain) + } else { + domain = fmt.Sprintf("http://%s", cfg.Domain) + } } else { domain = fmt.Sprintf("https://%s", cfg.Domain) } diff --git a/pkg/quickon/quickon.go b/pkg/quickon/quickon.go index 2cef0ed2..374834ac 100644 --- a/pkg/quickon/quickon.go +++ b/pkg/quickon/quickon.go @@ -280,10 +280,10 @@ func (m *Meta) Init() error { } } } else { - m.Log.Infof("use custom domain %s, you should add dns record to your domain: *.%s -> %s", m.Domain, color.SGreen(m.Domain), color.SGreen(m.IP)) + m.Log.Infof("use custom domain %s, you need to add two A records for your domain: %s -> %s, *.%s -> %s", m.Domain, color.SGreen(m.Domain), color.SGreen(m.IP), color.SGreen(m.Domain), color.SGreen(m.IP)) } } else { - m.Log.Infof("use custom domain %s, you should add dns record to your domain: *.%s -> %s", m.Domain, color.SGreen(m.Domain), color.SGreen(m.IP)) + m.Log.Infof("use custom domain %s, you need to add two A records for your domain: %s -> %s, *.%s -> %s", m.Domain, color.SGreen(m.Domain), color.SGreen(m.IP), color.SGreen(m.Domain), color.SGreen(m.IP)) } token := expass.PwGenAlphaNum(32) @@ -333,9 +333,7 @@ func (m *Meta) Init() error { // helmargs = append(helmargs, "--set", "ingress.tls.enabled=true") // helmargs = append(helmargs, "--set", "ingress.tls.secretName=tls-haogs-cn") } else { - if m.DevopsMode { - hostdomain = fmt.Sprintf("zentao.%s", hostdomain) - } else { + if !m.DevopsMode { hostdomain = fmt.Sprintf("console.%s", hostdomain) } }