func New(config Config) (*Service, error) {
	var serviceAddress string
	if config.Flag == nil {
		return nil, microerror.Maskf(invalidConfigError, "config.Flag must not be empty")
	}
	if config.Viper == nil {
		return nil, microerror.Maskf(invalidConfigError, "config.Viper must not be empty")
	}
	if config.Flag.Service.Kubernetes.KubeConfig == "" {
		serviceAddress = config.Viper.GetString(config.Flag.Service.Kubernetes.Address)
	} else {
		serviceAddress = ""
	}
	if config.Logger == nil {
		return nil, microerror.Maskf(invalidConfigError, "logger must not be empty")
	}
	var err error
	var restConfig *rest.Config
	{
		c := k8srestconfig.Config{
			Logger: config.Logger,
			Address:    serviceAddress,
			InCluster:  config.Viper.GetBool(config.Flag.Service.Kubernetes.InCluster),
			KubeConfig: config.Viper.GetString(config.Flag.Service.Kubernetes.KubeConfig),
			TLS: k8srestconfig.ConfigTLS{
				CAFile:  config.Viper.GetString(config.Flag.Service.Kubernetes.TLS.CAFile),
				CrtFile: config.Viper.GetString(config.Flag.Service.Kubernetes.TLS.CrtFile),
				KeyFile: config.Viper.GetString(config.Flag.Service.Kubernetes.TLS.KeyFile),
			},
		}
		restConfig, err = k8srestconfig.New(c)
		if err != nil {
			return nil, microerror.Mask(err)
		}
	}
	var k8sClient k8sclient.Interface
	{
		c := k8sclient.ClientsConfig{
			Logger: config.Logger,
			SchemeBuilder: k8sclient.SchemeBuilder{
				monitoringv1alpha1.AddToScheme,
			},
			RestConfig: restConfig,
		}
		k8sClient, err = k8sclient.NewClients(c)
		if err != nil {
			return nil, microerror.Mask(err)
		}
	}
	var silenceController *controller.Silence
	{
		c := controller.SilenceConfig{
			K8sClient: k8sClient,
			Logger:    config.Logger,
			AlertManagerAddress: config.Viper.GetString(config.Flag.Service.AlertManager.Address),
		}
		silenceController, err = controller.NewSilence(c)
		if err != nil {
			return nil, microerror.Mask(err)
		}
	}
	var operatorCollector *collector.Set
	{
		c := collector.SetConfig{
			K8sClient: k8sClient.K8sClient(),
			Logger:    config.Logger,
		}
		operatorCollector, err = collector.NewSet(c)
		if err != nil {
			return nil, microerror.Mask(err)
		}
	}
	var versionService *version.Service
	{
		c := version.Config{
			Description: project.Description(),
			GitCommit:   project.GitSHA(),
			Name:        project.Name(),
			Source:      project.Source(),
			Version:     project.Version(),
		}
		versionService, err = version.New(c)
		if err != nil {
			return nil, microerror.Mask(err)
		}
	}
	s := &Service{
		Version: versionService,
		bootOnce:          sync.Once{},
		silenceController: silenceController,
		operatorCollector: operatorCollector,
	}
	return s, nil
}
New creates a new configured service object.
package service
import (
	"context"
	"sync"
	"github.com/giantswarm/k8sclient/v4/pkg/k8sclient"
	"github.com/giantswarm/k8sclient/v4/pkg/k8srestconfig"
	"github.com/giantswarm/microendpoint/service/version"
	"github.com/giantswarm/microerror"
	"github.com/giantswarm/micrologger"
	"github.com/spf13/viper"
	"k8s.io/client-go/rest"
	monitoringv1alpha1 "github.com/giantswarm/apiextensions/v3/pkg/apis/monitoring/v1alpha1"
	"github.com/giantswarm/silence-operator/flag"
	"github.com/giantswarm/silence-operator/pkg/project"
	"github.com/giantswarm/silence-operator/service/collector"
	"github.com/giantswarm/silence-operator/service/controller"
)
type Config struct {
	Logger micrologger.Logger
	Flag  *flag.Flag
	Viper *viper.Viper
}
type Service struct {
	Version *version.Service
	bootOnce          sync.Once
	silenceController *controller.Silence
	operatorCollector *collector.Set
}