You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: tls.go
    path of file: ./repos/uptrace/pkg/bunconf
    
    the code of the file until where you have to start completion: package bunconf

import (
	"crypto/tls"
	"crypto/x509"
	"errors"
	"fmt"
	"os"
	"path/filepath"
)

const (
	defaultMinTLSVersion = tls.VersionTLS12
	defaultMaxTLSVersion = 0 // causes to use the default MaxVersion from "crypto/tls"
)

type TLS struct {
	CAFile     string `yaml:"ca_file"`
	CertFile   string `yaml:"cert_file"`
	KeyFile    string `yaml:"key_file"`
	MinVersion string `yaml:"min_version"`
	MaxVersion string `yaml:"max_version"`
}

func (c *TLS) tlsConfig() (*tls.Config, error) {
	var certPool *x509.CertPool
	if len(c.CAFile) != 0 {
		var err error
		certPool, err = c
    
func (c *TLS) tlsConfig() (*tls.Config, error) {
	var certPool *x509.CertPool
	if len(c.CAFile) != 0 {
		var err error
		certPool, err = c.readCert(c.CAFile)
		if err != nil {
			return nil, fmt.Errorf("failed to load CA %s: %w", c.CAFile, err)
		}
	}

	minTLS, err := tlsVersion(c.MinVersion, defaultMinTLSVersion)
	if err != nil {
		return nil, fmt.Errorf("invalid TLS min_version: %w", err)
	}
	maxTLS, err := tlsVersion(c.MaxVersion, defaultMaxTLSVersion)
	if err != nil {
		return nil, fmt.Errorf("invalid TLS max_version: %w", err)
	}

	if c.CertFile == "" && c.KeyFile == "" {
		return &tls.Config{
			RootCAs:              certPool,
			GetCertificate:       nil,
			GetClientCertificate: nil,
			MinVersion:           minTLS,
			MaxVersion:           maxTLS,
		}, nil
	}

	if c.CertFile == "" {
		return nil, fmt.Errorf("cert_file is required")
	}
	if c.KeyFile == "" {
		return nil, fmt.Errorf("key_file is required")
	}

	cert, err := tls.LoadX509KeyPair(c.CertFile, c.KeyFile)
	if err != nil {
		return nil, err
	}

	return &tls.Config{
		RootCAs: certPool,
		GetCertificate: func(chi *tls.ClientHelloInfo) (*tls.Certificate, error) {
			return &cert, nil
		},
		GetClientCertificate: func(cri *tls.CertificateRequestInfo) (*tls.Certificate, error) {
			return &cert, nil
		},
		MinVersion: minTLS,
		MaxVersion: maxTLS,
	}, nil
}