Skip to content

Commit

Permalink
Emit rest of discovery config event
Browse files Browse the repository at this point in the history
  • Loading branch information
kimlisa committed Aug 22, 2024
1 parent c06d025 commit 16b95fc
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ import {
ConfigureDiscoveryServiceDirections,
CreatedDiscoveryConfigDialog,
} from 'teleport/Discover/Shared/ConfigureDiscoveryService';
import {
DiscoverEvent,
DiscoverEventStatus,
} from 'teleport/services/userEvent';

import { ActionButtons, Header } from '../../Shared';

Expand Down Expand Up @@ -96,7 +100,8 @@ type EKSClusterEnrollmentState = {
};

export function EnrollEksCluster(props: AgentStepProps) {
const { agentMeta, updateAgentMeta, emitErrorEvent } = useDiscover();
const { agentMeta, updateAgentMeta, emitErrorEvent, emitEvent } =
useDiscover();
const { attempt: fetchClustersAttempt, setAttempt: setFetchClustersAttempt } =
useAttempt('');

Expand Down Expand Up @@ -245,6 +250,12 @@ export function EnrollEksCluster(props: AgentStepProps) {
}
);
setAutoDiscoveryCfg(discoveryConfig);
emitEvent(
{ stepStatus: DiscoverEventStatus.Success },
{
eventName: DiscoverEvent.CreateDiscoveryConfig,
}
);
} catch (err) {
const message = getErrMessage(err);
setAutoDiscoverAttempt({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ import {
} from 'teleport/services/discovery';
import { splitAwsIamArn } from 'teleport/services/integrations/aws';
import useStickyClusterId from 'teleport/useStickyClusterId';
import {
DiscoverEvent,
DiscoverEventStatus,
} from 'teleport/services/userEvent';

import { ActionButtons, Header, StyledBox } from '../../Shared';

Expand All @@ -62,8 +66,14 @@ import { DiscoveryConfigCreatedDialog } from './DiscoveryConfigCreatedDialog';
const IAM_POLICY_NAME = 'EC2DiscoverWithSSM';

export function DiscoveryConfigSsm() {
const { agentMeta, emitErrorEvent, nextStep, updateAgentMeta, prevStep } =
useDiscover();
const {
agentMeta,
emitErrorEvent,
nextStep,
updateAgentMeta,
prevStep,
emitEvent,
} = useDiscover();

const { arnResourceName, awsAccountId } = splitAwsIamArn(
agentMeta.awsIntegration.spec.roleArn
Expand Down Expand Up @@ -115,6 +125,13 @@ export function DiscoveryConfigSsm() {
],
});

emitEvent(
{ stepStatus: DiscoverEventStatus.Success },
{
eventName: DiscoverEvent.CreateDiscoveryConfig,
}
);

updateAgentMeta({
...agentMeta,
awsRegion: selectedRegion,
Expand Down

0 comments on commit 16b95fc

Please sign in to comment.