Lint code
This commit is contained in:
parent
875fd778e1
commit
b7b41248cb
7 changed files with 8 additions and 15 deletions
|
@ -52,11 +52,9 @@ func (s *statsCollector) stop(sm statusModule) {
|
||||||
case defaultStatusModule:
|
case defaultStatusModule:
|
||||||
s.basic.Stop()
|
s.basic.Stop()
|
||||||
prometheus.Unregister(s.basic)
|
prometheus.Unregister(s.basic)
|
||||||
break
|
|
||||||
case vtsStatusModule:
|
case vtsStatusModule:
|
||||||
s.vts.Stop()
|
s.vts.Stop()
|
||||||
prometheus.Unregister(s.vts)
|
prometheus.Unregister(s.vts)
|
||||||
break
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -252,9 +252,9 @@ func (p vtsCollector) scrapeVts(ch chan<- prometheus.Metric) {
|
||||||
reflectMetrics(&zone.Cache, p.data.filterZoneCache, ch, p.ingressClass, p.watchNamespace, serverZone, country)
|
reflectMetrics(&zone.Cache, p.data.filterZoneCache, ch, p.ingressClass, p.watchNamespace, serverZone, country)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(p.data.filterZoneBytes,
|
ch <- prometheus.MustNewConstMetric(p.data.filterZoneBytes,
|
||||||
prometheus.CounterValue, float64(zone.InBytes), p.ingressClass, p.watchNamespace, serverZone, country, "in")
|
prometheus.CounterValue, zone.InBytes, p.ingressClass, p.watchNamespace, serverZone, country, "in")
|
||||||
ch <- prometheus.MustNewConstMetric(p.data.filterZoneBytes,
|
ch <- prometheus.MustNewConstMetric(p.data.filterZoneBytes,
|
||||||
prometheus.CounterValue, float64(zone.OutBytes), p.ingressClass, p.watchNamespace, serverZone, country, "out")
|
prometheus.CounterValue, zone.OutBytes, p.ingressClass, p.watchNamespace, serverZone, country, "out")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -266,7 +266,7 @@ func reflectMetrics(value interface{}, desc *prometheus.Desc, ch chan<- promethe
|
||||||
tag := val.Type().Field(i).Tag
|
tag := val.Type().Field(i).Tag
|
||||||
l := append(labels, tag.Get("json"))
|
l := append(labels, tag.Get("json"))
|
||||||
ch <- prometheus.MustNewConstMetric(desc,
|
ch <- prometheus.MustNewConstMetric(desc,
|
||||||
prometheus.CounterValue, float64(val.Field(i).Interface().(float64)),
|
prometheus.CounterValue, val.Field(i).Interface().(float64),
|
||||||
l...)
|
l...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,8 +5,8 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Base64Encode
|
// Encode encodes a string to base64 removing the equals character
|
||||||
func Base64Encode(s string) string {
|
func Encode(s string) string {
|
||||||
str := base64.URLEncoding.EncodeToString([]byte(s))
|
str := base64.URLEncoding.EncodeToString([]byte(s))
|
||||||
return strings.Replace(str, "=", "", -1)
|
return strings.Replace(str, "=", "", -1)
|
||||||
}
|
}
|
||||||
|
|
|
@ -160,7 +160,7 @@ func (a authReq) Parse(ing *extensions.Ingress) (interface{}, error) {
|
||||||
|
|
||||||
harr := strings.Split(hstr, ",")
|
harr := strings.Split(hstr, ",")
|
||||||
for _, header := range harr {
|
for _, header := range harr {
|
||||||
header := strings.TrimSpace(header)
|
header = strings.TrimSpace(header)
|
||||||
if len(header) > 0 {
|
if len(header) > 0 {
|
||||||
if !validHeader(header) {
|
if !validHeader(header) {
|
||||||
return nil, ing_errors.NewLocationDenied("invalid headers list")
|
return nil, ing_errors.NewLocationDenied("invalid headers list")
|
||||||
|
|
|
@ -218,7 +218,7 @@ func (a ratelimit) Parse(ing *extensions.Ingress) (interface{}, error) {
|
||||||
LimitRate: lr,
|
LimitRate: lr,
|
||||||
LimitRateAfter: lra,
|
LimitRateAfter: lra,
|
||||||
Name: zoneName,
|
Name: zoneName,
|
||||||
ID: base64.Base64Encode(zoneName),
|
ID: base64.Encode(zoneName),
|
||||||
Whitelist: cidrs,
|
Whitelist: cidrs,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -1015,7 +1015,7 @@ func (ic *GenericController) createServers(data []interface{},
|
||||||
fakeCertificatePath := fmt.Sprintf("%v/%v.pem", ingress.DefaultSSLDirectory, fakeCertificate)
|
fakeCertificatePath := fmt.Sprintf("%v/%v.pem", ingress.DefaultSSLDirectory, fakeCertificate)
|
||||||
|
|
||||||
// Only generates a new certificate if it doesn't exists physically
|
// Only generates a new certificate if it doesn't exists physically
|
||||||
_, err := os.Stat(fakeCertificatePath)
|
_, err = os.Stat(fakeCertificatePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.V(3).Infof("No Default SSL Certificate found. Generating a new one")
|
glog.V(3).Infof("No Default SSL Certificate found. Generating a new one")
|
||||||
defCert, defKey := ssl.GetFakeSSLCert()
|
defCert, defKey := ssl.GetFakeSSLCert()
|
||||||
|
|
|
@ -28,11 +28,6 @@ import (
|
||||||
"k8s.io/ingress/core/pkg/ingress"
|
"k8s.io/ingress/core/pkg/ingress"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
|
||||||
rsaBits = 2048
|
|
||||||
validFor = 365 * 24 * time.Hour
|
|
||||||
)
|
|
||||||
|
|
||||||
// generateRSACerts generates a self signed certificate using a self generated ca
|
// generateRSACerts generates a self signed certificate using a self generated ca
|
||||||
func generateRSACerts(host string) (*triple.KeyPair, *triple.KeyPair, error) {
|
func generateRSACerts(host string) (*triple.KeyPair, *triple.KeyPair, error) {
|
||||||
ca, err := triple.NewCA("self-sign-ca")
|
ca, err := triple.NewCA("self-sign-ca")
|
||||||
|
|
Loading…
Reference in a new issue