Skip to content

Commit 165e000

Browse files
committed
MEDIUM: crd: leave support for v1alpha1 crds
1 parent 0948245 commit 165e000

File tree

15 files changed

+5066
-20
lines changed

15 files changed

+5066
-20
lines changed

crs/converters/backend-spec.go

Lines changed: 374 additions & 0 deletions
Large diffs are not rendered by default.

crs/converters/defaults-spec.go

Lines changed: 397 additions & 0 deletions
Large diffs are not rendered by default.

crs/converters/global-spec.go

Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
// Copyright 2022 HAProxy Technologies LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package converters
16+
17+
import (
18+
"github.com/haproxytech/client-native/v3/models"
19+
corev1alpha1 "github.com/haproxytech/kubernetes-ingress/crs/api/core/v1alpha1"
20+
corev1alpha2 "github.com/haproxytech/kubernetes-ingress/crs/api/core/v1alpha2"
21+
)
22+
23+
func DeepConvertGlobalSpecA1toA2(o corev1alpha1.GlobalSpec) corev1alpha2.GlobalSpec {
24+
var cp corev1alpha2.GlobalSpec
25+
if o.Config != nil {
26+
cp.Config = new(models.Global)
27+
28+
if o.Config.CPUMaps != nil {
29+
cp.Config.CPUMaps = make([]*models.CPUMap, len(o.Config.CPUMaps))
30+
for i4 := range o.Config.CPUMaps {
31+
if o.Config.CPUMaps[i4] != nil {
32+
cp.Config.CPUMaps[i4] = new(models.CPUMap)
33+
34+
if o.Config.CPUMaps[i4].CPUSet != nil {
35+
cp.Config.CPUMaps[i4].CPUSet = new(string)
36+
37+
cp.Config.CPUMaps[i4].CPUSet = o.Config.CPUMaps[i4].CPUSet
38+
}
39+
if o.Config.CPUMaps[i4].Process != nil {
40+
cp.Config.CPUMaps[i4].Process = new(string)
41+
42+
cp.Config.CPUMaps[i4].Process = o.Config.CPUMaps[i4].Process
43+
}
44+
}
45+
}
46+
}
47+
if o.Config.H1CaseAdjusts != nil {
48+
cp.Config.H1CaseAdjusts = make([]*models.H1CaseAdjust, len(o.Config.H1CaseAdjusts))
49+
for i4 := range o.Config.H1CaseAdjusts {
50+
if o.Config.H1CaseAdjusts[i4] != nil {
51+
cp.Config.H1CaseAdjusts[i4] = new(models.H1CaseAdjust)
52+
53+
if o.Config.H1CaseAdjusts[i4].From != nil {
54+
cp.Config.H1CaseAdjusts[i4].From = new(string)
55+
56+
cp.Config.H1CaseAdjusts[i4].From = o.Config.H1CaseAdjusts[i4].From
57+
}
58+
if o.Config.H1CaseAdjusts[i4].To != nil {
59+
cp.Config.H1CaseAdjusts[i4].To = new(string)
60+
61+
cp.Config.H1CaseAdjusts[i4].To = o.Config.H1CaseAdjusts[i4].To
62+
}
63+
}
64+
}
65+
}
66+
if o.Config.RuntimeAPIs != nil {
67+
cp.Config.RuntimeAPIs = make([]*models.RuntimeAPI, len(o.Config.RuntimeAPIs))
68+
for i4 := range o.Config.RuntimeAPIs {
69+
if o.Config.RuntimeAPIs[i4] != nil {
70+
cp.Config.RuntimeAPIs[i4] = new(models.RuntimeAPI)
71+
72+
if o.Config.RuntimeAPIs[i4].Address != nil {
73+
cp.Config.RuntimeAPIs[i4].Address = new(string)
74+
75+
cp.Config.RuntimeAPIs[i4].Address = o.Config.RuntimeAPIs[i4].Address
76+
}
77+
cp.Config.RuntimeAPIs[i4].ExposeFdListeners = o.Config.RuntimeAPIs[i4].ExposeFdListeners
78+
cp.Config.RuntimeAPIs[i4].Level = o.Config.RuntimeAPIs[i4].Level
79+
cp.Config.RuntimeAPIs[i4].Mode = o.Config.RuntimeAPIs[i4].Mode
80+
cp.Config.RuntimeAPIs[i4].Process = o.Config.RuntimeAPIs[i4].Process
81+
}
82+
}
83+
}
84+
cp.Config.Chroot = o.Config.Chroot
85+
cp.Config.Daemon = o.Config.Daemon
86+
cp.Config.ExternalCheck = o.Config.ExternalCheck
87+
cp.Config.Group = o.Config.Group
88+
cp.Config.H1CaseAdjustFile = o.Config.H1CaseAdjustFile
89+
if o.Config.HardStopAfter != nil {
90+
cp.Config.HardStopAfter = new(int64)
91+
92+
cp.Config.HardStopAfter = o.Config.HardStopAfter
93+
}
94+
cp.Config.Localpeer = o.Config.Localpeer
95+
if o.Config.LogSendHostname != nil {
96+
cp.Config.LogSendHostname = new(models.GlobalLogSendHostname)
97+
98+
if o.Config.LogSendHostname.Enabled != nil {
99+
cp.Config.LogSendHostname.Enabled = new(string)
100+
101+
cp.Config.LogSendHostname.Enabled = o.Config.LogSendHostname.Enabled
102+
}
103+
cp.Config.LogSendHostname.Param = o.Config.LogSendHostname.Param
104+
}
105+
if o.Config.LuaLoads != nil {
106+
cp.Config.LuaLoads = make([]*models.LuaLoad, len(o.Config.LuaLoads))
107+
for i4 := range o.Config.LuaLoads {
108+
if o.Config.LuaLoads[i4] != nil {
109+
cp.Config.LuaLoads[i4] = new(models.LuaLoad)
110+
111+
if o.Config.LuaLoads[i4].File != nil {
112+
cp.Config.LuaLoads[i4].File = new(string)
113+
114+
cp.Config.LuaLoads[i4].File = o.Config.LuaLoads[i4].File
115+
}
116+
}
117+
}
118+
}
119+
if o.Config.LuaPrependPath != nil {
120+
cp.Config.LuaPrependPath = make([]*models.LuaPrependPath, len(o.Config.LuaPrependPath))
121+
for i4 := range o.Config.LuaPrependPath {
122+
if o.Config.LuaPrependPath[i4] != nil {
123+
cp.Config.LuaPrependPath[i4] = new(models.LuaPrependPath)
124+
125+
if o.Config.LuaPrependPath[i4].Path != nil {
126+
cp.Config.LuaPrependPath[i4].Path = new(string)
127+
128+
cp.Config.LuaPrependPath[i4].Path = o.Config.LuaPrependPath[i4].Path
129+
}
130+
cp.Config.LuaPrependPath[i4].Type = o.Config.LuaPrependPath[i4].Type
131+
}
132+
}
133+
}
134+
cp.Config.MasterWorker = o.Config.MasterWorker
135+
cp.Config.Maxconn = o.Config.Maxconn
136+
cp.Config.Nbproc = o.Config.Nbproc
137+
cp.Config.Nbthread = o.Config.Nbthread
138+
cp.Config.Pidfile = o.Config.Pidfile
139+
cp.Config.ServerStateBase = o.Config.ServerStateBase
140+
cp.Config.ServerStateFile = o.Config.ServerStateFile
141+
cp.Config.SslDefaultBindCiphers = o.Config.SslDefaultBindCiphers
142+
cp.Config.SslDefaultBindCiphersuites = o.Config.SslDefaultBindCiphersuites
143+
cp.Config.SslDefaultBindOptions = o.Config.SslDefaultBindOptions
144+
cp.Config.SslDefaultServerCiphers = o.Config.SslDefaultServerCiphers
145+
cp.Config.SslDefaultServerCiphersuites = o.Config.SslDefaultServerCiphersuites
146+
cp.Config.SslDefaultServerOptions = o.Config.SslDefaultServerOptions
147+
cp.Config.SslModeAsync = o.Config.SslModeAsync
148+
if o.Config.StatsTimeout != nil {
149+
cp.Config.StatsTimeout = new(int64)
150+
151+
cp.Config.StatsTimeout = o.Config.StatsTimeout
152+
}
153+
cp.Config.TuneSslDefaultDhParam = o.Config.TuneSslDefaultDhParam
154+
cp.Config.User = o.Config.User
155+
}
156+
if o.LogTargets != nil {
157+
cp.LogTargets = make([]*models.LogTarget, len(o.LogTargets))
158+
for i2 := range o.LogTargets {
159+
if o.LogTargets[i2] != nil {
160+
cp.LogTargets[i2] = new(models.LogTarget)
161+
162+
cp.LogTargets[i2].Address = o.LogTargets[i2].Address
163+
cp.LogTargets[i2].Facility = o.LogTargets[i2].Facility
164+
cp.LogTargets[i2].Format = o.LogTargets[i2].Format
165+
cp.LogTargets[i2].Global = o.LogTargets[i2].Global
166+
if o.LogTargets[i2].Index != nil {
167+
cp.LogTargets[i2].Index = new(int64)
168+
169+
cp.LogTargets[i2].Index = o.LogTargets[i2].Index
170+
}
171+
cp.LogTargets[i2].Length = o.LogTargets[i2].Length
172+
cp.LogTargets[i2].Level = o.LogTargets[i2].Level
173+
cp.LogTargets[i2].Minlevel = o.LogTargets[i2].Minlevel
174+
cp.LogTargets[i2].Nolog = o.LogTargets[i2].Nolog
175+
}
176+
}
177+
}
178+
return cp
179+
}

crs/definition/backend.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ spec:
1919
properties:
2020
spec:
2121
type: object
22-
properties:
23-
config:
22+
properties:
23+
config:
2424
title: Backend
2525
description: HAProxy backend configuration
2626
type: object

crs/definition/defaults.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ spec:
1919
properties:
2020
spec:
2121
type: object
22-
required:
22+
required:
2323
- config
24-
properties:
25-
config:
24+
properties:
25+
config:
2626
title: Defaults
2727
description: HAProxy defaults configuration
2828
type: object

crs/definition/global.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ spec:
1919
properties:
2020
spec:
2121
type: object
22-
properties:
23-
config:
22+
properties:
23+
config:
2424
description: HAProxy global configuration
2525
type: object
2626
title: Global

0 commit comments

Comments
 (0)