Skip to content

Commit

Permalink
chore: fixup null-out
Browse files Browse the repository at this point in the history
Signed-off-by: Bence Csati <[email protected]>
  • Loading branch information
csatib02 committed Nov 2, 2024
1 parent 5d8c774 commit 95288f8
Show file tree
Hide file tree
Showing 14 changed files with 150 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4731,6 +4731,9 @@ spec:
type: object
type: object
nullout:
properties:
never_flush:
type: boolean
type: object
opensearch:
properties:
Expand Down Expand Up @@ -12134,6 +12137,9 @@ spec:
type: object
type: object
nullout:
properties:
never_flush:
type: boolean
type: object
opensearch:
properties:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4395,6 +4395,9 @@ spec:
type: object
type: object
nullout:
properties:
never_flush:
type: boolean
type: object
opensearch:
properties:
Expand Down Expand Up @@ -11404,6 +11407,9 @@ spec:
type: object
type: object
nullout:
properties:
never_flush:
type: boolean
type: object
opensearch:
properties:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4728,6 +4728,9 @@ spec:
type: object
type: object
nullout:
properties:
never_flush:
type: boolean
type: object
opensearch:
properties:
Expand Down Expand Up @@ -12131,6 +12134,9 @@ spec:
type: object
type: object
nullout:
properties:
never_flush:
type: boolean
type: object
opensearch:
properties:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4392,6 +4392,9 @@ spec:
type: object
type: object
nullout:
properties:
never_flush:
type: boolean
type: object
opensearch:
properties:
Expand Down Expand Up @@ -11401,6 +11404,9 @@ spec:
type: object
type: object
nullout:
properties:
never_flush:
type: boolean
type: object
opensearch:
properties:
Expand Down
1 change: 0 additions & 1 deletion cmd/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ func plugins() {
logger.WithName("pluginlister"))

lister.IgnoredSources = []string{
"null",
".*.deepcopy",
".*_test",
}
Expand Down
6 changes: 6 additions & 0 deletions config/crd/bases/logging.banzaicloud.io_clusteroutputs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4728,6 +4728,9 @@ spec:
type: object
type: object
nullout:
properties:
never_flush:
type: boolean
type: object
opensearch:
properties:
Expand Down Expand Up @@ -12131,6 +12134,9 @@ spec:
type: object
type: object
nullout:
properties:
never_flush:
type: boolean
type: object
opensearch:
properties:
Expand Down
6 changes: 6 additions & 0 deletions config/crd/bases/logging.banzaicloud.io_outputs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4392,6 +4392,9 @@ spec:
type: object
type: object
nullout:
properties:
never_flush:
type: boolean
type: object
opensearch:
properties:
Expand Down Expand Up @@ -11401,6 +11404,9 @@ spec:
type: object
type: object
nullout:
properties:
never_flush:
type: boolean
type: object
opensearch:
properties:
Expand Down
1 change: 1 addition & 0 deletions docs/configuration/plugins/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ For more information please click on the plugin name
| **[Grafana Loki](outputs/loki/)** | outputs | Transfer logs to Loki | GA | [1.2.19](https://github.com/grafana/loki/tree/master/fluentd/fluent-plugin-grafana-loki) |
| **[Mattermost](outputs/mattermost/)** | outputs | Sends logs to Mattermost via webhooks. | GA | [0.2.2](https://github.com/levigo-systems/fluent-plugin-mattermost) |
| **[NewRelic Logs](outputs/newrelic/)** | outputs | Send logs to New Relic Logs | GA | [1.2.1](https://github.com/newrelic/newrelic-fluentd-output) |
| **[Null](outputs/null/)** | outputs | Null output plugin just throws away events. | GA | [more info](https://docs.fluentd.org/output/null) |
| **[OpenSearch](outputs/opensearch/)** | outputs | Send your logs to OpenSearch | GA | [1.0.5](https://github.com/fluent/fluent-plugin-opensearch/releases/tag/v1.0.5) |
| **[Alibaba Cloud Storage](outputs/oss/)** | outputs | Store logs the Alibaba Cloud Object Storage Service | GA | [0.0.2](https://github.com/aliyun/fluent-plugin-oss) |
| **[Redis](outputs/redis/)** | outputs | Sends logs to Redis endpoints. | GA | [0.3.5](https://github.com/fluent-plugins-nursery/fluent-plugin-redis) |
Expand Down
30 changes: 30 additions & 0 deletions docs/configuration/plugins/outputs/null.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
title: Null
weight: 200
generated_file: true
---

# Null output plugin for Fluentd
## Overview


For details, see [https://docs.fluentd.org/output/null](https://docs.fluentd.org/output/null).

## Example output configurations

```yaml
spec:
nullout:
never_flush: false
```
## Configuration
## NullOutputConfig
### never_flush (*bool, optional) {#nulloutputconfig-never_flush}
The parameter for testing to simulate the output plugin that never succeeds to flush.
2 changes: 1 addition & 1 deletion pkg/sdk/logging/api/v1alpha1/zz_generated.deepcopy.go

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

2 changes: 1 addition & 1 deletion pkg/sdk/logging/api/v1beta1/zz_generated.deepcopy.go

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

38 changes: 32 additions & 6 deletions pkg/sdk/logging/model/output/null.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,21 @@ import (
// +weight:"200"
type _hugoNull interface{} //nolint:deadcode,unused

// +docName:"Null output plugin for Fluentd"
//
/*
For details, see [https://docs.fluentd.org/output/null](https://docs.fluentd.org/output/null).
## Example output configurations
```yaml
spec:
nullout:
never_flush: false
```
*/
type _docNull interface{} //nolint:deadcode,unused

// +name:"Null"
// +url:"https://docs.fluentd.org/output/null"
// +version:"more info"
Expand All @@ -33,6 +48,8 @@ type _metaNull interface{} //nolint:deadcode,unused
// +kubebuilder:object:generate=true

type NullOutputConfig struct {
// The parameter for testing to simulate the output plugin that never succeeds to flush.
NeverFlush *bool `json:"never_flush,omitempty"`
}

func NewNullOutputConfig() *NullOutputConfig {
Expand All @@ -41,10 +58,19 @@ func NewNullOutputConfig() *NullOutputConfig {

func (c *NullOutputConfig) ToDirective(secretLoader secret.SecretLoader, id string) (types.Directive, error) {
const pluginType = "null"
return types.NewFlatDirective(types.PluginMeta{
Type: pluginType,
Directive: "match",
Tag: "**",
Id: id,
}, c, secretLoader)
null := &types.OutputPlugin{
PluginMeta: types.PluginMeta{
Type: pluginType,
Directive: "match",
Tag: "**",
Id: id,
},
}
if params, err := types.NewStructToStringMapper(secretLoader).StringsMap(c); err != nil {
return nil, err
} else {
null.Params = params
}

return null, nil
}
44 changes: 44 additions & 0 deletions pkg/sdk/logging/model/output/null_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Copyright © 2024 Kube logging authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package output_test

import (
"testing"

"github.com/stretchr/testify/require"
"sigs.k8s.io/yaml"

"github.com/kube-logging/logging-operator/pkg/sdk/logging/model/output"
"github.com/kube-logging/logging-operator/pkg/sdk/logging/model/render"
)

func TestNull(t *testing.T) {
CONFIG := []byte(`
never_flush: false
`)

expected := `
<match **>
@type null
@id test
never_flush false
</match>
`

null := &output.NullOutputConfig{}
require.NoError(t, yaml.Unmarshal(CONFIG, null))
test := render.NewOutputPluginTest(t, null)
test.DiffResult(expected)
}
5 changes: 5 additions & 0 deletions pkg/sdk/logging/model/output/zz_generated.deepcopy.go

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

0 comments on commit 95288f8

Please sign in to comment.