Skip to content

Commit 1cc98ad

Browse files
Abirdcflyjkneubuh
authored andcommitted
cleanup: remove BoolTrue and BoolFalse variable
Signed-off-by: Abirdcfly <[email protected]>
1 parent 4bbf88f commit 1cc98ad

File tree

12 files changed

+31
-41
lines changed

12 files changed

+31
-41
lines changed

api/v1beta1/common_struct.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@ import (
2222
corev1 "k8s.io/api/core/v1"
2323
)
2424

25-
var BoolTrue = true
26-
var BoolFalse = false
27-
2825
// Service is the overrides to be used for Service of the component
2926
// +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true
3027
type Service struct {

api/v1beta1/ibporderer.go

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -236,27 +236,11 @@ func (s *IBPOrdererSpec) DomainSet() bool {
236236
}
237237

238238
func (s *IBPOrdererSpec) IsPrecreateOrderer() bool {
239-
if s.IsPrecreate == nil {
240-
return false
241-
}
242-
243-
if *s.IsPrecreate == BoolTrue {
244-
return true
245-
}
246-
247-
return false
239+
return s.IsPrecreate != nil && *s.IsPrecreate
248240
}
249241

250242
func (s *IBPOrdererSpec) IsUsingChannelLess() bool {
251-
if s.UseChannelLess == nil {
252-
return false
253-
}
254-
255-
if *s.UseChannelLess == BoolTrue {
256-
return true
257-
}
258-
259-
return false
243+
return s.UseChannelLess != nil && *s.UseChannelLess
260244
}
261245

262246
func (s *IBPOrdererSpec) GetNumSecondsWarningPeriod() int64 {

controllers/ibporderer/ibporderer_controller_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import (
2828

2929
. "github.com/onsi/ginkgo/v2"
3030
. "github.com/onsi/gomega"
31+
"k8s.io/utils/pointer"
3132

3233
current "github.com/IBM-Blockchain/fabric-operator/api/v1beta1"
3334
orderermocks "github.com/IBM-Blockchain/fabric-operator/controllers/ibporderer/mocks"
@@ -640,7 +641,7 @@ var _ = Describe("ReconcileIBPOrderer", func() {
640641
Name: instance.Name,
641642
},
642643
}
643-
newOrderer.Spec.DisableNodeOU = &current.BoolTrue
644+
newOrderer.Spec.DisableNodeOU = pointer.Bool(true)
644645

645646
e = event.UpdateEvent{
646647
ObjectOld: oldOrderer,

controllers/ibppeer/ibppeer_controller_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626

2727
. "github.com/onsi/ginkgo/v2"
2828
. "github.com/onsi/gomega"
29+
"k8s.io/utils/pointer"
2930

3031
current "github.com/IBM-Blockchain/fabric-operator/api/v1beta1"
3132
peermocks "github.com/IBM-Blockchain/fabric-operator/controllers/ibppeer/mocks"
@@ -41,7 +42,7 @@ import (
4142
"sigs.k8s.io/controller-runtime/pkg/client"
4243
"sigs.k8s.io/controller-runtime/pkg/event"
4344
"sigs.k8s.io/controller-runtime/pkg/reconcile"
44-
yaml "sigs.k8s.io/yaml"
45+
"sigs.k8s.io/yaml"
4546
)
4647

4748
var _ = Describe("ReconcileIBPPeer", func() {
@@ -606,7 +607,7 @@ var _ = Describe("ReconcileIBPPeer", func() {
606607
Name: instance.Name,
607608
},
608609
}
609-
newPeer.Spec.DisableNodeOU = &current.BoolTrue
610+
newPeer.Spec.DisableNodeOU = pointer.Bool(true)
610611

611612
e = event.UpdateEvent{
612613
ObjectOld: oldPeer,

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ require (
2828
k8s.io/apimachinery v0.21.5
2929
k8s.io/client-go v0.21.5
3030
k8s.io/code-generator v0.21.5
31+
k8s.io/utils v0.0.0-20210527160623-6fdb442a123b
3132
sigs.k8s.io/controller-runtime v0.9.0
3233
sigs.k8s.io/yaml v1.2.0
3334
)
@@ -142,7 +143,6 @@ require (
142143
k8s.io/gengo v0.0.0-20201214224949-b6c5ce23f027 // indirect
143144
k8s.io/klog/v2 v2.8.0 // indirect
144145
k8s.io/kube-openapi v0.0.0-20210305001622-591a79e4bda7 // indirect
145-
k8s.io/utils v0.0.0-20210527160623-6fdb442a123b // indirect
146146
sigs.k8s.io/structured-merge-diff/v4 v4.1.2 // indirect
147147
)
148148

integration/e2ev2/orderer_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import (
2828

2929
. "github.com/onsi/ginkgo/v2"
3030
. "github.com/onsi/gomega"
31+
"k8s.io/utils/pointer"
3132
"sigs.k8s.io/controller-runtime/pkg/client"
3233

3334
current "github.com/IBM-Blockchain/fabric-operator/api/v1beta1"
@@ -302,7 +303,7 @@ var _ = Describe("orderer", func() {
302303
result.Into(ibporderer)
303304

304305
// Disable node ou
305-
ibporderer.Spec.DisableNodeOU = &current.BoolTrue
306+
ibporderer.Spec.DisableNodeOU = pointer.Bool(true)
306307
bytes, err := json.Marshal(ibporderer)
307308
Expect(err).NotTo(HaveOccurred())
308309

integration/e2ev2/peer_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525

2626
. "github.com/onsi/ginkgo/v2"
2727
. "github.com/onsi/gomega"
28+
"k8s.io/utils/pointer"
2829

2930
current "github.com/IBM-Blockchain/fabric-operator/api/v1beta1"
3031
"github.com/IBM-Blockchain/fabric-operator/pkg/apis/common"
@@ -154,7 +155,7 @@ var _ = Describe("peer", func() {
154155
result.Into(peer)
155156

156157
// Disable node ou
157-
peer.Spec.DisableNodeOU = &current.BoolTrue
158+
peer.Spec.DisableNodeOU = pointer.Bool(true)
158159
bytes, err = json.Marshal(peer)
159160
Expect(err).NotTo(HaveOccurred())
160161
})

integration/init/orderer_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import (
3232
. "github.com/onsi/ginkgo/v2"
3333
. "github.com/onsi/gomega"
3434
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
35+
"k8s.io/utils/pointer"
3536
)
3637

3738
const (
@@ -86,7 +87,7 @@ var _ = Describe("Orderer init", func() {
8687
TLS: msp,
8788
},
8889
},
89-
DisableNodeOU: &current.BoolTrue,
90+
DisableNodeOU: pointer.Bool(true),
9091
},
9192
}
9293
instance.Namespace = namespace
@@ -211,7 +212,7 @@ var _ = Describe("Orderer init", func() {
211212
TLS: enrollment,
212213
},
213214
},
214-
DisableNodeOU: &current.BoolTrue,
215+
DisableNodeOU: pointer.Bool(true),
215216
},
216217
}
217218
instance.Namespace = namespace

integration/init/peer_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import (
2626
"path/filepath"
2727

2828
current "github.com/IBM-Blockchain/fabric-operator/api/v1beta1"
29-
operatorconfig "github.com/IBM-Blockchain/fabric-operator/operatorconfig"
29+
"github.com/IBM-Blockchain/fabric-operator/operatorconfig"
3030
"github.com/IBM-Blockchain/fabric-operator/pkg/initializer/common/enroller"
3131
initializer "github.com/IBM-Blockchain/fabric-operator/pkg/initializer/peer"
3232
peerinit "github.com/IBM-Blockchain/fabric-operator/pkg/initializer/peer"
@@ -37,6 +37,7 @@ import (
3737
. "github.com/onsi/ginkgo/v2"
3838
. "github.com/onsi/gomega"
3939
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
40+
"k8s.io/utils/pointer"
4041
)
4142

4243
const (
@@ -98,7 +99,7 @@ var _ = Describe("Peer init", func() {
9899
TLS: msp,
99100
},
100101
},
101-
DisableNodeOU: &current.BoolTrue,
102+
DisableNodeOU: pointer.Bool(true),
102103
},
103104
}
104105
instance.Namespace = namespace
@@ -220,7 +221,7 @@ var _ = Describe("Peer init", func() {
220221
TLS: enrollment,
221222
},
222223
},
223-
DisableNodeOU: &current.BoolTrue,
224+
DisableNodeOU: pointer.Bool(true),
224225
},
225226
}
226227
instance.Namespace = namespace

integration/orderer/orderer_test.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727
"fmt"
2828
"time"
2929

30+
"k8s.io/utils/pointer"
3031
"sigs.k8s.io/yaml"
3132

3233
current "github.com/IBM-Blockchain/fabric-operator/api/v1beta1"
@@ -939,7 +940,7 @@ func GetOrderer() (*Orderer, []Orderer) {
939940
},
940941
},
941942
ConfigOverride: &runtime.RawExtension{Raw: configBytes},
942-
DisableNodeOU: &current.BoolTrue,
943+
DisableNodeOU: pointer.Bool(true),
943944
FabricVersion: integration.FabricVersion + "-1",
944945
},
945946
}
@@ -1022,7 +1023,7 @@ func GetOrderer2() (*Orderer, []Orderer) {
10221023
Limits: defaultLimitsProxy,
10231024
},
10241025
},
1025-
DisableNodeOU: &current.BoolTrue,
1026+
DisableNodeOU: pointer.Bool(true),
10261027
FabricVersion: integration.FabricVersion + "-1",
10271028
},
10281029
}
@@ -1117,7 +1118,7 @@ func GetOrderer3() (*Orderer, []Orderer) {
11171118
Region: "us-south2",
11181119
},
11191120
},
1120-
DisableNodeOU: &current.BoolTrue,
1121+
DisableNodeOU: pointer.Bool(true),
11211122
FabricVersion: integration.FabricVersion + "-1",
11221123
},
11231124
}
@@ -1200,7 +1201,7 @@ func GetOrderer4() (*Orderer, []Orderer) {
12001201
Limits: defaultLimitsProxy,
12011202
},
12021203
},
1203-
DisableNodeOU: &current.BoolTrue,
1204+
DisableNodeOU: pointer.Bool(true),
12041205
FabricVersion: integration.FabricVersion + "-1",
12051206
},
12061207
}
@@ -1268,7 +1269,7 @@ func GetOrderer5() (*Orderer, []Orderer) {
12681269
},
12691270
OrdererType: "etcdraft",
12701271
SystemChannelName: "testchainid",
1271-
UseChannelLess: &current.BoolTrue,
1272+
UseChannelLess: pointer.Bool(true),
12721273
OrgName: "orderermsp",
12731274
MSPID: "orderermsp",
12741275
ImagePullSecrets: []string{"regcred"},
@@ -1297,7 +1298,7 @@ func GetOrderer5() (*Orderer, []Orderer) {
12971298
Limits: defaultLimitsProxy,
12981299
},
12991300
},
1300-
DisableNodeOU: &current.BoolTrue,
1301+
DisableNodeOU: pointer.Bool(true),
13011302
FabricVersion: integration.FabricVersion24 + "-1",
13021303
},
13031304
}

integration/peer/peer_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import (
4343
"k8s.io/apimachinery/pkg/runtime"
4444
"k8s.io/apimachinery/pkg/types"
4545
"k8s.io/apimachinery/pkg/util/wait"
46+
"k8s.io/utils/pointer"
4647
"sigs.k8s.io/yaml"
4748
)
4849

@@ -813,7 +814,7 @@ func GetPeer1() *Peer {
813814
MSP: testMSPSpec,
814815
},
815816
ConfigOverride: &runtime.RawExtension{Raw: configBytes},
816-
DisableNodeOU: &current.BoolTrue,
817+
DisableNodeOU: pointer.Bool(true),
817818
FabricVersion: integration.FabricVersion + "-1",
818819
},
819820
}
@@ -867,7 +868,7 @@ func GetPeer2() *Peer {
867868
Secret: &current.SecretSpec{
868869
MSP: testMSPSpec,
869870
},
870-
DisableNodeOU: &current.BoolTrue,
871+
DisableNodeOU: pointer.Bool(true),
871872
FabricVersion: integration.FabricVersion + "-1",
872873
},
873874
}

pkg/offering/base/orderer/orderer.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ import (
5555
"k8s.io/apimachinery/pkg/runtime"
5656
"k8s.io/apimachinery/pkg/types"
5757
"k8s.io/apimachinery/pkg/util/wait"
58+
"k8s.io/utils/pointer"
5859
"sigs.k8s.io/controller-runtime/pkg/client"
5960
logf "sigs.k8s.io/controller-runtime/pkg/log"
6061
"sigs.k8s.io/controller-runtime/pkg/reconcile"
@@ -461,7 +462,7 @@ func (o *Orderer) CreateNodeCR(instance *current.IBPOrderer, number int) error {
461462
if instance.Spec.IsUsingChannelLess() {
462463
node.Spec.UseChannelLess = instance.Spec.UseChannelLess
463464
} else {
464-
node.Spec.IsPrecreate = &current.BoolTrue
465+
node.Spec.IsPrecreate = pointer.Bool(true)
465466
}
466467
node.Spec.NodeNumber = &number
467468
node.Spec.ClusterSize = 1

0 commit comments

Comments
 (0)