Skip to content

Commit 3d75e7f

Browse files
committed
[Misc] Operator: Minor quality issues addressed
Fix minor code quality issues.
1 parent b683cca commit 3d75e7f

File tree

17 files changed

+30
-30
lines changed

17 files changed

+30
-30
lines changed

cmd/controller/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ func main() {
122122
go func() {
123123
migrationDone <- migrateToDomainRefs(crdClient, istioClient, certClient, certManagerClient, dnsClient)
124124
}()
125-
if ok := <-migrationDone; !ok {
125+
if !<-migrationDone {
126126
klog.Errorf("Migration failed; not starting controller")
127127
os.Exit(1)
128128
}

cmd/server/internal/certificate-check.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ type stringslice []string
1515

1616
func (s *stringslice) UnmarshalJSON(data []byte) error {
1717
var single string
18-
if err := json.Unmarshal(data, &single); err == nil {
18+
if json.Unmarshal(data, &single) == nil {
1919
*s = []string{single}
2020
return nil
2121
}
2222

2323
var multiple []string
24-
if err := json.Unmarshal(data, &multiple); err == nil {
24+
if json.Unmarshal(data, &multiple) == nil {
2525
slices.Sort(multiple)
2626
*s = multiple
2727
return nil
@@ -38,7 +38,7 @@ type JsonDN struct {
3838
CN string `json:"CN"`
3939
}
4040

41-
func check(source []string, target []string) bool {
41+
func check(source, target []string) bool {
4242
return slices.Contains(source, "*") || slices.Equal(source, target)
4343
}
4444

cmd/server/internal/handler.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ func (s *SubscriptionHandler) CreateTenant(reqInfo *RequestInfo) *Result {
196196
}
197197

198198
// Tenant created/exists
199-
message := func(isCreated bool, isUpdated bool) string {
199+
message := func(isCreated, isUpdated bool) string {
200200
if isCreated {
201201
return ResourceCreated
202202
} else if isUpdated {
@@ -517,7 +517,7 @@ func (s *SubscriptionHandler) authorizationCheck(headerDetails *requestHeaderDet
517517
return
518518
}
519519

520-
func (s *SubscriptionHandler) checkCAPApp(globalAccountId string, btpAppName string) (*v1alpha1.CAPApplication, error) {
520+
func (s *SubscriptionHandler) checkCAPApp(globalAccountId, btpAppName string) (*v1alpha1.CAPApplication, error) {
521521
labelSelector, err := labels.ValidatedSelectorFromSet(map[string]string{
522522
LabelBTPApplicationIdentifierHash: sha1Sum(globalAccountId, btpAppName),
523523
})

cmd/server/internal/handler_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1181,7 +1181,7 @@ func TestAsyncCallback(t *testing.T) {
11811181
client.Transport = &http.Transport{
11821182
DialContext: func(c context.Context, network, addr string) (net.Conn, error) {
11831183
if strings.Contains(addr, "auth.service.local:") {
1184-
if v := c.Value(cKey); v != nil {
1184+
if c.Value(cKey) != nil {
11851185
calledHost = addr
11861186
} else {
11871187
calledHost = ""

cmd/server/internal/jwt_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ func createJWTTestTLSServer(ctx context.Context, jwks *JWKeys) (*http.Client, er
154154
if err != nil {
155155
return nil, err
156156
}
157-
if ok := rootCAs.AppendCertsFromPEM(certs); !ok {
157+
if !rootCAs.AppendCertsFromPEM(certs) {
158158
return nil, errors.New("could not append CA cert")
159159
}
160160

cmd/web-hooks/internal/handler/handler.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ func (wh *WebhookHandler) checkCaIsConsistent(catObjOld v1alpha1.CAPTenant) vali
610610
return validAdmissionReviewObj()
611611
}
612612

613-
func (wh *WebhookHandler) checkForDuplicateDomains(domain string, name string) validateResource {
613+
func (wh *WebhookHandler) checkForDuplicateDomains(domain, name string) validateResource {
614614
clusterDoms, _ := wh.CrdClient.SmeV1alpha1().ClusterDomains(metav1.NamespaceAll).List(context.TODO(), metav1.ListOptions{})
615615
for _, clusterDom := range clusterDoms.Items {
616616
if clusterDom.Spec.Domain == domain && clusterDom.Name != name {

cmd/web-hooks/internal/handler/mutate.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ func (wh *WebhookHandler) handleDomain(domain string, ca *v1alpha1.CAPApplicatio
220220
return nil
221221
}
222222

223-
func (wh *WebhookHandler) getDomain(domain string, namespace string) (*matchingDomainDetails, error) {
223+
func (wh *WebhookHandler) getDomain(domain, namespace string) (*matchingDomainDetails, error) {
224224
// Check if the domain exists in current namespace
225225
doms, err := wh.CrdClient.SmeV1alpha1().Domains(namespace).List(context.TODO(), metav1.ListOptions{})
226226
if err != nil {

cmd/web-hooks/internal/handler/mutate_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func marshalJSON(obj interface{}) []byte {
3939

4040
type testReader struct{}
4141

42-
func (tr *testReader) Read(p []byte) (n int, err error) {
42+
func (tr *testReader) Read(_ []byte) (n int, err error) {
4343
return 0, errors.New("test error")
4444
}
4545

internal/controller/certificate-manager.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ func (h *CertificateManager) handleCertificate(ctx context.Context, info *Manage
7373
return
7474
}
7575

76-
func (h *CertificateManager) GetCredentialName(namespace string, name string) string {
76+
func (h *CertificateManager) GetCredentialName(namespace, name string) string {
7777
credentialSuffix := gardenerCredentialSuffix
7878
if h.managerType == certManagerCertManagerIO {
7979
credentialSuffix = certManagerCredentialSuffix

internal/controller/controller_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ type dummyInformerFactoryType struct {
2929
tweakListOptions func(*metav1.ListOptions)
3030
}
3131

32-
func (f *dummyInformerFactoryType) WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool {
32+
func (f *dummyInformerFactoryType) WaitForCacheSync(_ <-chan struct{}) map[reflect.Type]bool {
3333
//Simulate error
3434
return map[reflect.Type]bool{reflect.TypeOf(metav1.TypeMeta{}): false}
3535
}

0 commit comments

Comments
 (0)