Skip to content

Commit

Permalink
fix golint warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
jcmoraisjr committed Mar 10, 2021
1 parent 01d28f6 commit 03c76e9
Show file tree
Hide file tree
Showing 10 changed files with 65 additions and 67 deletions.
6 changes: 2 additions & 4 deletions pkg/common/ingress/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,9 @@ import (
"k8s.io/apiserver/pkg/server/healthz"
)

// Default<Type>Directory defines the location where HAProxy Ingress' generated
// files should be created.
var (
// DefaultCrtDirectory defines the location where the SSL certificates will be generated
// This directory contains all the SSL certificates that are specified in Ingress rules.
// The name of each file is <namespace>-<secret name>.pem. The content is the concatenated
// certificate and key.
DefaultCrtDirectory = "/var/lib/haproxy/crt"
DefaultDHParamDirectory = "/var/lib/haproxy/dhparam"
DefaultCACertsDirectory = "/var/lib/haproxy/cacerts"
Expand Down
2 changes: 1 addition & 1 deletion pkg/converters/ingress/annotations/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func (c *updater) buildBackendAffinity(d *backData) {
cookieStrategy := d.mapper.Get(ingtypes.BackSessionCookieValue)
switch cookieStrategy.Value {
case "pod-uid":
d.backend.EpCookieStrategy = hatypes.EpCookiePodUid
d.backend.EpCookieStrategy = hatypes.EpCookiePodUID
case "server-name":
d.backend.EpCookieStrategy = hatypes.EpCookieName
default:
Expand Down
6 changes: 3 additions & 3 deletions pkg/converters/ingress/annotations/global.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,10 @@ func (c *updater) buildGlobalProc(d *globalData) {
} else if ssl > 1 {
bindprocSSL = fmt.Sprintf("%v-%v", balance+1, procs)
}
useCpuMap := d.mapper.Get(ingtypes.GlobalUseCpuMap).Bool()
useCPUMap := d.mapper.Get(ingtypes.GlobalUseCPUMap).Bool()
cpumap := ""
if useCpuMap {
cpumap = d.mapper.Get(ingtypes.GlobalCpuMap).Value
if useCPUMap {
cpumap = d.mapper.Get(ingtypes.GlobalCPUMap).Value
if cpumap == "" {
if threads > 1 {
if procs == 1 {
Expand Down
12 changes: 6 additions & 6 deletions pkg/converters/ingress/annotations/global_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ func TestDisableCpuMap(t *testing.T) {
// 0
{
ann: map[string]string{
ingtypes.GlobalUseCpuMap: "false",
ingtypes.GlobalUseCPUMap: "false",
ingtypes.GlobalNbthread: "1",
ingtypes.GlobalNbprocBalance: "1",
},
Expand All @@ -348,8 +348,8 @@ func TestDisableCpuMap(t *testing.T) {
// 1
{
ann: map[string]string{
ingtypes.GlobalUseCpuMap: "false",
ingtypes.GlobalCpuMap: "auto 1/1 1-",
ingtypes.GlobalUseCPUMap: "false",
ingtypes.GlobalCPUMap: "auto 1/1 1-",
ingtypes.GlobalNbthread: "1",
ingtypes.GlobalNbprocBalance: "1",
},
Expand All @@ -358,8 +358,8 @@ func TestDisableCpuMap(t *testing.T) {
// 2
{
ann: map[string]string{
ingtypes.GlobalUseCpuMap: "true",
ingtypes.GlobalCpuMap: "auto:1/1 1-",
ingtypes.GlobalUseCPUMap: "true",
ingtypes.GlobalCPUMap: "auto:1/1 1-",
ingtypes.GlobalNbthread: "4",
ingtypes.GlobalNbprocBalance: "1",
},
Expand All @@ -368,7 +368,7 @@ func TestDisableCpuMap(t *testing.T) {
// 3
{
ann: map[string]string{
ingtypes.GlobalUseCpuMap: "true",
ingtypes.GlobalUseCPUMap: "true",
ingtypes.GlobalNbthread: "2",
ingtypes.GlobalNbprocBalance: "1",
},
Expand Down
2 changes: 1 addition & 1 deletion pkg/converters/ingress/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func createDefaults() map[string]string {
types.GlobalTimeoutClient: "50s",
types.GlobalTimeoutClientFin: "50s",
types.GlobalTimeoutStop: "10m",
types.GlobalUseCpuMap: "true",
types.GlobalUseCPUMap: "true",
types.GlobalUseForwardedProto: "true",
types.GlobalUseHTX: "true",
types.GlobalDefaultBackendRedirectCode: "302",
Expand Down
2 changes: 1 addition & 1 deletion pkg/converters/ingress/ingress.go
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ func (c *converter) syncBackendEndpointCookies(backend *hatypes.Backend) {
switch backend.EpCookieStrategy {
default:
ep.CookieValue = ep.Name
case hatypes.EpCookiePodUid:
case hatypes.EpCookiePodUID:
if ep.TargetRef != "" {
pod, err := c.cache.GetPod(ep.TargetRef)
if err == nil {
Expand Down
4 changes: 2 additions & 2 deletions pkg/converters/ingress/types/global.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const (
GlobalConfigGlobal = "config-global"
GlobalConfigSections = "config-sections"
GlobalCookieKey = "cookie-key"
GlobalCpuMap = "cpu-map"
GlobalCPUMap = "cpu-map"
GlobalDefaultBackendRedirect = "default-backend-redirect"
GlobalDefaultBackendRedirectCode = "default-backend-redirect-code"
GlobalDNSAcceptedPayloadSize = "dns-accepted-payload-size"
Expand Down Expand Up @@ -94,7 +94,7 @@ const (
GlobalTimeoutClientFin = "timeout-client-fin"
GlobalTimeoutStop = "timeout-stop"
GlobalUseChroot = "use-chroot"
GlobalUseCpuMap = "use-cpu-map"
GlobalUseCPUMap = "use-cpu-map"
GlobalUseForwardedProto = "use-forwarded-proto"
GlobalUseHAProxyUser = "use-haproxy-user"
GlobalUseHTX = "use-htx"
Expand Down
2 changes: 1 addition & 1 deletion pkg/haproxy/instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,7 @@ d1.local/ path01`,
b.Cookie.Name = "serverId"
b.Cookie.Strategy = "insert"
b.Cookie.Keywords = "nocache"
b.EpCookieStrategy = hatypes.EpCookiePodUid
b.EpCookieStrategy = hatypes.EpCookiePodUID
ep1 := *endpointS1
b.Endpoints = []*hatypes.Endpoint{&ep1}
b.Endpoints[0].CookieValue = "9d344d6c-6069-4aee-85e6-9348e70c71e6"
Expand Down
94 changes: 47 additions & 47 deletions pkg/haproxy/types/maps_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,8 +320,8 @@ func TestOverlap(t *testing.T) {
// 0
{
data: []data{
data{hostname: "local1.tld", path: "/a", match: MatchBegin},
data{hostname: "local1.tld", path: "/ab", match: MatchBegin},
{hostname: "local1.tld", path: "/a", match: MatchBegin},
{hostname: "local1.tld", path: "/ab", match: MatchBegin},
},
expected: `
hosts__begin.map first:true,lower:true,method:beg
Expand All @@ -332,8 +332,8 @@ local1.tld /a begin
// 1
{
data: []data{
data{hostname: "local1.tld", path: "/a", match: MatchBegin},
data{hostname: "local1.tld", path: "/ab", match: MatchPrefix},
{hostname: "local1.tld", path: "/a", match: MatchBegin},
{hostname: "local1.tld", path: "/ab", match: MatchPrefix},
},
expected: `
hosts__prefix_01.map first:true,lower:false,method:dir
Expand All @@ -346,8 +346,8 @@ local1.tld /a begin
// 2
{
data: []data{
data{hostname: "local1.tld", path: "/a", match: MatchBegin},
data{hostname: "local1.tld", path: "/ab.*", match: MatchRegex},
{hostname: "local1.tld", path: "/a", match: MatchBegin},
{hostname: "local1.tld", path: "/ab.*", match: MatchRegex},
},
expected: `
hosts__begin.map first:true,lower:true,method:beg
Expand All @@ -360,8 +360,8 @@ hosts__regex.map first:false,lower:false,method:reg
// 3
{
data: []data{
data{hostname: "local1.tld", path: "/a", match: MatchBegin},
data{hostname: "local2.tld", path: "/ab", match: MatchPrefix},
{hostname: "local1.tld", path: "/a", match: MatchBegin},
{hostname: "local2.tld", path: "/ab", match: MatchPrefix},
},
expected: `
hosts__prefix.map first:true,lower:false,method:dir
Expand All @@ -374,10 +374,10 @@ local1.tld /a begin
// 4
{
data: []data{
data{hostname: "local1.tld", path: "/a", match: MatchBegin},
data{hostname: "local1.tld", path: "/abc", match: MatchBegin},
data{hostname: "local1.tld", path: "/ab", match: MatchPrefix},
data{hostname: "local2.tld", path: "/a", match: MatchExact},
{hostname: "local1.tld", path: "/a", match: MatchBegin},
{hostname: "local1.tld", path: "/abc", match: MatchBegin},
{hostname: "local1.tld", path: "/ab", match: MatchPrefix},
{hostname: "local2.tld", path: "/a", match: MatchExact},
},
expected: `
hosts__begin_01.map first:true,lower:true,method:beg
Expand All @@ -396,12 +396,12 @@ local1.tld /a begin
// 5
{
data: []data{
data{hostname: "local1.tld", path: "/abc", match: MatchBegin},
data{hostname: "local1.tld", path: "/ab", match: MatchPrefix},
data{hostname: "local1.tld", path: "/a", match: MatchBegin},
data{hostname: "local2.tld", path: "/a", match: MatchExact},
data{hostname: "local2.tld", path: "/abc", match: MatchExact},
data{hostname: "local2.tld", path: "/ab", match: MatchExact},
{hostname: "local1.tld", path: "/abc", match: MatchBegin},
{hostname: "local1.tld", path: "/ab", match: MatchPrefix},
{hostname: "local1.tld", path: "/a", match: MatchBegin},
{hostname: "local2.tld", path: "/a", match: MatchExact},
{hostname: "local2.tld", path: "/abc", match: MatchExact},
{hostname: "local2.tld", path: "/ab", match: MatchExact},
},
expected: `
hosts__begin_01.map first:true,lower:true,method:beg
Expand All @@ -422,10 +422,10 @@ local1.tld /a begin
// 6
{
data: []data{
data{hostname: "local1.tld", path: "/abc", match: MatchBegin},
data{hostname: "local1.tld", path: "/ab", match: MatchPrefix},
data{hostname: "local1.tld", path: "/abcd", match: MatchExact},
data{hostname: "local1.tld", path: "/a", match: MatchBegin},
{hostname: "local1.tld", path: "/abc", match: MatchBegin},
{hostname: "local1.tld", path: "/ab", match: MatchPrefix},
{hostname: "local1.tld", path: "/abcd", match: MatchExact},
{hostname: "local1.tld", path: "/a", match: MatchBegin},
},
expected: `
hosts__exact_01.map first:true,lower:false,method:str
Expand All @@ -444,10 +444,10 @@ local1.tld /a begin
// 7
{
data: []data{
data{hostname: "local1.tld", path: "/ab", match: MatchPrefix},
data{hostname: "local1.tld", path: "/abc", match: MatchBegin},
data{hostname: "local1.tld", path: "/a", match: MatchBegin},
data{hostname: "local1.tld", path: "/abcd", match: MatchExact},
{hostname: "local1.tld", path: "/ab", match: MatchPrefix},
{hostname: "local1.tld", path: "/abc", match: MatchBegin},
{hostname: "local1.tld", path: "/a", match: MatchBegin},
{hostname: "local1.tld", path: "/abcd", match: MatchExact},
},
expected: `
hosts__exact_01.map first:true,lower:false,method:str
Expand All @@ -466,13 +466,13 @@ local1.tld /a begin
// 8
{
data: []data{
data{hostname: "local1.tld", path: "/a", match: MatchPrefix},
data{hostname: "local1.tld", path: "/", match: MatchBegin},
data{hostname: "local2.tld", path: "/a", match: MatchPrefix},
data{hostname: "local2.tld", path: "/", match: MatchBegin},
data{hostname: "local3.tld", path: "/a", match: MatchPrefix},
data{hostname: "local4.tld", path: "/a", match: MatchPrefix},
data{hostname: "local4.tld", path: "/", match: MatchBegin},
{hostname: "local1.tld", path: "/a", match: MatchPrefix},
{hostname: "local1.tld", path: "/", match: MatchBegin},
{hostname: "local2.tld", path: "/a", match: MatchPrefix},
{hostname: "local2.tld", path: "/", match: MatchBegin},
{hostname: "local3.tld", path: "/a", match: MatchPrefix},
{hostname: "local4.tld", path: "/a", match: MatchPrefix},
{hostname: "local4.tld", path: "/", match: MatchBegin},
},
expected: `
hosts__prefix_01.map first:true,lower:false,method:dir
Expand All @@ -492,13 +492,13 @@ local4.tld / begin
// 9
{
data: []data{
data{hostname: "local1.tld", path: "/a", match: MatchPrefix},
data{hostname: "local2.tld", path: "/a", match: MatchPrefix},
data{hostname: "local2.tld", path: "/", match: MatchBegin},
data{hostname: "local3.tld", path: "/a", match: MatchPrefix},
data{hostname: "local3.tld", path: "/", match: MatchBegin},
data{hostname: "local4.tld", path: "/a", match: MatchPrefix},
data{hostname: "local4.tld", path: "/", match: MatchBegin},
{hostname: "local1.tld", path: "/a", match: MatchPrefix},
{hostname: "local2.tld", path: "/a", match: MatchPrefix},
{hostname: "local2.tld", path: "/", match: MatchBegin},
{hostname: "local3.tld", path: "/a", match: MatchPrefix},
{hostname: "local3.tld", path: "/", match: MatchBegin},
{hostname: "local4.tld", path: "/a", match: MatchPrefix},
{hostname: "local4.tld", path: "/", match: MatchBegin},
},
expected: `
hosts__prefix_01.map first:true,lower:false,method:dir
Expand All @@ -518,13 +518,13 @@ local4.tld / begin
// 10
{
data: []data{
data{hostname: "local1.tld", path: "/a", match: MatchPrefix},
data{hostname: "local1.tld", path: "/", match: MatchBegin},
data{hostname: "local2.tld", path: "/a", match: MatchPrefix},
data{hostname: "local2.tld", path: "/", match: MatchBegin},
data{hostname: "local3.tld", path: "/a", match: MatchPrefix},
data{hostname: "local3.tld", path: "/", match: MatchBegin},
data{hostname: "local4.tld", path: "/a", match: MatchPrefix},
{hostname: "local1.tld", path: "/a", match: MatchPrefix},
{hostname: "local1.tld", path: "/", match: MatchBegin},
{hostname: "local2.tld", path: "/a", match: MatchPrefix},
{hostname: "local2.tld", path: "/", match: MatchBegin},
{hostname: "local3.tld", path: "/a", match: MatchPrefix},
{hostname: "local3.tld", path: "/", match: MatchBegin},
{hostname: "local4.tld", path: "/a", match: MatchPrefix},
},
expected: `
hosts__prefix_01.map first:true,lower:false,method:dir
Expand Down
2 changes: 1 addition & 1 deletion pkg/haproxy/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ type EndpointCookieStrategy int
// ...
const (
EpCookieName EndpointCookieStrategy = iota
EpCookiePodUid
EpCookiePodUID
)

// Backends ...
Expand Down

0 comments on commit 03c76e9

Please sign in to comment.