Skip to content

Commit

Permalink
chore: fix typos in the monitor
Browse files Browse the repository at this point in the history
  • Loading branch information
sophon-zt committed Oct 30, 2023
1 parent 4482da9 commit 1a5c821
Show file tree
Hide file tree
Showing 11 changed files with 102 additions and 102 deletions.
2 changes: 1 addition & 1 deletion controllers/monitor/oteld_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const (
mysqlCompName = "mysql"
)

var _ = Describe("Oteld Monitor Controller", func() {
var _ = Describe("OTeld Monitor Controller", func() {

const (
clusterDefName = "test-clusterdef"
Expand Down
4 changes: 2 additions & 2 deletions controllers/monitor/reconcile/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func Deployment(reqCtx monitortypes.ReconcileCtx, params monitortypes.OTeldParam
}

func buildDeploymentForOteld(instance *monitortypes.OteldInstance, namespace, name string) *appsv1.Deployment {
if instance == nil || instance.Oteld == nil {
if instance == nil || instance.OTeld == nil {
return nil
}

Expand All @@ -93,7 +93,7 @@ func buildDeploymentForOteld(instance *monitortypes.OteldInstance, namespace, na
MatchLabels: commonLabels,
}

template := instance.Oteld
template := instance.OTeld
podTemplate := corev1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Labels: commonLabels,
Expand Down
6 changes: 3 additions & 3 deletions controllers/monitor/reconcile/oteld.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func OTeld(reqCtx monitortype.ReconcileCtx, params monitortype.OTeldParams) erro
return err
}

instanceMap, err := BuildInstanceMapForPipline(userDateSources, metricsExporters, logsExporters, reqCtx.OTeld, params.Client, reqCtx.Ctx)
instanceMap, err := BuildInstanceMapForPipeline(userDateSources, metricsExporters, logsExporters, reqCtx.OTeld, params.Client, reqCtx.Ctx)
if err != nil {
return err
}
Expand All @@ -63,7 +63,7 @@ func OTeld(reqCtx monitortype.ReconcileCtx, params monitortype.OTeldParams) erro
return nil
}

func BuildInstanceMapForPipline(appDatasources *v1alpha1.CollectorDataSourceList,
func BuildInstanceMapForPipeline(appDatasources *v1alpha1.CollectorDataSourceList,
metricsExporters *v1alpha1.MetricsExporterSinkList,
logsExporters *v1alpha1.LogsExporterSinkList,
oteld *v1alpha1.OTeld,
Expand Down Expand Up @@ -98,6 +98,6 @@ func buildSystemInstanceMap(oteld *v1alpha1.OTeld,
buildNodePipeline().
buildPodLogsPipeline().
appendUserDataSource().
buildFixedPipline().
buildFixedPipeline().
complete()
}
2 changes: 1 addition & 1 deletion controllers/monitor/reconcile/oteld_agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func buildDaemonSetForOteld(instance *types.OteldInstance, namespace string, nam
MatchLabels: commonLabels,
}

template := instance.Oteld
template := instance.OTeld
podTemplate := corev1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Labels: commonLabels,
Expand Down
52 changes: 26 additions & 26 deletions controllers/monitor/reconcile/oteld_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,20 +115,20 @@ func (w *oteldWrapper) buildPodLogsPipeline() *oteldWrapper {
return w
}

func (w *oteldWrapper) createPipeline(mode v1alpha1.Mode, name string, collectType collectType) *types.Pipline {
func (w *oteldWrapper) createPipeline(mode v1alpha1.Mode, name string, collectType collectType) *types.Pipeline {
var instance *types.OteldInstance

if instance = w.instanceMap[mode]; instance == nil {
instance = types.NewOteldInstance(w.OTeld, w.cli, w.ctx)
w.instanceMap[mode] = instance
}
if instance.MetricsPipline == nil {
instance.MetricsPipline = []types.Pipline{}
if instance.MetricsPipeline == nil {
instance.MetricsPipeline = []types.Pipeline{}
}
return foundOrCreatePipeline(instance, name, collectType)
}

func (w *oteldWrapper) buildProcessor(pipeline *types.Pipline) {
func (w *oteldWrapper) buildProcessor(pipeline *types.Pipeline) {
if w.Spec.Batch.Enabled {
pipeline.ProcessorMap[types.BatchProcessorName] = true
}
Expand All @@ -137,7 +137,7 @@ func (w *oteldWrapper) buildProcessor(pipeline *types.Pipline) {
}
}

func (w *oteldWrapper) buildMetricsExporter(pipeline *types.Pipline) {
func (w *oteldWrapper) buildMetricsExporter(pipeline *types.Pipeline) {
for _, exporter := range w.metricsExporters.Items {
if exporter.Name == w.source.MetricsExporterRef {
pipeline.ExporterMap[fmt.Sprintf(ExporterNamePattern, exporter.Spec.Type, exporter.Name)] = true
Expand All @@ -147,7 +147,7 @@ func (w *oteldWrapper) buildMetricsExporter(pipeline *types.Pipline) {
w.errs = append(w.errs, cfgcore.MakeError("the metrics exporter[%s] relied on by %s was not found.", w.source.MetricsExporterRef, pipeline.Name))
}

func (w *oteldWrapper) buildLogsExporter(pipeline *types.Pipline) {
func (w *oteldWrapper) buildLogsExporter(pipeline *types.Pipeline) {
for _, exporter := range w.logsExporters.Items {
if exporter.Name == w.source.LogsExporterRef {
pipeline.ExporterMap[fmt.Sprintf(ExporterNamePattern, exporter.Spec.Type, exporter.Name)] = true
Expand All @@ -157,13 +157,13 @@ func (w *oteldWrapper) buildLogsExporter(pipeline *types.Pipline) {
w.errs = append(w.errs, cfgcore.MakeError("the logs exporter[%s] relied on by %s was not found.", w.source.LogsExporterRef, pipeline.Name))
}

func (w *oteldWrapper) appendAllMetricsExporter(pipeline *types.Pipline) {
func (w *oteldWrapper) appendAllMetricsExporter(pipeline *types.Pipeline) {
for _, exporter := range w.metricsExporters.Items {
pipeline.ExporterMap[fmt.Sprintf(ExporterNamePattern, exporter.Spec.Type, exporter.Name)] = true
}
}

func (w *oteldWrapper) appendAllLogsExporter(pipeline *types.Pipline) {
func (w *oteldWrapper) appendAllLogsExporter(pipeline *types.Pipeline) {
for _, exporter := range w.logsExporters.Items {
pipeline.ExporterMap[fmt.Sprintf(ExporterNamePattern, exporter.Spec.Type, exporter.Name)] = true
}
Expand All @@ -182,17 +182,17 @@ func (w *oteldWrapper) appendUserDataSource() *oteldWrapper {
return w
}

func (w *oteldWrapper) buildFixedPipline() *oteldWrapper {
func (w *oteldWrapper) buildFixedPipeline() *oteldWrapper {
for _, instance := range w.instanceMap {
logsPipline := types.NewPipeline(LogsCreatorName)
w.buildProcessor(&logsPipline)
w.appendAllLogsExporter(&logsPipline)
instance.AppLogsPipline = &logsPipline
logsPipeline := types.NewPipeline(LogsCreatorName)
w.buildProcessor(&logsPipeline)
w.appendAllLogsExporter(&logsPipeline)
instance.AppLogsPipeline = &logsPipeline

metricsPipline := types.NewPipeline(AppMetricsCreatorName)
w.buildProcessor(&metricsPipline)
w.appendAllMetricsExporter(&metricsPipline)
instance.AppMetricsPiplien = &metricsPipline
metricsPipeline := types.NewPipeline(AppMetricsCreatorName)
w.buildProcessor(&metricsPipeline)
w.appendAllMetricsExporter(&metricsPipeline)
instance.AppMetricsPipelien = &metricsPipeline
}
return w
}
Expand All @@ -201,8 +201,8 @@ func (w *oteldWrapper) complete() error {
return errors.Join(w.errs...)
}

func foundOrCreatePipeline(instance *types.OteldInstance, name string, collectType collectType) *types.Pipline {
foundPipeline := func(pipelines []types.Pipline) *types.Pipline {
func foundOrCreatePipeline(instance *types.OteldInstance, name string, collectType collectType) *types.Pipeline {
foundPipeline := func(pipelines []types.Pipeline) *types.Pipeline {
for i := range pipelines {
pipeline := &pipelines[i]
if pipeline.Name == name {
Expand All @@ -211,7 +211,7 @@ func foundOrCreatePipeline(instance *types.OteldInstance, name string, collectTy
}
return nil
}
checkAndCreate := func(pipeline []types.Pipline, update func(pipeline types.Pipline) *types.Pipline) *types.Pipline {
checkAndCreate := func(pipeline []types.Pipeline, update func(pipeline types.Pipeline) *types.Pipeline) *types.Pipeline {
if p := foundPipeline(pipeline); p != nil {
return p
}
Expand All @@ -221,14 +221,14 @@ func foundOrCreatePipeline(instance *types.OteldInstance, name string, collectTy

switch collectType {
case collectTypeMetrics:
return checkAndCreate(instance.MetricsPipline, func(pipeline types.Pipline) *types.Pipline {
instance.MetricsPipline = append(instance.MetricsPipline, pipeline)
return &instance.MetricsPipline[len(instance.MetricsPipline)-1]
return checkAndCreate(instance.MetricsPipeline, func(pipeline types.Pipeline) *types.Pipeline {
instance.MetricsPipeline = append(instance.MetricsPipeline, pipeline)
return &instance.MetricsPipeline[len(instance.MetricsPipeline)-1]
})
case collectTypeLogs:
return checkAndCreate(instance.LogPipline, func(pipeline types.Pipline) *types.Pipline {
instance.LogPipline = append(instance.LogPipline, pipeline)
return &instance.LogPipline[len(instance.LogPipline)-1]
return checkAndCreate(instance.LogPipeline, func(pipeline types.Pipeline) *types.Pipeline {
instance.LogPipeline = append(instance.LogPipeline, pipeline)
return &instance.LogPipeline[len(instance.LogPipeline)-1]
})
default:
return nil
Expand Down
2 changes: 1 addition & 1 deletion controllers/monitor/reconcile/oteld_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ var _ = Describe("monitor_controller", func() {

BeforeEach(func() {
instance = &types.OteldInstance{
Oteld: &appsv1alpha1.OTeld{},
OTeld: &appsv1alpha1.OTeld{},
}
})

Expand Down
4 changes: 2 additions & 2 deletions controllers/monitor/reconcile/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ func Service(reqCtx types.ReconcileCtx, params types.OTeldParams) error {
desired := make([]*corev1.Service, 0)

if daemon := reqCtx.OteldCfgRef.GetOteldInstance(monitorv1alpha1.ModeDaemonSet); daemon != nil {
desired = append(desired, buildSvcForOtel(daemon.Oteld, reqCtx.OTeld.Namespace, monitorv1alpha1.ModeDaemonSet))
desired = append(desired, buildSvcForOtel(daemon.OTeld, reqCtx.OTeld.Namespace, monitorv1alpha1.ModeDaemonSet))
}
if deploy := reqCtx.OteldCfgRef.GetOteldInstance(monitorv1alpha1.ModeDeployment); deploy != nil {
desired = append(desired, buildSvcForOtel(deploy.Oteld, reqCtx.OTeld.Namespace, monitorv1alpha1.ModeDeployment))
desired = append(desired, buildSvcForOtel(deploy.OTeld, reqCtx.OTeld.Namespace, monitorv1alpha1.ModeDeployment))
}
return expectedService(reqCtx, params, desired)
}
Expand Down
16 changes: 8 additions & 8 deletions controllers/monitor/reconcile/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ func buildSvcForOtel(oteld *v1alpha1.OTeld, namespace string, mode v1alpha1.Mode
}

func buildConfigMapForOteld(instance *types.OteldInstance, namespace string, exporters *types.Exporters, mode v1alpha1.Mode, gc *types.OteldConfigGenerater) (*corev1.ConfigMap, error) {
if instance == nil || instance.Oteld == nil {
if instance == nil || instance.OTeld == nil {
return nil, nil
}

Expand All @@ -278,12 +278,12 @@ func buildConfigMapForOteld(instance *types.OteldInstance, namespace string, exp
return builder.NewConfigMapBuilder(namespace, name).
SetData(map[string]string{"config.yaml": string(marshal)}).
AddLabelsInMap(commonLabels).
SetOwnerReferences(instance.Oteld.APIVersion, instance.Oteld.Kind, instance.Oteld).
SetOwnerReferences(instance.OTeld.APIVersion, instance.OTeld.Kind, instance.OTeld).
GetObject(), nil
}

func buildEngineConfigForOteld(instance *types.OteldInstance, namespace string, mode v1alpha1.Mode, gc *types.OteldConfigGenerater) (*corev1.ConfigMap, error) {
if instance == nil || instance.Oteld == nil {
if instance == nil || instance.OTeld == nil {
return nil, nil
}

Expand All @@ -304,12 +304,12 @@ func buildEngineConfigForOteld(instance *types.OteldInstance, namespace string,
return builder.NewConfigMapBuilder(namespace, name).
SetData(map[string]string{"kb_engine.yaml": string(marshal)}).
AddLabelsInMap(commonLabels).
SetOwnerReferences(instance.Oteld.APIVersion, instance.Oteld.Kind, instance.Oteld).
SetOwnerReferences(instance.OTeld.APIVersion, instance.OTeld.Kind, instance.OTeld).
GetObject(), nil
}

func buildSecretForOteld(instance *types.OteldInstance, namespace string, exporters *types.Exporters, mode v1alpha1.Mode, gc *types.OteldConfigGenerater) (*corev1.Secret, error) {
if instance == nil || instance.Oteld == nil {
if instance == nil || instance.OTeld == nil {
return nil, nil
}

Expand All @@ -330,12 +330,12 @@ func buildSecretForOteld(instance *types.OteldInstance, namespace string, export
return builder.NewSecretBuilder(namespace, name).
PutData("config.yaml", marshal).
AddLabelsInMap(commonLabels).
SetOwnerReferences(instance.Oteld.APIVersion, instance.Oteld.Kind, instance.Oteld).
SetOwnerReferences(instance.OTeld.APIVersion, instance.OTeld.Kind, instance.OTeld).
GetObject(), nil
}

func buildEngineSecretForOteld(instance *types.OteldInstance, namespace string, mode v1alpha1.Mode, gc *types.OteldConfigGenerater) (*corev1.Secret, error) {
if instance == nil || instance.Oteld == nil {
if instance == nil || instance.OTeld == nil {
return nil, nil
}

Expand All @@ -356,6 +356,6 @@ func buildEngineSecretForOteld(instance *types.OteldInstance, namespace string,
return builder.NewSecretBuilder(namespace, name).
PutData("kb_engine.yaml", marshal).
AddLabelsInMap(commonLabels).
SetOwnerReferences(instance.Oteld.APIVersion, instance.Oteld.Kind, instance.Oteld).
SetOwnerReferences(instance.OTeld.APIVersion, instance.OTeld.Kind, instance.OTeld).
GetObject(), nil
}
Loading

0 comments on commit 1a5c821

Please sign in to comment.