Skip to content
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
12 changes: 6 additions & 6 deletions internal/generator/fluentd/conf.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ package fluentd

import (
logging "github.com/openshift/cluster-logging-operator/apis/logging/v1"
"github.com/openshift/cluster-logging-operator/internal/generator"
"github.com/openshift/cluster-logging-operator/internal/generator/framework"
corev1 "k8s.io/api/core/v1"
)

//nolint:govet // using declarative style
func Conf(clspec *logging.CollectionSpec, secrets map[string]*corev1.Secret, clfspec *logging.ClusterLogForwarderSpec, namespace, name string, op generator.Options) []generator.Section {
return []generator.Section{
func Conf(clspec *logging.CollectionSpec, secrets map[string]*corev1.Secret, clfspec *logging.ClusterLogForwarderSpec, namespace, name string, op framework.Options) []framework.Section {
return []framework.Section{
{
Header(op),
`Generated fluentd conf Header`,
Expand Down Expand Up @@ -44,7 +44,7 @@ func Conf(clspec *logging.CollectionSpec, secrets map[string]*corev1.Secret, clf
}
}

func Header(op generator.Options) []generator.Element {
func Header(op framework.Options) []framework.Element {
const Header = `
{{define "header" -}}
## CLO GENERATED CONFIGURATION ###
Expand All @@ -56,8 +56,8 @@ func Header(op generator.Options) []generator.Element {
</system>
{{end}}
`
return []generator.Element{
generator.ConfLiteral{
return []framework.Element{
framework.ConfLiteral{
TemplateName: "header",
TemplateStr: Header,
},
Expand Down
6 changes: 3 additions & 3 deletions internal/generator/fluentd/conf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
_ "embed"
"encoding/json"
"fmt"
"github.com/openshift/cluster-logging-operator/internal/generator/framework"
"strings"

"github.com/openshift/cluster-logging-operator/internal/constants"
Expand All @@ -17,7 +18,6 @@ import (
. "github.com/onsi/ginkgo/extensions/table"
. "github.com/onsi/gomega"
logging "github.com/openshift/cluster-logging-operator/apis/logging/v1"
"github.com/openshift/cluster-logging-operator/internal/generator"
corev1 "k8s.io/api/core/v1"
)

Expand All @@ -27,8 +27,8 @@ var ExpectedFluentConf string
// TODO: Use a detailed CLF spec
var _ = Describe("Testing Complete Config Generation", func() {
var f = func(testcase testhelpers.ConfGenerateTest) {
g := generator.MakeGenerator()
e := generator.MergeSections(Conf(&testcase.CLSpec, testcase.Secrets, &testcase.CLFSpec, constants.OpenshiftNS, constants.SingletonName, generator.Options{generator.ClusterTLSProfileSpec: tls.GetClusterTLSProfileSpec(nil)}))
g := framework.MakeGenerator()
e := framework.MergeSections(Conf(&testcase.CLSpec, testcase.Secrets, &testcase.CLFSpec, constants.OpenshiftNS, constants.SingletonName, framework.Options{framework.ClusterTLSProfileSpec: tls.GetClusterTLSProfileSpec(nil)}))
conf, err := g.GenerateConf(e...)
Expect(err).To(BeNil())
diff := cmp.Diff(
Expand Down
8 changes: 4 additions & 4 deletions internal/generator/fluentd/elements/copy.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package elements

import (
"github.com/openshift/cluster-logging-operator/internal/generator"
"github.com/openshift/cluster-logging-operator/internal/generator/framework"
)

type Copy struct {
DeepCopy bool
Stores []generator.Element
Stores []framework.Element
}

func (c Copy) Name() string {
Expand All @@ -23,8 +23,8 @@ copy_mode deep
{{end}}`
}

func CopyToLabels(labels []string) []generator.Element {
s := []generator.Element{}
func CopyToLabels(labels []string) []framework.Element {
s := []framework.Element{}
for _, l := range labels {
s = append(s, Store{
Element: Relabel{
Expand Down
4 changes: 2 additions & 2 deletions internal/generator/fluentd/elements/filter.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package elements

import (
"github.com/openshift/cluster-logging-operator/internal/generator"
"github.com/openshift/cluster-logging-operator/internal/generator/framework"
)

type Filter struct {
Desc string
MatchTags string
Element generator.Element
Element framework.Element
}

func (f Filter) Name() string {
Expand Down
2 changes: 1 addition & 1 deletion internal/generator/fluentd/elements/keyval_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ package elements

import (
"fmt"
. "github.com/openshift/cluster-logging-operator/internal/generator/framework"
"strings"
"testing"

"github.com/google/go-cmp/cmp"
. "github.com/openshift/cluster-logging-operator/internal/generator"
)

type FluentConfig struct {
Expand Down
8 changes: 4 additions & 4 deletions internal/generator/fluentd/elements/label.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package elements

import (
"github.com/openshift/cluster-logging-operator/internal/generator"
"github.com/openshift/cluster-logging-operator/internal/generator/framework"
)

type FromLabel struct {
generator.InLabel
SubElements []generator.Element
framework.InLabel
SubElements []framework.Element
Desc string
}

Expand All @@ -25,7 +25,7 @@ func (f FromLabel) Template() string {
{{end}}`
}

func (f FromLabel) Elements() []generator.Element {
func (f FromLabel) Elements() []framework.Element {
return f.SubElements
}

Expand Down
4 changes: 2 additions & 2 deletions internal/generator/fluentd/elements/match.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package elements

import (
"github.com/openshift/cluster-logging-operator/internal/generator"
"github.com/openshift/cluster-logging-operator/internal/generator/framework"
)

type Match struct {
Desc string
MatchTags string
MatchElement generator.Element
MatchElement framework.Element
}

func (m Match) Name() string {
Expand Down
4 changes: 2 additions & 2 deletions internal/generator/fluentd/elements/relabel.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package elements

import (
"github.com/openshift/cluster-logging-operator/internal/generator"
"github.com/openshift/cluster-logging-operator/internal/generator/framework"
)

type Relabel struct {
generator.OutLabel
framework.OutLabel
}

func (r Relabel) Name() string {
Expand Down
4 changes: 2 additions & 2 deletions internal/generator/fluentd/elements/store.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package elements

import (
"github.com/openshift/cluster-logging-operator/internal/generator"
"github.com/openshift/cluster-logging-operator/internal/generator/framework"
)

type Store struct {
Element generator.Element
Element framework.Element
}

func (s Store) Name() string {
Expand Down
32 changes: 16 additions & 16 deletions internal/generator/fluentd/fluent_conf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ package fluentd

import (
_ "embed"
"github.com/openshift/cluster-logging-operator/internal/generator/helpers/security"

. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/extensions/table"
. "github.com/onsi/gomega"
logging "github.com/openshift/cluster-logging-operator/apis/logging/v1"
"github.com/openshift/cluster-logging-operator/internal/constants"
"github.com/openshift/cluster-logging-operator/internal/generator"
"github.com/openshift/cluster-logging-operator/internal/generator/framework"
"github.com/openshift/cluster-logging-operator/internal/generator/helpers/security"
"github.com/openshift/cluster-logging-operator/internal/generator/utils"
"github.com/openshift/cluster-logging-operator/internal/tls"
. "github.com/openshift/cluster-logging-operator/test/matchers"
"gopkg.in/yaml.v2"
Expand Down Expand Up @@ -38,8 +38,8 @@ var ExpectedValidForwardersConf string
var _ = Describe("Generating fluentd config", func() {
var (
forwarder *logging.ClusterLogForwarderSpec
g generator.Generator
op generator.Options = generator.Options{generator.ClusterTLSProfileSpec: tls.GetClusterTLSProfileSpec(nil)}
g framework.Generator
op framework.Options = framework.Options{framework.ClusterTLSProfileSpec: tls.GetClusterTLSProfileSpec(nil)}
secret corev1.Secret
secretData = map[string][]byte{
"tls.key": []byte("test-key"),
Expand Down Expand Up @@ -75,8 +75,8 @@ var _ = Describe("Generating fluentd config", func() {
)

BeforeEach(func() {
g = generator.MakeGenerator()
op = generator.Options{generator.ClusterTLSProfileSpec: tls.GetClusterTLSProfileSpec(nil)}
g = framework.MakeGenerator()
op = framework.Options{framework.ClusterTLSProfileSpec: tls.GetClusterTLSProfileSpec(nil)}
forwarder = &logging.ClusterLogForwarderSpec{
Outputs: []logging.OutputSpec{
{
Expand Down Expand Up @@ -207,7 +207,7 @@ var _ = Describe("Generating fluentd config", func() {
Data: secretData,
},
}
c := generator.MergeSections(Conf(nil, secrets, forwarder, constants.OpenshiftNS, constants.SingletonName, op))
c := framework.MergeSections(Conf(nil, secrets, forwarder, constants.OpenshiftNS, constants.SingletonName, op))
results, err := g.GenerateConf(c...)
Expect(err).To(BeNil())

Expand Down Expand Up @@ -286,7 +286,7 @@ var _ = Describe("Generating fluentd config", func() {
Data: secretData,
},
}
c := generator.MergeSections(Conf(nil, secrets, forwarder, constants.OpenshiftNS, constants.SingletonName, op))
c := framework.MergeSections(Conf(nil, secrets, forwarder, constants.OpenshiftNS, constants.SingletonName, op))
results, err := g.GenerateConf(c...)
Expect(err).To(BeNil())
Expect(results).To(EqualTrimLines(ExpectedPodLabelsConf))
Expand Down Expand Up @@ -366,7 +366,7 @@ var _ = Describe("Generating fluentd config", func() {
Data: secretData,
},
}
c := generator.MergeSections(Conf(nil, secrets, forwarder, constants.OpenshiftNS, constants.SingletonName, op))
c := framework.MergeSections(Conf(nil, secrets, forwarder, constants.OpenshiftNS, constants.SingletonName, op))
results, err := g.GenerateConf(c...)
Expect(err).To(BeNil())
Expect(results).To(EqualTrimLines(ExpectedPodLabelsNSConf))
Expand All @@ -389,21 +389,21 @@ var _ = Describe("Generating fluentd config", func() {
},
},
}
c := generator.MergeSections(Conf(nil, nil, forwarder, constants.OpenshiftNS, constants.SingletonName, op))
c := framework.MergeSections(Conf(nil, nil, forwarder, constants.OpenshiftNS, constants.SingletonName, op))
results, err := g.GenerateConf(c...)
Expect(err).To(BeNil())
Expect(results).To(EqualTrimLines(ExpectedExcludeConf))
})

It("should produce well formed fluent.conf", func() {
c := generator.MergeSections(Conf(nil, secrets, forwarder, constants.OpenshiftNS, constants.SingletonName, op))
c := framework.MergeSections(Conf(nil, secrets, forwarder, constants.OpenshiftNS, constants.SingletonName, op))
results, err := g.GenerateConf(c...)
Expect(err).To(BeNil())
Expect(results).To(EqualTrimLines(ExpectedWellFormedConf))
})

It("should generate sources for reserved inputs used as names or types", func() {
sources := generator.GatherSources(&logging.ClusterLogForwarderSpec{
sources := utils.GatherSources(&logging.ClusterLogForwarderSpec{
Inputs: []logging.InputSpec{{Name: "in", Application: &logging.Application{}}},
Pipelines: []logging.PipelineSpec{
{
Expand All @@ -415,7 +415,7 @@ var _ = Describe("Generating fluentd config", func() {
OutputRefs: []string{"default"},
},
},
}, generator.NoOptions)
}, framework.NoOptions)
Expect(sources.List()).To(ContainElements("application", "audit"))
})

Expand Down Expand Up @@ -478,9 +478,9 @@ var _ = Describe("Generating fluentd config", func() {
func(yamlSpec, wantFluentdConf string) {
var spec logging.ClusterLogForwarderSpec
Expect(yaml.Unmarshal([]byte(yamlSpec), &spec)).To(Succeed())
g := generator.MakeGenerator()
g := framework.MakeGenerator()
s := Conf(nil, security.NoSecrets, &spec, constants.OpenshiftNS, constants.SingletonName, op)
gotFluentdConf, err := g.GenerateConf(generator.MergeSections(s)...)
gotFluentdConf, err := g.GenerateConf(framework.MergeSections(s)...)
Expect(err).To(Succeed())
Expect(gotFluentdConf).To(EqualTrimLines(wantFluentdConf))
},
Expand Down
6 changes: 3 additions & 3 deletions internal/generator/fluentd/generators_test.go
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
package fluentd

import (
"github.com/openshift/cluster-logging-operator/internal/generator/framework"
. "github.com/openshift/cluster-logging-operator/test/matchers"

. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"

logging "github.com/openshift/cluster-logging-operator/apis/logging/v1"
"github.com/openshift/cluster-logging-operator/internal/generator"
)

var _ = Describe("Generating pipeline to output labels", func() {
var (
g generator.Generator
g framework.Generator
)
BeforeEach(func() {
g = generator.MakeGenerator()
g = framework.MakeGenerator()
})

It("should generate no labels for a single pipeline", func() {
Expand Down
2 changes: 1 addition & 1 deletion internal/generator/fluentd/ingress.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ package fluentd

import (
logging "github.com/openshift/cluster-logging-operator/apis/logging/v1"
. "github.com/openshift/cluster-logging-operator/internal/generator"
. "github.com/openshift/cluster-logging-operator/internal/generator/fluentd/elements"
"github.com/openshift/cluster-logging-operator/internal/generator/fluentd/helpers"
. "github.com/openshift/cluster-logging-operator/internal/generator/framework"
)

func Concat(spec *logging.ClusterLogForwarderSpec, o Options) []Element {
Expand Down
6 changes: 3 additions & 3 deletions internal/generator/fluentd/inputes_to_pipeline_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/extensions/table"
logging "github.com/openshift/cluster-logging-operator/apis/logging/v1"
"github.com/openshift/cluster-logging-operator/internal/generator"
"github.com/openshift/cluster-logging-operator/internal/generator/framework"
"github.com/openshift/cluster-logging-operator/test/helpers"
corev1 "k8s.io/api/core/v1"
)

var _ = Describe("Generating conf to route entries to pipelines", func() {

DescribeTable("#SourceTypeToPipeline", func(sourceType string, conf helpers.ConfGenerateTest) {
helpers.TestGenerateConfWith(func(clspec logging.CollectionSpec, secrets map[string]*corev1.Secret, clfspec logging.ClusterLogForwarderSpec, op generator.Options) []generator.Element {
return []generator.Element{SourceTypeToPipeline(sourceType, &clfspec, generator.NoOptions)}
helpers.TestGenerateConfWith(func(clspec logging.CollectionSpec, secrets map[string]*corev1.Secret, clfspec logging.ClusterLogForwarderSpec, op framework.Options) []framework.Element {
return []framework.Element{SourceTypeToPipeline(sourceType, &clfspec, framework.NoOptions)}
})(conf)
},
Entry("should deep copy when parsing is enabled and more then one pipeline", logging.InputNameApplication, helpers.ConfGenerateTest{
Expand Down
2 changes: 1 addition & 1 deletion internal/generator/fluentd/inputs_to_pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ package fluentd

import (
"fmt"
. "github.com/openshift/cluster-logging-operator/internal/generator/framework"
"strings"

logging "github.com/openshift/cluster-logging-operator/apis/logging/v1"
. "github.com/openshift/cluster-logging-operator/internal/generator"
. "github.com/openshift/cluster-logging-operator/internal/generator/fluentd/elements"
"github.com/openshift/cluster-logging-operator/internal/generator/fluentd/helpers"
)
Expand Down
Loading