Skip to content

Commit 558c76c

Browse files
committed
fix golangci reported issues
Signed-off-by: Martin Schuppert <mschuppert@redhat.com>
1 parent e4a69c1 commit 558c76c

16 files changed

Lines changed: 55 additions & 48 deletions

controllers/barbican_common.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17+
// Package controllers implements the barbican-operator Kubernetes controllers.
1718
package controllers
1819

1920
import (
@@ -52,7 +53,6 @@ func ensureTopology(
5253
conditionUpdater conditionUpdater,
5354
defaultLabelSelector metav1.LabelSelector,
5455
) (*topologyv1.Topology, error) {
55-
5656
topology, err := topologyv1.EnsureServiceTopology(
5757
ctx,
5858
helper,
@@ -94,7 +94,6 @@ func GenerateConfigsGeneric(
9494
cmLabels map[string]string,
9595
scripts bool,
9696
) error {
97-
9897
cms := []util.Template{
9998
// Templates where the BarbicanAPI config is stored
10099
{
@@ -120,6 +119,7 @@ func GenerateConfigsGeneric(
120119
return secret.EnsureSecrets(ctx, h, instance, cms, envVars)
121120
}
122121

122+
// GenerateSecretStoreTemplateMap generates a template map for configured secret stores
123123
func GenerateSecretStoreTemplateMap(
124124
enabledSecretStores []barbicanv1beta1.SecretStore,
125125
globalDefaultSecretStore barbicanv1beta1.SecretStore,

controllers/barbican_controller.go

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,18 @@ import (
6464
)
6565

6666
const (
67-
PKCS11PrepReadyCondition = "PKCS11PrepReady"
68-
PKCS11PrepReadyInitMessage = "PKCS11 Prep job not started"
69-
PKCS11PrepReadyMessage = "PKCS11 Prep job completed"
70-
PKCS11PrepReadyErrorMessage = "PKCS11 Prep job error occurred %s"
67+
// PKCS11PrepReadyCondition indicates whether PKCS11 preparation is ready
68+
PKCS11PrepReadyCondition = "PKCS11PrepReady"
69+
// PKCS11PrepReadyInitMessage is the initial message for PKCS11 prep status
70+
PKCS11PrepReadyInitMessage = "PKCS11 Prep job not started"
71+
// PKCS11PrepReadyMessage is the message when PKCS11 prep job is completed
72+
PKCS11PrepReadyMessage = "PKCS11 Prep job completed"
73+
// PKCS11PrepReadyErrorMessage is the error message template for PKCS11 prep job failures
74+
PKCS11PrepReadyErrorMessage = "PKCS11 Prep job error occurred %s"
75+
// PKCS11PrepReadyRunningMessage is the message when PKCS11 prep job is still running
7176
PKCS11PrepReadyRunningMessage = "PKCS11 Prep job is still running"
72-
PKCS11PrepReadyNotRunMessage = "PKCS11 Prep job not run"
77+
// PKCS11PrepReadyNotRunMessage is the message when PKCS11 prep job has not been run
78+
PKCS11PrepReadyNotRunMessage = "PKCS11 Prep job not run"
7379
)
7480

7581
// BarbicanReconciler reconciles a Barbican object
@@ -123,7 +129,7 @@ func (r *BarbicanReconciler) Reconcile(ctx context.Context, req ctrl.Request) (r
123129
Log := r.GetLogger(ctx)
124130

125131
instance := &barbicanv1beta1.Barbican{}
126-
err := r.Client.Get(ctx, req.NamespacedName, instance)
132+
err := r.Get(ctx, req.NamespacedName, instance)
127133
if err != nil {
128134
if k8s_errors.IsNotFound(err) {
129135
// Request object not found, could have been deleted after reconcile request.
@@ -551,13 +557,13 @@ func (r *BarbicanReconciler) reconcileDelete(ctx context.Context, instance *barb
551557
// fields to index to reconcile when change
552558
const (
553559
passwordSecretField = ".spec.secret"
554-
caBundleSecretNameField = ".spec.tls.caBundleSecretName"
560+
caBundleSecretNameField = ".spec.tls.caBundleSecretName" // #nosec G101
555561
tlsAPIInternalField = ".spec.tls.api.internal.secretName"
556562
tlsAPIPublicField = ".spec.tls.api.public.secretName"
557-
pkcs11LoginSecretField = ".spec.pkcs11.loginSecret"
558-
pkcs11ClientDataSecretField = ".spec.pkcs11.clientDataSecret"
563+
pkcs11LoginSecretField = ".spec.pkcs11.loginSecret" // #nosec G101
564+
pkcs11ClientDataSecretField = ".spec.pkcs11.clientDataSecret" // #nosec G101
559565
topologyField = ".spec.topologyRef.Name"
560-
customServiceConfigSecretsField = ".spec.customServiceConfigSecrets"
566+
customServiceConfigSecretsField = ".spec.customServiceConfigSecrets" // #nosec G101
561567
parentBarbicanConfigDataSecretField = ".status.parentBarbicanConfigDataSecret"
562568
)
563569

@@ -623,7 +629,7 @@ func (r *BarbicanReconciler) findObjectForSrc(ctx context.Context, src client.Ob
623629
listOps := &client.ListOptions{
624630
Namespace: src.GetNamespace(),
625631
}
626-
err := r.Client.List(ctx, crList, listOps)
632+
err := r.List(ctx, crList, listOps)
627633
if err != nil {
628634
Log.Error(err, fmt.Sprintf("listing %s for namespace: %s", crList.GroupVersionKind().Kind, src.GetNamespace()))
629635
return requests
@@ -670,7 +676,7 @@ func (r *BarbicanReconciler) generateServiceConfig(
670676
}
671677

672678
var tlsCfg *tls.Service
673-
if instance.Spec.BarbicanAPI.TLS.Ca.CaBundleSecretName != "" {
679+
if instance.Spec.BarbicanAPI.TLS.CaBundleSecretName != "" {
674680
tlsCfg = &tls.Service{}
675681
}
676682
customData := map[string]string{
@@ -816,7 +822,7 @@ func (r *BarbicanReconciler) apiDeploymentCreateOrUpdate(ctx context.Context, in
816822
}
817823

818824
// Note: The top-level .spec.apiTimeout ALWAYS overrides .spec.barbicanAPI.apiTimeout
819-
apiSpec.BarbicanAPITemplate.APITimeout = instance.Spec.APITimeout
825+
apiSpec.APITimeout = instance.Spec.APITimeout
820826

821827
deployment := &barbicanv1beta1.BarbicanAPI{
822828
ObjectMeta: metav1.ObjectMeta{
@@ -1166,7 +1172,6 @@ func (r *BarbicanReconciler) ensureDB(
11661172
ctx, h, instance.Spec.DatabaseAccount,
11671173
instance.Namespace, false, barbican.DatabaseUsernamePrefix,
11681174
)
1169-
11701175
if err != nil {
11711176
instance.Status.Conditions.Set(condition.FalseCondition(
11721177
mariadbv1.MariaDBAccountReadyCondition,
@@ -1194,7 +1199,6 @@ func (r *BarbicanReconciler) ensureDB(
11941199

11951200
// create or patch the DB
11961201
ctrlResult, err := db.CreateOrPatchAll(ctx, h)
1197-
11981202
if err != nil {
11991203
instance.Status.Conditions.Set(condition.FalseCondition(
12001204
condition.DBReadyCondition,

controllers/barbicanapi_controller.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ import (
6161
)
6262

6363
const (
64+
// TransportURL is the configuration key for transport URL
6465
TransportURL = "transport_url"
6566
)
6667

@@ -101,7 +102,7 @@ func (r *BarbicanAPIReconciler) Reconcile(ctx context.Context, req ctrl.Request)
101102
Log := r.GetLogger(ctx)
102103

103104
instance := &barbicanv1beta1.BarbicanAPI{}
104-
err := r.Client.Get(ctx, req.NamespacedName, instance)
105+
err := r.Get(ctx, req.NamespacedName, instance)
105106
if err != nil {
106107
if k8s_errors.IsNotFound(err) {
107108
// Object not found
@@ -606,7 +607,7 @@ func (r *BarbicanAPIReconciler) reconcileNormal(ctx context.Context, instance *b
606607
}
607608
}
608609

609-
//check CustomServiceConfigSecrets
610+
// check CustomServiceConfigSecrets
610611
for _, v := range instance.Spec.CustomServiceConfigSecrets {
611612
Log.Info(fmt.Sprintf("[API] Verify secret '%s' from CustomServiceConfigSecrets", v))
612613
ctrlResult, err = r.verifySecret(ctx, helper, instance, v, []string{}, &configVars)

controllers/barbicankeystonelistener_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ func (r *BarbicanKeystoneListenerReconciler) Reconcile(ctx context.Context, req
8181
Log := r.GetLogger(ctx)
8282

8383
instance := &barbicanv1beta1.BarbicanKeystoneListener{}
84-
err := r.Client.Get(ctx, req.NamespacedName, instance)
84+
err := r.Get(ctx, req.NamespacedName, instance)
8585
if err != nil {
8686
if k8s_errors.IsNotFound(err) {
8787
// Object not found

controllers/barbicanworker_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ func (r *BarbicanWorkerReconciler) Reconcile(ctx context.Context, req ctrl.Reque
8080
Log := r.GetLogger(ctx)
8181

8282
instance := &barbicanv1beta1.BarbicanWorker{}
83-
err := r.Client.Get(ctx, req.NamespacedName, instance)
83+
err := r.Get(ctx, req.NamespacedName, instance)
8484
if err != nil {
8585
if k8s_errors.IsNotFound(err) {
8686
// Object not found

main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17+
// Package main implements the barbican-operator controller manager.
1718
package main
1819

1920
import (

pkg/barbican/const.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Package barbican contains barbican service constants and configuration.
12
package barbican
23

34
import "github.com/openstack-k8s-operators/lib-common/modules/storage"
@@ -35,7 +36,7 @@ const (
3536
// CustomServiceConfigFileName -
3637
CustomServiceConfigFileName = "02-service-custom.conf"
3738
// CustomServiceConfigSecretsFileName -
38-
CustomServiceConfigSecretsFileName = "03-secrets-custom.conf"
39+
CustomServiceConfigSecretsFileName = "03-secrets-custom.conf" // #nosec G101
3940
// BarbicanAPI defines the barbican-api group
4041
BarbicanAPI storage.PropagationType = "BarbicanAPI"
4142
// BarbicanWorker defines the barbican-worker group
@@ -61,9 +62,9 @@ const (
6162
ScriptVolume = "scripts"
6263
// ScriptMountPoint is the mount point for scripts
6364
ScriptMountPoint = "/usr/local/bin/container-scripts"
64-
// PKCS11DataVolume is the volume used to mount PKCS11 client Data
65+
// PKCS11ClientDataVolume is the volume used to mount PKCS11 client Data
6566
PKCS11ClientDataVolume = "pkcs11-client-data"
66-
// PKCS11DataVolume is the mount point used for PKCS11 client Data
67+
// PKCS11ClientDataMountPoint is the mount point used for PKCS11 client Data
6768
PKCS11ClientDataMountPoint = "/var/lib/config-data/hsm"
6869
// BarbicanUID - based on https://github.com/openstack-k8s-operators/tcib/blob/main/container-images/kolla/base/uid_gid_manage.sh
6970
BarbicanUID int64 = 42403

pkg/barbican/volumes.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ func GetVolumes(name string) []corev1.Volume {
2929

3030
// GetVolumeMounts - general VolumeMounts
3131
func GetVolumeMounts() []corev1.VolumeMount {
32-
3332
return []corev1.VolumeMount{
3433
{
3534
Name: ConfigVolume,
@@ -96,7 +95,7 @@ func GetKollaConfigVolumeMount(serviceName string) corev1.VolumeMount {
9695
}
9796
}
9897

99-
// GetHSMVolume - Returns Volumes for HSM secrets
98+
// GetHSMVolumes returns Volumes for HSM secrets
10099
func GetHSMVolumes(pkcs11 barbicanv1beta1.BarbicanPKCS11Template) []corev1.Volume {
101100
return []corev1.Volume{
102101
{
@@ -111,7 +110,7 @@ func GetHSMVolumes(pkcs11 barbicanv1beta1.BarbicanPKCS11Template) []corev1.Volum
111110
}
112111
}
113112

114-
// GetHSMVolumeMount - Returns Volume Mounts for HSM secrets
113+
// GetHSMVolumeMounts returns Volume Mounts for HSM secrets
115114
func GetHSMVolumeMounts() []corev1.VolumeMount {
116115
return []corev1.VolumeMount{
117116
{

pkg/barbicanapi/deployment.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Package barbicanapi contains barbican API deployment functionality.
12
package barbicanapi
23

34
import (

pkg/barbicanapi/volumes.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,8 @@ import (
1111
corev1 "k8s.io/api/core/v1"
1212
)
1313

14-
// GetVolumesAndMounts - return the volumes and mounts for a BarbicanAPI deployment
14+
// GetAPIVolumesAndMounts returns the volumes and mounts for a BarbicanAPI deployment
1515
func GetAPIVolumesAndMounts(instance *barbicanv1beta1.BarbicanAPI) ([]corev1.Volume, []corev1.VolumeMount, error) {
16-
1716
apiVolumes := []corev1.Volume{
1817
barbican.GetCustomConfigVolume(instance.Name),
1918
barbican.GetLogVolume(),

0 commit comments

Comments
 (0)