-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1280f45
commit b7f899e
Showing
16 changed files
with
264 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package bridge | ||
|
||
import ( | ||
"context" | ||
"github.com/hashicorp/consul/internal/tenancy/internal/types" | ||
"github.com/hashicorp/consul/proto-public/pbresource" | ||
) | ||
|
||
// V2TenancyBridge is used by the resource service to access V2 implementations of | ||
// partitions and namespaces. | ||
type V2TenancyBridge struct { | ||
client pbresource.ResourceServiceClient | ||
} | ||
|
||
// WithClient inject a ResourceServiceClient in the V2TenancyBridge. | ||
// This is needed to break a circular dependency between | ||
// the ResourceServiceServer, ResourceServiceClient and the TenancyBridge | ||
func (b *V2TenancyBridge) WithClient(client pbresource.ResourceServiceClient) *V2TenancyBridge { | ||
b.client = client | ||
return b | ||
} | ||
|
||
func NewV2TenancyBridge() *V2TenancyBridge { | ||
return &V2TenancyBridge{} | ||
} | ||
|
||
func (b *V2TenancyBridge) NamespaceExists(partition, namespace string) (bool, error) { | ||
read, err := b.client.Read(context.Background(), &pbresource.ReadRequest{ | ||
Id: &pbresource.ID{ | ||
Name: namespace, | ||
Tenancy: &pbresource.Tenancy{ | ||
Partition: partition, | ||
}, | ||
Type: types.NamespaceType, | ||
}, | ||
}) | ||
return read != nil && read.Resource != nil, err | ||
} | ||
|
||
func (b *V2TenancyBridge) IsNamespaceMarkedForDeletion(partition, namespace string) (bool, error) { | ||
read, err := b.client.Read(context.Background(), &pbresource.ReadRequest{ | ||
Id: &pbresource.ID{ | ||
Name: namespace, | ||
Tenancy: &pbresource.Tenancy{ | ||
Partition: partition, | ||
}, | ||
Type: types.NamespaceType, | ||
}, | ||
}) | ||
return read.Resource != nil, err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.