Skip to content

Commit

Permalink
fix/ignore linter errors
Browse files Browse the repository at this point in the history
Signed-off-by: odubajDT <[email protected]>
  • Loading branch information
odubajDT committed Nov 7, 2023
1 parent 8c180d9 commit a2ce06b
Show file tree
Hide file tree
Showing 13 changed files with 34 additions and 27 deletions.
2 changes: 2 additions & 0 deletions apis/core/v1alpha1/flagsourceconfiguration_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ type FlagSourceConfigurationList struct {
Items []FlagSourceConfiguration `json:"items"`
}

//nolint:gocyclo
func NewFlagSourceConfigurationSpec() (*FlagSourceConfigurationSpec, error) {
fsc := &FlagSourceConfigurationSpec{
MetricsPort: DefaultMetricPort,
Expand Down Expand Up @@ -278,6 +279,7 @@ func NewFlagSourceConfigurationSpec() (*FlagSourceConfigurationSpec, error) {
return fsc, nil
}

//nolint:gocyclo
func (fc *FlagSourceConfigurationSpec) Merge(new *FlagSourceConfigurationSpec) {
if new == nil {
return
Expand Down
4 changes: 2 additions & 2 deletions controllers/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ package common
import (
"context"
"fmt"
"github.com/open-feature/open-feature-operator/apis/core/v1alpha1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"time"

"github.com/open-feature/open-feature-operator/apis/core/v1alpha1"
appsV1 "k8s.io/api/apps/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/controller-runtime/pkg/client"
)

Expand Down
5 changes: 4 additions & 1 deletion controllers/common/flagd-injector.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
"context"
"encoding/json"
"fmt"
"time"

"github.com/go-logr/logr"
"github.com/open-feature/open-feature-operator/apis/core/v1alpha1"
"github.com/open-feature/open-feature-operator/controllers/common/constant"
Expand All @@ -16,7 +18,6 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"
"sigs.k8s.io/controller-runtime/pkg/client"
"time"
)

const (
Expand Down Expand Up @@ -45,6 +46,7 @@ type FlagdContainerInjector struct {
FlagDResourceRequirements corev1.ResourceRequirements
}

//nolint:gocyclo
func (fi *FlagdContainerInjector) InjectFlagd(
ctx context.Context,
objectMeta *metav1.ObjectMeta,
Expand Down Expand Up @@ -179,6 +181,7 @@ func (fi *FlagdContainerInjector) handleSidecarSources(ctx context.Context, obje
return nil
}

//nolint:gocyclo
func (fi *FlagdContainerInjector) buildSources(ctx context.Context, objectMeta *metav1.ObjectMeta, flagSourceConfig *v1alpha1.FlagSourceConfigurationSpec, podSpec *corev1.PodSpec, sidecar *corev1.Container) ([]types.SourceConfig, error) {
var sourceCfgCollection []types.SourceConfig

Expand Down
7 changes: 5 additions & 2 deletions controllers/common/flagd-injector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ package common
import (
"context"
"errors"
"reflect"
"testing"

"github.com/go-logr/logr/testr"
"github.com/open-feature/open-feature-operator/apis/core/v1alpha1"
"github.com/open-feature/open-feature-operator/controllers/common/constant"
Expand All @@ -17,10 +20,8 @@ import (
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/intstr"
"k8s.io/client-go/kubernetes/scheme"
"reflect"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/client/fake"
"testing"
)

func TestFlagdContainerInjector_InjectDefaultSyncProvider(t *testing.T) {
Expand Down Expand Up @@ -999,6 +1000,7 @@ func Test_getSecurityContext(t *testing.T) {
}
}

//nolint:dupl
func TestFlagdContainerInjector_EnableClusterRoleBinding_AddDefaultServiceAccountName(t *testing.T) {

namespace, fakeClient := initEnableClusterroleBindingTestEnv()
Expand Down Expand Up @@ -1042,6 +1044,7 @@ func TestFlagdContainerInjector_EnableClusterRoleBinding_AddDefaultServiceAccoun
require.Equal(t, namespace, updatedCrb.Subjects[0].Namespace)
}

//nolint:dupl
func TestFlagdContainerInjector_EnableClusterRoleBinding_ServiceAccountName(t *testing.T) {

namespace, fakeClient := initEnableClusterroleBindingTestEnv()
Expand Down
3 changes: 2 additions & 1 deletion controllers/common/flagd-proxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ package common

import (
"context"
"testing"

"github.com/go-logr/logr/testr"
"github.com/stretchr/testify/require"
v1 "k8s.io/api/apps/v1"
v12 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/client/fake"
"testing"
)

func TestNewFlagdProxyConfiguration(t *testing.T) {
Expand Down
1 change: 0 additions & 1 deletion controllers/common/mock/flagd-injector.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 5 additions & 6 deletions controllers/core/featureflagconfiguration/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,17 @@ import (
"context"

"github.com/go-logr/logr"
corev1alpha1 "github.com/open-feature/open-feature-operator/apis/core/v1alpha1"
"github.com/open-feature/open-feature-operator/controllers/common"
"github.com/open-feature/open-feature-operator/pkg/utils"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
"sigs.k8s.io/controller-runtime/pkg/builder"
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
"sigs.k8s.io/controller-runtime/pkg/predicate"

"k8s.io/apimachinery/pkg/runtime"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/builder"
"sigs.k8s.io/controller-runtime/pkg/client"

corev1alpha1 "github.com/open-feature/open-feature-operator/apis/core/v1alpha1"
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
"sigs.k8s.io/controller-runtime/pkg/predicate"
)

// FeatureFlagConfigurationReconciler reconciles a FeatureFlagConfiguration object
Expand Down Expand Up @@ -61,6 +59,7 @@ type FeatureFlagConfigurationReconciler struct {

const CrdName = "FeatureFlagConfiguration"

//nolint:gocognit
func (r *FeatureFlagConfigurationReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {

Check failure on line 63 in controllers/core/featureflagconfiguration/controller.go

View workflow job for this annotation

GitHub Actions / golangci-lint

cyclomatic complexity 19 of func `(*FeatureFlagConfigurationReconciler).Reconcile` is high (> 10) (gocyclo)
r.Log.Info("Reconciling" + CrdName)

Expand Down
5 changes: 2 additions & 3 deletions controllers/core/flagsourceconfiguration/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import (
"strings"
"time"

"github.com/go-logr/logr"
corev1alpha1 "github.com/open-feature/open-feature-operator/apis/core/v1alpha1"
"github.com/open-feature/open-feature-operator/controllers/common"
appsV1 "k8s.io/api/apps/v1"
"k8s.io/apimachinery/pkg/api/errors"
Expand All @@ -30,9 +32,6 @@ import (
"sigs.k8s.io/controller-runtime/pkg/builder"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/predicate"

"github.com/go-logr/logr"
corev1alpha1 "github.com/open-feature/open-feature-operator/apis/core/v1alpha1"
)

// FlagSourceConfigurationReconciler reconciles a FlagSourceConfiguration object
Expand Down
5 changes: 2 additions & 3 deletions webhooks/featureflagconfiguration_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@ import (
"net/http"
"strings"

schemas "github.com/open-feature/schemas/json"
"k8s.io/apimachinery/pkg/api/errors"

"github.com/go-logr/logr"
corev1alpha1 "github.com/open-feature/open-feature-operator/apis/core/v1alpha1"
schemas "github.com/open-feature/schemas/json"
"github.com/xeipuuv/gojsonschema"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
)
Expand Down
9 changes: 5 additions & 4 deletions webhooks/pod_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,17 @@ package webhooks
import (
"context"
"encoding/json"
goErr "errors"
"fmt"
controllercommon "github.com/open-feature/open-feature-operator/controllers/common"
"github.com/open-feature/open-feature-operator/controllers/common/constant"
"net/http"
"reflect"
"strings"
"time"

goErr "errors"

"github.com/go-logr/logr"
"github.com/open-feature/open-feature-operator/apis/core/v1alpha1"
controllercommon "github.com/open-feature/open-feature-operator/controllers/common"
"github.com/open-feature/open-feature-operator/controllers/common/constant"
"github.com/open-feature/open-feature-operator/pkg/utils"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
Expand Down Expand Up @@ -57,6 +56,8 @@ type PodMutator struct {
}

// Handle injects the flagd sidecar (if the prerequisites are all met)
//
//nolint:gocyclo
func (m *PodMutator) Handle(ctx context.Context, req admission.Request) admission.Response {
defer func() {
if err := recover(); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion webhooks/pod_webhook_component_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"encoding/json"
"fmt"
controllercommon "github.com/open-feature/open-feature-operator/controllers/common"
"reflect"
"testing"
"time"
Expand All @@ -14,6 +13,7 @@ import (
"github.com/open-feature/open-feature-operator/apis/core/v1alpha1"
corev1alpha2 "github.com/open-feature/open-feature-operator/apis/core/v1alpha2"
corev1alpha3 "github.com/open-feature/open-feature-operator/apis/core/v1alpha3"
controllercommon "github.com/open-feature/open-feature-operator/controllers/common"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
admissionv1 "k8s.io/api/admission/v1"
Expand Down
1 change: 1 addition & 0 deletions webhooks/pod_webhook_deprecated.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/open-feature/open-feature-operator/pkg/utils"
)

//nolint:gocyclo
func (m *PodMutator) handleFeatureFlagConfigurationAnnotation(ctx context.Context, fcConfig *v1alpha1.FlagSourceConfigurationSpec, ffconfigAnnotation string, defaultNamespace string) error {
for _, ffName := range parseList(ffconfigAnnotation) {
ns, name := utils.ParseAnnotation(ffName, defaultNamespace)
Expand Down
6 changes: 3 additions & 3 deletions webhooks/pod_webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ import (
"encoding/json"
"errors"
"fmt"
"github.com/golang/mock/gomock"
"github.com/open-feature/open-feature-operator/controllers/common/constant"
commonmock "github.com/open-feature/open-feature-operator/controllers/common/mock"
"net/http"
"reflect"
"testing"

"github.com/go-logr/logr/testr"
"github.com/golang/mock/gomock"
"github.com/open-feature/open-feature-operator/apis/core/v1alpha1"
"github.com/open-feature/open-feature-operator/apis/core/v1alpha2"
"github.com/open-feature/open-feature-operator/apis/core/v1alpha3"
"github.com/open-feature/open-feature-operator/controllers/common/constant"
commonmock "github.com/open-feature/open-feature-operator/controllers/common/mock"
"github.com/open-feature/open-feature-operator/pkg/utils"
"github.com/stretchr/testify/require"
admissionv1 "k8s.io/api/admission/v1"
Expand Down

0 comments on commit a2ce06b

Please sign in to comment.