Browse Source

Ensure that the default namespace always exists even prior to resource creation (#19852)

pull/19861/head
Matt Keeler 12 months ago committed by GitHub
parent
commit
bfad6a4e07
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      internal/tenancy/internal/bridge/tenancy_bridge.go
  2. 6
      internal/tenancy/internal/bridge/tenancy_bridge_ce.go

7
internal/tenancy/internal/bridge/tenancy_bridge.go

@ -33,6 +33,13 @@ func NewV2TenancyBridge() *V2TenancyBridge {
}
func (b *V2TenancyBridge) NamespaceExists(partition, namespace string) (bool, error) {
if namespace == resource.DefaultNamespaceName {
// The default namespace implicitly exists in all partitions regardless of whether
// the resource has actually been created yet. Therefore all we need to do is check
// if the partition exists to know whether the namespace exists.
return b.PartitionExists(partition)
}
_, err := b.client.Read(context.Background(), &pbresource.ReadRequest{
Id: &pbresource.ID{
Name: namespace,

6
internal/tenancy/internal/bridge/tenancy_bridge_ce.go

@ -5,8 +5,12 @@
package bridge
import "github.com/hashicorp/consul/internal/resource"
func (b *V2TenancyBridge) PartitionExists(partition string) (bool, error) {
if partition == "default" {
if partition == resource.DefaultPartitionName {
// In CE partition resources are never actually created. However, conceptually
// the default partition always exists.
return true, nil
}
return false, nil

Loading…
Cancel
Save