func StaticDynatraceClient(c dtclient.Client) DynatraceClientFunc {
	return func(properties DynatraceClientProperties) (dtclient.Client, error) {
		return c, nil
	}
}
StaticDynatraceClient creates a DynatraceClientFunc always returning c.
package dynakube
import (
	"context"
	"fmt"
	dynatracev1beta1 "github.com/Dynatrace/dynatrace-operator/api/v1beta1"
	"github.com/Dynatrace/dynatrace-operator/controllers/kubeobjects"
	"github.com/Dynatrace/dynatrace-operator/dtclient"
	"github.com/pkg/errors"
	corev1 "k8s.io/api/core/v1"
	"sigs.k8s.io/controller-runtime/pkg/client"
)
type options struct {
	Opts []dtclient.Option
}
type DynatraceClientProperties struct {
	ApiReader           client.Reader
	Secret              *corev1.Secret
	Proxy               *DynatraceClientProxy
	ApiUrl              string
	Namespace           string
	NetworkZone         string
	TrustedCerts        string
	SkipCertCheck       bool
	DisableHostRequests bool
}
type DynatraceClientProxy struct {
	Value     string
	ValueFrom string
}
const (
	proxy        = "proxy"
	certificates = "certs"
)
func NewDynatraceClientProperties(ctx context.Context, apiReader client.Reader, dk dynatracev1beta1.DynaKube) (*DynatraceClientProperties, error) {
	var tokens corev1.Secret
	var err error
	if err = apiReader.Get(ctx, client.ObjectKey{Name: dk.Tokens(), Namespace: dk.Namespace}, &tokens); err != nil {
		err = fmt.Errorf("failed to query tokens: %w", err)
	}
	return &DynatraceClientProperties{
		ApiReader:           apiReader,
		Secret:              &tokens,
		ApiUrl:              dk.Spec.APIURL,
		Namespace:           dk.Namespace,
		Proxy:               (*DynatraceClientProxy)(dk.Spec.Proxy),
		NetworkZone:         dk.Spec.NetworkZone,
		TrustedCerts:        dk.Spec.TrustedCAs,
		SkipCertCheck:       dk.Spec.SkipCertCheck,
		DisableHostRequests: dk.FeatureDisableHostsRequests(),
	}, err
}
func BuildDynatraceClient(properties DynatraceClientProperties) (dtclient.Client, error) {
	namespace := properties.Namespace
	secret := properties.Secret
	apiReader := properties.ApiReader
	tokens, err := kubeobjects.NewTokens(secret)
	if err != nil {
		return nil, errors.WithStack(err)
	}
	opts := newOptions()
	opts.appendCertCheck(properties.SkipCertCheck)
	opts.appendNetworkZone(properties.NetworkZone)
	opts.appendDisableHostsRequests(properties.DisableHostRequests)
	err = opts.appendProxySettings(apiReader, properties.Proxy, namespace)
	if err != nil {
		return nil, errors.WithStack(err)
	}
	err = opts.appendTrustedCerts(apiReader, properties.TrustedCerts, namespace)
	if err != nil {
		return nil, errors.WithStack(err)
	}
	return dtclient.NewClient(properties.ApiUrl, tokens.ApiToken, tokens.PaasToken, opts.Opts...)
}
func newOptions() *options {
	return &options{
		Opts: []dtclient.Option{},
	}
}