Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Environments builder silently overwrites existing addons #846

Open
pmalek opened this issue Oct 20, 2023 · 0 comments
Open

Environments builder silently overwrites existing addons #846

pmalek opened this issue Oct 20, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@pmalek
Copy link
Member

pmalek commented Oct 20, 2023

Problem statement

#845 introduces an ability to deploy multiple kong addons into a cluster.

environment.Builder allows adding addons via WithAddons()

The problem with the current implementation is that it silently overwrites already added addons by name. So for instance if based on #845 we were to write:

	testNS1 := "kong-test-1"
	kong1 := kongaddon.NewBuilder().WithNamespace(testNS1).WithProxyServiceType(corev1.ServiceTypeClusterIP).Build()

	testNS2 := "kong-test-2"
	kong2 := kongaddon.NewBuilder().WithNamespace(testNS2).WithProxyServiceType(corev1.ServiceTypeClusterIP).Build()

	t.Log("configuring the testing environment")
	builder := environment.NewBuilder().WithAddons(kong1, kong2)

	t.Log("building the testing environment and Kubernetes cluster")
	env, err := builder.Build(ctx)
	require.NoError(t, err)

This would silently pass but the cluster would only get 1 addon deployed.

func (b *Builder) WithAddons(addons ...clusters.Addon) *Builder doesn't return an error so it cannot act when called with an addon that has a name that's already added.

Proposed solution

We have several options to address this:

  • make Builder.addons a slice not a map (of type type Addons map[AddonName]Addon)
  • make Builder.addons return an error when an addon with the same name (and type?) already exists
@pmalek pmalek added the bug Something isn't working label Oct 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant