Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
2,636 changes: 1,131 additions & 1,505 deletions api/client/proto/authservice.pb.go

Large diffs are not rendered by default.

24 changes: 0 additions & 24 deletions api/client/proto/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,30 +39,6 @@ func (d *Duration) Set(value time.Duration) {
*d = Duration(value)
}

// FromWatchKind converts the watch kind value between internal
// and the protobuf format
func FromWatchKind(wk types.WatchKind) WatchKind {
return WatchKind{
Name: wk.Name,
Kind: wk.Kind,
SubKind: wk.SubKind,
LoadSecrets: wk.LoadSecrets,
Filter: wk.Filter,
}
}

// ToWatchKind converts the watch kind value between the protobuf
// and the internal format
func ToWatchKind(wk WatchKind) types.WatchKind {
return types.WatchKind{
Name: wk.Name,
Kind: wk.Kind,
SubKind: wk.SubKind,
LoadSecrets: wk.LoadSecrets,
Filter: wk.Filter,
}
}

// CheckAndSetDefaults checks and sets default values
func (req *HostCertsRequest) CheckAndSetDefaults() error {
if req.HostID == "" {
Expand Down
6 changes: 1 addition & 5 deletions api/client/streamwatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,7 @@ import (
// NewWatcher returns a new streamWatcher
func (c *Client) NewWatcher(ctx context.Context, watch types.Watch) (types.Watcher, error) {
cancelCtx, cancel := context.WithCancel(ctx)
var protoWatch proto.Watch
for _, kind := range watch.Kinds {
protoWatch.Kinds = append(protoWatch.Kinds, proto.FromWatchKind(kind))
}
stream, err := c.grpc.WatchEvents(cancelCtx, &protoWatch, c.callOpts...)
stream, err := c.grpc.WatchEvents(cancelCtx, &proto.Watch{Kinds: watch.Kinds}, c.callOpts...)
if err != nil {
cancel()
return nil, trail.FromGRPC(err)
Expand Down
22 changes: 4 additions & 18 deletions api/proto/teleport/legacy/client/proto/authservice.proto
Original file line number Diff line number Diff line change
Expand Up @@ -133,33 +133,19 @@ message Event {
types.OktaAssignmentV1 OktaAssignment = 41 [(gogoproto.jsontag) = "okta_assignment,omitempty"];
// Integration is an Integration resource.
types.IntegrationV1 Integration = 42 [(gogoproto.jsontag) = "integration,omitempty"];
// WatchStatus is an WatchStatus resource.
types.WatchStatusV1 WatchStatus = 43 [(gogoproto.jsontag) = "watch_status,omitempty"];
}
}

// Watch specifies watch parameters
message Watch {
// Kinds specifies object kinds to watch
repeated WatchKind Kinds = 1 [
repeated types.WatchKind Kinds = 1 [
(gogoproto.nullable) = false,
(gogoproto.jsontag) = "kinds,omitempty"
];
}

// WatchKind specifies resource kind to watch
message WatchKind {
// Kind is a resource kind to watch
string Kind = 1 [(gogoproto.jsontag) = "kind"];
// LoadSecrets specifies whether to load secrets
bool LoadSecrets = 2 [(gogoproto.jsontag) = "load_secrets"];
// Name is an optional specific resource type to watch,
// if specified only the events with a specific resource
// name will be sent
string Name = 3 [(gogoproto.jsontag) = "name"];
// Filter is an optional mapping of custom filter parameters.
// Valid values vary by resource kind.
map<string, string> Filter = 4 [(gogoproto.jsontag) = "filter,omitempty"];
// SubKind is a resource subkind to watch
string SubKind = 5 [(gogoproto.jsontag) = "sub_kind,omitempty"];
bool AllowPartialSuccess = 2 [(gogoproto.jsontag) = "allow_partial_success,omitempty"];
}

// HostCertsRequest specifies certificate-generation parameters
Expand Down
47 changes: 47 additions & 0 deletions api/proto/teleport/legacy/types/types.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5352,3 +5352,50 @@ enum HeadlessAuthenticationState {
// authentication approved.
HEADLESS_AUTHENTICATION_STATE_APPROVED = 3;
}

// WatchKind specifies resource kind to watch
message WatchKind {
// Kind is a resource kind to watch
string Kind = 1 [(gogoproto.jsontag) = "kind"];
// LoadSecrets specifies whether to load secrets
bool LoadSecrets = 2 [(gogoproto.jsontag) = "load_secrets"];
// Name is an optional specific resource type to watch,
// if specified only the events with a specific resource
// name will be sent
string Name = 3 [(gogoproto.jsontag) = "name"];
// Filter is an optional mapping of custom filter parameters.
// Valid values vary by resource kind.
map<string, string> Filter = 4 [(gogoproto.jsontag) = "filter,omitempty"];
// SubKind is a resource subkind to watch
string SubKind = 5 [(gogoproto.jsontag) = "sub_kind,omitempty"];
// Version optionally specifies the resource version to watch.
string Version = 6 [(gogoproto.jsontag) = "version,omitempty"];
}

// WatchStatusV1 is intended to be attached to OpInit events and contain information about a successful WatchEvents call.
message WatchStatusV1 {
// Kind is the resource kind.
string Kind = 1 [(gogoproto.jsontag) = "kind"];
// SubKind is an optional resource subkind. Currently unused for this resource.
string SubKind = 2 [(gogoproto.jsontag) = "sub_kind,omitempty"];
// Version is the resource version.
string Version = 3 [(gogoproto.jsontag) = "version"];
// Metadata is the resource metadata.
Metadata Metadata = 4 [
(gogoproto.nullable) = false,
(gogoproto.jsontag) = "metadata"
];
// Spec is the resource spec.
WatchStatusSpecV1 Spec = 5 [
(gogoproto.nullable) = false,
(gogoproto.jsontag) = "spec"
];
}

// WatchStatusSpecV1 contains resource kinds confirmed by WatchEvents to be included in the event stream.
message WatchStatusSpecV1 {
repeated WatchKind Kinds = 1 [
(gogoproto.nullable) = false,
(gogoproto.jsontag) = "kinds"
];
}
21 changes: 0 additions & 21 deletions api/types/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,27 +99,6 @@ type Watch struct {
MetricComponent string
}

// WatchKind specifies resource kind to watch
type WatchKind struct {
// Kind is a resource kind to watch
Kind string
// SubKind optionally specifies the subkind of resource to watch.
// Some resource kinds are ambigious like web sessions, subkind in this case
// specifies the type of web session
SubKind string
// Name is an optional specific resource type to watch,
// if specified, only the events with the given resource
// name will be sent
Name string
// Version optionally specifies the resource version to watch.
Version string
// LoadSecrets specifies whether to load secrets
LoadSecrets bool
// Filter supplies custom event filter parameters that differ by
// resource (e.g. "state":"pending" for access requests).
Filter map[string]string
}

// Matches attempts to determine if the supplied event matches
// this WatchKind. If the WatchKind is misconfigured, or the
// event appears malformed, an error is returned.
Expand Down
Loading