Skip to content

Commit

Permalink
Add basic CRUD for BotInstanceService (#42899)
Browse files Browse the repository at this point in the history
* Add basic CRUD for BotInstanceService

This adds an early backend for the bot instance service, with resource
definitions and basic CRUD operations.

* Update api/proto/teleport/machineid/v1/bot_instance.proto

Co-authored-by: Noah Stride <noah.stride@goteleport.com>

* Further work on BotInstance boilerplate

Among other things, this adds event definitions, RBAC and presets,
and client definitions. This also includes a few proto changes,
namely moving bot name and instance ID from .Status to .Spec so
metadata can be uniformly generated.

This also adds tests for the backend service showing functional CRUD.

* gRPC tests; fix filtering; fix import lints; misc cleanup

* Consistently use `instance_id` in gRPC fields

* Add tctl support for bot_instance resource

* protos update

* Various typo fixes

* Fix more comment typos

* More doc comments and minor test tweaks

---------

Co-authored-by: Noah Stride <noah.stride@goteleport.com>
  • Loading branch information
timothyb89 and strideynet committed Aug 8, 2024
1 parent c40d141 commit a319f62
Show file tree
Hide file tree
Showing 25 changed files with 3,342 additions and 243 deletions.
5 changes: 5 additions & 0 deletions api/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -857,6 +857,11 @@ func (c *Client) BotServiceClient() machineidv1pb.BotServiceClient {
return machineidv1pb.NewBotServiceClient(c.conn)
}

// BotInstanceServiceClient returns an unadorned client for the bot instance service
func (c *Client) BotInstanceServiceClient() machineidv1pb.BotInstanceServiceClient {
return machineidv1pb.NewBotInstanceServiceClient(c.conn)
}

// WorkloadIdentityServiceClient returns an unadorned client for the workload
// identity service.
func (c *Client) WorkloadIdentityServiceClient() machineidv1pb.WorkloadIdentityServiceClient {
Expand Down
8 changes: 8 additions & 0 deletions api/client/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
accessmonitoringrulesv1 "github.com/gravitational/teleport/api/gen/proto/go/teleport/accessmonitoringrules/v1"
crownjewelv1 "github.com/gravitational/teleport/api/gen/proto/go/teleport/crownjewel/v1"
kubewaitingcontainerpb "github.com/gravitational/teleport/api/gen/proto/go/teleport/kubewaitingcontainer/v1"
machineidv1 "github.com/gravitational/teleport/api/gen/proto/go/teleport/machineid/v1"
"github.com/gravitational/teleport/api/types"
"github.com/gravitational/teleport/api/types/accesslist"
accesslistv1conv "github.com/gravitational/teleport/api/types/accesslist/convert/v1"
Expand Down Expand Up @@ -66,6 +67,10 @@ func EventToGRPC(in types.Event) (*proto.Event, error) {
out.Resource = &proto.Event_CrownJewel{
CrownJewel: r,
}
case *machineidv1.BotInstance:
out.Resource = &proto.Event_BotInstance{
BotInstance: r,
}
}
case *types.ResourceHeader:
out.Resource = &proto.Event_ResourceHeader{
Expand Down Expand Up @@ -486,6 +491,9 @@ func EventFromGRPC(in *proto.Event) (*types.Event, error) {
} else if r := in.GetCrownJewel(); r != nil {
out.Resource = types.Resource153ToLegacy(r)
return &out, nil
} else if r := in.GetBotInstance(); r != nil {
out.Resource = types.Resource153ToLegacy(r)
return &out, nil
} else {
return nil, trace.BadParameter("received unsupported resource %T", in.Resource)
}
Expand Down
510 changes: 268 additions & 242 deletions api/client/proto/event.pb.go

Large diffs are not rendered by default.

Loading

0 comments on commit a319f62

Please sign in to comment.