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 redpanda connect secret manager to console #1527

Merged
merged 19 commits into from
Nov 28, 2024

Conversation

andresaristizabal
Copy link
Contributor

@andresaristizabal andresaristizabal commented Nov 22, 2024

This PR introduces a new tab for Redpanda Connect

Features:

  • Create secrets
  • Edit secrets
  • Delete secrets
  • Update secrets
  • Secret autocomplete on pipeline RPCN editor
  • Choose which connect tab is showing as default based on query param defaultTab

Pending:

  • Handle BYOC, Serverless and Hosted cluster
  • Avoid duplications auto complete secrets in the pipeline editor -- disable autocomplete
  • Disable buttons in the "Update Secret" form while an update request is in progress.

Dedicated integration cluster

Screen.Recording.2024-11-21.at.8.43.30.PM.mov

Serverless integration cluster

Screen.Recording.2024-11-26.at.8.41.10.AM.mov

Before:

image

Enterprice self-hosted

Screen.Recording.2024-11-25.at.7.42.10.PM.mov

@CLAassistant
Copy link

CLAassistant commented Nov 22, 2024

CLA assistant check
All committers have signed the CLA.

@andresaristizabal andresaristizabal changed the title Add redpanda connect secret manager to console WIP: Add redpanda connect secret manager to console Nov 22, 2024
@andresaristizabal andresaristizabal marked this pull request as draft November 22, 2024 01:41
Comment on lines 44 to 48
const getDefaultView = (defaultView: string): { initialTab: ConnectView, redpandaConnectTab: ConnectView } => {

const showPipelines = Features.pipelinesApi
const showKafkaTab = {initialTab: ConnectView.kafkaConnect, redpandaConnectTab: ConnectView.RedpandaConnect}
const showRedpandaConnectTab = {initialTab: ConnectView.RedpandaConnect, redpandaConnectTab: ConnectView.RedpandaConnect}
Copy link
Contributor

Choose a reason for hiding this comment

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

Nothing to say about this change but overall we desperately need a linter 😓 I will try to put something together when I have spare 5 mins

case 'redpanda-connect':
return showRedpandaConnectTab;
case 'redpanda-connect-secret':
return {initialTab: ConnectView.RedpandaConnect, redpandaConnectTab: ConnectView.RedpandaConncetSecret};
Copy link
Contributor

Choose a reason for hiding this comment

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

RedpandaConncetSecret -> RedpandaConnectSecret

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fix

import { useLocation } from 'react-router-dom';

enum ConnectView {
kafkaConnect = 'kafka-connect',
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's make it uppercase to match the other values
kafkaConnect -> KafkaConnect

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fix

const {search}= useLocation();
const searchParams = new URLSearchParams(search);
const defaultTab = searchParams.get('defaultTab') || '';
return <KafkaConnectOverview defaultView={defaultTab} {...props}/>
Copy link
Contributor

@malinskibeniamin malinskibeniamin Nov 26, 2024

Choose a reason for hiding this comment

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

What happens if defaultTab is ''? I think we need to return to tabConnectView.RedpandaConnect by default?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it should default from getDefaultView()

Comment on lines 179 to 180
startLineNumber: position.lineNumber,
endLineNumber: position.lineNumber,
Copy link
Contributor

Choose a reason for hiding this comment

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

It's always going to start and end on the same line, is that intentional?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, it is intencional, but I disabled autocomplete, because it needs more testing and there isn't time now

Copy link
Contributor Author

Choose a reason for hiding this comment

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

remove this function for now, I need to improve the autocomplete

Comment on lines 184 to 187
const last_chars = model.getValueInRange({startLineNumber: position.lineNumber, startColumn: 0, endLineNumber: position.lineNumber, endColumn: position.column});
const words = last_chars.replace('\t', '').replace('\{', '').split(' ');
const active_typing = words[words.length - 1];
const empty = {suggestions: []}
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we can continue using camelCase

<PageContent>
<ToastContainer/>
<Flex flexDirection="column" gap={5}>
<FormField label="Secret name" isInvalid={alreadyExists} errorText="Secret name is already in use">
Copy link
Contributor

Choose a reason for hiding this comment

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

Is that always going to be the reason for the error? What if some invalid character is used? Wouldn't it show wrong error text?

Comment on lines +46 to +51
if (String(err).includes('404')) {
// Hacky special handling for OSS version, it is possible for the /endpoints request to not complete in time for this to render
// so in this case there would be an error shown because we were too fast (with rendering, or the req was too slow)
// We don't want to show an error in that case
return;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think maybe it sounds worse than it is, but thanks for explaining 😬

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I copy and past this handle.

return (
<PageContent>
<Section>
<ToastContainer/>
Copy link
Contributor

@malinskibeniamin malinskibeniamin Nov 26, 2024

Choose a reason for hiding this comment

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

Do we need ToastContainer copied everywhere? There's no global provider?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Again, I use pipeline as model, we can improve it later, when we have all console context


initPage(p: PageInitHelper) {
p.title = 'Update Secret';
p.addBreadcrumb('Redpanda Connect Secret Manager', '/rp-connect/secret/update');
Copy link
Contributor

Choose a reason for hiding this comment

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

Note: I think in the future we should have a global place with all the routes to ensure we can easily change name/forbid accessing it across the app if we needed to. Just in the router file there should be a place to get all the route paths.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't know what was the reason for this change, we can discuss it later

Copy link
Contributor

Choose a reason for hiding this comment

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

Should it be secret or secrets?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it should be secrets, I fixing it

<Input
placeholder="Enter a secret name..."
data-testid="secretId"
pattern="[a-zA-Z0-9_\-]+"
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we can reuse this regex for secrets, actually I see this pattern is different
^[A-Z][A-Z0-9_]*$ vs [a-zA-Z0-9_\-]+, which one should we use?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I updated this based on proto

@@ -234,6 +234,10 @@ const defaultUiSettings = {
quickSearch: ''
},

rpncSecretList: {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you meant
rpcnSecretList -> rpncSecretList

Copy link
Contributor Author

Choose a reason for hiding this comment

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

right

@andresaristizabal andresaristizabal marked this pull request as ready for review November 26, 2024 16:20
@andresaristizabal andresaristizabal changed the title WIP: Add redpanda connect secret manager to console Add redpanda connect secret manager to console Nov 26, 2024


@observer
class RpConnectSecretCreate extends PageComponent {
Copy link
Collaborator

Choose a reason for hiding this comment

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

When we try to load these new pages and RP-connect is not enabled, we get infinite loading, this applies for both new URLs that have been added to the router. Can we please show something that prompts the user to configure it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@bojand
Copy link
Member

bojand commented Nov 27, 2024

Maybe it doesn't have to be part of this PR, but it's related, is there any way we can add the well known predefined contextual env vars to auto completion. The env vars added in https://github.com/redpanda-data/cloudv2/pull/18566.
Defined:
https://github.com/redpanda-data/cloudv2/blob/main/apps/redpanda-connect-api/config/config.go#L229
https://github.com/redpanda-data/cloudv2/blob/main/apps/redpanda-connect-api/config/config.go#L382-L391

@andresaristizabal
Copy link
Contributor Author

Maybe it doesn't have to be part of this PR, but it's related, is there any way we can add the well known predefined contextual env vars to auto completion. The env vars added in redpanda-data/cloudv2#18566. Defined: https://github.com/redpanda-data/cloudv2/blob/main/apps/redpanda-connect-api/config/config.go#L229 https://github.com/redpanda-data/cloudv2/blob/main/apps/redpanda-connect-api/config/config.go#L382-L391

Good idea, we need to check how we can add it on autocomplete, I disabled autocomplete because I want to spend more time on it

@andresaristizabal andresaristizabal merged commit 0d0f7f3 into master Nov 28, 2024
6 checks passed
@andresaristizabal andresaristizabal deleted the feature/rpcn-secrets branch November 28, 2024 12:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants