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

     1  package metricsserver
     2  
     3  import (
     4  	toolsetslatest "github.com/caos/orbos/internal/operator/boom/api/latest"
     5  	"github.com/caos/orbos/internal/operator/boom/application/applications/metricsserver/helm"
     6  	"github.com/caos/orbos/internal/operator/boom/templator/helm/chart"
     7  	"github.com/caos/orbos/internal/utils/helper"
     8  	"github.com/caos/orbos/mntr"
     9  )
    10  
    11  func (m *MetricsServer) HelmMutate(monitor mntr.Monitor, toolsetCRDSpec *toolsetslatest.ToolsetSpec, resultFilePath string) error {
    12  
    13  	if err := helper.DeleteFirstResourceFromYaml(resultFilePath, "v1", "Pod", "metrics-server-test"); err != nil {
    14  		return err
    15  	}
    16  
    17  	return nil
    18  }
    19  
    20  func (m *MetricsServer) SpecToHelmValues(monitor mntr.Monitor, toolset *toolsetslatest.ToolsetSpec) interface{} {
    21  	imageTags := m.GetImageTags()
    22  	image := "k8s.gcr.io/metrics-server-amd64"
    23  
    24  	if toolset != nil && toolset.MetricsServer != nil {
    25  		helper.OverwriteExistingValues(imageTags, map[string]string{
    26  			image: toolset.MetricsServer.OverwriteVersion,
    27  		})
    28  		helper.OverwriteExistingKey(imageTags, &image, toolset.MetricsServer.OverwriteImage)
    29  	}
    30  	values := helm.DefaultValues(imageTags, image)
    31  
    32  	if toolset != nil && toolset.MetricsServer != nil {
    33  		if toolset.MetricsServer.Resources != nil {
    34  			values.Resources = toolset.MetricsServer.Resources
    35  		}
    36  
    37  		if toolset.MetricsServer.NodeSelector != nil {
    38  			for k, v := range toolset.MetricsServer.NodeSelector {
    39  				values.NodeSelector[k] = v
    40  			}
    41  		}
    42  
    43  		if toolset.MetricsServer.Tolerations != nil {
    44  			for _, tol := range toolset.MetricsServer.Tolerations {
    45  				values.Tolerations = append(values.Tolerations, tol)
    46  			}
    47  		}
    48  	}
    49  
    50  	return values
    51  }
    52  
    53  func (m *MetricsServer) GetChartInfo() *chart.Chart {
    54  	return helm.GetChartInfo()
    55  }
    56  
    57  func (m *MetricsServer) GetImageTags() map[string]string {
    58  	return helm.GetImageTags()
    59  }