Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
zacharyblasczyk committed Dec 2, 2024
1 parent 9ebdb86 commit b6cfbe6
Show file tree
Hide file tree
Showing 6 changed files with 28,450 additions and 35 deletions.
12 changes: 11 additions & 1 deletion apps/event-worker/src/target-scan/eks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,17 @@ const convertEksClusterToKubernetesResource = (
cluster: Cluster,
): KubernetesClusterAPIV1 => {
const region = cluster.endpoint?.split(".")[2];
const appUrl = `https://console.aws.amazon.com/eks/home?region=${region}#/clusters/${cluster.name}`;

const partition =
cluster.arn?.split(":")[1] ??
(region?.startsWith("us-gov-") ? "aws-us-gov" : "aws");

const appUrl = `https://${
partition === "aws-us-gov"
? `console.${region}.${partition}`
: "console.aws.amazon"
}.com/eks/home?region=${region}#/clusters/${cluster.name}`;

const version = cluster.version!;
const [major, minor] = version.split(".");

Expand Down
54 changes: 26 additions & 28 deletions apps/event-worker/src/target-scan/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,44 +94,42 @@ const createResourceScanWorker = (

export const createGoogleResourceScanWorker = () =>
createResourceScanWorker(async (rp) => {
if (rp.resource_provider_google == null) {
log.info(
`No Google provider found for resource provider ${rp.resource_provider.id}, skipping scan`,
);
return [];
}

const resources: InsertResource[] = [];
log.info("Found Google config, scanning for GKE resources");

if (rp.resource_provider_google != null) {
log.info("Found Google config, scanning for GKE resources");
try {
const gkeResources = await getGkeResources(
rp.workspace,
rp.resource_provider_google,
);
resources.push(...gkeResources);
} catch (error: any) {
log.error(`Error scanning GKE resources: ${error.message}`, {
error,
});
}
}
const gkeResources = await getGkeResources(
rp.workspace,
rp.resource_provider_google,
);
resources.push(...gkeResources);

return resources;
});

export const createAwsResourceScanWorker = () =>
createResourceScanWorker(async (rp) => {
if (rp.resource_provider_aws == null) {
log.info(
`No AWS provider found for resource provider ${rp.resource_provider.id}, skipping scan`,
);
return [];
}

const resources: InsertResource[] = [];
log.info("Found AWS config, scanning for EKS resources");

if (rp.resource_provider_aws != null) {
log.info("Found AWS config, scanning for EKS resources");
try {
const eksResources = await getEksResources(
rp.workspace,
rp.resource_provider_aws,
);
resources.push(...eksResources);
} catch (error: any) {
log.error(`Error scanning EKS resources: ${error.message}`, {
error,
});
}
}
const eksResources = await getEksResources(
rp.workspace,
rp.resource_provider_aws,
);
resources.push(...eksResources);

return resources;
});
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ export const AwsActionButton: React.FC<AwsActionButtonProps> = ({
onClick={async () =>
createAwsRole
.mutateAsync(workspace.id)
.then(() => toast.success(`AWS role arn created`))
.then(() => toast.success(`AWS role ARN created`))
.then(() => router.refresh())
.catch((error) => {
toast.error(`Failed to create role arn. ${error.message}`);
})
.catch((error) =>
toast.error(`Failed to create role ARN. ${error.message}`),
)
}
>
Enable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import { createAwsSchema } from "./AwsDialog";

const formSchema = createAwsSchema.and(
z.object({
repeatSeconds: z.number(),
repeatSeconds: z.number().min(0),
}),
);

Expand Down Expand Up @@ -151,6 +151,7 @@ export const UpdateAwsProviderDialog: React.FC<{
type="button"
onClick={handleCopy}
className="absolute right-2 h-4 w-4 bg-neutral-950 backdrop-blur-sm transition-all hover:bg-neutral-950 focus-visible:ring-0"
aria-label="Copy AWS Role ARN"
>
{isCopied ? (
<IconCheck className="h-4 w-4 bg-neutral-950 text-green-500" />
Expand Down Expand Up @@ -200,6 +201,7 @@ export const UpdateAwsProviderDialog: React.FC<{
size="icon"
className="absolute right-2 h-4 w-4 bg-neutral-950 hover:bg-neutral-950"
onClick={() => remove(index)}
aria-label="Remove AWS Account Role ARN"
>
<IconX className="h-4 w-4" />
</Button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ export const PATCH = request()
{ body: z.infer<typeof bodySchema> },
{ params: { providerId: string } }
>(async (ctx, { params }) => {
console.log({ ctx });
const { body } = ctx;

const query = await db
Expand Down
Loading

0 comments on commit b6cfbe6

Please sign in to comment.