github.com/caos/orbos@v1.5.14-0.20221103111702-e6cd0cea7ad4/internal/operator/boom/application/applications/logcollection/helm.go (about)

     1  package logcollection
     2  
     3  import (
     4  	"errors"
     5  	"fmt"
     6  	toolsetslatest "github.com/caos/orbos/internal/operator/boom/api/latest"
     7  	"github.com/caos/orbos/internal/operator/boom/application/applications/logcollection/helm"
     8  	"github.com/caos/orbos/internal/operator/boom/application/applications/logcollection/info"
     9  	"github.com/caos/orbos/internal/operator/boom/application/applications/logspersisting/logs"
    10  	"github.com/caos/orbos/internal/operator/boom/templator/helm/chart"
    11  	"github.com/caos/orbos/internal/utils/clientgo"
    12  	"github.com/caos/orbos/internal/utils/helper"
    13  	"github.com/caos/orbos/mntr"
    14  	k8serrors "k8s.io/apimachinery/pkg/api/errors"
    15  )
    16  
    17  func (l *LoggingOperator) HelmPreApplySteps(monitor mntr.Monitor, toolsetCRDSpec *toolsetslatest.ToolsetSpec) ([]interface{}, error) {
    18  
    19  	secretName := "grafana-cloud-logs"
    20  
    21  	_, getSecretErr := clientgo.GetSecret(secretName, info.GetNamespace())
    22  	telemetrySecretAbsent := k8serrors.IsNotFound(errors.Unwrap(getSecretErr))
    23  	if getSecretErr != nil && !telemetrySecretAbsent {
    24  		monitor.Info(fmt.Sprintf("Not sending telemetry data to MISSION as secret %s is missing in namespace caos-system", secretName))
    25  	}
    26  
    27  	return logs.GetAllResources(toolsetCRDSpec, getSecretErr == nil && !telemetrySecretAbsent, secretName, l.orb), nil
    28  }
    29  
    30  func (l *LoggingOperator) SpecToHelmValues(monitor mntr.Monitor, toolset *toolsetslatest.ToolsetSpec) interface{} {
    31  	// spec := toolset.LoggingOperator
    32  	imageTags := l.GetImageTags()
    33  	image := "banzaicloud/logging-operator"
    34  
    35  	if toolset != nil && toolset.LogCollection != nil {
    36  		helper.OverwriteExistingValues(imageTags, map[string]string{
    37  			image: toolset.LogCollection.OverwriteVersion,
    38  		})
    39  		helper.OverwriteExistingKey(imageTags, &image, toolset.LogCollection.OverwriteImage)
    40  	}
    41  	values := helm.DefaultValues(imageTags, image)
    42  
    43  	// if spec.ReplicaCount != 0 {
    44  	// 	values.ReplicaCount = spec.ReplicaCount
    45  	// }
    46  
    47  	spec := toolset.LogCollection
    48  	if spec == nil || spec.Operator == nil {
    49  		return values
    50  	}
    51  
    52  	if spec.Operator.NodeSelector != nil {
    53  		for k, v := range spec.Operator.NodeSelector {
    54  			values.NodeSelector[k] = v
    55  		}
    56  	}
    57  
    58  	if spec.Operator.Tolerations != nil {
    59  		for _, tol := range spec.Operator.Tolerations {
    60  			values.Tolerations = append(values.Tolerations, tol)
    61  		}
    62  	}
    63  
    64  	if spec.Operator.Resources != nil {
    65  		values.Resources = spec.Operator.Resources
    66  	}
    67  
    68  	return values
    69  }
    70  
    71  func (l *LoggingOperator) GetChartInfo() *chart.Chart {
    72  	return helm.GetChartInfo()
    73  }
    74  
    75  func (l *LoggingOperator) GetImageTags() map[string]string {
    76  	return helm.GetImageTags()
    77  }