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: dnsprovider.go
    path of file: ./repos/easegress/pkg/object/autocertmanager
    
    the code of the file until where you have to start completion: /*
 * Copyright (c) 2017, The Easegress Authors
 * All rights reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the Lice
    
func newDNSProvider(d *DomainSpec) (dnsProvider, error) {
	if len(d.DNSProvider) == 0 {
		return nil, fmt.Errorf("DNS provider is not configured for domain: %s", d.Name)
	}

	name := d.DNSProvider["name"]
	if len(name) == 0 {
		return nil, fmt.Errorf("DNS provider name is required for domain: %s", d.Name)
	}

	if _, ok := d.DNSProvider["zone"]; !ok {
		return nil, fmt.Errorf("DNS provider field 'zone' is required for domain: %s", d.Name)
	}

	creator := dnsProviderCreators[name]
	if creator == nil {
		return nil, fmt.Errorf("unknown DNS provider %q for domain: %s", name, d.Name)
	}

	for _, f := range creator.requiredFields {
		if _, ok := d.DNSProvider[f]; !ok {
			return nil, fmt.Errorf("DNS provider field %q is required for domain: %s", f, d.Name)
		}
	}

	return creator.creatorFn(d)
}