Skip to content

Commit e15a9cf

Browse files
authored
Merge pull request #102 from ntnn/multi-list
✨ Add multi.Provider.ProviderPrefixes
2 parents 9406a39 + 9fc4a59 commit e15a9cf

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

providers/multi/provider.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,14 @@ func (p *Provider) splitClusterName(clusterName string) (string, string) {
177177
return parts[0], parts[1]
178178
}
179179

180+
// ProviderNames returns the sorted list of prefixes for the
181+
// registered providers.
182+
func (p *Provider) ProviderNames() []string {
183+
p.lock.RLock()
184+
defer p.lock.RUnlock()
185+
return slices.Sorted(maps.Keys(p.providers))
186+
}
187+
180188
// GetProvider returns the provider for the given provider name.
181189
func (p *Provider) GetProvider(providerName string) (multicluster.Provider, bool) {
182190
p.lock.RLock()

providers/multi/provider_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,9 @@ var _ = Describe("Provider Multi", Ordered, func() {
184184
By("Adding the second namespace provider after starting the manager", func() {
185185
err := provider.AddProvider("cloud2", cloud2provider)
186186
Expect(err).NotTo(HaveOccurred())
187+
188+
providerNames := provider.ProviderNames()
189+
Expect(providerNames).To(ContainElements("cloud1", "cloud2"))
187190
})
188191
})
189192

0 commit comments

Comments
 (0)