Skip to content

Commit

Permalink
+ [feat]: enhance domain handling and installation version
Browse files Browse the repository at this point in the history
  • Loading branch information
ysicing committed Sep 11, 2024
1 parent 892f469 commit 8c4c3a8
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 11 deletions.
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 3 additions & 2 deletions internal/app/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
10 changes: 7 additions & 3 deletions internal/pkg/util/kutil/kutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
}
Expand Down
1 change: 1 addition & 0 deletions pkg/cluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

Expand Down
7 changes: 6 additions & 1 deletion pkg/providers/devops/devops.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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)
}
Expand Down
8 changes: 3 additions & 5 deletions pkg/quickon/quickon.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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)
}
}
Expand Down

0 comments on commit 8c4c3a8

Please sign in to comment.