func (brokerRegistry BrokerRegistry) GetAllServices() []*ServiceDefinition {
	var out []*ServiceDefinition
	for _, svc := range brokerRegistry {
		out = append(out, svc)
	}
	sort.Slice(out, func(i int, j int) bool { return out[i].Name < out[j].Name })
	return out
}
GetAllServices returns a list of all registered brokers whether or not the
user has enabled them. The brokers are sorted in lexocographic order based
on name.
package broker
import (
	"fmt"
	"log"
	"sort"
	"github.com/GoogleCloudPlatform/gcp-service-broker/pkg/toggles"
	"github.com/GoogleCloudPlatform/gcp-service-broker/utils"
)
var (
	lifecycleTagToggles = map[string]toggles.Toggle{
		"preview":      toggles.Features.Toggle("enable-preview-services", true, `Enable services that are new to the broker this release.`),
		"unmaintained": toggles.Features.Toggle("enable-unmaintained-services", false, `Enable broker services that are unmaintained.`),
		"eol":          toggles.Features.Toggle("enable-eol-services", false, `Enable broker services that are end of life.`),
		"beta":         toggles.Features.Toggle("enable-gcp-beta-services", true, "Enable services that are in GCP Beta. These have no SLA or support policy."),
		"deprecated":   toggles.Features.Toggle("enable-gcp-deprecated-services", false, "Enable services that use deprecated GCP components."),
		"terraform":    toggles.Features.Toggle("enable-terraform-services", false, "Enable services that use the experimental, unstable, Terraform back-end."),
	}
	enableBuiltinServices = toggles.Features.Toggle("enable-builtin-services", true, `Enable services that are built in to the broker i.e. not brokerpaks.`)
)
type BrokerRegistry map[string]*ServiceDefinition
func (brokerRegistry BrokerRegistry) Register(service *ServiceDefinition) {
	name := service.Name
	if _, ok := brokerRegistry[name]; ok {
		log.Fatalf("Tried to register multiple instances of: %q", name)
	}
	if _, err := service.CatalogEntry(); err != nil {
		log.Fatalf("Error registering service %q, %s", name, err)
	}
	if err := service.Validate(); err != nil {
		log.Fatalf("Error validating service %q, %s", name, err)
	}
	brokerRegistry[name] = service
}
func (brokerRegistry *BrokerRegistry) GetEnabledServices() ([]*ServiceDefinition, error) {
	var out []*ServiceDefinition
	for _, svc := range brokerRegistry.GetAllServices() {
		isEnabled := true
		if svc.IsBuiltin {
			isEnabled = enableBuiltinServices.IsActive()
		}
		if entry, err := svc.CatalogEntry(); err != nil {
			return nil, err
		} else {
			tags := utils.NewStringSet(entry.Tags...)
			for tag, toggle := range lifecycleTagToggles {
				if !toggle.IsActive() && tags.Contains(tag) {
					isEnabled = false
					break
				}
			}
		}
		if isEnabled {
			out = append(out, svc)
		}
	}
	return out, nil
}