Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure golangci-lint runs on all files #422

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,5 @@ repos:
- repo: https://github.com/golangci/golangci-lint
rev: v1.55.2
hooks:
- id: golangci-lint
- id: golangci-lint-full
args: ["-v"]
3 changes: 0 additions & 3 deletions controllers/funcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ const (
)

var (
ironicWatchFields = []string{
passwordSecretField,
}
ironicAPIWatchFields = []string{
passwordSecretField,
caBundleSecretNameField,
Expand Down
7 changes: 3 additions & 4 deletions controllers/ironic_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import (
job "github.com/openstack-k8s-operators/lib-common/modules/common/job"
labels "github.com/openstack-k8s-operators/lib-common/modules/common/labels"
common_rbac "github.com/openstack-k8s-operators/lib-common/modules/common/rbac"
"github.com/openstack-k8s-operators/lib-common/modules/common/secret"
oko_secret "github.com/openstack-k8s-operators/lib-common/modules/common/secret"
"github.com/openstack-k8s-operators/lib-common/modules/common/tls"
util "github.com/openstack-k8s-operators/lib-common/modules/common/util"
Expand Down Expand Up @@ -420,7 +419,7 @@ func (r *IronicReconciler) reconcileNormal(ctx context.Context, instance *ironic
}

// Handle service update
ctrlResult, err := r.reconcileUpdate(ctx, instance, helper)
ctrlResult, err := r.reconcileUpdate()
if err != nil {
return ctrlResult, err
} else if (ctrlResult != ctrl.Result{}) {
Expand Down Expand Up @@ -600,7 +599,7 @@ func (r *IronicReconciler) reconcileNormal(ctx context.Context, instance *ironic
return ctrl.Result{}, nil
}

func (r *IronicReconciler) reconcileUpdate(ctx context.Context, instance *ironicv1.Ironic, helper *helper.Helper) (ctrl.Result, error) {
func (r *IronicReconciler) reconcileUpdate() (ctrl.Result, error) {
// Log.Info("Reconciling Ironic update")

// Log.Info("Reconciled Ironic update successfully")
Expand Down Expand Up @@ -844,7 +843,7 @@ func (r *IronicReconciler) generateServiceConfigMaps(
},
}

return secret.EnsureSecrets(ctx, h, instance, cms, envVars)
return oko_secret.EnsureSecrets(ctx, h, instance, cms, envVars)
}

// createHashOfInputHashes - creates a hash of hashes which gets added to the resources which requires a restart
Expand Down
22 changes: 11 additions & 11 deletions controllers/ironicapi_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ func (r *IronicAPIReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Man
listOpts := []client.ListOption{
client.InNamespace(o.GetNamespace()),
}
if err := r.Client.List(context.Background(), apis, listOpts...); err != nil {
if err := r.Client.List(ctx, apis, listOpts...); err != nil {
Log.Error(err, "Unable to retrieve API CRs %v")
return nil
}
Expand Down Expand Up @@ -248,7 +248,7 @@ func (r *IronicAPIReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Man
}

// index passwordSecretField
if err := mgr.GetFieldIndexer().IndexField(context.Background(), &ironicv1.IronicAPI{}, passwordSecretField, func(rawObj client.Object) []string {
if err := mgr.GetFieldIndexer().IndexField(ctx, &ironicv1.IronicAPI{}, passwordSecretField, func(rawObj client.Object) []string {
// Extract the secret name from the spec, if one is provided
cr := rawObj.(*ironicv1.IronicAPI)
if cr.Spec.Secret == "" {
Expand All @@ -260,7 +260,7 @@ func (r *IronicAPIReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Man
}

// index caBundleSecretNameField
if err := mgr.GetFieldIndexer().IndexField(context.Background(), &ironicv1.IronicAPI{}, caBundleSecretNameField, func(rawObj client.Object) []string {
if err := mgr.GetFieldIndexer().IndexField(ctx, &ironicv1.IronicAPI{}, caBundleSecretNameField, func(rawObj client.Object) []string {
// Extract the secret name from the spec, if one is provided
cr := rawObj.(*ironicv1.IronicAPI)
if cr.Spec.TLS.CaBundleSecretName == "" {
Expand All @@ -272,7 +272,7 @@ func (r *IronicAPIReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Man
}

// index tlsAPIInternalField
if err := mgr.GetFieldIndexer().IndexField(context.Background(), &ironicv1.IronicAPI{}, tlsAPIInternalField, func(rawObj client.Object) []string {
if err := mgr.GetFieldIndexer().IndexField(ctx, &ironicv1.IronicAPI{}, tlsAPIInternalField, func(rawObj client.Object) []string {
// Extract the secret name from the spec, if one is provided
cr := rawObj.(*ironicv1.IronicAPI)
if cr.Spec.TLS.API.Internal.SecretName == nil {
Expand All @@ -284,7 +284,7 @@ func (r *IronicAPIReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Man
}

// index tlsAPIPublicField
if err := mgr.GetFieldIndexer().IndexField(context.Background(), &ironicv1.IronicAPI{}, tlsAPIPublicField, func(rawObj client.Object) []string {
if err := mgr.GetFieldIndexer().IndexField(ctx, &ironicv1.IronicAPI{}, tlsAPIPublicField, func(rawObj client.Object) []string {
// Extract the secret name from the spec, if one is provided
cr := rawObj.(*ironicv1.IronicAPI)
if cr.Spec.TLS.API.Public.SecretName == nil {
Expand Down Expand Up @@ -319,15 +319,15 @@ func (r *IronicAPIReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Man
func (r *IronicAPIReconciler) findObjectsForSrc(ctx context.Context, src client.Object) []reconcile.Request {
requests := []reconcile.Request{}

l := log.FromContext(context.Background()).WithName("Controllers").WithName("IronicAPI")
l := log.FromContext(ctx).WithName("Controllers").WithName("IronicAPI")

for _, field := range ironicAPIWatchFields {
crList := &ironicv1.IronicAPIList{}
listOps := &client.ListOptions{
FieldSelector: fields.OneTermEqualSelector(field, src.GetName()),
Namespace: src.GetNamespace(),
}
err := r.List(context.TODO(), crList, listOps)
err := r.List(ctx, crList, listOps)
if err != nil {
return []reconcile.Request{}
}
Expand Down Expand Up @@ -807,15 +807,15 @@ func (r *IronicAPIReconciler) reconcileNormal(ctx context.Context, instance *iro
}

// Handle service update
ctrlResult, err = r.reconcileUpdate(ctx, instance, helper)
ctrlResult, err = r.reconcileUpdate()
if err != nil {
return ctrlResult, err
} else if (ctrlResult != ctrl.Result{}) {
return ctrlResult, nil
}

// Handle service upgrade
ctrlResult, err = r.reconcileUpgrade(ctx, instance, helper)
ctrlResult, err = r.reconcileUpgrade()
if err != nil {
return ctrlResult, err
} else if (ctrlResult != ctrl.Result{}) {
Expand Down Expand Up @@ -898,14 +898,14 @@ func (r *IronicAPIReconciler) reconcileNormal(ctx context.Context, instance *iro
return ctrl.Result{}, nil
}

func (r *IronicAPIReconciler) reconcileUpdate(ctx context.Context, instance *ironicv1.IronicAPI, helper *helper.Helper) (ctrl.Result, error) {
func (r *IronicAPIReconciler) reconcileUpdate() (ctrl.Result, error) {
// Log.Info("Reconciling API update")

// Log.Info("Reconciled API update successfully")
return ctrl.Result{}, nil
}

func (r *IronicAPIReconciler) reconcileUpgrade(ctx context.Context, instance *ironicv1.IronicAPI, helper *helper.Helper) (ctrl.Result, error) {
func (r *IronicAPIReconciler) reconcileUpgrade() (ctrl.Result, error) {
// Log.Info("Reconciling API upgrade")

// Log.Info("Reconciled API upgrade successfully")
Expand Down
21 changes: 10 additions & 11 deletions controllers/ironicconductor_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
"time"

"k8s.io/apimachinery/pkg/fields"
"k8s.io/apimachinery/pkg/types"
k8s_types "k8s.io/apimachinery/pkg/types"

"github.com/go-logr/logr"
Expand Down Expand Up @@ -249,7 +248,7 @@ func (r *IronicConductorReconciler) SetupWithManager(ctx context.Context, mgr ct
}

// index passwordSecretField
if err := mgr.GetFieldIndexer().IndexField(context.Background(), &ironicv1.IronicConductor{}, passwordSecretField, func(rawObj client.Object) []string {
if err := mgr.GetFieldIndexer().IndexField(ctx, &ironicv1.IronicConductor{}, passwordSecretField, func(rawObj client.Object) []string {
// Extract the secret name from the spec, if one is provided
cr := rawObj.(*ironicv1.IronicConductor)
if cr.Spec.Secret == "" {
Expand All @@ -261,7 +260,7 @@ func (r *IronicConductorReconciler) SetupWithManager(ctx context.Context, mgr ct
}

// index caBundleSecretNameField
if err := mgr.GetFieldIndexer().IndexField(context.Background(), &ironicv1.IronicConductor{}, caBundleSecretNameField, func(rawObj client.Object) []string {
if err := mgr.GetFieldIndexer().IndexField(ctx, &ironicv1.IronicConductor{}, caBundleSecretNameField, func(rawObj client.Object) []string {
// Extract the secret name from the spec, if one is provided
cr := rawObj.(*ironicv1.IronicConductor)
if cr.Spec.TLS.CaBundleSecretName == "" {
Expand Down Expand Up @@ -296,15 +295,15 @@ func (r *IronicConductorReconciler) SetupWithManager(ctx context.Context, mgr ct
func (r *IronicConductorReconciler) findObjectsForSrc(ctx context.Context, src client.Object) []reconcile.Request {
requests := []reconcile.Request{}

l := log.FromContext(context.Background()).WithName("Controllers").WithName("IronicConductor")
l := log.FromContext(ctx).WithName("Controllers").WithName("IronicConductor")

for _, field := range ironicConductorWatchFields {
crList := &ironicv1.IronicConductorList{}
listOps := &client.ListOptions{
FieldSelector: fields.OneTermEqualSelector(field, src.GetName()),
Namespace: src.GetNamespace(),
}
err := r.List(context.TODO(), crList, listOps)
err := r.List(ctx, crList, listOps)
if err != nil {
return []reconcile.Request{}
}
Expand All @@ -314,7 +313,7 @@ func (r *IronicConductorReconciler) findObjectsForSrc(ctx context.Context, src c

requests = append(requests,
reconcile.Request{
NamespacedName: types.NamespacedName{
NamespacedName: k8s_types.NamespacedName{
Name: item.GetName(),
Namespace: item.GetNamespace(),
},
Expand Down Expand Up @@ -536,7 +535,7 @@ func (r *IronicConductorReconciler) reconcileNormal(ctx context.Context, instanc
hash, ctrlResult, err := tls.ValidateCACertSecret(
ctx,
helper.GetClient(),
types.NamespacedName{
k8s_types.NamespacedName{
Name: instance.Spec.TLS.CaBundleSecretName,
Namespace: instance.Namespace,
},
Expand Down Expand Up @@ -605,15 +604,15 @@ func (r *IronicConductorReconciler) reconcileNormal(ctx context.Context, instanc
//

// Handle service update
ctrlResult, err := r.reconcileUpdate(ctx, instance, helper)
ctrlResult, err := r.reconcileUpdate()
if err != nil {
return ctrlResult, err
} else if (ctrlResult != ctrl.Result{}) {
return ctrlResult, nil
}

// Handle service upgrade
ctrlResult, err = r.reconcileUpgrade(ctx, instance, helper)
ctrlResult, err = r.reconcileUpgrade()
if err != nil {
return ctrlResult, err
} else if (ctrlResult != ctrl.Result{}) {
Expand Down Expand Up @@ -737,14 +736,14 @@ func (r *IronicConductorReconciler) reconcileNormal(ctx context.Context, instanc
return ctrl.Result{}, nil
}

func (r *IronicConductorReconciler) reconcileUpdate(ctx context.Context, instance *ironicv1.IronicConductor, helper *helper.Helper) (ctrl.Result, error) {
func (r *IronicConductorReconciler) reconcileUpdate() (ctrl.Result, error) {
// Log.Info("Reconciling Service update")

// Log.Info("Reconciled Service update successfully")
return ctrl.Result{}, nil
}

func (r *IronicConductorReconciler) reconcileUpgrade(ctx context.Context, instance *ironicv1.IronicConductor, helper *helper.Helper) (ctrl.Result, error) {
func (r *IronicConductorReconciler) reconcileUpgrade() (ctrl.Result, error) {
// Log.Info("Reconciling Service upgrade")

// Log.Info("Reconciled Service upgrade successfully")
Expand Down
29 changes: 11 additions & 18 deletions controllers/ironicinspector_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import (
job "github.com/openstack-k8s-operators/lib-common/modules/common/job"
nad "github.com/openstack-k8s-operators/lib-common/modules/common/networkattachment"
common_rbac "github.com/openstack-k8s-operators/lib-common/modules/common/rbac"
"github.com/openstack-k8s-operators/lib-common/modules/common/secret"
oko_secret "github.com/openstack-k8s-operators/lib-common/modules/common/secret"
"github.com/openstack-k8s-operators/lib-common/modules/common/service"
"github.com/openstack-k8s-operators/lib-common/modules/common/statefulset"
Expand All @@ -42,7 +41,6 @@ import (
routev1 "github.com/openshift/api/route/v1"
k8s_errors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/fields"
"k8s.io/apimachinery/pkg/types"
k8s_types "k8s.io/apimachinery/pkg/types"
"k8s.io/utils/ptr"

Expand Down Expand Up @@ -264,7 +262,7 @@ func (r *IronicInspectorReconciler) Reconcile(

// SetupWithManager sets up the controller with the Manager.
func (r *IronicInspectorReconciler) SetupWithManager(
mgr ctrl.Manager, ctx context.Context,
ctx context.Context, mgr ctrl.Manager,
) error {
// watch for configmap where the CM owner label AND the CR.Spec.ManagingCrName label matches
configMapFn := func(ctx context.Context, o client.Object) []reconcile.Request {
Expand Down Expand Up @@ -314,7 +312,7 @@ func (r *IronicInspectorReconciler) SetupWithManager(
}

// index passwordSecretField
if err := mgr.GetFieldIndexer().IndexField(context.Background(), &ironicv1.IronicInspector{}, passwordSecretField, func(rawObj client.Object) []string {
if err := mgr.GetFieldIndexer().IndexField(ctx, &ironicv1.IronicInspector{}, passwordSecretField, func(rawObj client.Object) []string {
// Extract the secret name from the spec, if one is provided
cr := rawObj.(*ironicv1.IronicInspector)
if cr.Spec.Secret == "" {
Expand All @@ -326,7 +324,7 @@ func (r *IronicInspectorReconciler) SetupWithManager(
}

// index caBundleSecretNameField
if err := mgr.GetFieldIndexer().IndexField(context.Background(), &ironicv1.IronicInspector{}, caBundleSecretNameField, func(rawObj client.Object) []string {
if err := mgr.GetFieldIndexer().IndexField(ctx, &ironicv1.IronicInspector{}, caBundleSecretNameField, func(rawObj client.Object) []string {
// Extract the secret name from the spec, if one is provided
cr := rawObj.(*ironicv1.IronicInspector)
if cr.Spec.TLS.CaBundleSecretName == "" {
Expand Down Expand Up @@ -361,15 +359,15 @@ func (r *IronicInspectorReconciler) SetupWithManager(
func (r *IronicInspectorReconciler) findObjectsForSrc(ctx context.Context, src client.Object) []reconcile.Request {
requests := []reconcile.Request{}

l := log.FromContext(context.Background()).WithName("Controllers").WithName("IronicInspector")
l := log.FromContext(ctx).WithName("Controllers").WithName("IronicInspector")

for _, field := range ironicInspectorWatchFields {
crList := &ironicv1.IronicInspectorList{}
listOps := &client.ListOptions{
FieldSelector: fields.OneTermEqualSelector(field, src.GetName()),
Namespace: src.GetNamespace(),
}
err := r.List(context.TODO(), crList, listOps)
err := r.List(ctx, crList, listOps)
if err != nil {
return []reconcile.Request{}
}
Expand All @@ -379,7 +377,7 @@ func (r *IronicInspectorReconciler) findObjectsForSrc(ctx context.Context, src c

requests = append(requests,
reconcile.Request{
NamespacedName: types.NamespacedName{
NamespacedName: k8s_types.NamespacedName{
Name: item.GetName(),
Namespace: item.GetNamespace(),
},
Expand Down Expand Up @@ -509,7 +507,7 @@ func (r *IronicInspectorReconciler) reconcileConfigMapsAndSecrets(
hash, ctrlResult, err := tls.ValidateCACertSecret(
ctx,
helper.GetClient(),
types.NamespacedName{
k8s_types.NamespacedName{
Name: instance.Spec.TLS.CaBundleSecretName,
Namespace: instance.Namespace,
},
Expand Down Expand Up @@ -730,7 +728,7 @@ func (r *IronicInspectorReconciler) reconcileNormal(
return ctrlResult, nil
}

db, ctrlResult, err := r.reconcileServiceDBinstance(ctx, instance, helper, serviceLabels)
db, ctrlResult, err := r.reconcileServiceDBinstance(ctx, instance, helper)
if err != nil {
return ctrlResult, err
} else if (ctrlResult != ctrl.Result{}) {
Expand Down Expand Up @@ -786,15 +784,15 @@ func (r *IronicInspectorReconciler) reconcileNormal(
}

// Handle service update
ctrlResult, err = r.reconcileUpdate(ctx, instance, helper)
ctrlResult, err = r.reconcileUpdate(ctx)
if err != nil {
return ctrlResult, err
} else if (ctrlResult != ctrl.Result{}) {
return ctrlResult, nil
}

// Handle service upgrade
ctrlResult, err = r.reconcileUpgrade(ctx, instance, helper)
ctrlResult, err = r.reconcileUpgrade(ctx)
if err != nil {
return ctrlResult, err
} else if (ctrlResult != ctrl.Result{}) {
Expand Down Expand Up @@ -928,7 +926,6 @@ func (r *IronicInspectorReconciler) reconcileServiceDBinstance(
ctx context.Context,
instance *ironicv1.IronicInspector,
helper *helper.Helper,
serviceLabels map[string]string,
) (*mariadbv1.Database, ctrl.Result, error) {

// ensure MariaDBAccount exists. This account record may be created by
Expand Down Expand Up @@ -1306,8 +1303,6 @@ func (r *IronicInspectorReconciler) reconcileInit(

func (r *IronicInspectorReconciler) reconcileUpdate(
ctx context.Context,
instance *ironicv1.IronicInspector,
helper *helper.Helper,
) (ctrl.Result, error) {
Log := r.GetLogger(ctx)

Expand All @@ -1321,8 +1316,6 @@ func (r *IronicInspectorReconciler) reconcileUpdate(

func (r *IronicInspectorReconciler) reconcileUpgrade(
ctx context.Context,
instance *ironicv1.IronicInspector,
helper *helper.Helper,
) (ctrl.Result, error) {
Log := r.GetLogger(ctx)
Log.Info("Reconciling Ironic Inspector Service upgrade")
Expand Down Expand Up @@ -1460,7 +1453,7 @@ func (r *IronicInspectorReconciler) generateServiceConfigMaps(
Labels: cmLabels,
},
}
return secret.EnsureSecrets(ctx, h, instance, cms, envVars)
return oko_secret.EnsureSecrets(ctx, h, instance, cms, envVars)
}

// createHashOfInputHashes - creates a hash of hashes which gets added to the
Expand Down
Loading
Loading