Skip to content

Commit

Permalink
fix: import cycle
Browse files Browse the repository at this point in the history
Signed-off-by: Mike Beaumont <mjboamail@gmail.com>
  • Loading branch information
michaelbeaumont committed Mar 31, 2022
1 parent cc7cb0f commit 0e59d8b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
11 changes: 8 additions & 3 deletions pkg/core/resources/apis/mesh/proxytemplate_validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,14 @@ import (
mesh_proto "github.com/kumahq/kuma/api/mesh/v1alpha1"
"github.com/kumahq/kuma/pkg/core/validators"
"github.com/kumahq/kuma/pkg/util/envoy"
"github.com/kumahq/kuma/pkg/xds/generator"
)

var AvailableProfiles map[string]struct{}

func init() {
AvailableProfiles = map[string]struct{}{}
}

func (t *ProxyTemplateResource) Validate() error {
var verr validators.ValidationError
verr.Add(validateSelectors(t.Spec.Selectors))
Expand Down Expand Up @@ -191,9 +196,9 @@ func validateImports(imports []string) validators.ValidationError {
verr.AddViolationAt(validators.RootedAt("imports").Index(i), "cannot be empty")
continue
}
if _, ok := generator.AvailableProfiles[imp]; !ok {
if _, ok := AvailableProfiles[imp]; !ok {
var profiles []string
for profile := range generator.AvailableProfiles {
for profile := range AvailableProfiles {
profiles = append(profiles, profile)
}
availableProfilesMsg := strings.Join(profiles, ",")
Expand Down
4 changes: 1 addition & 3 deletions pkg/xds/generator/proxy_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,6 @@ var DefaultTemplateResolver template.ProxyTemplateResolver = &template.StaticPro

var predefinedProfiles = make(map[string]ResourceGenerator)

var AvailableProfiles map[string]struct{}

func init() {
RegisterProfile(core_mesh.ProfileDefaultProxy, NewDefaultProxyProfile())
RegisterProfile(IngressProxy, CompositeResourceGenerator{AdminProxyGenerator{}, IngressGenerator{}})
Expand All @@ -122,5 +120,5 @@ func init() {

func RegisterProfile(profileName string, generator ResourceGenerator) {
predefinedProfiles[profileName] = generator
AvailableProfiles[profileName] = struct{}{}
core_mesh.AvailableProfiles[profileName] = struct{}{}
}

0 comments on commit 0e59d8b

Please sign in to comment.