Skip to content

Environments builder silently overwrites existing addons #846

Open
@pmalek

Description

@pmalek

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions