Skip to content

Commit

Permalink
Merge branch 'main' into ui/more-kafka-logos
Browse files Browse the repository at this point in the history
  • Loading branch information
Amogh-Bharadwaj authored May 23, 2024
2 parents dbaaf03 + cac1780 commit 14fa30d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 12 deletions.
4 changes: 2 additions & 2 deletions flow/connectors/utils/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,13 +170,13 @@ func LoadPeerDBAWSEnvConfigProvider(connectorName string) AWSCredentialsProvider

func GetAWSCredentialsProvider(ctx context.Context, connectorName string, peerCredentials PeerAWSCredentials) (AWSCredentialsProvider, error) {
if !(peerCredentials.Credentials.AccessKeyID == "" && peerCredentials.Credentials.SecretAccessKey == "" &&
peerCredentials.Region == "" && peerCredentials.RoleArn == nil &&
peerCredentials.Region == "" && (peerCredentials.RoleArn == nil || *peerCredentials.RoleArn == "") &&
(peerCredentials.EndpointUrl == nil || *peerCredentials.EndpointUrl == "")) {
staticProvider := NewStaticAWSCredentialsProvider(AWSCredentials{
AWS: peerCredentials.Credentials,
EndpointUrl: peerCredentials.EndpointUrl,
}, peerCredentials.Region)
if peerCredentials.RoleArn == nil {
if peerCredentials.RoleArn == nil || *peerCredentials.RoleArn == "" {
logger.LoggerFromCtx(ctx).Info("Received AWS credentials from peer for connector: " + connectorName)
return staticProvider, nil
}
Expand Down
7 changes: 7 additions & 0 deletions ui/app/peers/create/[peerType]/helpers/s3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ export const s3Setting: PeerSetting[] = [
setter((curr) => ({ ...curr, region: value as string })),
tips: 'The region where your bucket is located. For example, us-east-1. In case of GCS, this will be set to auto, which detects where your bucket it.',
},
{
label: 'Endpoint',
stateHandler: (value, setter) =>
setter((curr) => ({ ...curr, endpoint: value as string })),
tips: 'The endpoint of your S3 bucket. This is optional.',
optional: true,
},
{
label: 'Role ARN',
stateHandler: (value, setter) =>
Expand Down
1 change: 1 addition & 0 deletions ui/app/utils/gcsEndpoint.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const GCS_ENDPOINT = 'https://storage.googleapis.com';
13 changes: 3 additions & 10 deletions ui/components/PeerForms/S3Form.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use client';
import { PeerSetter } from '@/app/dto/PeersDTO';
import { s3Setting } from '@/app/peers/create/[peerType]/helpers/s3';
import { GCS_ENDPOINT } from '@/app/utils/gcsEndpoint';
import { Label } from '@/lib/Label';
import { RowWithRadiobutton, RowWithTextField } from '@/lib/Layout';
import { RadioButton, RadioButtonGroup } from '@/lib/RadioButtonGroup';
Expand All @@ -16,26 +17,18 @@ const S3Form = ({ setter }: S3Props) => {
const [storageType, setStorageType] = useState<'S3' | 'GCS'>('S3');
const displayCondition = (label: string) => {
return !(
(label === 'Region' || label === 'Role ARN') &&
(label === 'Region' || label === 'Role ARN' || label === 'Endpoint') &&
storageType === 'GCS'
);
};

useEffect(() => {
const endpoint =
storageType === 'S3' ? '' : 'https://storage.googleapis.com';
setter((prev) => {
return {
...prev,
endpoint,
};
});

if (storageType === 'GCS') {
setter((prev) => {
return {
...prev,
region: 'auto',
endpoint: GCS_ENDPOINT,
};
});
}
Expand Down

0 comments on commit 14fa30d

Please sign in to comment.