diff --git a/pkg/redshift/api/api.go b/pkg/redshift/api/api.go
index e957b81f..19976e80 100644
--- a/pkg/redshift/api/api.go
+++ b/pkg/redshift/api/api.go
@@ -89,6 +89,7 @@ func (c *API) Execute(ctx context.Context, input *api.ExecuteQueryInput) (*api.E
DbUser: commonInput.DbUser,
SecretArn: commonInput.SecretARN,
Sql: aws.String(input.Query),
+ WithEvent: aws.Bool(c.settings.WithEvent),
}
output, err := c.DataClient.ExecuteStatementWithContext(ctx, redshiftInput)
@@ -352,7 +353,7 @@ func (c *API) Clusters() ([]models.RedshiftCluster, error) {
}
res := []models.RedshiftCluster{}
for _, r := range out.Clusters {
- if (r != nil && r.ClusterIdentifier != nil && r.Endpoint != nil && r.Endpoint.Address != nil && r.Endpoint.Port != nil && r.DBName != nil) {
+ if r != nil && r.ClusterIdentifier != nil && r.Endpoint != nil && r.Endpoint.Address != nil && r.Endpoint.Port != nil && r.DBName != nil {
res = append(res, models.RedshiftCluster{
ClusterIdentifier: *r.ClusterIdentifier,
Endpoint: models.RedshiftEndpoint{
diff --git a/pkg/redshift/api/api_test.go b/pkg/redshift/api/api_test.go
index 0560fd30..2e91ce2f 100644
--- a/pkg/redshift/api/api_test.go
+++ b/pkg/redshift/api/api_test.go
@@ -250,14 +250,14 @@ func Test_GetClusters(t *testing.T) {
expectedClusters: []models.RedshiftCluster{*expectedCluster1, *expectedCluster2},
},
{
- c: errC,
- desc: "Error with DescribeCluster",
- errMsg: "Boom!",
+ c: errC,
+ desc: "Error with DescribeCluster",
+ errMsg: "Boom!",
},
{
- c: nilC,
- desc: "DescribeCluster returned nil",
- errMsg: "missing clusters content",
+ c: nilC,
+ desc: "DescribeCluster returned nil",
+ errMsg: "missing clusters content",
},
}
for _, tt := range tests {
diff --git a/pkg/redshift/models/settings.go b/pkg/redshift/models/settings.go
index 4104297d..4cc85686 100644
--- a/pkg/redshift/models/settings.go
+++ b/pkg/redshift/models/settings.go
@@ -37,6 +37,7 @@ type RedshiftDataSourceSettings struct {
ClusterIdentifier string `json:"clusterIdentifier"`
Database string `json:"database"`
UseManagedSecret bool `json:"useManagedSecret"`
+ WithEvent bool `json:"withEvent"`
DBUser string `json:"dbUser"`
ManagedSecret ManagedSecret
}
diff --git a/src/ConfigEditor/ConfigEditor.test.tsx b/src/ConfigEditor/ConfigEditor.test.tsx
index b7a14746..c2daa237 100644
--- a/src/ConfigEditor/ConfigEditor.test.tsx
+++ b/src/ConfigEditor/ConfigEditor.test.tsx
@@ -88,6 +88,21 @@ describe('ConfigEditor', () => {
});
});
+ it('should enable WithEvent when it is toggled on', async () => {
+ const onChange = jest.fn();
+ render();
+ const withEventField = screen.getByTestId(selectors.components.ConfigEditor.WithEvent.testID);
+ expect(withEventField).toBeInTheDocument();
+
+ fireEvent.click(withEventField);
+
+ expect(onChange).toHaveBeenCalledTimes(1);
+ expect(onChange).toHaveBeenCalledWith({
+ ...props.options,
+ jsonData: { ...props.options.jsonData, withEvent: true },
+ });
+ });
+
it('should populate the `url` prop when clusterIdentifier is selected', async () => {
const onChange = jest.fn();
render(
diff --git a/src/ConfigEditor/ConfigEditor.tsx b/src/ConfigEditor/ConfigEditor.tsx
index 9cac2a74..4e9ef627 100644
--- a/src/ConfigEditor/ConfigEditor.tsx
+++ b/src/ConfigEditor/ConfigEditor.tsx
@@ -11,6 +11,7 @@ import {
RedshiftManagedSecret,
} from '../types';
import { AuthTypeSwitch } from './AuthTypeSwitch';
+import { InlineField, Switch } from '@grafana/ui';
export type Props = DataSourcePluginOptionsEditorProps;
@@ -209,6 +210,27 @@ export function ConfigEditor(props: Props) {
label={selectors.components.ConfigEditor.Database.input}
data-testid={selectors.components.ConfigEditor.Database.testID}
/>
+
+
+ props.onOptionsChange({
+ ...props.options,
+ jsonData: {
+ ...props.options.jsonData,
+ withEvent: e.currentTarget.checked,
+ },
+ })
+ }
+ css={undefined}
+ data-testid={selectors.components.ConfigEditor.WithEvent.testID}
+ />
+
);
}
diff --git a/src/selectors.ts b/src/selectors.ts
index 92a29f57..c5b725d2 100644
--- a/src/selectors.ts
+++ b/src/selectors.ts
@@ -46,6 +46,10 @@ export const Components = {
input: 'Column',
testID: 'data-testid column',
},
+ WithEvent: {
+ input: 'Send events to Amazon EventBridge',
+ testID: 'data-testid withEvent',
+ },
},
QueryEditor: {
CodeEditor: {
diff --git a/src/types.ts b/src/types.ts
index e662dc57..0bbff717 100644
--- a/src/types.ts
+++ b/src/types.ts
@@ -47,6 +47,7 @@ export const defaultQuery: Partial = {
* These are options configured for each DataSource instance
*/
export interface RedshiftDataSourceOptions extends AwsAuthDataSourceJsonData {
+ withEvent?: boolean;
useManagedSecret?: boolean;
clusterIdentifier?: string;
database?: string;