Skip to content

Commit

Permalink
fix(domain): fix domain show
Browse files Browse the repository at this point in the history
fix domain show

Signed-off-by: ysicing <[email protected]>
  • Loading branch information
ysicing committed Sep 7, 2023
1 parent 90c66a6 commit 124dd60
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
6 changes: 6 additions & 0 deletions internal/app/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ type Install struct {
type Quickon struct {
Type common.QuickonType `yaml:"type" json:"type"`
DevOps bool `yaml:"devops" json:"devops"`
Domain Domain `yaml:"domain" json:"domain"`
}

type Domain struct {
Type string `yaml:"type" json:"type"`
Name string `yaml:"name" json:"name"`
}

type Cluster struct {
Expand Down
9 changes: 7 additions & 2 deletions internal/pkg/status/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,14 @@ func (s *Status) Format() error {
consoleURL := ""
if len(domain) > 0 {
if !kutil.IsLegalDomain(domain) {
domain = fmt.Sprintf("http://console.%s", domain)
if cfg.Quickon.DevOps {
consoleURL = fmt.Sprintf("http://zentao.%s", domain)
} else {
consoleURL = fmt.Sprintf("http://console.%s", domain)
}
} else {
consoleURL = fmt.Sprintf("https://%s", domain)
}
consoleURL = domain
} else {
consoleURL = fmt.Sprintf("http://%s:32379", loginIP)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/providers/devops/devops.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func (q *Devops) Show() {

q.MetaData.Log.Info("----------------------------\t")
if len(domain) > 0 {
if !kutil.IsLegalDomain(cfg.Domain) {
if !kutil.IsLegalDomain(cfg.Domain) || cfg.Quickon.Domain.Type != "api" {
domain = fmt.Sprintf("http://zentao.%s", cfg.Domain)
} else {
domain = fmt.Sprintf("https://%s", cfg.Domain)
Expand Down
7 changes: 6 additions & 1 deletion pkg/quickon/quickon.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ type Meta struct {
App string
kubeClient *k8s.Client
Log log.Logger
DomainType string
}

func New(f factory.Factory) *Meta {
Expand All @@ -55,6 +56,7 @@ func New(f factory.Factory) *Meta {
// Version: common.DefaultQuickonOSSVersion,
ConsolePassword: expass.PwGenAlphaNum(32),
Type: common.ZenTaoOSSType.String(),
DomainType: "custom",
}
}

Expand Down Expand Up @@ -228,6 +230,7 @@ func (m *Meta) Init() error {
return false, err
}
m.Domain = domain
m.DomainType = "api"
m.Log.Infof("generate suffix domain: %s, ip: %v", color.SGreen(m.Domain), color.SGreen(m.IP))
return true, nil
})
Expand Down Expand Up @@ -274,6 +277,8 @@ func (m *Meta) Init() error {

cfg.Domain = m.Domain
cfg.APIToken = token
cfg.Quickon.Domain.Name = m.Domain
cfg.Quickon.Domain.Type = m.DomainType
cfg.S3.Username = expass.PwGenAlphaNum(8)
cfg.S3.Password = expass.PwGenAlphaNum(16)
cfg.SaveConfig()
Expand Down Expand Up @@ -311,7 +316,7 @@ func (m *Meta) Init() error {
helmargs = append(helmargs, "--set", "cloud.selectVersion=true")
}
hostdomain := m.Domain
if kutil.IsLegalDomain(hostdomain) {
if kutil.IsLegalDomain(hostdomain) && m.DomainType == "api" {
helmargs = append(helmargs, "--set", "ingress.tls.enabled=true")
helmargs = append(helmargs, "--set", "ingress.tls.secretName=tls-haogs-cn")
} else {
Expand Down

0 comments on commit 124dd60

Please sign in to comment.