func RunExample(client *Client, serviceExample CompleteServiceExample) error {
	executor, err := newExampleExecutor(client, serviceExample)
	if err != nil {
		return err
	}
	executor.LogTestInfo()
	defer func() {
		log.Println("Cleaning up the environment")
		executor.Unbind()
		executor.Deprovision()
	}()
	if err := executor.Provision(); err != nil {
		return err
	}
	bindResponse, err := executor.Bind()
	if err != nil {
		return err
	}
	if err := executor.Unbind(); err != nil {
		return err
	}
	if err := executor.Deprovision(); err != nil {
		return err
	}
	var binding brokerapi.Binding
	err = json.Unmarshal(bindResponse, &binding)
	if err != nil {
		return err
	}
	credentialsEntry := binding.Credentials.(map[string]interface{})
	if err := broker.ValidateVariablesAgainstSchema(credentialsEntry, serviceExample.ExpectedOutput); err != nil {
		log.Printf("Error: results don't match JSON Schema: %v", err)
		return err
	}
	return nil
}
RunExample runs a single example against the given service on the broker
pointed to by client.
package client
import (
	"encoding/json"
	"errors"
	"fmt"
	"io/ioutil"
	"log"
	"math/rand"
	"os"
	"time"
	"github.com/pivotal-cf/brokerapi"
	"github.com/GoogleCloudPlatform/gcp-service-broker/pkg/broker"
)
func RunExamplesForService(allExamples []CompleteServiceExample, client *Client, serviceName, exampleName string) error {
	rand.Seed(time.Now().UTC().UnixNano())
	for _, completeServiceExample := range FilterMatchingServiceExamples(allExamples, serviceName, exampleName) {
		if err := RunExample(client, completeServiceExample); err != nil {
			return err
		}
	}
	return nil
}
func RunExamplesFromFile(client *Client, fileName, serviceName, exampleName string) error {
	rand.Seed(time.Now().UTC().UnixNano())
	jsonFile, err := os.Open(fileName)
	if err != nil {
		log.Fatalf("Error opening file: %v", err)
	}
	defer jsonFile.Close()
	var allExamples []CompleteServiceExample
	byteValue, _ := ioutil.ReadAll(jsonFile)
	json.Unmarshal(byteValue, &allExamples)
	for _, completeServiceExample := range FilterMatchingServiceExamples(allExamples, serviceName, exampleName) {
		if err := RunExample(client, completeServiceExample); err != nil {
			return err
		}
	}
	return nil
}
type CompleteServiceExample struct {
	broker.ServiceExample `json: ",inline"`
	ServiceName           string                  `json: "service_name"`
	ServiceId             string                  `json: "service_id"`
	ExpectedOutput        map[string]interface{} `json: "expected_output"`
}
func GetExamplesForAService(service *broker.ServiceDefinition) ([]CompleteServiceExample, error) {
	var examples []CompleteServiceExample
	for _, example := range service.Examples {
		serviceCatalogEntry, err := service.CatalogEntry()
		if err != nil {
			return nil, err
		}
		var completeServiceExample = CompleteServiceExample{
			ServiceExample: example,
			ServiceId:      serviceCatalogEntry.ID,
			ServiceName:    service.Name,
			ExpectedOutput: broker.CreateJsonSchema(service.BindOutputVariables),
		}
		examples = append(examples, completeServiceExample)
	}
	return examples, nil
}
func FilterMatchingServiceExamples(allExamples []CompleteServiceExample, serviceName, exampleName string) []CompleteServiceExample {
	var matchingExamples []CompleteServiceExample
	for _, completeServiceExample := range allExamples {
		if (serviceName != "" && serviceName != completeServiceExample.ServiceName) || (exampleName != "" && exampleName != completeServiceExample.ServiceExample.Name) {
			continue
		}
		matchingExamples = append(matchingExamples, completeServiceExample)
	}
	return matchingExamples
}