func (builder *PolicyBuilder) External() *external.Data {
	return external.NewData(
		builder.users,
		builder.secrets,
	)
}
External returns the generated external data
package builder
import (
	"math/rand"
	"strings"
	"github.com/Aptomi/aptomi/pkg/external"
	"github.com/Aptomi/aptomi/pkg/external/secrets"
	"github.com/Aptomi/aptomi/pkg/external/users"
	"github.com/Aptomi/aptomi/pkg/lang"
	"github.com/Aptomi/aptomi/pkg/runtime"
	"github.com/Aptomi/aptomi/pkg/util"
)
var randSeed = int64(239)
var idLength = 16
type PolicyBuilder struct {
	random    *rand.Rand
	namespace string
	policy    *lang.Policy
	users     *users.UserLoaderMock
	secrets   *secrets.SecretLoaderMock
	domainAdmin     *lang.User
	domainAdminView *lang.PolicyView
}
func NewPolicyBuilder() *PolicyBuilder {
	return NewPolicyBuilderWithNS("main")
}
func NewPolicyBuilderWithNS(namespace string) *PolicyBuilder {
	result := &PolicyBuilder{
		random:    rand.New(rand.NewSource(randSeed)),
		namespace: namespace,
		policy:    lang.NewPolicy(),
		users:     users.NewUserLoaderMock(),
		secrets:   secrets.NewSecretLoaderMock(),
	}
	result.domainAdmin = result.AddUserDomainAdmin()
	result.domainAdminView = result.policy.View(result.domainAdmin)
	return result
}
func (builder *PolicyBuilder) SwitchNamespace(namespace string) {
	builder.namespace = namespace
}
func (builder *PolicyBuilder) AddClaim(user *lang.User, service *lang.Service) *lang.Claim {
	result := &lang.Claim{
		TypeKind: lang.TypeClaim.GetTypeKind(),
		Metadata: lang.Metadata{
			Namespace: builder.namespace,
			Name:      util.RandomID(builder.random, idLength),
		},
		User:    strings.ToUpper(user.Name),  
		Service: service.Namespace + "/" + service.Name,
		Labels:  make(map[string]string),
	}
	builder.addObject(builder.domainAdminView, result)
	return result
}
func (builder *PolicyBuilder) AddUser() *lang.User {
	result := &lang.User{
		Name:        util.RandomID(builder.random, idLength),
		Labels:      map[string]string{},
		DomainAdmin: true,  
	}
	builder.users.AddUser(result)
	return result
}
func (builder *PolicyBuilder) PanicWhenLoadingUsers() {
	builder.users.SetPanic(true)
}
func (builder *PolicyBuilder) AddUserDomainAdmin() *lang.User {
	return builder.AddUser()
}
func (builder *PolicyBuilder) AddBundle() *lang.Bundle {
	result := &lang.Bundle{
		TypeKind: lang.TypeBundle.GetTypeKind(),
		Metadata: lang.Metadata{
			Namespace: builder.namespace,
			Name:      util.RandomID(builder.random, idLength),
		},
	}
	builder.addObject(builder.domainAdminView, result)
	return result
}
func (builder *PolicyBuilder) AddService(bundle *lang.Bundle, criteria *lang.Criteria) *lang.Service {
	result := &lang.Service{
		TypeKind: lang.TypeService.GetTypeKind(),
		Metadata: lang.Metadata{
			Namespace: builder.namespace,
			Name:      util.RandomID(builder.random, idLength),
		},
		Contexts: []*lang.Context{{
			Name:     util.RandomID(builder.random, idLength),
			Criteria: criteria,
			Allocation: &lang.Allocation{
				Bundle: bundle.Name,
			},
		}},
	}
	builder.addObject(builder.domainAdminView, result)
	return result
}
func (builder *PolicyBuilder) AddServiceMultipleContexts(bundle *lang.Bundle, criteriaArray ...*lang.Criteria) *lang.Service {
	result := &lang.Service{
		TypeKind: lang.TypeService.GetTypeKind(),
		Metadata: lang.Metadata{
			Namespace: builder.namespace,
			Name:      util.RandomID(builder.random, idLength),
		},
	}
	for _, criteria := range criteriaArray {
		result.Contexts = append(result.Contexts,
			&lang.Context{
				Name:     util.RandomID(builder.random, idLength),
				Criteria: criteria,
				Allocation: &lang.Allocation{
					Bundle: bundle.Name,
				},
			},
		)
	}
	builder.addObject(builder.domainAdminView, result)
	return result
}
func (builder *PolicyBuilder) AddRule(criteria *lang.Criteria, actions *lang.RuleActions) *lang.Rule {
	result := &lang.Rule{
		TypeKind: lang.TypeRule.GetTypeKind(),
		Metadata: lang.Metadata{
			Namespace: builder.namespace,
			Name:      util.RandomID(builder.random, idLength),
		},
		Weight:   len(builder.policy.GetObjectsByKind(lang.TypeRule.Kind)),
		Criteria: criteria,
		Actions:  actions,
	}
	builder.addObject(builder.domainAdminView, result)
	return result
}
func (builder *PolicyBuilder) AddCluster() *lang.Cluster {
	result := &lang.Cluster{
		TypeKind: lang.TypeCluster.GetTypeKind(),
		Metadata: lang.Metadata{
			Namespace: runtime.SystemNS,
			Name:      util.RandomID(builder.random, idLength),
		},
		Type: "kubernetes",
		Config: struct {
			Namespace        string
			DefaultNamespace string
		}{
			Namespace:        "default",
			DefaultNamespace: "k8ns",
		},
	}
	builder.addObject(builder.domainAdminView, result)
	return result
}
func (builder *PolicyBuilder) Criteria(all string, any string, none string) *lang.Criteria {
	return &lang.Criteria{
		RequireAll:  []string{all},
		RequireAny:  []string{any},
		RequireNone: []string{none},
	}
}
func (builder *PolicyBuilder) CriteriaTrue() *lang.Criteria {
	return &lang.Criteria{
		RequireAny: []string{"true"},
	}
}
func (builder *PolicyBuilder) AllocationKeys(key ...string) []string {
	return key
}
func (builder *PolicyBuilder) UnknownComponent() *lang.BundleComponent {
	return &lang.BundleComponent{
		Name: util.RandomID(builder.random, idLength),
	}
}
func (builder *PolicyBuilder) CodeComponent(codeParams util.NestedParameterMap, discoveryParams util.NestedParameterMap) *lang.BundleComponent {
	return &lang.BundleComponent{
		Name: util.RandomID(builder.random, idLength),
		Code: &lang.Code{
			Type:   "helm",
			Params: codeParams,
		},
		Discovery: discoveryParams,
	}
}
func (builder *PolicyBuilder) ServiceComponent(service *lang.Service) *lang.BundleComponent {
	return &lang.BundleComponent{
		Name:    util.RandomID(builder.random, idLength),
		Service: service.Namespace + "/" + service.Name,
	}
}
func (builder *PolicyBuilder) AddBundleComponent(bundle *lang.Bundle, component *lang.BundleComponent) *lang.BundleComponent {
	bundle.Components = append(bundle.Components, component)
	return component
}
func (builder *PolicyBuilder) AddComponentClaim(component *lang.BundleComponent, dependsOn *lang.BundleComponent) {
	component.Dependencies = append(component.Dependencies, dependsOn.Name)
}
func (builder *PolicyBuilder) RuleActions(labelOps lang.LabelOperations) *lang.RuleActions {
	result := &lang.RuleActions{}
	if labelOps != nil {
		result.ChangeLabels = labelOps
	}
	return result
}
func (builder *PolicyBuilder) Policy() *lang.Policy {
	err := builder.policy.Validate()
	if err != nil {
		panic(err)
	}
	return builder.policy
}