Skip to content

Commit

Permalink
Enable ListNotifierConnectors for Slack (#4505)
Browse files Browse the repository at this point in the history
* Enable ListNotifierConnectors for Slack

* Detect implicitly defined connectors

* Fix lint
  • Loading branch information
begelundmuller authored Apr 3, 2024
1 parent c845cc1 commit 7758469
Show file tree
Hide file tree
Showing 11 changed files with 750 additions and 707 deletions.
2 changes: 1 addition & 1 deletion proto/gen/rill/admin/v1/admin.swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2187,7 +2187,7 @@ definitions:
`NullValue` is a singleton enumeration to represent the null value for the
`Value` type union.
The JSON representation for `NullValue` is JSON `null`.
The JSON representation for `NullValue` is JSON `null`.
- NULL_VALUE: Null value.
rpcStatus:
Expand Down
1,335 changes: 673 additions & 662 deletions proto/gen/rill/runtime/v1/api.pb.go

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions proto/gen/rill/runtime/v1/api.pb.validate.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion proto/gen/rill/runtime/v1/runtime.swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2925,7 +2925,7 @@ definitions:
`NullValue` is a singleton enumeration to represent the null value for the
`Value` type union.
The JSON representation for `NullValue` is JSON `null`.
The JSON representation for `NullValue` is JSON `null`.
- NULL_VALUE: Null value.
rpcStatus:
Expand Down Expand Up @@ -3594,6 +3594,8 @@ definitions:
type: boolean
implementsFileStore:
type: boolean
implementsNotifier:
type: boolean
description: ConnectorDriver represents a connector driver available in the runtime.
v1CreateInstanceRequest:
type: object
Expand Down
1 change: 1 addition & 0 deletions proto/rill/runtime/v1/api.proto
Original file line number Diff line number Diff line change
Expand Up @@ -698,6 +698,7 @@ message ConnectorDriver {
bool implements_olap = 16;
bool implements_object_store = 17;
bool implements_file_store = 18;
bool implements_notifier = 19;
}

// AnalyzedConnector contains information about a connector that is referenced in the project files.
Expand Down
1 change: 1 addition & 0 deletions runtime/drivers/connectors.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ type Spec struct {
ImplementsOLAP bool
ImplementsObjectStore bool
ImplementsFileStore bool
ImplementsNotifier bool
}

// PropertySpec provides metadata about a single connector property.
Expand Down
2 changes: 2 additions & 0 deletions runtime/drivers/slack/slack.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ var spec = drivers.Spec{
ConfigProperties: []*drivers.PropertySpec{
{
Key: "bot_token",
Type: drivers.StringPropertyType,
Secret: true,
},
},
ImplementsNotifier: true,
}

func init() {
Expand Down
26 changes: 25 additions & 1 deletion runtime/server/connectors.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package server

import (
"context"
"strings"

runtimev1 "github.com/rilldata/rill/proto/gen/rill/runtime/v1"
"github.com/rilldata/rill/runtime"
Expand Down Expand Up @@ -106,6 +107,28 @@ func (s *Server) ListNotifierConnectors(ctx context.Context, req *runtimev1.List
}
}

// Connectors may be implicitly defined just by adding variables in the format "connector.<name>.<property>".
// NOTE: We can remove this if we move to explicitly defined connectors.
for k := range inst.ResolveVariables() {
if !strings.HasPrefix(k, "connector.") {
continue
}

parts := strings.Split(k, ".")
if len(parts) <= 2 {
continue
}

// Implicitly defined connectors always have the same name as the driver
name := parts[1]
if driverIsNotifier(name) {
res[name] = &runtimev1.Connector{
Type: name,
Name: name,
}
}
}

return &runtimev1.ListNotifierConnectorsResponse{
Connectors: maps.Values(res),
}, nil
Expand All @@ -127,6 +150,7 @@ func driverSpecToPB(name string, spec drivers.Spec) *runtimev1.ConnectorDriver {
ImplementsOlap: spec.ImplementsOLAP,
ImplementsObjectStore: spec.ImplementsObjectStore,
ImplementsFileStore: spec.ImplementsFileStore,
ImplementsNotifier: spec.ImplementsNotifier,
}

for _, prop := range spec.ConfigProperties {
Expand Down Expand Up @@ -175,5 +199,5 @@ func driverIsNotifier(driver string) bool {
return false
}

return connector.Spec().ImplementsAdmin // TODO: Replace with ImplementsNotifier when this PR merges: https://github.com/rilldata/rill/pull/4371
return connector.Spec().ImplementsNotifier
}
2 changes: 1 addition & 1 deletion web-admin/src/client/gen/index.schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -893,7 +893,7 @@ export interface RpcStatus {
* `NullValue` is a singleton enumeration to represent the null value for the
`Value` type union.
The JSON representation for `NullValue` is JSON `null`.
The JSON representation for `NullValue` is JSON `null`.
- NULL_VALUE: Null value.
*/
Expand Down
6 changes: 6 additions & 0 deletions web-common/src/proto/gen/rill/runtime/v1/api_pb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2755,6 +2755,11 @@ export class ConnectorDriver extends Message<ConnectorDriver> {
*/
implementsFileStore = false;

/**
* @generated from field: bool implements_notifier = 19;
*/
implementsNotifier = false;

constructor(data?: PartialMessage<ConnectorDriver>) {
super();
proto3.util.initPartial(data, this);
Expand All @@ -2777,6 +2782,7 @@ export class ConnectorDriver extends Message<ConnectorDriver> {
{ no: 16, name: "implements_olap", kind: "scalar", T: 8 /* ScalarType.BOOL */ },
{ no: 17, name: "implements_object_store", kind: "scalar", T: 8 /* ScalarType.BOOL */ },
{ no: 18, name: "implements_file_store", kind: "scalar", T: 8 /* ScalarType.BOOL */ },
{ no: 19, name: "implements_notifier", kind: "scalar", T: 8 /* ScalarType.BOOL */ },
]);

static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): ConnectorDriver {
Expand Down
76 changes: 35 additions & 41 deletions web-common/src/runtime-client/gen/index.schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -779,18 +779,22 @@ export const V1ResourceEvent = {
RESOURCE_EVENT_DELETE: "RESOURCE_EVENT_DELETE",
} as const;

export interface V1ReportState {
nextRunOn?: string;
currentExecution?: V1ReportExecution;
executionHistory?: V1ReportExecution[];
executionCount?: number;
}

export interface V1ReportState {
nextRunOn?: string;
currentExecution?: V1ReportExecution;
executionHistory?: V1ReportExecution[];
executionCount?: number;
export interface V1Resource {
meta?: V1ResourceMeta;
projectParser?: V1ProjectParser;
source?: V1SourceV2;
model?: V1ModelV2;
metricsView?: V1MetricsViewV2;
migration?: V1Migration;
report?: V1Report;
alert?: V1Alert;
pullTrigger?: V1PullTrigger;
refreshTrigger?: V1RefreshTrigger;
bucketPlanner?: V1BucketPlanner;
theme?: V1Theme;
chart?: V1Chart;
dashboard?: V1Dashboard;
api?: V1API;
}

export type V1ReportSpecAnnotations = { [key: string]: string };
Expand All @@ -816,29 +820,18 @@ export interface V1ReportExecution {
finishedOn?: string;
}

export interface V1ReportState {
nextRunOn?: string;
currentExecution?: V1ReportExecution;
executionHistory?: V1ReportExecution[];
executionCount?: number;
}

export interface V1Report {
spec?: V1ReportSpec;
state?: V1ReportState;
}

export interface V1Resource {
meta?: V1ResourceMeta;
projectParser?: V1ProjectParser;
source?: V1SourceV2;
model?: V1ModelV2;
metricsView?: V1MetricsViewV2;
migration?: V1Migration;
report?: V1Report;
alert?: V1Alert;
pullTrigger?: V1PullTrigger;
refreshTrigger?: V1RefreshTrigger;
bucketPlanner?: V1BucketPlanner;
theme?: V1Theme;
chart?: V1Chart;
dashboard?: V1Dashboard;
api?: V1API;
}

export interface V1RenameFileResponse {
[key: string]: any;
}
Expand Down Expand Up @@ -875,6 +868,16 @@ export interface V1RefreshTrigger {
state?: V1RefreshTriggerState;
}

export interface V1RefreshAndReconcileResponse {
/** Errors encountered during reconciliation. If strict = false, any path in
affected_paths without an error can be assumed to have been reconciled succesfully. */
errors?: V1ReconcileError[];
/** affected_paths lists all the file artifact paths that were considered while
executing the reconciliation. If changed_paths was empty, this will include all
code artifacts in the repo. */
affectedPaths?: string[];
}

export interface V1RefreshAndReconcileRequest {
instanceId?: string;
path?: string;
Expand Down Expand Up @@ -938,16 +941,6 @@ Only applicable if file_path is set. */
endLocation?: V1ReconcileErrorCharLocation;
}

export interface V1RefreshAndReconcileResponse {
/** Errors encountered during reconciliation. If strict = false, any path in
affected_paths without an error can be assumed to have been reconciled succesfully. */
errors?: V1ReconcileError[];
/** affected_paths lists all the file artifact paths that were considered while
executing the reconciliation. If changed_paths was empty, this will include all
code artifacts in the repo. */
affectedPaths?: string[];
}

export interface V1ReconcileResponse {
/** Errors encountered during reconciliation. If strict = false, any path in
affected_paths without an error can be assumed to have been reconciled succesfully. */
Expand Down Expand Up @@ -1817,6 +1810,7 @@ export interface V1ConnectorDriver {
implementsOlap?: boolean;
implementsObjectStore?: boolean;
implementsFileStore?: boolean;
implementsNotifier?: boolean;
}

export type V1ConnectorConfig = { [key: string]: string };
Expand Down Expand Up @@ -2180,7 +2174,7 @@ export interface Runtimev1CharLocation {
* `NullValue` is a singleton enumeration to represent the null value for the
`Value` type union.
The JSON representation for `NullValue` is JSON `null`.
The JSON representation for `NullValue` is JSON `null`.
- NULL_VALUE: Null value.
*/
Expand Down

1 comment on commit 7758469

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.