Skip to content

Commit

Permalink
add database uses db configure create (#912)
Browse files Browse the repository at this point in the history
- remove teleport db start instructions
  • Loading branch information
michellescripts authored Jul 20, 2022
1 parent c1ee83d commit 14bafa5
Show file tree
Hide file tree
Showing 3 changed files with 188 additions and 88 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ import { State } from './useAddDatabase';
describe('correct database add command generated with given input', () => {
test.each`
input | output
${'self-hosted mysql'} | ${'teleport db start --token=[generated-join-token] --auth-server=localhost:443 --name=[db-name] --protocol=mysql --uri=[uri]'}
${'rds mysql'} | ${'teleport db start --token=[generated-join-token] --auth-server=localhost:443 --name=[db-name] --protocol=mysql --uri=[uri] --aws-region=[region]'}
${'cloud sql mysql'} | ${'teleport db start --token=[generated-join-token] --auth-server=localhost:443 --name=[db-name] --protocol=mysql --uri=[uri] --ca-cert=[instance-ca-filepath] --gcp-project-id=[project-id] --gcp-instance-id=[instance-id]'}
${'self-hosted postgres'} | ${'teleport db start --token=[generated-join-token] --auth-server=localhost:443 --name=[db-name] --protocol=postgres --uri=[uri]'}
${'rds postgres'} | ${'teleport db start --token=[generated-join-token] --auth-server=localhost:443 --name=[db-name] --protocol=postgres --uri=[uri] --aws-region=[region]'}
${'cloud sql postgres'} | ${'teleport db start --token=[generated-join-token] --auth-server=localhost:443 --name=[db-name] --protocol=postgres --uri=[uri] --ca-cert=[instance-ca-filepath] --gcp-project-id=[project-id] --gcp-instance-id=[instance-id]'}
${'redshift'} | ${'teleport db start --token=[generated-join-token] --auth-server=localhost:443 --name=[db-name] --protocol=postgres --uri=[uri] --aws-region=[region] --aws-redshift-cluster-id=[cluster-id]'}
${'self-hosted mongodb'} | ${'teleport db start --token=[generated-join-token] --auth-server=localhost:443 --name=[db-name] --protocol=mongodb --uri=[uri]'}
${'self-hosted mysql'} | ${'teleport db configure create --token=[generated-join-token] --proxy=localhost:443 --name=[db-name] --protocol=mysql --uri=[uri] -o file'}
${'rds mysql'} | ${'teleport db configure create --token=[generated-join-token] --proxy=localhost:443 --name=[db-name] --protocol=mysql --uri=[uri] -o file --aws-region=[region]'}
${'cloud sql mysql'} | ${'teleport db configure create --token=[generated-join-token] --proxy=localhost:443 --name=[db-name] --protocol=mysql --uri=[uri] -o file --ca-cert-file=[instance-ca-filepath] --gcp-project-id=[project-id] --gcp-instance-id=[instance-id]'}
${'self-hosted postgres'} | ${'teleport db configure create --token=[generated-join-token] --proxy=localhost:443 --name=[db-name] --protocol=postgres --uri=[uri] -o file'}
${'rds postgres'} | ${'teleport db configure create --token=[generated-join-token] --proxy=localhost:443 --name=[db-name] --protocol=postgres --uri=[uri] -o file --aws-region=[region]'}
${'cloud sql postgres'} | ${'teleport db configure create --token=[generated-join-token] --proxy=localhost:443 --name=[db-name] --protocol=postgres --uri=[uri] -o file --ca-cert-file=[instance-ca-filepath] --gcp-project-id=[project-id] --gcp-instance-id=[instance-id]'}
${'redshift'} | ${'teleport db configure create --token=[generated-join-token] --proxy=localhost:443 --name=[db-name] --protocol=postgres --uri=[uri] -o file --aws-region=[region] --aws-redshift-cluster-id=[cluster-id]'}
${'self-hosted mongodb'} | ${'teleport db configure create --token=[generated-join-token] --proxy=localhost:443 --name=[db-name] --protocol=mongodb --uri=[uri] -o file'}
`(
'should generate correct command for input: $input',
({ input, output }) => {
Expand Down
48 changes: 30 additions & 18 deletions web/packages/teleport/src/Databases/AddDatabase/AddDatabase.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,25 @@

import React, { useState } from 'react';
import Dialog, {
DialogHeader,
DialogTitle,
DialogContent,
DialogFooter,
DialogHeader,
DialogTitle,
} from 'design/Dialog';
import {
Text,
Box,
ButtonSecondary,
Link,
ButtonLink,
ButtonSecondary,
Indicator,
Link,
Text,
} from 'design';
import Select, { Option } from 'shared/components/Select';
import { AuthType } from 'teleport/services/user';
import { DbType, DbProtocol } from 'teleport/services/databases';
import { DbProtocol, DbType } from 'teleport/services/databases';
import {
formatDatabaseInfo,
DatabaseInfo,
formatDatabaseInfo,
} from 'teleport/services/databases/makeDatabase';
import TextSelectCopy from 'teleport/components/TextSelectCopy';
import DownloadLinks from 'teleport/components/DownloadLinks';
Expand Down Expand Up @@ -182,23 +182,28 @@ const StepsWithToken = ({
/>
</Box>
</Box>
<Box>
<Box mb={2}>
<Text bold as="span">
Step 3
</Text>
{' - Start the Teleport agent with the following parameters'}
{' - Generate the Teleport config file'}
<Text mt="1">
The token will be valid for{' '}
<Text bold as={'span'}>
{expiry}.
</Text>
</Text>
<TextSelectCopy mt="2" text={command} />
</Box>
<Box>
<ButtonLink onClick={onRegenerateToken}>Regenerate Token</ButtonLink>
</Box>
<Box mt={4}>
<Box mb={4}>
<Text bold as="span">
Step 4
</Text>
{' - Start the Teleport agent with the following parameters'}
<TextSelectCopy mt="2" text="teleport start" />
</Box>
<Box>
{`Learn more about database access in our `}
<Link
href={'https://goteleport.com/docs/database-access/'}
Expand Down Expand Up @@ -267,14 +272,21 @@ const StepsWithoutToken = ({
/>
</Box>
</Box>
<Box>
<Box mb={4}>
<Text bold as="span">
Step 5
</Text>
{' - Start the Teleport agent with the following parameters'}
{' - Generate the Teleport config file'}
<TextSelectCopy mt="2" text={addCommand} />
</Box>
<Box mt={4}>
<Box mb={4}>
<Text bold as="span">
Step 6
</Text>
{' - Start the Teleport agent with the following parameters'}
<TextSelectCopy mt="2" text="teleport start" />
</Box>
<Box>
{`Learn more about database access in our `}
<Link
href={'https://goteleport.com/docs/database-access/'}
Expand All @@ -293,9 +305,9 @@ const generateDbStartCmd = (
host: string,
token: string
) => {
let baseCommand = `teleport db start --token=${
let baseCommand = `teleport db configure create --token=${
token || '[generated-join-token]'
} --auth-server=${host} --name=[db-name] --protocol=${protocol} --uri=[uri]`;
} --proxy=${host} --name=[db-name] --protocol=${protocol} --uri=[uri] -o file`;

if (protocol === 'sqlserver') {
baseCommand =
Expand All @@ -312,7 +324,7 @@ const generateDbStartCmd = (
case 'redshift':
return `${baseCommand} --aws-region=[region] --aws-redshift-cluster-id=[cluster-id]`;
case 'gcp':
return `${baseCommand} --ca-cert=[instance-ca-filepath] --gcp-project-id=[project-id] --gcp-instance-id=[instance-id]`;
return `${baseCommand} --ca-cert-file=[instance-ca-filepath] --gcp-project-id=[project-id] --gcp-instance-id=[instance-id]`;
default:
return 'unknown type and protocol';
}
Expand Down
Loading

0 comments on commit 14bafa5

Please sign in to comment.