Skip to content

Commit

Permalink
CircleCI 1.17 golang support (kube-logging#848)
Browse files Browse the repository at this point in the history
  • Loading branch information
ahma authored Oct 6, 2021
1 parent 9e95343 commit 79c0e85
Show file tree
Hide file tree
Showing 107 changed files with 273 additions and 270 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ executors:
jobs:
build:
docker:
- image: circleci/golang:1.16
- image: circleci/golang:1.17.1
environment:
GOFLAGS: -mod=readonly

Expand Down
36 changes: 1 addition & 35 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,48 +4,14 @@ run:
- client

linters-settings:
golint:
revive:
min-confidence: 0.9
gocyclo:
min-complexity: 15
# goimports:
# local-prefixes: github.com/banzaicloud/logging-operator

linters:
enable-all: true
disable:
- funlen
- dupl
- maligned
- wsl

# TODO: fix these
- gci
- godot
- nlreturn
- gomnd
- goerr113
- gofumpt
- exhaustivestruct
- wrapcheck
- deadcode
- unused
- goconst
- unparam
- nakedret
- prealloc
- errcheck
- gochecknoinits
- gochecknoglobals
- lll
- gosec
- stylecheck
- staticcheck
- gosimple
- gocritic
- godox
- gocyclo
- gocognit

issues:
exclude:
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ DRAIN_WATCH_IMAGE_TAG_NAME ?= ghcr.io/banzaicloud/fluentd-drain-watch
DRAIN_WATCH_IMAGE_TAG_VERSION ?= latest

CONTROLLER_GEN_VERSION = v0.5.0
GOLANGCI_VERSION = v1.33.0
GOLANGCI_VERSION = v1.42.1
KIND_VERSION = v0.11.1
LICENSEI_VERSION = v0.3.1
ENVTEST_CTRL_VERSION = v0.8.3
Expand Down
4 changes: 1 addition & 3 deletions controllers/logging_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ import (
"k8s.io/client-go/kubernetes/scheme"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
)

var (
Expand Down Expand Up @@ -1179,8 +1178,7 @@ func beforeEachWithError(t *testing.T, errors chan<- error) func() {
flowReconciler := controllers.NewLoggingReconciler(mgr.GetClient(), ctrl.Log.WithName("controllers").WithName("Flow"))

var stopped bool
var wrappedReconciler reconcile.Reconciler
wrappedReconciler = duplicateRequest(t, flowReconciler, &stopped, errors)
wrappedReconciler := duplicateRequest(t, flowReconciler, &stopped, errors)

err := controllers.SetupLoggingWithManager(mgr, ctrl.Log.WithName("manager").WithName("Setup")).
Named(uuid.New()[:8]).Complete(wrappedReconciler)
Expand Down
2 changes: 1 addition & 1 deletion pkg/resources/fluentbit/configsecret.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func (r *Reconciler) configSecret() (runtime.Object, reconciler.DesiredState, er
}
fluentbitInput.Values = fluentbitInputValues

disableKubernetesFilter := r.Logging.Spec.FluentbitSpec.DisableKubernetesFilter != nil && *r.Logging.Spec.FluentbitSpec.DisableKubernetesFilter == true
disableKubernetesFilter := r.Logging.Spec.FluentbitSpec.DisableKubernetesFilter != nil && *r.Logging.Spec.FluentbitSpec.DisableKubernetesFilter

if !disableKubernetesFilter {
if r.Logging.Spec.FluentbitSpec.FilterKubernetes.BufferSize == "" {
Expand Down
8 changes: 1 addition & 7 deletions pkg/resources/model/reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,7 @@ func NewValidationReconciler(
continue
}

co, ok := req.Obj.(client.Object)
if !ok {
errors.Append(errs, errors.New("unable to cast runtime.Object to client.Object"))
continue
}

if err := repo.Status().Patch(ctx, co, req.Patch); err != nil {
if err := repo.Status().Patch(ctx, req.Obj, req.Patch); err != nil {
errs = errors.Append(errs, err)
}
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/sdk/api/v1alpha1/clusterflow_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ import (

// +name:"ClusterFlow"
// +weight:"200"
type _hugoClusterFlow interface{}
type _hugoClusterFlow interface{} //nolint:deadcode,unused

// +name:"ClusterFlow"
// +version:"v1alpha1"
// +description:"ClusterFlow is the Schema for the clusterflows API"
type _metaClusterFlow interface{}
type _metaClusterFlow interface{} //nolint:deadcode,unused

// +kubebuilder:object:root=true
// +kubebuilder:resource:categories=logging-all
Expand Down
4 changes: 2 additions & 2 deletions pkg/sdk/api/v1alpha1/clusteroutput_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ import (

// +name:"ClusterOutput"
// +weight:"200"
type _hugoClusterOutput interface{}
type _hugoClusterOutput interface{} //nolint:deadcode,unused

// +name:"ClusterOutput"
// +version:"v1alpha1"
// +description:"ClusterOutput is the Schema for the clusteroutputs API"
type _metaClusterOutput interface{}
type _metaClusterOutput interface{} //nolint:deadcode,unused

// +kubebuilder:object:root=true
// +kubebuilder:resource:categories=logging-all
Expand Down
4 changes: 2 additions & 2 deletions pkg/sdk/api/v1alpha1/output_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ import (

// +name:"OutputSpec"
// +weight:"200"
type _hugoOutputSpec interface{}
type _hugoOutputSpec interface{} //nolint:deadcode,unused

// +name:"OutputSpec"
// +version:"v1alpha1"
// +description:"OutputSpec defines the desired state of Output"
type _metaOutputSpec interface{}
type _metaOutputSpec interface{} //nolint:deadcode,unused

// OutputSpec defines the desired state of Output
type OutputSpec struct {
Expand Down
1 change: 1 addition & 0 deletions pkg/sdk/api/v1alpha1/zz_generated.deepcopy.go

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

4 changes: 2 additions & 2 deletions pkg/sdk/api/v1beta1/clusterflow_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ import (

// +name:"ClusterFlow"
// +weight:"200"
type _hugoClusterFlow interface{}
type _hugoClusterFlow interface{} //nolint:deadcode,unused

// +name:"ClusterFlow"
// +version:"v1beta1"
// +description:"ClusterFlow is the Schema for the clusterflows API"
type _metaClusterFlow interface{}
type _metaClusterFlow interface{} //nolint:deadcode,unused

// +kubebuilder:object:root=true
// +kubebuilder:resource:categories=logging-all
Expand Down
4 changes: 2 additions & 2 deletions pkg/sdk/api/v1beta1/clusteroutput_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ import (

// +name:"ClusterOutput"
// +weight:"200"
type _hugoClusterOutput interface{}
type _hugoClusterOutput interface{} //nolint:deadcode,unused

// +name:"ClusterOutput"
// +version:"v1beta1"
// +description:"ClusterOutput is the Schema for the clusteroutputs API"
type _metaClusterOutput interface{}
type _metaClusterOutput interface{} //nolint:deadcode,unused

// +kubebuilder:object:root=true
// +kubebuilder:resource:categories=logging-all
Expand Down
4 changes: 2 additions & 2 deletions pkg/sdk/api/v1beta1/common_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ import (

// +name:"Common"
// +weight:"200"
type _hugoCommon interface{}
type _hugoCommon interface{} //nolint:deadcode,unused

// +name:"Common"
// +version:"v1beta1"
// +description:"ImageSpec Metrics Security"
type _metaCommon interface{}
type _metaCommon interface{} //nolint:deadcode,unused

const (
HostPath = "/opt/logging-operator/%s/%s"
Expand Down
4 changes: 2 additions & 2 deletions pkg/sdk/api/v1beta1/flow_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ import (

// +name:"FlowSpec"
// +weight:"200"
type _hugoFlowSpec interface{}
type _hugoFlowSpec interface{} //nolint:deadcode,unused

// +name:"FlowSpec"
// +version:"v1beta1"
// +description:"FlowSpec is the Kubernetes spec for Flows"
type _metaFlowSpec interface{}
type _metaFlowSpec interface{} //nolint:deadcode,unused

// FlowSpec is the Kubernetes spec for Flows
type FlowSpec struct {
Expand Down
4 changes: 2 additions & 2 deletions pkg/sdk/api/v1beta1/fluentbit_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ import (

// +name:"FluentbitSpec"
// +weight:"200"
type _hugoFluentbitSpec interface{}
type _hugoFluentbitSpec interface{} //nolint:deadcode,unused

// +name:"FluentbitSpec"
// +version:"v1beta1"
// +description:"FluentbitSpec defines the desired state of Fluentbit"
type _metaFluentbitSpec interface{}
type _metaFluentbitSpec interface{} //nolint:deadcode,unused

// +kubebuilder:object:generate=true

Expand Down
4 changes: 2 additions & 2 deletions pkg/sdk/api/v1beta1/fluentd_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ import (

// +name:"FluentdSpec"
// +weight:"200"
type _hugoFluentdSpec interface{}
type _hugoFluentdSpec interface{} //nolint:deadcode,unused

// +name:"FluentdSpec"
// +version:"v1beta1"
// +description:"FluentdSpec defines the desired state of Fluentd"
type _metaFluentdSpec interface{}
type _metaFluentdSpec interface{} //nolint:deadcode,unused

// +kubebuilder:object:generate=true

Expand Down
4 changes: 2 additions & 2 deletions pkg/sdk/api/v1beta1/logging_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ import (

// +name:"LoggingSpec"
// +weight:"200"
type _hugoLoggingSpec interface{}
type _hugoLoggingSpec interface{} //nolint:deadcode,unused

// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.

// +name:"Logging"
// +version:"v1beta1"
// +description:"Logging system configuration"
type _metaLoggingSpec interface{}
type _metaLoggingSpec interface{} //nolint:deadcode,unused

// LoggingSpec defines the desired state of Logging
type LoggingSpec struct {
Expand Down
4 changes: 2 additions & 2 deletions pkg/sdk/api/v1beta1/output_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ import (

// +name:"OutputSpec"
// +weight:"200"
type _hugoOutputSpec interface{}
type _hugoOutputSpec interface{} //nolint:deadcode,unused

// +name:"OutputSpec"
// +version:"v1beta1"
// +description:"OutputSpec defines the desired state of Output"
type _metaOutputSpec interface{}
type _metaOutputSpec interface{} //nolint:deadcode,unused

// OutputSpec defines the desired state of Output
type OutputSpec struct {
Expand Down
1 change: 1 addition & 0 deletions pkg/sdk/api/v1beta1/zz_generated.deepcopy.go

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

1 change: 1 addition & 0 deletions pkg/sdk/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ require (
github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring v0.43.0
github.com/shurcooL/vfsgen v0.0.0-20181202132449-6a9ea43bcacd
github.com/spf13/cast v1.3.1
github.com/stretchr/testify v1.7.0
go.uber.org/zap v1.18.1
golang.org/x/net v0.0.0-20210428140749-89ef3d95e781
k8s.io/api v0.21.3
Expand Down
4 changes: 2 additions & 2 deletions pkg/sdk/model/common/security.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ import (

// +name:"Security"
// +weight:"200"
type _hugoSecurity interface{}
type _hugoSecurity interface{} //nolint:deadcode,unused

// +name:"Security"
type _metaSecurity interface{}
type _metaSecurity interface{} //nolint:deadcode,unused

type Security struct {
// Hostname
Expand Down
4 changes: 2 additions & 2 deletions pkg/sdk/model/common/transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ import (

// +name:"Transport"
// +weight:"200"
type _hugoTransport interface{}
type _hugoTransport interface{} //nolint:deadcode,unused

// +name:"Transport"
type _metaTransport interface{}
type _metaTransport interface{} //nolint:deadcode,unused

type Transport struct {
// Protocol Default: :tcp
Expand Down
8 changes: 4 additions & 4 deletions pkg/sdk/model/filter/concat.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,19 @@ import (

// +name:"Concat"
// +weight:"200"
type _hugoConcat interface{}
type _hugoConcat interface{} //nolint:deadcode,unused

// +kubebuilder:object:generate=true
// +docName:"[Concat Filter](https://github.com/fluent-plugins-nursery/fluent-plugin-concat)"
// Fluentd Filter plugin to concatenate multiline log separated in multiple events.
type _docConcat interface{}
type _docConcat interface{} //nolint:deadcode,unused

// +name:"Concat"
// +url:"https://github.com/fluent-plugins-nursery/fluent-plugin-concat"
// +version:"2.5.0"
// +description:"Fluentd Filter plugin to concatenate multiline log separated in multiple events."
// +status:"GA"
type _metaConcat interface{}
type _metaConcat interface{} //nolint:deadcode,unused

// +kubebuilder:object:generate=true
type Concat struct {
Expand Down Expand Up @@ -96,7 +96,7 @@ type Concat struct {
// partial_key partial_message
//</filter>
// ```
type _expConcat interface{}
type _expConcat interface{} //nolint:deadcode,unused

func (c *Concat) ToDirective(secretLoader secret.SecretLoader, id string) (types.Directive, error) {
const pluginType = "concat"
Expand Down
3 changes: 2 additions & 1 deletion pkg/sdk/model/filter/concat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"github.com/banzaicloud/logging-operator/pkg/sdk/model/filter"
"github.com/banzaicloud/logging-operator/pkg/sdk/model/render"
"github.com/ghodss/yaml"
"github.com/stretchr/testify/require"
)

func TestConcat(t *testing.T) {
Expand All @@ -39,7 +40,7 @@ n_lines: 10
</filter>
`
parser := &filter.Concat{}
yaml.Unmarshal(CONFIG, parser)
require.NoError(t, yaml.Unmarshal(CONFIG, parser))
test := render.NewOutputPluginTest(t, parser)
test.DiffResult(expected)
}
Loading

0 comments on commit 79c0e85

Please sign in to comment.