Skip to content

Commit d0d7b77

Browse files
refactor: unify stack creation (#651)
1 parent 53b4f02 commit d0d7b77

File tree

5 files changed

+24
-185
lines changed

5 files changed

+24
-185
lines changed

src/app/stacks/create/existing-infrastructure/steps/container_registry/useContainerRegistry.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import AlertCircle from "@/assets/icons/alert-circle.svg?react";
22
import { useWizardContext } from "@/context/WizardContext";
33
import { stackQueries } from "@/data/stacks";
4-
import { useCreateFullstack } from "@/data/stacks/full-stack-create";
4+
import { useCreateStack } from "@/data/stacks/create-stack";
55
import { ComponentResourceInfo } from "@/types/service-connectors";
66
import { useQueryClient } from "@tanstack/react-query";
77
import { useToast } from "@zenml-io/react-component-library";
@@ -15,7 +15,7 @@ export function useContainerRegistries() {
1515
const { toast } = useToast();
1616

1717
const { setCurrentStep } = useWizardContext();
18-
const { mutate } = useCreateFullstack({
18+
const { mutate } = useCreateStack({
1919
onError: (error) => {
2020
if (error instanceof Error) {
2121
toast({
@@ -73,9 +73,9 @@ export function useContainerRegistries() {
7373
name: updatedData.stackName || Math.random().toString(36).substring(7),
7474
service_connectors: updatedData.connectorConfig ? [updatedData.connectorConfig] : [],
7575
components: {
76-
orchestrator: { ...updatedData.orchestratorConfig, service_connector_index: 0 },
77-
artifact_store: { ...updatedData.artifactStoreConfig, service_connector_index: 0 },
78-
container_registry: { ...updatedData.registryConfig, service_connector_index: 0 }
76+
orchestrator: [{ ...updatedData.orchestratorConfig, service_connector_index: 0 }],
77+
artifact_store: [{ ...updatedData.artifactStoreConfig, service_connector_index: 0 }],
78+
container_registry: [{ ...updatedData.registryConfig, service_connector_index: 0 }]
7979
}
8080
}
8181
});

src/app/stacks/create/manual/useManualStack.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import AlertCircle from "@/assets/icons/alert-circle.svg?react";
22
import { stackQueries } from "@/data/stacks";
33
import { useCreateStack } from "@/data/stacks/create-stack";
4-
import { useCurrentUser } from "@/data/users/current-user-query";
54
import { workspaceQueries } from "@/data/workspaces";
65
import { routes } from "@/router/routes";
76
import { StackRequest } from "@/types/stack";
@@ -14,7 +13,6 @@ import { FormType, formSchema } from "./schema";
1413

1514
export function useManualStack() {
1615
const workspace = useQuery({ ...workspaceQueries.workspaceDetail("default") });
17-
const user = useCurrentUser();
1816
const { toast } = useToast();
1917
const navigate = useNavigate();
2018
const queryClient = useQueryClient();
@@ -48,8 +46,6 @@ export function useManualStack() {
4846

4947
const payload: StackRequest = {
5048
name: data.stackName,
51-
user: user.data?.id || "",
52-
workspace: workspace.data?.id || "",
5349
components: components
5450
};
5551

src/data/stacks/full-stack-create.ts

Lines changed: 0 additions & 54 deletions
This file was deleted.

src/types/core.ts

Lines changed: 19 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -2405,30 +2405,12 @@ export type paths = {
24052405
* Args:
24062406
* workspace_name_or_id: Name or ID of the workspace.
24072407
* stack: Stack to register.
2408-
*
2409-
* Returns:
2410-
* The created stack.
2411-
*
2412-
* Raises:
2413-
* IllegalOperationError: If the workspace specified in the stack
2414-
* does not match the current workspace.
2415-
*/
2416-
post: operations["create_stack_api_v1_workspaces__workspace_name_or_id__stacks_post"];
2417-
};
2418-
"/api/v1/workspaces/{workspace_name_or_id}/full-stack": {
2419-
/**
2420-
* Create Full Stack
2421-
* @description Creates a stack for a particular workspace.
2422-
*
2423-
* Args:
2424-
* workspace_name_or_id: Name or ID of the workspace.
2425-
* full_stack: Stack to register.
24262408
* auth_context: Authentication context.
24272409
*
24282410
* Returns:
24292411
* The created stack.
24302412
*/
2431-
post: operations["create_full_stack_api_v1_workspaces__workspace_name_or_id__full_stack_post"];
2413+
post: operations["create_stack_api_v1_workspaces__workspace_name_or_id__stacks_post"];
24322414
};
24332415
"/api/v1/workspaces/{workspace_name_or_id}/components": {
24342416
/**
@@ -4493,40 +4475,6 @@ export type components = {
44934475
/** The workspace to which this resource belongs. */
44944476
workspace?: string | null;
44954477
};
4496-
/**
4497-
* FullStackRequest
4498-
* @description Request model for a full-stack.
4499-
*/
4500-
FullStackRequest: {
4501-
/** User */
4502-
user?: string | null;
4503-
/** Workspace */
4504-
workspace?: string | null;
4505-
/** The name of the stack. */
4506-
name: string;
4507-
/**
4508-
* The description of the stack
4509-
* @default
4510-
*/
4511-
description?: string | null;
4512-
/** The stack labels. */
4513-
labels?: {
4514-
[key: string]: unknown;
4515-
} | null;
4516-
/**
4517-
* The service connectors dictionary for the full stack registration.
4518-
* @description The UUID of an already existing service connector or request information to create a service connector from scratch.
4519-
* @default []
4520-
*/
4521-
service_connectors?: (string | components["schemas"]["ServiceConnectorInfo"])[];
4522-
/**
4523-
* The mapping for the components of the full stack registration.
4524-
* @description The mapping from component types to either UUIDs of existing components or request information for brand new components.
4525-
*/
4526-
components: {
4527-
[key: string]: unknown;
4528-
};
4529-
};
45304478
/** HTTPValidationError */
45314479
HTTPValidationError: {
45324480
/** Detail */
@@ -8172,19 +8120,13 @@ export type components = {
81728120
StackDeploymentProvider: "aws" | "gcp" | "azure";
81738121
/**
81748122
* StackRequest
8175-
* @description Request model for stacks.
8123+
* @description Request model for a stack.
81768124
*/
81778125
StackRequest: {
8178-
/**
8179-
* The id of the user that created this resource.
8180-
* Format: uuid
8181-
*/
8182-
user: string;
8183-
/**
8184-
* The workspace to which this resource belongs.
8185-
* Format: uuid
8186-
*/
8187-
workspace: string;
8126+
/** User */
8127+
user?: string | null;
8128+
/** Workspace */
8129+
workspace?: string | null;
81888130
/** The name of the stack. */
81898131
name: string;
81908132
/**
@@ -8194,14 +8136,23 @@ export type components = {
81948136
description?: string;
81958137
/** The path to the stack spec used for mlstacks deployments. */
81968138
stack_spec_path?: string | null;
8197-
/** A mapping of stack component types to the actualinstances of components of this type. */
8198-
components?: {
8139+
/**
8140+
* The mapping for the components of the full stack registration.
8141+
* @description The mapping from component types to either UUIDs of existing components or request information for brand new components.
8142+
*/
8143+
components: {
81998144
[key: string]: unknown;
8200-
} | null;
8145+
};
82018146
/** The stack labels. */
82028147
labels?: {
82038148
[key: string]: unknown;
82048149
} | null;
8150+
/**
8151+
* The service connectors dictionary for the full stack registration.
8152+
* @description The UUID of an already existing service connector or request information to create a service connector from scratch.
8153+
* @default []
8154+
*/
8155+
service_connectors?: (string | components["schemas"]["ServiceConnectorInfo"])[];
82058156
};
82068157
/**
82078158
* StackResponse
@@ -18444,13 +18395,10 @@ export type operations = {
1844418395
* Args:
1844518396
* workspace_name_or_id: Name or ID of the workspace.
1844618397
* stack: Stack to register.
18398+
* auth_context: Authentication context.
1844718399
*
1844818400
* Returns:
1844918401
* The created stack.
18450-
*
18451-
* Raises:
18452-
* IllegalOperationError: If the workspace specified in the stack
18453-
* does not match the current workspace.
1845418402
*/
1845518403
create_stack_api_v1_workspaces__workspace_name_or_id__stacks_post: {
1845618404
parameters: {
@@ -18490,56 +18438,6 @@ export type operations = {
1849018438
};
1849118439
};
1849218440
};
18493-
/**
18494-
* Create Full Stack
18495-
* @description Creates a stack for a particular workspace.
18496-
*
18497-
* Args:
18498-
* workspace_name_or_id: Name or ID of the workspace.
18499-
* full_stack: Stack to register.
18500-
* auth_context: Authentication context.
18501-
*
18502-
* Returns:
18503-
* The created stack.
18504-
*/
18505-
create_full_stack_api_v1_workspaces__workspace_name_or_id__full_stack_post: {
18506-
parameters: {
18507-
path: {
18508-
workspace_name_or_id: string;
18509-
};
18510-
};
18511-
requestBody: {
18512-
content: {
18513-
"application/json": components["schemas"]["FullStackRequest"];
18514-
};
18515-
};
18516-
responses: {
18517-
/** @description Successful Response */
18518-
200: {
18519-
content: {
18520-
"application/json": components["schemas"]["StackResponse"];
18521-
};
18522-
};
18523-
/** @description Unauthorized */
18524-
401: {
18525-
content: {
18526-
"application/json": components["schemas"]["ErrorModel"];
18527-
};
18528-
};
18529-
/** @description Conflict */
18530-
409: {
18531-
content: {
18532-
"application/json": components["schemas"]["ErrorModel"];
18533-
};
18534-
};
18535-
/** @description Unprocessable Entity */
18536-
422: {
18537-
content: {
18538-
"application/json": components["schemas"]["ErrorModel"];
18539-
};
18540-
};
18541-
};
18542-
};
1854318441
/**
1854418442
* List Workspace Stack Components
1854518443
* @description List stack components that are part of a specific workspace.

src/types/stack.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,4 @@ export type StackDeploymentStack = components["schemas"]["DeployedStack"];
2727

2828
export type StackDeploymentProvider = components["schemas"]["StackDeploymentProvider"];
2929

30-
export type FullStackRequest = components["schemas"]["FullStackRequest"];
3130
export type StackRequest = components["schemas"]["StackRequest"];

0 commit comments

Comments
 (0)