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

Add UpsertTrustedClusterV2 RPC #49789

Merged
merged 24 commits into from
Dec 21, 2024
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
fb760dc
Add UpsertTrustedClusterV2 rpc
bernardjkim Dec 4, 2024
bc9e0fb
Replace confusing UpsertValidationTrustedCluster name
bernardjkim Dec 5, 2024
415d72e
Use UpsertTrustedClusterV2 in tests
bernardjkim Dec 5, 2024
7049271
Address feedback
bernardjkim Dec 5, 2024
7ebe5ce
Merge branch 'master' into bernard/upsert-trusted-cluster-v2
bernardjkim Dec 5, 2024
1933ba6
Use webclient.Find
bernardjkim Dec 5, 2024
cb1f827
Fix test/lint
bernardjkim Dec 5, 2024
6243ff2
Allow label updates
bernardjkim Dec 6, 2024
4142256
Fix test
bernardjkim Dec 6, 2024
5db82b4
Merge branch 'master' into bernard/upsert-trusted-cluster-v2
bernardjkim Dec 6, 2024
330a663
Fix error handling
bernardjkim Dec 7, 2024
456a2fe
Implement CreateTrustedClusterV2 and UpdateTrustedClusterV2
bernardjkim Dec 10, 2024
d3118e2
Address feedback
bernardjkim Dec 10, 2024
aa82d22
Minor fixes
bernardjkim Dec 10, 2024
96eea47
Merge branch 'master' into bernard/upsert-trusted-cluster-v2
bernardjkim Dec 10, 2024
3036745
Move V2 RPCs to the trust service
bernardjkim Dec 11, 2024
57fc180
Merge branch 'master' into bernard/upsert-trusted-cluster-v2
bernardjkim Dec 12, 2024
4a4bb8d
Update comment
bernardjkim Dec 12, 2024
6470291
Drop V2 suffix
bernardjkim Dec 12, 2024
f8bc242
Require matching revision
bernardjkim Dec 12, 2024
fba6930
Fix upsert/update revision
bernardjkim Dec 20, 2024
519c124
Drop V2 from Create and Update APIs
bernardjkim Dec 20, 2024
3f46c89
Merge branch 'master' into bernard/upsert-trusted-cluster-v2
bernardjkim Dec 20, 2024
a290e38
Lint: Fix typo
bernardjkim Dec 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 48 additions & 4 deletions api/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -2285,12 +2285,56 @@ func (c *Client) GetTrustedClusters(ctx context.Context) ([]types.TrustedCluster
}

// UpsertTrustedCluster creates or updates a Trusted Cluster.
func (c *Client) UpsertTrustedCluster(ctx context.Context, trusedCluster types.TrustedCluster) (types.TrustedCluster, error) {
trustedCluster, ok := trusedCluster.(*types.TrustedClusterV2)
//
// Deprecated: Use [Client.UpsertTrustedClusterV2] instead.
func (c *Client) UpsertTrustedCluster(ctx context.Context, trustedCluster types.TrustedCluster) (types.TrustedCluster, error) {
trustedClusterV2, ok := trustedCluster.(*types.TrustedClusterV2)
if !ok {
return nil, trace.BadParameter("invalid type %T", trustedCluster)
}
resp, err := c.grpc.UpsertTrustedCluster(ctx, trustedClusterV2)
if err != nil {
return nil, trace.Wrap(err)
}
return resp, nil
}

// UpsertTrustedClusterV2 creates or updates a Trusted Cluster.
func (c *Client) UpsertTrustedClusterV2(ctx context.Context, trustedCluster types.TrustedCluster) (types.TrustedCluster, error) {
trustedClusterV2, ok := trustedCluster.(*types.TrustedClusterV2)
if !ok {
return nil, trace.BadParameter("invalid type %T", trustedCluster)
}
req := &trustpb.UpsertTrustedClusterRequest{TrustedCluster: trustedClusterV2}
resp, err := c.TrustClient().UpsertTrustedCluster(ctx, req)
if err != nil {
return nil, trace.Wrap(err)
}
return resp, nil
}

// CreateTrustedClusterV2 creates a Trusted Cluster.
func (c *Client) CreateTrustedClusterV2(ctx context.Context, trustedCluster types.TrustedCluster) (types.TrustedCluster, error) {
trustedClusterV2, ok := trustedCluster.(*types.TrustedClusterV2)
if !ok {
return nil, trace.BadParameter("invalid type %T", trustedCluster)
}
req := &trustpb.CreateTrustedClusterRequest{TrustedCluster: trustedClusterV2}
resp, err := c.TrustClient().CreateTrustedCluster(ctx, req)
if err != nil {
return nil, trace.Wrap(err)
}
return resp, nil
}

// UpdateTrustedClusterV2 updates a Trusted Cluster.
func (c *Client) UpdateTrustedClusterV2(ctx context.Context, trustedCluster types.TrustedCluster) (types.TrustedCluster, error) {
trustedClusterV2, ok := trustedCluster.(*types.TrustedClusterV2)
if !ok {
return nil, trace.BadParameter("invalid type %T", trusedCluster)
return nil, trace.BadParameter("invalid type %T", trustedCluster)
}
resp, err := c.grpc.UpsertTrustedCluster(ctx, trustedCluster)
req := &trustpb.UpdateTrustedClusterRequest{TrustedCluster: trustedClusterV2}
resp, err := c.TrustClient().UpdateTrustedCluster(ctx, req)
if err != nil {
return nil, trace.Wrap(err)
}
Expand Down
1,925 changes: 965 additions & 960 deletions api/client/proto/authservice.pb.go

Large diffs are not rendered by default.

Loading
Loading