Parcourir la source

pod status -> service status

Feroze Mohideen il y a 2 ans
Parent
commit
af2d253dc1

+ 4 - 6
api/server/handlers/porter_app/pod_status.go

@@ -72,15 +72,13 @@ func (c *ServiceStatusHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
 		telemetry.AttributeKV{Key: "service-name", Value: request.ServiceName},
 		telemetry.AttributeKV{Key: "app-name", Value: appName},
 		telemetry.AttributeKV{Key: "input-deployment-target-id", Value: request.DeploymentTargetID},
-		telemetry.AttributeKV{Key: "input-deployment-target-name", Value: request.DeploymentTargetName},
 	)
 
 	deploymentTarget, err := deployment_target.DeploymentTargetDetails(ctx, deployment_target.DeploymentTargetDetailsInput{
-		ProjectID:            int64(project.ID),
-		ClusterID:            int64(cluster.ID),
-		DeploymentTargetID:   request.DeploymentTargetID,
-		DeploymentTargetName: request.DeploymentTargetName,
-		CCPClient:            c.Config().ClusterControlPlaneClient,
+		ProjectID:          int64(project.ID),
+		ClusterID:          int64(cluster.ID),
+		DeploymentTargetID: request.DeploymentTargetID,
+		CCPClient:          c.Config().ClusterControlPlaneClient,
 	})
 	if err != nil {
 		err := telemetry.Error(ctx, span, err, "error getting deployment target details")

+ 6 - 6
api/server/router/porter_app.go

@@ -1183,14 +1183,14 @@ func getPorterAppRoutes(
 		Router:   r,
 	})
 
-	// GET /api/projects/{project_id}/clusters/{cluster_id}/apps/{porter_app_name}/pods -> cluster.NewPodStatusHandler
-	appPodStatusEndpoint := factory.NewAPIEndpoint(
+	// GET /api/projects/{project_id}/clusters/{cluster_id}/apps/{porter_app_name}/service_status -> cluster.NewAppServiceStatusHandler
+	appServiceStatusEndpoint := factory.NewAPIEndpoint(
 		&types.APIRequestMetadata{
 			Verb:   types.APIVerbGet,
 			Method: types.HTTPVerbGet,
 			Path: &types.Path{
 				Parent:       basePath,
-				RelativePath: fmt.Sprintf("%s/{%s}/pods", relPathV2, types.URLParamPorterAppName),
+				RelativePath: fmt.Sprintf("%s/{%s}/service_status", relPathV2, types.URLParamPorterAppName),
 			},
 			Scopes: []types.PermissionScope{
 				types.UserScope,
@@ -1200,15 +1200,15 @@ func getPorterAppRoutes(
 		},
 	)
 
-	appPodStatusHandler := porter_app.NewServiceStatusHandler(
+	appServiceStatusHandler := porter_app.NewServiceStatusHandler(
 		config,
 		factory.GetDecoderValidator(),
 		factory.GetResultWriter(),
 	)
 
 	routes = append(routes, &router.Route{
-		Endpoint: appPodStatusEndpoint,
-		Handler:  appPodStatusHandler,
+		Endpoint: appServiceStatusEndpoint,
+		Handler:  appServiceStatusHandler,
 		Router:   r,
 	})
 

+ 1 - 1
dashboard/src/lib/hooks/useAppStatus.ts

@@ -91,7 +91,7 @@ export const useAppStatus = ({
 
   const updatePods = async (serviceName: string): Promise<void> => {
     try {
-      const res = await api.appPodStatus(
+      const res = await api.appServiceStatus(
         "<token>",
         {
           deployment_target_id: deploymentTargetId,

+ 65 - 53
dashboard/src/shared/api.tsx

@@ -336,14 +336,14 @@ const appJobs = baseApi<
     `/api/projects/${project_id}/clusters/${cluster_id}/apps/${porter_app_name}/jobs`
 );
 
-const appPodStatus = baseApi<
+const appServiceStatus = baseApi<
   {
     deployment_target_id: string;
     service: string;
   },
   { project_id: number; cluster_id: number; app_name: string }
 >("GET", ({ project_id, cluster_id, app_name }) => {
-  return `/api/projects/${project_id}/clusters/${cluster_id}/apps/${app_name}/pods`;
+  return `/api/projects/${project_id}/clusters/${cluster_id}/apps/${app_name}/service_status`;
 });
 
 const appEvents = baseApi<
@@ -371,8 +371,9 @@ const getFeedEvents = baseApi<
   }
 >("GET", (pathParams) => {
   const { project_id, cluster_id, stack_name, page } = pathParams;
-  return `/api/projects/${project_id}/clusters/${cluster_id}/applications/${stack_name}/events?page=${page || 1
-    }`;
+  return `/api/projects/${project_id}/clusters/${cluster_id}/applications/${stack_name}/events?page=${
+    page || 1
+  }`;
 });
 
 const createEnvironment = baseApi<
@@ -797,9 +798,11 @@ const detectBuildpack = baseApi<
     branch: string;
   }
 >("GET", (pathParams) => {
-  return `/api/projects/${pathParams.project_id}/gitrepos/${pathParams.git_repo_id
-    }/repos/${pathParams.kind}/${pathParams.owner}/${pathParams.name
-    }/${encodeURIComponent(pathParams.branch)}/buildpack/detect`;
+  return `/api/projects/${pathParams.project_id}/gitrepos/${
+    pathParams.git_repo_id
+  }/repos/${pathParams.kind}/${pathParams.owner}/${
+    pathParams.name
+  }/${encodeURIComponent(pathParams.branch)}/buildpack/detect`;
 });
 
 const detectGitlabBuildpack = baseApi<
@@ -830,9 +833,11 @@ const getBranchContents = baseApi<
     branch: string;
   }
 >("GET", (pathParams) => {
-  return `/api/projects/${pathParams.project_id}/gitrepos/${pathParams.git_repo_id
-    }/repos/${pathParams.kind}/${pathParams.owner}/${pathParams.name
-    }/${encodeURIComponent(pathParams.branch)}/contents`;
+  return `/api/projects/${pathParams.project_id}/gitrepos/${
+    pathParams.git_repo_id
+  }/repos/${pathParams.kind}/${pathParams.owner}/${
+    pathParams.name
+  }/${encodeURIComponent(pathParams.branch)}/contents`;
 });
 
 const getProcfileContents = baseApi<
@@ -848,9 +853,11 @@ const getProcfileContents = baseApi<
     branch: string;
   }
 >("GET", (pathParams) => {
-  return `/api/projects/${pathParams.project_id}/gitrepos/${pathParams.git_repo_id
-    }/repos/${pathParams.kind}/${pathParams.owner}/${pathParams.name
-    }/${encodeURIComponent(pathParams.branch)}/procfile`;
+  return `/api/projects/${pathParams.project_id}/gitrepos/${
+    pathParams.git_repo_id
+  }/repos/${pathParams.kind}/${pathParams.owner}/${
+    pathParams.name
+  }/${encodeURIComponent(pathParams.branch)}/procfile`;
 });
 
 const getPorterYamlContents = baseApi<
@@ -866,9 +873,11 @@ const getPorterYamlContents = baseApi<
     branch: string;
   }
 >("GET", (pathParams) => {
-  return `/api/projects/${pathParams.project_id}/gitrepos/${pathParams.git_repo_id
-    }/repos/${pathParams.kind}/${pathParams.owner}/${pathParams.name
-    }/${encodeURIComponent(pathParams.branch)}/porteryaml`;
+  return `/api/projects/${pathParams.project_id}/gitrepos/${
+    pathParams.git_repo_id
+  }/repos/${pathParams.kind}/${pathParams.owner}/${
+    pathParams.name
+  }/${encodeURIComponent(pathParams.branch)}/porteryaml`;
 });
 
 const parsePorterYaml = baseApi<
@@ -916,9 +925,11 @@ const getBranchHead = baseApi<
     branch: string;
   }
 >("GET", (pathParams) => {
-  return `/api/projects/${pathParams.project_id}/gitrepos/${pathParams.git_repo_id
-    }/repos/${pathParams.kind}/${pathParams.owner}/${pathParams.name
-    }/${encodeURIComponent(pathParams.branch)}/head`;
+  return `/api/projects/${pathParams.project_id}/gitrepos/${
+    pathParams.git_repo_id
+  }/repos/${pathParams.kind}/${pathParams.owner}/${
+    pathParams.name
+  }/${encodeURIComponent(pathParams.branch)}/head`;
 });
 
 const validatePorterApp = baseApi<
@@ -950,23 +961,23 @@ const validatePorterApp = baseApi<
 
 const createApp = baseApi<
   | {
-    name: string;
-    deployment_target_id: string;
-    type: "github";
-    git_repo_id: number;
-    git_branch: string;
-    git_repo_name: string;
-    porter_yaml_path: string;
-  }
+      name: string;
+      deployment_target_id: string;
+      type: "github";
+      git_repo_id: number;
+      git_branch: string;
+      git_repo_name: string;
+      porter_yaml_path: string;
+    }
   | {
-    name: string;
-    deployment_target_id: string;
-    type: "docker-registry";
-    image: {
-      repository: string;
-      tag: string;
-    };
-  },
+      name: string;
+      deployment_target_id: string;
+      type: "docker-registry";
+      image: {
+        repository: string;
+        tag: string;
+      };
+    },
   {
     project_id: number;
     cluster_id: number;
@@ -985,7 +996,7 @@ const createAppTemplate = baseApi<
       base64_addon: string;
       variables: Record<string, string>;
       secrets: Record<string, string>;
-    }>
+    }>;
   },
   {
     project_id: number;
@@ -1200,16 +1211,16 @@ const listDeploymentTargets = baseApi<
 });
 
 const createDeploymentTarget = baseApi<
-    {
-        name: string;
-        preview: boolean;
-    },
-    {
-        project_id: number;
-        cluster_id: number;
-    }
+  {
+    name: string;
+    preview: boolean;
+  },
+  {
+    project_id: number;
+    cluster_id: number;
+  }
 >("POST", ({ project_id, cluster_id }) => {
-    return `/api/projects/${project_id}/clusters/${cluster_id}/deployment-targets`;
+  return `/api/projects/${project_id}/clusters/${cluster_id}/deployment-targets`;
 });
 
 const getDeploymentTarget = baseApi<
@@ -1904,12 +1915,11 @@ const updateDatabaseStatus = baseApi<
 const getDatabaseStatus = baseApi<
   {
     name: string;
-    type: string
+    type: string;
   },
   {
     project_id: number;
     cluster_id: number;
-
   }
 >("GET", (pathParams) => {
   return `/api/projects/${pathParams.project_id}/clusters/${pathParams.cluster_id}/datastore/status`;
@@ -2175,9 +2185,11 @@ const getEnvGroup = baseApi<
     version?: number;
   }
 >("GET", (pathParams) => {
-  return `/api/projects/${pathParams.id}/clusters/${pathParams.cluster_id
-    }/namespaces/${pathParams.namespace}/envgroup?name=${pathParams.name}${pathParams.version ? "&version=" + pathParams.version : ""
-    }`;
+  return `/api/projects/${pathParams.id}/clusters/${
+    pathParams.cluster_id
+  }/namespaces/${pathParams.namespace}/envgroup?name=${pathParams.name}${
+    pathParams.version ? "&version=" + pathParams.version : ""
+  }`;
 });
 
 const getConfigMap = baseApi<
@@ -3258,7 +3270,7 @@ const removeStackEnvGroup = baseApi<
     `/api/v1/projects/${project_id}/clusters/${cluster_id}/namespaces/${namespace}/stacks/${stack_id}/remove_env_group/${env_group_name}`
 );
 
-const getGithubStatus = baseApi<{}, {}>("GET", ({ }) => `/api/status/github`);
+const getGithubStatus = baseApi<{}, {}>("GET", ({}) => `/api/status/github`);
 
 const createSecretAndOpenGitHubPullRequest = baseApi<
   {
@@ -3331,7 +3343,7 @@ export default {
   appLogs,
   appJobs,
   appEvents,
-  appPodStatus,
+  appServiceStatus,
   getFeedEvents,
   updateStackStep,
   porterYamlFromRevision,
@@ -3559,5 +3571,5 @@ export default {
 
   // STATUS
   getGithubStatus,
-  getDatabaseStatus
+  getDatabaseStatus,
 };