Skip to content

Commit

Permalink
Fix Code format (including comment)
Browse files Browse the repository at this point in the history
Signed-off-by: fengshunli <1171313930@qq.com>
  • Loading branch information
fengshunli committed Feb 15, 2023
1 parent f94c976 commit 4911e35
Show file tree
Hide file tree
Showing 25 changed files with 74 additions and 71 deletions.
6 changes: 3 additions & 3 deletions apis/fluentbit/v1alpha2/clusterfilter_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ type FilterItem struct {
Throttle *filter.Throttle `json:"throttle,omitempty"`
// RewriteTag defines a RewriteTag configuration.
RewriteTag *filter.RewriteTag `json:"rewriteTag,omitempty"`
//Aws defines a Aws configuration.
// Aws defines a Aws configuration.
AWS *filter.AWS `json:"aws,omitempty"`
//Multiline defines a Multiline configuration.
// Multiline defines a Multiline configuration.
Multiline *filter.Multiline `json:"multiline,omitempty"`
//CustomPlugin defines a Custom plugin configuration.
// CustomPlugin defines a Custom plugin configuration.
CustomPlugin *custom.CustomPlugin `json:"customPlugin,omitempty"`
}

Expand Down
6 changes: 4 additions & 2 deletions apis/fluentbit/v1alpha2/clusterfluentbitconfig_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ type FluentBitConfigSpec struct {
OutputSelector metav1.LabelSelector `json:"outputSelector,omitempty"`
// Select parser plugins
ParserSelector metav1.LabelSelector `json:"parserSelector,omitempty"`
//If namespace is defined, then the configmap and secret for fluent-bit is in this namespace.
//If it is not defined, it is in the namespace of the fluentd-operator
// If namespace is defined, then the configmap and secret for fluent-bit is in this namespace.
// If it is not defined, it is in the namespace of the fluentd-operator
Namespace *string `json:"namespace,omitempty"`
}

Expand Down Expand Up @@ -179,12 +179,14 @@ func (cfg ClusterFluentBitConfig) RenderParserConfig(sl plugins.SecretLoader, pa
}

// +kubebuilder:object:generate:=false

type Script struct {
Name string
Content string
}

// +kubebuilder:object:generate:=false

// ByName implements sort.Interface for []Script based on the Name field.
type ByName []Script

Expand Down
3 changes: 2 additions & 1 deletion apis/fluentbit/v1alpha2/clusteroutput_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ type OutputSpec struct {
DataDog *output.DataDog `json:"datadog,omitempty"`
// Firehose defines Firehose Output configuration.
Fireose *output.Firehose `json:"firehose,omitempty"`
//Splunk defines Splunk Output Configuration
// Splunk defines Splunk Output Configuration
Splunk *output.Splunk `json:"splunk,omitempty"`
// OpenSearch defines OpenSearch Output configuration.
OpenSearch *output.OpenSearch `json:"opensearch,omitempty"`
Expand Down Expand Up @@ -107,6 +107,7 @@ type ClusterOutputList struct {
}

// +kubebuilder:object:generate:=false

// OutputByName implements sort.Interface for []ClusterOutput based on the Name field.
type OutputByName []ClusterOutput

Expand Down
1 change: 1 addition & 0 deletions apis/fluentbit/v1alpha2/clusterparser_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ type ClusterParserList struct {
}

// +kubebuilder:object:generate:=false

// ParserByName implements sort.Interface for []ClusterParser based on the Name field.
type ParserByName []ClusterParser

Expand Down
2 changes: 1 addition & 1 deletion apis/fluentbit/v1alpha2/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ limitations under the License.
// +k8s:deepcopy-gen=package
// +groupName=fluentbit.fluent.io

package v1alpha2 // import "github.com/fluent/fluent-operator/apis/fluentbit/v1alpha2"
package v1alpha2 // Package v1alpha2 import "github.com/fluent/fluent-operator/apis/fluentbit/v1alpha2"
2 changes: 1 addition & 1 deletion apis/fluentd/v1alpha1/clusterfilter_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ type ClusterFilter struct {
Status ClusterFilterStatus `json:"status,omitempty"`
}

//+kubebuilder:object:root=true
// +kubebuilder:object:root=true

// ClusterFilterList contains a list of ClusterFilter
type ClusterFilterList struct {
Expand Down
2 changes: 1 addition & 1 deletion apis/fluentd/v1alpha1/clusterfluentdconfig_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ type ClusterFluentdConfig struct {
Status ClusterFluentdConfigStatus `json:"status,omitempty"`
}

//+kubebuilder:object:root=true
// +kubebuilder:object:root=true

// ClusterFluentdConfigList contains a list of ClusterFluentdConfig
type ClusterFluentdConfigList struct {
Expand Down
2 changes: 1 addition & 1 deletion apis/fluentd/v1alpha1/clusteroutput_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ type ClusterOutput struct {
Status ClusterOutputStatus `json:"status,omitempty"`
}

//+kubebuilder:object:root=true
// +kubebuilder:object:root=true

// ClusterOutputList contains a list of ClusterOutput
type ClusterOutputList struct {
Expand Down
10 changes: 5 additions & 5 deletions apis/fluentd/v1alpha1/filter_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ type FilterStatus struct {
// Important: Run "make" to regenerate code after modifying this file
}

//+kubebuilder:object:root=true
//+kubebuilder:subresource:status
//+kubebuilder:resource:shortName=fdf
//+genclient
// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:resource:shortName=fdf
// +genclient

// Filter is the Schema for the filters API
type Filter struct {
Expand All @@ -46,7 +46,7 @@ type Filter struct {
Status FilterStatus `json:"status,omitempty"`
}

//+kubebuilder:object:root=true
// +kubebuilder:object:root=true

// FilterList contains a list of Filter
type FilterList struct {
Expand Down
10 changes: 5 additions & 5 deletions apis/fluentd/v1alpha1/fluentd_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,10 @@ type FluentdStatus struct {
State StatusState `json:"state,omitempty"`
}

//+kubebuilder:object:root=true
//+kubebuilder:subresource:status
//+kubebuilder:resource:shortName=fd
//+genclient
// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:resource:shortName=fd
// +genclient

// Fluentd is the Schema for the fluentds API
type Fluentd struct {
Expand Down Expand Up @@ -127,7 +127,7 @@ func (fd *Fluentd) RemoveFinalizer(finalizerName string) {
fd.ObjectMeta.Finalizers = utils.RemoveString(fd.ObjectMeta.Finalizers, finalizerName)
}

//+kubebuilder:object:root=true
// +kubebuilder:object:root=true

// FluentdList contains a list of Fluentd
type FluentdList struct {
Expand Down
10 changes: 5 additions & 5 deletions apis/fluentd/v1alpha1/fluentdconfig_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ type FluentdConfigStatus struct {
State StatusState `json:"state,omitempty"`
}

//+kubebuilder:object:root=true
//+kubebuilder:subresource:status
//+kubebuilder:resource:shortName=fdc
//+genclient
// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:resource:shortName=fdc
// +genclient

// FluentdConfig is the Schema for the fluentdconfigs API
type FluentdConfig struct {
Expand All @@ -69,7 +69,7 @@ type FluentdConfig struct {
Status FluentdConfigStatus `json:"status,omitempty"`
}

//+kubebuilder:object:root=true
// +kubebuilder:object:root=true

// FluentdConfigList contains a list of FluentdConfig
type FluentdConfigList struct {
Expand Down
10 changes: 5 additions & 5 deletions apis/fluentd/v1alpha1/output_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ type OutputStatus struct {
// Important: Run "make" to regenerate code after modifying this file
}

//+kubebuilder:object:root=true
//+kubebuilder:subresource:status
//+kubebuilder:resource:shortName=fdo
//+genclient
// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:resource:shortName=fdo
// +genclient

// Output is the Schema for the outputs API
type Output struct {
Expand All @@ -49,7 +49,7 @@ type Output struct {
Status OutputStatus `json:"status,omitempty"`
}

//+kubebuilder:object:root=true
// +kubebuilder:object:root=true

// OutputList contains a list of Output
type OutputList struct {
Expand Down
8 changes: 4 additions & 4 deletions cmd/fluent-manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import (
fluentdv1alpha1 "github.com/fluent/fluent-operator/apis/fluentd/v1alpha1"

"github.com/fluent/fluent-operator/controllers"
//+kubebuilder:scaffold:imports
// +kubebuilder:scaffold:imports
)

var (
Expand All @@ -52,7 +52,7 @@ func init() {

utilruntime.Must(fluentbitv1alpha2.AddToScheme(scheme))
utilruntime.Must(fluentdv1alpha1.AddToScheme(scheme))
//+kubebuilder:scaffold:scheme
// +kubebuilder:scaffold:scheme
}

func main() {
Expand Down Expand Up @@ -131,7 +131,7 @@ func main() {
setupLog.Error(err, "unable to create controller", "controller", "FluentBit")
os.Exit(1)
}
//+kubebuilder:scaffold:builder
// +kubebuilder:scaffold:builder

if err = (&controllers.FluentdConfigReconciler{
Client: mgr.GetClient(),
Expand All @@ -150,7 +150,7 @@ func main() {
setupLog.Error(err, "unable to create controller", "controller", "Fluentd")
os.Exit(1)
}
//+kubebuilder:scaffold:builder
// +kubebuilder:scaffold:builder

if err := mgr.AddHealthzCheck("healthz", healthz.Ping); err != nil {
setupLog.Error(err, "unable to set up health check")
Expand Down
12 changes: 6 additions & 6 deletions controllers/collector_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ type CollectorReconciler struct {
Scheme *runtime.Scheme
}

//+kubebuilder:rbac:groups=fluentbit.fluent.io,resources=fluentbits;fluentbitconfigs;collectors;inputs;filters;outputs,verbs=get;list;watch;create;update;patch;delete
//+kubebuilder:rbac:groups=apps,resources=statefulsets,verbs=get;list;watch;create;update;patch;delete
//+kubebuilder:rbac:groups=core,resources=serviceaccounts,verbs=get;list;watch;create;update;patch;delete
//+kubebuilder:rbac:groups=rbac.authorization.k8s.io,resources=clusterroles,verbs=create
//+kubebuilder:rbac:groups=rbac.authorization.k8s.io,resources=clusterrolebindings,verbs=create
//+kubebuilder:rbac:groups=core,resources=pods,verbs=get
// +kubebuilder:rbac:groups=fluentbit.fluent.io,resources=fluentbits;fluentbitconfigs;collectors;inputs;filters;outputs,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=apps,resources=statefulsets,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=core,resources=serviceaccounts,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=rbac.authorization.k8s.io,resources=clusterroles,verbs=create
// +kubebuilder:rbac:groups=rbac.authorization.k8s.io,resources=clusterrolebindings,verbs=create
// +kubebuilder:rbac:groups=core,resources=pods,verbs=get

// Reconcile is part of the main kubernetes reconciliation loop which aims to
// move the current state of the cluster closer to the desired state.
Expand Down
12 changes: 6 additions & 6 deletions controllers/fluentbit_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ type FluentBitReconciler struct {
Namespaced bool
}

//+kubebuilder:rbac:groups=fluentbit.fluent.io,resources=fluentbits;fluentbitconfigs;inputs;filters;outputs,verbs=get;list;watch;create;update;patch;delete
//+kubebuilder:rbac:groups=apps,resources=daemonsets,verbs=get;list;watch;create;update;patch;delete
//+kubebuilder:rbac:groups=core,resources=serviceaccounts,verbs=get;list;watch;create;update;patch;delete
//+kubebuilder:rbac:groups=rbac.authorization.k8s.io,resources=clusterroles,verbs=create
//+kubebuilder:rbac:groups=rbac.authorization.k8s.io,resources=clusterrolebindings,verbs=create
//+kubebuilder:rbac:groups=core,resources=pods,verbs=get
// +kubebuilder:rbac:groups=fluentbit.fluent.io,resources=fluentbits;fluentbitconfigs;inputs;filters;outputs,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=apps,resources=daemonsets,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=core,resources=serviceaccounts,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=rbac.authorization.k8s.io,resources=clusterroles,verbs=create
// +kubebuilder:rbac:groups=rbac.authorization.k8s.io,resources=clusterrolebindings,verbs=create
// +kubebuilder:rbac:groups=core,resources=pods,verbs=get

// Reconcile is part of the main kubernetes reconciliation loop which aims to
// move the current state of the cluster closer to the desired state.
Expand Down
6 changes: 3 additions & 3 deletions controllers/fluentbitconfig_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ type FluentBitConfigReconciler struct {
Scheme *runtime.Scheme
}

//+kubebuilder:rbac:groups=fluentbit.fluent.io,resources=clusterfluentbitconfigs,verbs=get;list;watch;create;update;patch;delete
//+kubebuilder:rbac:groups=fluentbit.fluent.io,resources=clusterinputs;clusterfilters;clusteroutputs;clusterparsers,verbs=list
//+kubebuilder:rbac:groups=core,resources=secrets,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=fluentbit.fluent.io,resources=clusterfluentbitconfigs,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=fluentbit.fluent.io,resources=clusterinputs;clusterfilters;clusteroutputs;clusterparsers,verbs=list
// +kubebuilder:rbac:groups=core,resources=secrets,verbs=get;list;watch;create;update;patch;delete

// Reconcile is part of the main kubernetes reconciliation loop which aims to
// move the current state of the cluster closer to the desired state.
Expand Down
6 changes: 3 additions & 3 deletions controllers/fluentd_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ type FluentdReconciler struct {
Scheme *runtime.Scheme
}

//+kubebuilder:rbac:groups=fluentd.fluent.io,resources=fluentds,verbs=get;list;watch;create;update;patch;delete
//+kubebuilder:rbac:groups=fluentd.fluent.io,resources=fluentds/status,verbs=get;update;patch
//+kubebuilder:rbac:groups=fluentd.fluent.io,resources=fluentds/finalizers,verbs=update
// +kubebuilder:rbac:groups=fluentd.fluent.io,resources=fluentds,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=fluentd.fluent.io,resources=fluentds/status,verbs=get;update;patch
// +kubebuilder:rbac:groups=fluentd.fluent.io,resources=fluentds/finalizers,verbs=update

// Reconcile is part of the main kubernetes reconciliation loop which aims to
// move the current state of the cluster closer to the desired state.
Expand Down
16 changes: 8 additions & 8 deletions controllers/fluentdconfig_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,14 @@ type FluentdConfigReconciler struct {
Scheme *runtime.Scheme
}

//+kubebuilder:rbac:groups=fluentd.fluent.io,resources=fluentdconfigs,verbs=get;list;watch;create;update;patch;delete
//+kubebuilder:rbac:groups=fluentd.fluent.io,resources=clusterfluentdconfigs,verbs=get;list;watch;create;update;patch;delete
//+kubebuilder:rbac:groups=fluentd.fluent.io,resources=inputs;filters;outputs,verbs=list
//+kubebuilder:rbac:groups=fluentd.fluent.io,resources=clusterinputs;clusterfilters;clusteroutputs,verbs=list;
//+kubebuilder:rbac:groups=fluentd.fluent.io,resources=fluentds,verbs=list
//+kubebuilder:rbac:groups=fluentd.fluent.io,resources=fluentds/status,verbs=patch
//+kubebuilder:rbac:groups=fluentd.fluent.io,resources=fluentdconfigs/status,verbs=get;update;patch
//+kubebuilder:rbac:groups=fluentd.fluent.io,resources=fluentdconfigs/finalizers,verbs=update
// +kubebuilder:rbac:groups=fluentd.fluent.io,resources=fluentdconfigs,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=fluentd.fluent.io,resources=clusterfluentdconfigs,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=fluentd.fluent.io,resources=inputs;filters;outputs,verbs=list
// +kubebuilder:rbac:groups=fluentd.fluent.io,resources=clusterinputs;clusterfilters;clusteroutputs,verbs=list;
// +kubebuilder:rbac:groups=fluentd.fluent.io,resources=fluentds,verbs=list
// +kubebuilder:rbac:groups=fluentd.fluent.io,resources=fluentds/status,verbs=patch
// +kubebuilder:rbac:groups=fluentd.fluent.io,resources=fluentdconfigs/status,verbs=get;update;patch
// +kubebuilder:rbac:groups=fluentd.fluent.io,resources=fluentdconfigs/finalizers,verbs=update

// Reconcile is part of the main kubernetes reconciliation loop which aims to
// move the current state of the cluster closer to the desired state.
Expand Down
4 changes: 2 additions & 2 deletions controllers/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (

fluentbitv1alpha2 "github.com/fluent/fluent-operator/apis/fluentbit/v1alpha2"
fluentdv1alpha1 "github.com/fluent/fluent-operator/apis/fluentd/v1alpha1"
//+kubebuilder:scaffold:imports
// +kubebuilder:scaffold:imports
)

// These tests use Ginkgo (BDD-style Go testing framework). Refer to
Expand Down Expand Up @@ -67,7 +67,7 @@ var _ = BeforeSuite(func() {
err = fluentdv1alpha1.AddToScheme(scheme.Scheme)
Expect(err).NotTo(HaveOccurred())

//+kubebuilder:scaffold:scheme
// +kubebuilder:scaffold:scheme

k8sClient, err = client.New(cfg, client.Options{Scheme: scheme.Scheme})
Expect(err).NotTo(HaveOccurred())
Expand Down
2 changes: 1 addition & 1 deletion pkg/filenotify/filenotify.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Adapted from https://github.com/gohugoio/hugo
// Apache License 2.0
// Copyright Hugo Authors
//

// Package filenotify provides a mechanism for watching file(s) for changes.
// Generally leans on fsnotify, but provides a poll-based notifier which fsnotify does not support.
// These are wrapped up in a common interface so that either can be used interchangeably in your code.
Expand Down
2 changes: 1 addition & 1 deletion pkg/filenotify/fsnotify.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Adapted from https://github.com/gohugoio/hugo
// Apache License 2.0
// Copyright Hugo Authors
//

// Package filenotify is adapted from https://github.com/moby/moby/tree/master/pkg/filenotify, Apache-2.0 License.
// Hopefully this can be replaced with an external package sometime in the future, see https://github.com/fsnotify/fsnotify/issues/9
package filenotify
Expand Down
2 changes: 1 addition & 1 deletion pkg/filenotify/poller.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Adapted from https://github.com/gohugoio/hugo
// Apache License 2.0
// Copyright Hugo Authors
//

// Package filenotify is adapted from https://github.com/moby/moby/tree/master/pkg/filenotify, Apache-2.0 License.
// Hopefully this can be replaced with an external package sometime in the future, see https://github.com/fsnotify/fsnotify/issues/9
package filenotify
Expand Down
4 changes: 2 additions & 2 deletions pkg/fluentd/router/pluginstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ type LabelRouter struct {
Routes []*Route `json:"routes,omitempty"`
}

// Each fluentd config instance will create a route pluginstore.
// NewRoutePlugin will create a route pluginstore for each fluentd config instance
func (r *Route) NewRoutePlugin() (*params.PluginStore, error) {
ps := params.NewPluginStore("route")
childs := make([]*params.PluginStore, 0)
Expand Down Expand Up @@ -83,7 +83,7 @@ func (r *Route) NewRoutePlugin() (*params.PluginStore, error) {
return ps, nil
}

// The global router to store routes
// NewGlobalRouter will create a global router to store routes
func NewGlobalRouter(id string) *params.PluginStore {
ps := params.NewPluginStore("match")
ps.InsertPairs("@id", id)
Expand Down
4 changes: 2 additions & 2 deletions pkg/operator/collector-statefulset.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
)

var (
// Buffer path for single process
// DefaultBufferPath defines the buffer path for single process
DefaultBufferPath = "/buffers/fluentbit/log"
)

Expand Down Expand Up @@ -129,7 +129,7 @@ func MakefbStatefuset(co fluentbitv1alpha2.Collector) appsv1.StatefulSet {
})
}

//Bind pvc
// Bind pvc
statefulset.Spec.VolumeClaimTemplates = append(statefulset.Spec.VolumeClaimTemplates, MakeFluentbitPVC(co))
statefulset.Spec.Template.Spec.Containers[0].VolumeMounts = append(statefulset.Spec.Template.Spec.Containers[0].VolumeMounts, corev1.VolumeMount{
Name: fmt.Sprintf("%s-buffer-pvc", co.Name),
Expand Down

0 comments on commit 4911e35

Please sign in to comment.