chore: fix controller config lint. (#4702)

* chore: fix controller config lint.
Signed-off-by: yy <lingdie.yy@outlook.com>

Signed-off-by: yy <lingdie.yy@outlook.com>

* chore: fix controller config lint.
Signed-off-by: yy <lingdie.yy@outlook.com>

Signed-off-by: yy <lingdie.yy@outlook.com>

* chore: fix controller config lint.
Signed-off-by: yy <lingdie.yy@outlook.com>

Signed-off-by: yy <lingdie.yy@outlook.com>

* chore: fix controller config lint.
Signed-off-by: yy <lingdie.yy@outlook.com>

Signed-off-by: yy <lingdie.yy@outlook.com>

* chore: fix controller config lint.
Signed-off-by: yy <lingdie.yy@outlook.com>

Signed-off-by: yy <lingdie.yy@outlook.com>

* chore: fix license.
Signed-off-by: yy <lingdie.yy@outlook.com>

Signed-off-by: yy <lingdie.yy@outlook.com>

---------

Signed-off-by: yy <lingdie.yy@outlook.com>
This commit is contained in:
yy
2024-04-23 10:19:19 +08:00
committed by GitHub
parent e00054f966
commit efbda9539f
7 changed files with 55 additions and 49 deletions
+23 -9
View File
@@ -1,7 +1,21 @@
// Copyright © 2024 sealos.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package config
import (
"io/ioutil"
"os"
"gopkg.in/yaml.v3"
)
@@ -9,29 +23,29 @@ import (
type Global struct {
CloudDomain string `yaml:"cloudDomain"`
CloudPort string `yaml:"cloudPort"`
RegionUid string `yaml:"regionUid"`
RegionUID string `yaml:"regionUID"`
CertSecretName string `yaml:"certSecretName"`
}
type Kube struct {
Version string `yaml:"version"`
ApiServerHost string `yaml:"apiServerHost"`
ApiServerPort string `yaml:"apiServerPort"`
APIServerHost string `yaml:"apiServerHost"`
APIServerPort string `yaml:"apiServerPort"`
}
type Common struct {
GuideEnabled string `yaml:"guideEnabled"`
ApiEnabled string `yaml:"apiEnabled"`
APIEnabled string `yaml:"apiEnabled"`
}
type Database struct {
MongodbUri string `yaml:"mongodbUri"`
GlobalCockroachdbUri string `yaml:"globalCockroachdbUri"`
RegionalCockroachdbUri string `yaml:"regionalCockroachdbUri"`
MongodbURI string `yaml:"mongodbURI"`
GlobalCockroachdbURI string `yaml:"globalCockroachdbURI"`
RegionalCockroachdbURI string `yaml:"regionalCockroachdbURI"`
}
func LoadConfig(path string, target interface{}) error {
configData, err := ioutil.ReadFile(path)
configData, err := os.ReadFile(path)
if err != nil {
return err
}
+15 -1
View File
@@ -1,3 +1,17 @@
// Copyright © 2024 sealos.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package controllers
import (
@@ -10,5 +24,5 @@ type Config struct {
}
type TerminalConfig struct {
IngressTlsSecretName string `yaml:"ingressTlsSecretName"`
IngressTLSSecretName string `yaml:"ingressTLSSecretName"`
}
+1 -1
View File
@@ -78,7 +78,7 @@ func (r *TerminalReconciler) createNginxIngress(terminal *terminalv1.Terminal, h
tls := networkingv1.IngressTLS{
Hosts: []string{host},
SecretName: r.CtrConfig.TerminalConfig.IngressTlsSecretName,
SecretName: r.CtrConfig.TerminalConfig.IngressTLSSecretName,
}
ingress := &networkingv1.Ingress{
@@ -18,7 +18,6 @@ package controllers
import (
"context"
"os"
"time"
"github.com/jaevor/go-nanoid"
@@ -372,38 +371,6 @@ func isExpired(terminal *terminalv1.Terminal) bool {
return lastUpdateTime.Add(duration).Before(time.Now())
}
func getDomain() string {
domain := os.Getenv("DOMAIN")
if domain == "" {
return DefaultDomain
}
return domain
}
func getPort() string {
port := os.Getenv("PORT")
if port == "" {
return DefaultPort
}
return port
}
func getSecretName() string {
secretName := os.Getenv("SECRET_NAME")
if secretName == "" {
return DefaultSecretName
}
return secretName
}
func getSecretNamespace() string {
secretNamespace := os.Getenv("SECRET_NAMESPACE")
if secretNamespace == "" {
return DefaultSecretNamespace
}
return secretNamespace
}
func (r *TerminalReconciler) getPort() string {
if r.CtrConfig.Global.CloudPort == "" || r.CtrConfig.Global.CloudPort == "80" || r.CtrConfig.Global.CloudPort == "443" {
return ""
@@ -350,7 +350,7 @@ data:
cloudDomain: {{ .cloudDomain }}
cloudPort: {{ if .cloudPort }}:{{ .cloudPort }}{{ end }}
terminalController:
ingressTlsSecretName: {{ .wildcardCertSecretName }}
ingressTLSSecretName: {{ .wildcardCertSecretName }}
kind: ConfigMap
metadata:
name: terminal-manager-config
+14
View File
@@ -1,3 +1,17 @@
// Copyright © 2024 sealos.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package controllers
import (
+1 -4
View File
@@ -176,8 +176,5 @@ func setConfigToEnv(cfg controllers.Config) error {
if err := os.Setenv("SEALOS_CLOUD_HOST", cfg.Global.CloudDomain); err != nil {
return err
}
if err := os.Setenv("APISERVER_PORT", cfg.Kube.ApiServerPort); err != nil {
return err
}
return nil
return os.Setenv("APISERVER_PORT", cfg.Kube.APIServerPort)
}