From e0d62d3645716413fd326353189a9805c49c130a Mon Sep 17 00:00:00 2001 From: Abdhesh Nayak Date: Mon, 1 Jan 2024 18:54:47 +0530 Subject: [PATCH 01/10] :sparkles: Added cli queries --- gql-queries-generator/doc/queries.graphql | 76 +++++ src/apps/auth/server/gql/cli-queries.ts | 63 ++++ src/generated/gql/sdl.graphql | 377 ++++++++++++++++------ 3 files changed, 419 insertions(+), 97 deletions(-) diff --git a/gql-queries-generator/doc/queries.graphql b/gql-queries-generator/doc/queries.graphql index 89fa70e75..86c37b6bd 100644 --- a/gql-queries-generator/doc/queries.graphql +++ b/gql-queries-generator/doc/queries.graphql @@ -2679,6 +2679,82 @@ query consoleGetBuildRun($repoName: String!, $buildRunName: String!) { } } +query authCli_listProjects($clusterName: String, $search: SearchProjects, $pq: CursorPaginationIn) { + core_listProjects(clusterName: $clusterName, search: $search, pq: $pq) { + edges { + cursor + node { + accountName + apiVersion + clusterName + createdBy { + userEmail + userId + userName + } + creationTime + displayName + id + kind + lastUpdatedBy { + userEmail + userId + userName + } + markedForDeletion + metadata { + annotations + creationTimestamp + deletionTimestamp + generation + labels + name + namespace + } + recordVersion + spec { + accountName + clusterName + displayName + logo + targetNamespace + } + status { + checks + isReady + lastReadyGeneration + lastReconcileTime + message { + RawMessage + } + resources { + apiVersion + kind + name + namespace + } + } + syncStatus { + action + error + lastSyncedAt + recordVersion + state + syncScheduledAt + } + updateTime + } + } + pageInfo { + endCursor + hasNextPage + hasPreviousPage + startCursor + } + totalCount + } +} + query authCli_getKubeConfig($name: String!) { infra_getCluster(name: $name) { adminKubeconfig { diff --git a/src/apps/auth/server/gql/cli-queries.ts b/src/apps/auth/server/gql/cli-queries.ts index 0195aaaf7..a5b5502e3 100644 --- a/src/apps/auth/server/gql/cli-queries.ts +++ b/src/apps/auth/server/gql/cli-queries.ts @@ -17,6 +17,69 @@ import { } from '~/root/src/generated/gql/server'; export const cliQueries = (executor: IExecutor) => ({ + cli_listEnvironments: executor( + gql` + query Core_listProjects($project: ProjectId!, $pq: CursorPaginationIn) { + core_listEnvironments(project: $project, pq: $pq) { + edges { + node { + displayName + markedForDeletion + metadata { + name + namespace + } + spec { + isEnvironment + projectName + targetNamespace + } + status { + isReady + message { + RawMessage + } + } + } + } + } + } + `, + { + transformer: (data: any) => data.core_listEnvironments, + vars: (_: any) => {}, + } + ), + + cli_listProjects: executor( + gql` + query Core_listProjects($clusterName: String, $pq: CursorPaginationIn) { + core_listProjects(clusterName: $clusterName, pq: $pq) { + edges { + node { + displayName + markedForDeletion + metadata { + name + namespace + } + status { + isReady + message { + RawMessage + } + } + } + } + } + } + `, + { + transformer: (data: any) => data.core_listProjects, + vars: (_: any) => {}, + } + ), + cli_getKubeConfig: executor( gql` query Infra_getCluster($name: String!) { diff --git a/src/generated/gql/sdl.graphql b/src/generated/gql/sdl.graphql index 9ceef7538..9507e83b2 100644 --- a/src/generated/gql/sdl.graphql +++ b/src/generated/gql/sdl.graphql @@ -506,46 +506,6 @@ type GitBranch { protected: Boolean } -type Github__com___kloudlite___api___apps___console___internal___entities__InputField { - defaultValue: Any - inputType: String! - label: String! - max: Float - min: Float - name: String! - required: Boolean - unit: String -} - -type Github__com___kloudlite___api___apps___console___internal___entities__MresTemplate { - apiVersion: String - description: String! - displayName: String! - fields: [Github__com___kloudlite___api___apps___console___internal___entities__InputField!]! - kind: String - name: String! - outputs: [Github__com___kloudlite___api___apps___console___internal___entities__OutputField!]! -} - -type Github__com___kloudlite___api___apps___console___internal___entities__MsvcTemplateEntry { - active: Boolean! - apiVersion: String - description: String! - displayName: String! - fields: [Github__com___kloudlite___api___apps___console___internal___entities__InputField!]! - kind: String - logoUrl: String! - name: String! - outputs: [Github__com___kloudlite___api___apps___console___internal___entities__OutputField!]! - resources: [Github__com___kloudlite___api___apps___console___internal___entities__MresTemplate!]! -} - -type Github__com___kloudlite___api___apps___console___internal___entities__OutputField { - description: String! - label: String! - name: String! -} - enum Github__com___kloudlite___api___apps___container____registry___internal___domain___entities__BuildStatus { error failed @@ -666,6 +626,46 @@ input Github__com___kloudlite___api___apps___infra___internal___entities__AWSSec secretKey: String } +type Github__com___kloudlite___api___apps___infra___internal___entities__InputField { + defaultValue: Any + inputType: String! + label: String! + max: Float + min: Float + name: String! + required: Boolean + unit: String +} + +type Github__com___kloudlite___api___apps___infra___internal___entities__MresTemplate { + apiVersion: String + description: String! + displayName: String! + fields: [Github__com___kloudlite___api___apps___infra___internal___entities__InputField!]! + kind: String + name: String! + outputs: [Github__com___kloudlite___api___apps___infra___internal___entities__OutputField!]! +} + +type Github__com___kloudlite___api___apps___infra___internal___entities__MsvcTemplateEntry { + active: Boolean! + apiVersion: String + description: String! + displayName: String! + fields: [Github__com___kloudlite___api___apps___infra___internal___entities__InputField!]! + kind: String + logoUrl: String! + name: String! + outputs: [Github__com___kloudlite___api___apps___infra___internal___entities__OutputField!]! + resources: [Github__com___kloudlite___api___apps___infra___internal___entities__MresTemplate!]! +} + +type Github__com___kloudlite___api___apps___infra___internal___entities__OutputField { + description: String! + label: String! + name: String! +} + type Github__com___kloudlite___api___common__CreatedOrUpdatedBy { userEmail: String! userId: String! @@ -1022,6 +1022,16 @@ input Github__com___kloudlite___operator___apis___crds___v1__BasicAuthIn { username: String } +type Github__com___kloudlite___operator___apis___crds___v1__ChartRepo { + name: String! + url: String! +} + +input Github__com___kloudlite___operator___apis___crds___v1__ChartRepoIn { + name: String! + url: String! +} + type Github__com___kloudlite___operator___apis___crds___v1__ClusterManagedServiceSpec { msvcSpec: Github__com___kloudlite___operator___apis___crds___v1__ManagedServiceSpec! namespace: String! @@ -1111,6 +1121,41 @@ input Github__com___kloudlite___operator___apis___crds___v1__EnvFromIn { type: Github__com___kloudlite___operator___apis___crds___v1__ConfigOrSecret! } +type Github__com___kloudlite___operator___apis___crds___v1__HelmChartSpec { + chartName: String! + chartRepo: Github__com___kloudlite___operator___apis___crds___v1__ChartRepo! + chartVersion: String! + jobVars: Github__com___kloudlite___operator___apis___crds___v1__JobVars + postInstall: String + postUninstall: String + preInstall: String + preUninstall: String + values: Map! +} + +input Github__com___kloudlite___operator___apis___crds___v1__HelmChartSpecIn { + chartName: String! + chartRepo: Github__com___kloudlite___operator___apis___crds___v1__ChartRepoIn! + chartVersion: String! + jobVars: Github__com___kloudlite___operator___apis___crds___v1__JobVarsIn + postInstall: String + postUninstall: String + preInstall: String + preUninstall: String + values: Map! +} + +type Github__com___kloudlite___operator___apis___crds___v1__HelmChartStatus { + checks: Map + isReady: Boolean! + lastReadyGeneration: Int + lastReconcileTime: Date + message: Github__com___kloudlite___operator___pkg___raw____json__RawJson + releaseNotes: String! + releaseStatus: String! + resources: [Github__com___kloudlite___operator___pkg___operator__ResourceRef!] +} + type Github__com___kloudlite___operator___apis___crds___v1__HPA { enabled: Boolean maxReplicas: Int @@ -1159,6 +1204,20 @@ input Github__com___kloudlite___operator___apis___crds___v1__InterceptIn { toDevice: String! } +type Github__com___kloudlite___operator___apis___crds___v1__JobVars { + affinity: K8s__io___api___core___v1__Affinity + backOffLimit: Int + nodeSelector: Map + tolerations: [K8s__io___api___core___v1__Toleration!] +} + +input Github__com___kloudlite___operator___apis___crds___v1__JobVarsIn { + affinity: K8s__io___api___core___v1__AffinityIn + backOffLimit: Int + nodeSelector: Map + tolerations: [K8s__io___api___core___v1__TolerationIn!] +} + type Github__com___kloudlite___operator___apis___crds___v1__ManagedResourceSpec { resourceTemplate: Github__com___kloudlite___operator___apis___crds___v1__MresResourceTemplate! } @@ -1191,12 +1250,14 @@ type Github__com___kloudlite___operator___apis___crds___v1__MsvcNamedRef { apiVersion: String! kind: String! name: String! + namespace: String! } input Github__com___kloudlite___operator___apis___crds___v1__MsvcNamedRefIn { apiVersion: String! kind: String! name: String! + namespace: String! } type Github__com___kloudlite___operator___apis___crds___v1__Probe { @@ -1296,6 +1357,8 @@ type Github__com___kloudlite___operator___apis___crds___v1__ServiceTemplate { } input Github__com___kloudlite___operator___apis___crds___v1__ServiceTemplateIn { + apiVersion: String! + kind: String! spec: Map! } @@ -1388,17 +1451,25 @@ input Github__com___kloudlite___operator___apis___distribution___v1__ResourceIn memoryInMb: Int! } +type Github__com___kloudlite___operator___apis___wireguard___v1__CNameRecord { + host: String + target: String +} + +input Github__com___kloudlite___operator___apis___wireguard___v1__CNameRecordIn { + host: String + target: String +} + type Github__com___kloudlite___operator___apis___wireguard___v1__DeviceSpec { - accountName: String! - clusterName: String! + cnameRecords: [Github__com___kloudlite___operator___apis___wireguard___v1__CNameRecord!] deviceNamespace: String nodeSelector: Map ports: [Github__com___kloudlite___operator___apis___wireguard___v1__Port!] } input Github__com___kloudlite___operator___apis___wireguard___v1__DeviceSpecIn { - accountName: String! - clusterName: String! + cnameRecords: [Github__com___kloudlite___operator___apis___wireguard___v1__CNameRecordIn!] deviceNamespace: String nodeSelector: Map ports: [Github__com___kloudlite___operator___apis___wireguard___v1__PortIn!] @@ -1529,6 +1600,42 @@ type GitlabProject { webUrl: String! } +type HelmRelease { + accountName: String! + apiVersion: String! + clusterName: String! + createdBy: Github__com___kloudlite___api___common__CreatedOrUpdatedBy! + creationTime: Date! + displayName: String! + id: String! + kind: String! + lastUpdatedBy: Github__com___kloudlite___api___common__CreatedOrUpdatedBy! + markedForDeletion: Boolean + metadata: Metadata + recordVersion: Int! + spec: Github__com___kloudlite___operator___apis___crds___v1__HelmChartSpec + status: Github__com___kloudlite___operator___apis___crds___v1__HelmChartStatus + syncStatus: Github__com___kloudlite___api___pkg___types__SyncStatus! + updateTime: Date! +} + +type HelmReleaseEdge { + cursor: String! + node: HelmRelease! +} + +input HelmReleaseIn { + displayName: String! + metadata: MetadataIn + spec: Github__com___kloudlite___operator___apis___crds___v1__HelmChartSpecIn +} + +type HelmReleasePaginatedRecords { + edges: [HelmReleaseEdge!]! + pageInfo: PageInfo! + totalCount: Int! +} + type ImagePullSecret { accountName: String! creationTime: Date! @@ -1585,12 +1692,73 @@ input InvitationIn { scalar Json +type K8s__io___api___core___v1__Affinity { + nodeAffinity: K8s__io___api___core___v1__NodeAffinity + podAffinity: K8s__io___api___core___v1__PodAffinity + podAntiAffinity: K8s__io___api___core___v1__PodAntiAffinity +} + +input K8s__io___api___core___v1__AffinityIn { + nodeAffinity: K8s__io___api___core___v1__NodeAffinityIn + podAffinity: K8s__io___api___core___v1__PodAffinityIn + podAntiAffinity: K8s__io___api___core___v1__PodAntiAffinityIn +} + enum K8s__io___api___core___v1__ConditionStatus { False True Unknown } +type K8s__io___api___core___v1__NodeAffinity { + preferredDuringSchedulingIgnoredDuringExecution: [K8s__io___api___core___v1__PreferredSchedulingTerm!] + requiredDuringSchedulingIgnoredDuringExecution: K8s__io___api___core___v1__NodeSelector +} + +input K8s__io___api___core___v1__NodeAffinityIn { + preferredDuringSchedulingIgnoredDuringExecution: [K8s__io___api___core___v1__PreferredSchedulingTermIn!] + requiredDuringSchedulingIgnoredDuringExecution: K8s__io___api___core___v1__NodeSelectorIn +} + +type K8s__io___api___core___v1__NodeSelector { + nodeSelectorTerms: [K8s__io___api___core___v1__NodeSelectorTerm!]! +} + +input K8s__io___api___core___v1__NodeSelectorIn { + nodeSelectorTerms: [K8s__io___api___core___v1__NodeSelectorTermIn!]! +} + +enum K8s__io___api___core___v1__NodeSelectorOperator { + DoesNotExist + Exists + Gt + In + Lt + NotIn +} + +type K8s__io___api___core___v1__NodeSelectorRequirement { + key: String! + operator: K8s__io___api___core___v1__NodeSelectorOperator! + values: [String!] +} + +input K8s__io___api___core___v1__NodeSelectorRequirementIn { + key: String! + operator: K8s__io___api___core___v1__NodeSelectorOperator! + values: [String!] +} + +type K8s__io___api___core___v1__NodeSelectorTerm { + matchExpressions: [K8s__io___api___core___v1__NodeSelectorRequirement!] + matchFields: [K8s__io___api___core___v1__NodeSelectorRequirement!] +} + +input K8s__io___api___core___v1__NodeSelectorTermIn { + matchExpressions: [K8s__io___api___core___v1__NodeSelectorRequirementIn!] + matchFields: [K8s__io___api___core___v1__NodeSelectorRequirementIn!] +} + type K8s__io___api___core___v1__PersistentVolumeClaimCondition { lastProbeTime: Date lastTransitionTime: Date @@ -1660,6 +1828,50 @@ input K8s__io___api___core___v1__PersistentVolumeClaimStatusIn { phase: K8s__io___api___core___v1__PersistentVolumeClaimPhase } +type K8s__io___api___core___v1__PodAffinity { + preferredDuringSchedulingIgnoredDuringExecution: [K8s__io___api___core___v1__WeightedPodAffinityTerm!] + requiredDuringSchedulingIgnoredDuringExecution: [K8s__io___api___core___v1__PodAffinityTerm!] +} + +input K8s__io___api___core___v1__PodAffinityIn { + preferredDuringSchedulingIgnoredDuringExecution: [K8s__io___api___core___v1__WeightedPodAffinityTermIn!] + requiredDuringSchedulingIgnoredDuringExecution: [K8s__io___api___core___v1__PodAffinityTermIn!] +} + +type K8s__io___api___core___v1__PodAffinityTerm { + labelSelector: K8s__io___apimachinery___pkg___apis___meta___v1__LabelSelector + namespaces: [String!] + namespaceSelector: K8s__io___apimachinery___pkg___apis___meta___v1__LabelSelector + topologyKey: String! +} + +input K8s__io___api___core___v1__PodAffinityTermIn { + labelSelector: K8s__io___apimachinery___pkg___apis___meta___v1__LabelSelectorIn + namespaces: [String!] + namespaceSelector: K8s__io___apimachinery___pkg___apis___meta___v1__LabelSelectorIn + topologyKey: String! +} + +type K8s__io___api___core___v1__PodAntiAffinity { + preferredDuringSchedulingIgnoredDuringExecution: [K8s__io___api___core___v1__WeightedPodAffinityTerm!] + requiredDuringSchedulingIgnoredDuringExecution: [K8s__io___api___core___v1__PodAffinityTerm!] +} + +input K8s__io___api___core___v1__PodAntiAffinityIn { + preferredDuringSchedulingIgnoredDuringExecution: [K8s__io___api___core___v1__WeightedPodAffinityTermIn!] + requiredDuringSchedulingIgnoredDuringExecution: [K8s__io___api___core___v1__PodAffinityTermIn!] +} + +type K8s__io___api___core___v1__PreferredSchedulingTerm { + preference: K8s__io___api___core___v1__NodeSelectorTerm! + weight: Int! +} + +input K8s__io___api___core___v1__PreferredSchedulingTermIn { + preference: K8s__io___api___core___v1__NodeSelectorTermIn! + weight: Int! +} + type K8s__io___api___core___v1__ResourceClaim { name: String! } @@ -1758,6 +1970,16 @@ input K8s__io___api___core___v1__TypedObjectReferenceIn { namespace: String } +type K8s__io___api___core___v1__WeightedPodAffinityTerm { + podAffinityTerm: K8s__io___api___core___v1__PodAffinityTerm! + weight: Int! +} + +input K8s__io___api___core___v1__WeightedPodAffinityTermIn { + podAffinityTerm: K8s__io___api___core___v1__PodAffinityTermIn! + weight: Int! +} + enum K8s__io___apimachinery___pkg___api___resource__Format { BinarySI DecimalExponent @@ -1839,44 +2061,6 @@ type ManagedResourcePaginatedRecords { totalCount: Int! } -type ManagedService { - accountName: String! - apiVersion: String! - clusterName: String! - createdBy: Github__com___kloudlite___api___common__CreatedOrUpdatedBy! - creationTime: Date! - displayName: String! - enabled: Boolean - id: String! - kind: String! - lastUpdatedBy: Github__com___kloudlite___api___common__CreatedOrUpdatedBy! - markedForDeletion: Boolean - metadata: Metadata - recordVersion: Int! - spec: Github__com___kloudlite___operator___apis___crds___v1__ManagedServiceSpec! - status: Github__com___kloudlite___operator___pkg___operator__Status - syncStatus: Github__com___kloudlite___api___pkg___types__SyncStatus! - updateTime: Date! -} - -type ManagedServiceEdge { - cursor: String! - node: ManagedService! -} - -input ManagedServiceIn { - displayName: String! - enabled: Boolean - metadata: MetadataIn - spec: Github__com___kloudlite___operator___apis___crds___v1__ManagedServiceSpecIn! -} - -type ManagedServicePaginatedRecords { - edges: [ManagedServiceEdge!]! - pageInfo: PageInfo! - totalCount: Int! -} - scalar Map type MatchFilter { @@ -1919,7 +2103,7 @@ input MetadataIn { type MsvcTemplate { category: String! displayName: String! - items: [Github__com___kloudlite___api___apps___console___internal___entities__MsvcTemplateEntry!]! + items: [Github__com___kloudlite___api___apps___infra___internal___entities__MsvcTemplateEntry!]! } type Mutation { @@ -1953,7 +2137,6 @@ type Mutation { core_createEnvironment(env: WorkspaceIn!): Workspace core_createImagePullSecret(imagePullSecretIn: ImagePullSecretIn!): ImagePullSecret core_createManagedResource(mres: ManagedResourceIn!): ManagedResource - core_createManagedService(msvc: ManagedServiceIn!): ManagedService core_createProject(project: ProjectIn!): Project core_createRouter(router: RouterIn!): Router core_createSecret(secret: SecretIn!): Secret @@ -1963,7 +2146,6 @@ type Mutation { core_deleteEnvironment(name: String!, namespace: String!): Boolean! core_deleteImagePullSecret(name: String!, namespace: String!): Boolean! core_deleteManagedResource(name: String!, namespace: String!): Boolean! - core_deleteManagedService(name: String!, namespace: String!): Boolean! core_deleteProject(name: String!): Boolean! core_deleteRouter(name: String!, namespace: String!): Boolean! core_deleteSecret(name: String!, namespace: String!): Boolean! @@ -1972,7 +2154,6 @@ type Mutation { core_updateConfig(config: ConfigIn!): Config core_updateEnvironment(env: WorkspaceIn!): Workspace core_updateManagedResource(mres: ManagedResourceIn!): ManagedResource - core_updateManagedService(msvc: ManagedServiceIn!): ManagedService core_updateProject(project: ProjectIn!): Project core_updateRouter(router: RouterIn!): Router core_updateSecret(secret: SecretIn!): Secret @@ -1993,18 +2174,21 @@ type Mutation { infra_createCluster(cluster: ClusterIn!): Cluster infra_createClusterManagedService(clusterName: String!, service: ClusterManagedServiceIn!): ClusterManagedService infra_createDomainEntry(domainEntry: DomainEntryIn!): DomainEntry + infra_createHelmRelease(clusterName: String!, release: HelmReleaseIn!): HelmRelease infra_createNodePool(clusterName: String!, pool: NodePoolIn!): NodePool infra_createProviderSecret(secret: CloudProviderSecretIn!): CloudProviderSecret infra_createVPNDevice(clusterName: String!, vpnDevice: VPNDeviceIn!): VPNDevice infra_deleteCluster(name: String!): Boolean! infra_deleteClusterManagedService(clusterName: String!, serviceName: String!): Boolean! infra_deleteDomainEntry(domainName: String!): Boolean! + infra_deleteHelmRelease(clusterName: String!, releaseName: String!): Boolean! infra_deleteNodePool(clusterName: String!, poolName: String!): Boolean! infra_deleteProviderSecret(secretName: String!): Boolean! infra_deleteVPNDevice(clusterName: String!, deviceName: String!): Boolean! infra_updateCluster(cluster: ClusterIn!): Cluster infra_updateClusterManagedService(clusterName: String!, service: ClusterManagedServiceIn!): ClusterManagedService infra_updateDomainEntry(domainEntry: DomainEntryIn!): DomainEntry + infra_updateHelmRelease(clusterName: String!, release: HelmReleaseIn!): HelmRelease infra_updateNodePool(clusterName: String!, pool: NodePoolIn!): NodePool infra_updateProviderSecret(secret: CloudProviderSecretIn!): CloudProviderSecret infra_updateVPNDevice(clusterName: String!, vpnDevice: VPNDeviceIn!): VPNDevice @@ -2114,6 +2298,7 @@ type PersistentVolumeClaim { recordVersion: Int! spec: K8s__io___api___core___v1__PersistentVolumeClaimSpec status: K8s__io___api___core___v1__PersistentVolumeClaimStatus + syncStatus: Github__com___kloudlite___api___pkg___types__SyncStatus! updateTime: Date! } @@ -2197,8 +2382,6 @@ type Query { core_getEnvironment(name: String!, project: ProjectId!): Workspace core_getImagePullSecret(name: String!, project: ProjectId!, scope: WorkspaceOrEnvId): ImagePullSecret core_getManagedResource(name: String!, project: ProjectId!, scope: WorkspaceOrEnvId!): ManagedResource - core_getManagedService(name: String!, project: ProjectId!, scope: WorkspaceOrEnvId!): ManagedService - core_getManagedServiceTemplate(category: String!, name: String!): Github__com___kloudlite___api___apps___console___internal___entities__MsvcTemplateEntry core_getProject(name: String!): Project core_getRouter(name: String!, project: ProjectId!, scope: WorkspaceOrEnvId!): Router core_getSecret(name: String!, project: ProjectId!, scope: WorkspaceOrEnvId!): Secret @@ -2208,18 +2391,14 @@ type Query { core_listEnvironments(pq: CursorPaginationIn, project: ProjectId!, search: SearchWorkspaces): WorkspacePaginatedRecords core_listImagePullSecrets(pq: CursorPaginationIn, project: ProjectId!, scope: WorkspaceOrEnvId, search: SearchImagePullSecrets): ImagePullSecretPaginatedRecords core_listManagedResources(pq: CursorPaginationIn, project: ProjectId!, scope: WorkspaceOrEnvId!, search: SearchManagedResources): ManagedResourcePaginatedRecords - core_listManagedServices(pq: CursorPaginationIn, project: ProjectId!, scope: WorkspaceOrEnvId!, search: SearchManagedServices): ManagedServicePaginatedRecords - core_listManagedServiceTemplates: [MsvcTemplate!] core_listProjects(clusterName: String, pq: CursorPaginationIn, search: SearchProjects): ProjectPaginatedRecords core_listRouters(pq: CursorPaginationIn, project: ProjectId!, scope: WorkspaceOrEnvId!, search: SearchRouters): RouterPaginatedRecords core_listSecrets(pq: CursorPaginationIn, project: ProjectId!, scope: WorkspaceOrEnvId!, search: SearchSecrets): SecretPaginatedRecords - core_listWorkspaces(pq: CursorPaginationIn, project: ProjectId!, search: SearchWorkspaces): WorkspacePaginatedRecords core_resyncApp(name: String!, project: ProjectId!, scope: WorkspaceOrEnvId!): Boolean! core_resyncConfig(name: String!, project: ProjectId!, scope: WorkspaceOrEnvId!): Boolean! core_resyncEnvironment(name: String!, project: ProjectId!): Boolean! core_resyncImagePullSecret(name: String!, project: ProjectId!, scope: WorkspaceOrEnvId): Boolean! core_resyncManagedResource(name: String!, project: ProjectId!, scope: WorkspaceOrEnvId!): Boolean! - core_resyncManagedService(name: String!, project: ProjectId!, scope: WorkspaceOrEnvId!): Boolean! core_resyncProject(name: String!): Boolean! core_resyncRouter(name: String!, project: ProjectId!, scope: WorkspaceOrEnvId!): Boolean! core_resyncSecret(name: String!, project: ProjectId!, scope: WorkspaceOrEnvId!): Boolean! @@ -2246,6 +2425,8 @@ type Query { infra_getCluster(name: String!): Cluster infra_getClusterManagedService(clusterName: String!, name: String!): ClusterManagedService infra_getDomainEntry(domainName: String!): DomainEntry + infra_getHelmRelease(clusterName: String!, name: String!): HelmRelease + infra_getManagedServiceTemplate(category: String!, name: String!): Github__com___kloudlite___api___apps___infra___internal___entities__MsvcTemplateEntry infra_getNodePool(clusterName: String!, poolName: String!): NodePool infra_getProviderSecret(name: String!): CloudProviderSecret infra_getPVC(clusterName: String!, name: String!): PersistentVolumeClaim @@ -2253,6 +2434,8 @@ type Query { infra_listClusterManagedServices(clusterName: String!, pagination: CursorPaginationIn, search: SearchClusterManagedService): ClusterManagedServicePaginatedRecords infra_listClusters(pagination: CursorPaginationIn, search: SearchCluster): ClusterPaginatedRecords infra_listDomainEntries(pagination: CursorPaginationIn, search: SearchDomainEntry): DomainEntryPaginatedRecords + infra_listHelmReleases(clusterName: String!, pagination: CursorPaginationIn, search: SearchHelmRelease): HelmReleasePaginatedRecords + infra_listManagedServiceTemplates: [MsvcTemplate!] infra_listNodePools(clusterName: String!, pagination: CursorPaginationIn, search: SearchNodepool): NodePoolPaginatedRecords infra_listProviderSecrets(pagination: CursorPaginationIn, search: SearchProviderSecret): CloudProviderSecretPaginatedRecords infra_listPVCs(clusterName: String!, pq: CursorPaginationIn, search: SearchPersistentVolumeClaims): PersistentVolumeClaimPaginatedRecords @@ -2294,6 +2477,7 @@ type RepositoryPaginatedRecords { enum ResType { cluster + helm_release nodepool providersecret vpn_device @@ -2389,21 +2573,20 @@ input SearchEnvironments { text: MatchFilterIn } -input SearchImagePullSecrets { +input SearchHelmRelease { isReady: MatchFilterIn - markedForDeletion: MatchFilterIn text: MatchFilterIn } -input SearchManagedResources { +input SearchImagePullSecrets { isReady: MatchFilterIn - managedServiceName: MatchFilterIn markedForDeletion: MatchFilterIn text: MatchFilterIn } -input SearchManagedServices { +input SearchManagedResources { isReady: MatchFilterIn + managedServiceName: MatchFilterIn markedForDeletion: MatchFilterIn text: MatchFilterIn } From 23d987bc054587da7eabb6881f06299e70784a31 Mon Sep 17 00:00:00 2001 From: Abdhesh Nayak Date: Mon, 1 Jan 2024 23:54:45 +0530 Subject: [PATCH 02/10] :sparkles: Added some cli queries --- src/apps/auth/server/gql/cli-queries.ts | 84 +++++++++++++++++++++++++ 1 file changed, 84 insertions(+) diff --git a/src/apps/auth/server/gql/cli-queries.ts b/src/apps/auth/server/gql/cli-queries.ts index a5b5502e3..0c7992c74 100644 --- a/src/apps/auth/server/gql/cli-queries.ts +++ b/src/apps/auth/server/gql/cli-queries.ts @@ -17,6 +17,90 @@ import { } from '~/root/src/generated/gql/server'; export const cliQueries = (executor: IExecutor) => ({ + cli_listDevices: executor( + gql` + query Infra_listVPNDevices( + $pq: CursorPaginationIn + $clusterName: String + ) { + infra_listVPNDevices(pq: $pq, clusterName: $clusterName) { + edges { + node { + displayName + markedForDeletion + metadata { + name + namespace + } + spec { + cnameRecords { + host + target + } + deviceNamespace + ports { + port + targetPort + } + } + status { + isReady + message { + RawMessage + } + } + } + } + } + } + `, + { + transformer: (data: any) => data.infra_listVPNDevices, + vars: (_: any) => {}, + } + ), + + cli_getDevice: executor( + gql` + query Infra_getVPNDevice($clusterName: String!, $name: String!) { + infra_getVPNDevice(clusterName: $clusterName, name: $name) { + displayName + markedForDeletion + metadata { + name + namespace + } + spec { + cnameRecords { + host + target + } + deviceNamespace + nodeSelector + ports { + port + targetPort + } + } + status { + isReady + message { + RawMessage + } + } + wireguardConfig { + encoding + value + } + } + } + `, + { + transformer: (data: any) => data.infra_getVPNDevice, + vars: (_: any) => {}, + } + ), + cli_listEnvironments: executor( gql` query Core_listProjects($project: ProjectId!, $pq: CursorPaginationIn) { From 28e7e370742eeaa3dc54e777198a3490abd2830d Mon Sep 17 00:00:00 2001 From: Abdhesh Nayak Date: Wed, 3 Jan 2024 14:40:12 +0530 Subject: [PATCH 03/10] :art: Cli queries updated --- src/apps/auth/server/gql/cli-queries.ts | 180 ++++++++++++++++++++++++ 1 file changed, 180 insertions(+) diff --git a/src/apps/auth/server/gql/cli-queries.ts b/src/apps/auth/server/gql/cli-queries.ts index 0c7992c74..35961ffba 100644 --- a/src/apps/auth/server/gql/cli-queries.ts +++ b/src/apps/auth/server/gql/cli-queries.ts @@ -17,6 +17,186 @@ import { } from '~/root/src/generated/gql/server'; export const cliQueries = (executor: IExecutor) => ({ + cli_listApps: executor( + gql` + query Core_listApps( + $project: ProjectId! + $scope: WorkspaceOrEnvId! + $pq: CursorPaginationIn + ) { + core_listApps(project: $project, scope: $scope, pq: $pq) { + edges { + node { + displayName + markedForDeletion + metadata { + name + namespace + } + projectName + spec { + containers { + args + command + env { + key + optional + refKey + refName + type + value + } + envFrom { + refName + type + } + image + imagePullPolicy + livenessProbe { + failureThreshold + + initialDelay + interval + + type + } + name + readinessProbe { + failureThreshold + initialDelay + interval + type + } + resourceCpu { + max + min + } + resourceMemory { + max + min + } + volumes { + mountPath + refName + type + } + } + displayName + freeze + hpa { + enabled + maxReplicas + minReplicas + thresholdCpu + thresholdMemory + } + intercept { + enabled + toDevice + } + nodeSelector + region + replicas + serviceAccount + services { + name + port + targetPort + type + } + tolerations { + effect + key + operator + tolerationSeconds + value + } + } + status { + isReady + message { + RawMessage + } + } + workspaceName + } + } + } + } + `, + { + transformer: (data: any) => data, + vars: (_: any) => {}, + } + ), + cli_listSecrets: executor( + gql` + query Core_listSecrets( + $project: ProjectId! + $scope: WorkspaceOrEnvId! + $pq: CursorPaginationIn + ) { + core_listSecrets(project: $project, scope: $scope, pq: $pq) { + edges { + node { + displayName + markedForDeletion + metadata { + name + namespace + } + status { + isReady + message { + RawMessage + } + } + stringData + } + } + } + } + `, + { + transformer: (data: any) => data, + vars: (_: any) => {}, + } + ), + cli_updateDevice: executor( + gql` + mutation Mutation($clusterName: String!, $vpnDevice: VPNDeviceIn!) { + infra_updateVPNDevice( + clusterName: $clusterName + vpnDevice: $vpnDevice + ) { + metadata { + name + } + spec { + deviceNamespace + cnameRecords { + target + host + } + ports { + targetPort + port + } + } + status { + message { + RawMessage + } + isReady + } + } + } + `, + { + transformer: (data: any) => data.infra_updateVPNDevice, + vars: (_: any) => {}, + } + ), cli_listDevices: executor( gql` query Infra_listVPNDevices( From f01f98fee567a6d6af0a3dd1e615898f8e22a452 Mon Sep 17 00:00:00 2001 From: Bikash Date: Wed, 3 Jan 2024 15:50:35 +0530 Subject: [PATCH 04/10] WIP - warning - do not revert to this commit --- Taskfile.yaml | 2 +- fake-data-generator/gen.ts | 3 +- gql-queries-generator/doc/queries.graphql | 813 +++++++-------- package.json | 2 +- pnpm-lock.yaml | 8 +- src/apps/console/components/id-selector.tsx | 6 + .../console/components/key-value-pair.tsx | 130 +++ .../components/render-dynamic-field.tsx | 4 +- .../$project+/$scope+/$workspace+/_layout.tsx | 8 +- .../backing-service+/$service/_index.tsx | 102 -- .../resources/handle-backend-resources.tsx | 229 ----- .../$service/resources/managed-resources.tsx | 128 --- .../$service/resources/route.tsx | 137 --- .../$service/resources/tools.tsx | 57 -- .../backend-services-resources.tsx | 196 ---- .../handle-backend-service.tsx | 437 -------- .../$workspace+/backing-services/route.tsx | 108 -- .../$cluster+/$project+/$scope+/_index.tsx | 2 +- .../$cluster+/$project+/$scope+/_layout.tsx | 7 +- .../$account+/$cluster+/$project+/_layout.tsx | 63 +- .../$project+/environments/route.tsx | 9 +- .../$cluster+/$project+/settings+/_layout.tsx | 2 +- .../$project+/workspaces/resources.tsx | 173 ---- .../$cluster+/$project+/workspaces/route.tsx | 116 --- .../$cluster+/$project+/workspaces/tools.tsx | 13 - .../routes/_main+/$account+/_layout.tsx | 6 +- .../$account+/infra+/$cluster+/_layout.tsx | 57 +- .../$cluster+/managedservices+/_layout.tsx | 24 + .../managedservices+/helm-chart/_index.tsx | 93 ++ .../helm-chart/handle-helm-chart.tsx | 244 +++++ .../helm-chart/helm-chart-resources.tsx | 204 ++++ .../managedservices+/helm-chart}/tools.tsx | 2 - .../backend-services-resources.tsx | 233 +++++ .../handle-backend-service.tsx | 628 ++++++++++++ .../kl-operator-services/route.tsx | 124 +++ .../kl-operator-services/tools.tsx | 29 + .../infra+/$cluster+/network+/_layout.tsx | 14 +- .../$cluster+/network+/vpn/handle-devices.tsx | 8 +- .../infra+/$cluster+/network+/vpn/route.tsx | 2 +- .../$cluster+/nodepools/handle-nodepool.tsx | 1 - .../infra+/$cluster+/nodepools/route.tsx | 10 +- .../infra+/$cluster+/settings+/_layout.tsx | 6 +- .../domain/domain-detail.tsx | 0 .../domain/domain-resources.tsx | 0 .../domain/handle-domain.tsx | 0 .../{network+ => settings+}/domain/route.tsx | 2 +- .../{network+ => settings+}/domain/tools.tsx | 0 .../_main+/$account+/infra+/_layout.tsx | 2 +- .../$account+/infra+/clusters/route.tsx | 1 + .../_main+/$account+/packages+/_index.tsx | 6 +- .../_main+/$account+/packages+/_layout.tsx | 2 +- .../$account+/packages+/repos/route.tsx | 8 +- .../$account+/projects/project-resources.tsx | 4 +- .../_main+/$account+/repo+/$repo+/_layout.tsx | 99 +- .../buildruns-resources.tsx | 0 .../$repo+/{$build => buildruns}/route.tsx | 43 +- .../$repo+/{$build => buildruns}/tools.tsx | 0 .../$account+/repo+/$repo+/builds/_index.tsx | 47 +- .../$account+/repo+/$repo+/builds/_layout.tsx | 8 - .../repo+/$repo+/builds/build-resources.tsx | 3 +- .../repo+/$repo+/builds/handle-builds.tsx | 159 +-- .../$account+/repo+/$repo+/images/route.tsx | 4 + .../repo+/$repo+/images/tags-resources.tsx | 6 +- .../repo+/$repo+/settings/_index.tsx | 5 + .../buildcaches/build-caches-resources.tsx | 0 .../buildcaches/handle-build-cache.tsx | 0 .../{ => settings}/buildcaches/route.tsx | 48 +- .../{ => settings}/buildcaches/tools.tsx | 0 .../repo+/$repo+/settings/general/route.tsx | 115 +++ .../$account+/repo+/$repo+/settings/route.tsx | 19 + .../settings+/cloud-providers/route.tsx | 3 +- .../cluster-managed-services-queries.ts | 215 ++++ .../server/gql/queries/cluster-queries.ts | 18 +- .../server/gql/queries/environment-queries.ts | 24 +- .../server/gql/queries/helm-chart-queries.ts | 222 ++++ .../gql/queries/managed-service-queries.ts | 330 ------ .../gql/queries/managed-templates-queries.ts | 115 +++ .../server/gql/queries/nodepool-queries.ts | 27 +- .../server/gql/queries/project-queries.ts | 17 +- .../console/server/gql/queries/vpn-queries.ts | 14 +- .../server/gql/queries/workspace-queries.ts | 70 +- src/apps/console/server/gql/saved-queries.ts | 8 +- src/apps/console/server/r-utils/common.ts | 24 +- src/apps/console/utils/commons.tsx | 18 +- src/generated/gql/sdl.graphql | 405 ++++++-- src/generated/gql/server.ts | 969 ++++++++++-------- 86 files changed, 4027 insertions(+), 3473 deletions(-) create mode 100644 src/apps/console/components/key-value-pair.tsx delete mode 100644 src/apps/console/routes/_main+/$account+/$cluster+/$project+/$scope+/$workspace+/backing-service+/$service/_index.tsx delete mode 100644 src/apps/console/routes/_main+/$account+/$cluster+/$project+/$scope+/$workspace+/backing-service+/$service/resources/handle-backend-resources.tsx delete mode 100644 src/apps/console/routes/_main+/$account+/$cluster+/$project+/$scope+/$workspace+/backing-service+/$service/resources/managed-resources.tsx delete mode 100644 src/apps/console/routes/_main+/$account+/$cluster+/$project+/$scope+/$workspace+/backing-service+/$service/resources/route.tsx delete mode 100644 src/apps/console/routes/_main+/$account+/$cluster+/$project+/$scope+/$workspace+/backing-service+/$service/resources/tools.tsx delete mode 100644 src/apps/console/routes/_main+/$account+/$cluster+/$project+/$scope+/$workspace+/backing-services/backend-services-resources.tsx delete mode 100644 src/apps/console/routes/_main+/$account+/$cluster+/$project+/$scope+/$workspace+/backing-services/handle-backend-service.tsx delete mode 100644 src/apps/console/routes/_main+/$account+/$cluster+/$project+/$scope+/$workspace+/backing-services/route.tsx delete mode 100644 src/apps/console/routes/_main+/$account+/$cluster+/$project+/workspaces/resources.tsx delete mode 100644 src/apps/console/routes/_main+/$account+/$cluster+/$project+/workspaces/route.tsx delete mode 100644 src/apps/console/routes/_main+/$account+/$cluster+/$project+/workspaces/tools.tsx create mode 100644 src/apps/console/routes/_main+/$account+/infra+/$cluster+/managedservices+/_layout.tsx create mode 100644 src/apps/console/routes/_main+/$account+/infra+/$cluster+/managedservices+/helm-chart/_index.tsx create mode 100644 src/apps/console/routes/_main+/$account+/infra+/$cluster+/managedservices+/helm-chart/handle-helm-chart.tsx create mode 100644 src/apps/console/routes/_main+/$account+/infra+/$cluster+/managedservices+/helm-chart/helm-chart-resources.tsx rename src/apps/console/routes/_main+/$account+/{$cluster+/$project+/$scope+/$workspace+/backing-services => infra+/$cluster+/managedservices+/helm-chart}/tools.tsx (90%) create mode 100644 src/apps/console/routes/_main+/$account+/infra+/$cluster+/managedservices+/kl-operator-services/backend-services-resources.tsx create mode 100644 src/apps/console/routes/_main+/$account+/infra+/$cluster+/managedservices+/kl-operator-services/handle-backend-service.tsx create mode 100644 src/apps/console/routes/_main+/$account+/infra+/$cluster+/managedservices+/kl-operator-services/route.tsx create mode 100644 src/apps/console/routes/_main+/$account+/infra+/$cluster+/managedservices+/kl-operator-services/tools.tsx rename src/apps/console/routes/_main+/$account+/infra+/$cluster+/{network+ => settings+}/domain/domain-detail.tsx (100%) rename src/apps/console/routes/_main+/$account+/infra+/$cluster+/{network+ => settings+}/domain/domain-resources.tsx (100%) rename src/apps/console/routes/_main+/$account+/infra+/$cluster+/{network+ => settings+}/domain/handle-domain.tsx (100%) rename src/apps/console/routes/_main+/$account+/infra+/$cluster+/{network+ => settings+}/domain/route.tsx (98%) rename src/apps/console/routes/_main+/$account+/infra+/$cluster+/{network+ => settings+}/domain/tools.tsx (100%) rename src/apps/console/routes/_main+/$account+/repo+/$repo+/{$build => buildruns}/buildruns-resources.tsx (100%) rename src/apps/console/routes/_main+/$account+/repo+/$repo+/{$build => buildruns}/route.tsx (68%) rename src/apps/console/routes/_main+/$account+/repo+/$repo+/{$build => buildruns}/tools.tsx (100%) delete mode 100644 src/apps/console/routes/_main+/$account+/repo+/$repo+/builds/_layout.tsx create mode 100644 src/apps/console/routes/_main+/$account+/repo+/$repo+/settings/_index.tsx rename src/apps/console/routes/_main+/$account+/repo+/$repo+/{ => settings}/buildcaches/build-caches-resources.tsx (100%) rename src/apps/console/routes/_main+/$account+/repo+/$repo+/{ => settings}/buildcaches/handle-build-cache.tsx (100%) rename src/apps/console/routes/_main+/$account+/repo+/$repo+/{ => settings}/buildcaches/route.tsx (79%) rename src/apps/console/routes/_main+/$account+/repo+/$repo+/{ => settings}/buildcaches/tools.tsx (100%) create mode 100644 src/apps/console/routes/_main+/$account+/repo+/$repo+/settings/general/route.tsx create mode 100644 src/apps/console/routes/_main+/$account+/repo+/$repo+/settings/route.tsx create mode 100644 src/apps/console/server/gql/queries/cluster-managed-services-queries.ts create mode 100644 src/apps/console/server/gql/queries/helm-chart-queries.ts delete mode 100644 src/apps/console/server/gql/queries/managed-service-queries.ts create mode 100644 src/apps/console/server/gql/queries/managed-templates-queries.ts diff --git a/Taskfile.yaml b/Taskfile.yaml index 44a4c35da..0ae03f4d6 100644 --- a/Taskfile.yaml +++ b/Taskfile.yaml @@ -35,7 +35,7 @@ tasks: case $(whoami) in "bikash") - URL_SUFFIX="" + URL_SUFFIX="-bikash" ;; "vision") diff --git a/fake-data-generator/gen.ts b/fake-data-generator/gen.ts index c569c0ac8..6ad903c25 100644 --- a/fake-data-generator/gen.ts +++ b/fake-data-generator/gen.ts @@ -18,8 +18,9 @@ const types: string[] = [ 'ConsoleListAppsQuery', 'ConsoleListConfigsQuery', 'ConsoleListSecretsQuery', - 'ConsoleListManagedServicesQuery', + 'ConsoleListClusterMSvsQuery', 'ConsoleListManagedResourceQuery', + 'ConsoleListHelmChartQuery', ]; async function fake(files: string[], types: string[] = []) { diff --git a/gql-queries-generator/doc/queries.graphql b/gql-queries-generator/doc/queries.graphql index 89fa70e75..4c2f7ebe9 100644 --- a/gql-queries-generator/doc/queries.graphql +++ b/gql-queries-generator/doc/queries.graphql @@ -202,14 +202,6 @@ query consoleListProjects($clusterName: String, $pagination: CursorPaginationIn, isReady checks } - syncStatus { - syncScheduledAt - state - recordVersion - lastSyncedAt - error - action - } updateTime accountName } @@ -273,9 +265,7 @@ query consoleListClusters($search: SearchCluster, $pagination: CursorPaginationI syncScheduledAt lastSyncedAt recordVersion - state error - action } status { resources { @@ -434,11 +424,9 @@ query consoleGetCluster($name: String!) { } } syncStatus { - action error lastSyncedAt recordVersion - state syncScheduledAt } updateTime @@ -630,14 +618,6 @@ query consoleGetNodePool($clusterName: String!, $poolName: String!) { namespace } } - syncStatus { - action - error - lastSyncedAt - recordVersion - state - syncScheduledAt - } updateTime } } @@ -732,14 +712,6 @@ query consoleListNodePools($clusterName: String!, $search: SearchNodepool, $pagi namespace } } - syncStatus { - action - error - lastSyncedAt - recordVersion - state - syncScheduledAt - } updateTime } } @@ -780,46 +752,6 @@ mutation consoleUpdateWorkspace($env: WorkspaceIn!) { } } -query consoleListWorkspaces($project: ProjectId!, $search: SearchWorkspaces, $pagination: CursorPaginationIn) { - core_listWorkspaces(project: $project, search: $search, pq: $pagination) { - pageInfo { - startCursor - hasPreviousPage - hasNextPage - endCursor - } - totalCount - edges { - node { - metadata { - name - namespace - labels - annotations - } - displayName - clusterName - updateTime - creationTime - spec { - targetNamespace - projectName - } - createdBy { - userEmail - userId - userName - } - lastUpdatedBy { - userEmail - userId - userName - } - } - } - } -} - query consoleGetEnvironment($project: ProjectId!, $name: String!) { core_getEnvironment(project: $project, name: $name) { accountName @@ -870,14 +802,6 @@ query consoleGetEnvironment($project: ProjectId!, $name: String!) { namespace } } - syncStatus { - action - error - lastSyncedAt - recordVersion - state - syncScheduledAt - } updateTime } } @@ -947,14 +871,6 @@ query consoleListEnvironments($project: ProjectId!, $search: SearchWorkspaces, $ namespace } } - syncStatus { - action - error - lastSyncedAt - recordVersion - state - syncScheduledAt - } updateTime } } @@ -1444,8 +1360,6 @@ query consoleListVpnDevices($clusterName: String, $search: SearchVPNDevices, $pq namespace } spec { - accountName - clusterName ports { port targetPort @@ -1513,8 +1427,6 @@ query consoleGetVpnDevice($clusterName: String!, $name: String!) { namespace } spec { - accountName - clusterName ports { port targetPort @@ -1627,110 +1539,8 @@ mutation consoleDeleteAccountMembership($accountName: String!, $memberId: ID!) { accounts_removeAccountMembership(accountName: $accountName, memberId: $memberId) } -query consoleGetTemplate($category: String!, $name: String!) { - core_getManagedServiceTemplate(category: $category, name: $name) { - active - apiVersion - description - displayName - fields { - defaultValue - inputType - label - max - min - name - required - unit - } - kind - logoUrl - name - outputs { - description - label - name - } - resources { - apiVersion - description - displayName - fields { - defaultValue - inputType - label - max - min - name - required - unit - } - kind - name - outputs { - description - label - name - } - } - } -} - -query consoleListTemplates { - core_listManagedServiceTemplates { - category - displayName - items { - description - active - displayName - fields { - defaultValue - inputType - label - max - min - name - required - unit - } - logoUrl - name - outputs { - name - label - description - } - resources { - description - displayName - fields { - defaultValue - inputType - label - max - min - name - required - unit - } - name - outputs { - description - label - name - } - kind - apiVersion - } - kind - apiVersion - } - } -} - -query consoleGetManagedService($project: ProjectId!, $scope: WorkspaceOrEnvId!, $name: String!) { - core_getManagedService(project: $project, scope: $scope, name: $name) { +query consoleGetManagedResource($project: ProjectId!, $scope: WorkspaceOrEnvId!, $name: String!) { + core_getManagedResource(project: $project, scope: $scope, name: $name) { accountName apiVersion clusterName @@ -1761,9 +1571,14 @@ query consoleGetManagedService($project: ProjectId!, $scope: WorkspaceOrEnvId!, } recordVersion spec { - serviceTemplate { + resourceTemplate { apiVersion kind + msvcRef { + name + kind + apiVersion + } spec } } @@ -1793,229 +1608,78 @@ query consoleGetManagedService($project: ProjectId!, $scope: WorkspaceOrEnvId!, } } -query consoleListManagedServices($project: ProjectId!, $scope: WorkspaceOrEnvId!) { - core_listManagedServices(project: $project, scope: $scope) { +query consoleListManagedResource($project: ProjectId!, $scope: WorkspaceOrEnvId!, $search: SearchManagedResources, $pq: CursorPaginationIn) { + core_listManagedResources( + project: $project + scope: $scope + search: $search + pq: $pq + ) { + pageInfo { + endCursor + hasNextPage + hasPreviousPage + startCursor + } + totalCount + edges { + cursor + node { + updateTime + metadata { + name + } + lastUpdatedBy { + userEmail + userName + } + kind + displayName + creationTime + createdBy { + userEmail + userName + } + } + } + } +} + +mutation consoleCreateManagedResource($mres: ManagedResourceIn!) { + core_createManagedResource(mres: $mres) { + id + } +} + +query consoleGetCredToken($username: String!) { + cr_getCredToken(username: $username) +} + +query consoleListCred($search: SearchCreds, $pagination: CursorPaginationIn) { + cr_listCreds(search: $search, pagination: $pagination) { edges { cursor node { + access accountName - apiVersion - clusterName createdBy { userEmail userId userName } creationTime - displayName - enabled + expiration { + unit + value + } id - kind lastUpdatedBy { userEmail userId userName } markedForDeletion - metadata { - annotations - creationTimestamp - deletionTimestamp - generation - labels - name - namespace - } - recordVersion - spec { - serviceTemplate { - apiVersion - kind - spec - } - } - status { - checks - isReady - lastReconcileTime - message { - RawMessage - } - resources { - apiVersion - kind - name - namespace - } - } - syncStatus { - action - error - lastSyncedAt - recordVersion - state - syncScheduledAt - } - updateTime - } - } - pageInfo { - endCursor - hasNextPage - hasPreviousPage - startCursor - } - totalCount - } -} - -mutation consoleCreateManagedService($msvc: ManagedServiceIn!) { - core_createManagedService(msvc: $msvc) { - id - } -} - -query consoleGetManagedResource($project: ProjectId!, $scope: WorkspaceOrEnvId!, $name: String!) { - core_getManagedResource(project: $project, scope: $scope, name: $name) { - accountName - apiVersion - clusterName - createdBy { - userEmail - userId - userName - } - creationTime - displayName - enabled - id - kind - lastUpdatedBy { - userEmail - userId - userName - } - markedForDeletion - metadata { - annotations - creationTimestamp - deletionTimestamp - generation - labels - name - namespace - } - recordVersion - spec { - resourceTemplate { - apiVersion - kind - msvcRef { - name - kind - apiVersion - } - spec - } - } - status { - checks - isReady - lastReconcileTime - message { - RawMessage - } - resources { - apiVersion - kind - name - namespace - } - } - syncStatus { - action - error - lastSyncedAt - recordVersion - state - syncScheduledAt - } - updateTime - } -} - -query consoleListManagedResource($project: ProjectId!, $scope: WorkspaceOrEnvId!, $search: SearchManagedResources, $pq: CursorPaginationIn) { - core_listManagedResources( - project: $project - scope: $scope - search: $search - pq: $pq - ) { - pageInfo { - endCursor - hasNextPage - hasPreviousPage - startCursor - } - totalCount - edges { - cursor - node { - updateTime - metadata { - name - } - lastUpdatedBy { - userEmail - userName - } - kind - displayName - creationTime - createdBy { - userEmail - userName - } - } - } - } -} - -mutation consoleCreateManagedResource($mres: ManagedResourceIn!) { - core_createManagedResource(mres: $mres) { - id - } -} - -query consoleGetCredToken($username: String!) { - cr_getCredToken(username: $username) -} - -query consoleListCred($search: SearchCreds, $pagination: CursorPaginationIn) { - cr_listCreds(search: $search, pagination: $pagination) { - edges { - cursor - node { - access - accountName - createdBy { - userEmail - userId - userName - } - creationTime - expiration { - unit - value - } - id - lastUpdatedBy { - userEmail - userId - userName - } - markedForDeletion - name + name recordVersion updateTime username @@ -2679,6 +2343,357 @@ query consoleGetBuildRun($repoName: String!, $buildRunName: String!) { } } +query consoleGetClusterMSv($clusterName: String!, $name: String!) { + infra_getClusterManagedService(clusterName: $clusterName, name: $name) { + displayName + creationTime + createdBy { + userEmail + userId + userName + } + clusterName + lastUpdatedBy { + userEmail + userId + userName + } + markedForDeletion + metadata { + annotations + creationTimestamp + deletionTimestamp + generation + labels + name + namespace + } + spec { + msvcSpec { + serviceTemplate { + apiVersion + kind + spec + } + } + namespace + } + status { + checks + isReady + lastReadyGeneration + lastReconcileTime + message { + RawMessage + } + resources { + apiVersion + kind + name + namespace + } + } + updateTime + } +} + +mutation consoleCreateClusterMSv($clusterName: String!, $service: ClusterManagedServiceIn!) { + infra_createClusterManagedService(clusterName: $clusterName, service: $service) { + id + } +} + +mutation consoleUpdateClusterMSv($clusterName: String!, $service: ClusterManagedServiceIn!) { + infra_updateClusterManagedService(clusterName: $clusterName, service: $service) { + id + } +} + +query consoleListClusterMSvs($clusterName: String!) { + infra_listClusterManagedServices(clusterName: $clusterName) { + edges { + cursor + node { + createdBy { + userEmail + userId + userName + } + creationTime + displayName + lastUpdatedBy { + userEmail + userId + userName + } + markedForDeletion + metadata { + name + } + spec { + msvcSpec { + serviceTemplate { + apiVersion + kind + spec + } + } + } + status { + checks + isReady + lastReadyGeneration + lastReconcileTime + message { + RawMessage + } + resources { + apiVersion + kind + name + namespace + } + } + updateTime + } + } + pageInfo { + endCursor + hasNextPage + hasPreviousPage + startCursor + } + totalCount + } +} + +mutation consoleDeleteClusterMSv($clusterName: String!, $serviceName: String!) { + infra_deleteClusterManagedService( + clusterName: $clusterName + serviceName: $serviceName + ) +} + +query consoleGetMSvTemplate($category: String!, $name: String!) { + infra_getManagedServiceTemplate(category: $category, name: $name) { + active + apiVersion + description + displayName + fields { + defaultValue + inputType + label + max + min + name + required + unit + displayUnit + multiplier + } + kind + logoUrl + name + outputs { + description + label + name + } + resources { + apiVersion + description + displayName + kind + name + } + } +} + +query consoleListMSvTemplates { + infra_listManagedServiceTemplates { + category + displayName + items { + active + apiVersion + description + displayName + fields { + defaultValue + inputType + label + max + min + name + required + unit + displayUnit + multiplier + } + kind + logoUrl + name + outputs { + description + label + name + } + resources { + apiVersion + description + displayName + kind + name + } + } + } +} + +query consoleGetHelmChart($clusterName: String!, $name: String!) { + infra_getHelmRelease(clusterName: $clusterName, name: $name) { + createdBy { + userEmail + userId + userName + } + creationTime + displayName + lastUpdatedBy { + userEmail + userId + userName + } + markedForDeletion + metadata { + annotations + creationTimestamp + deletionTimestamp + generation + labels + name + namespace + } + spec { + chartName + chartRepo { + name + url + } + chartVersion + postInstall + postUninstall + preInstall + preUninstall + values + } + status { + checks + isReady + lastReadyGeneration + lastReconcileTime + message { + RawMessage + } + releaseNotes + releaseStatus + resources { + apiVersion + kind + name + namespace + } + } + updateTime + } +} + +query consoleListHelmChart($clusterName: String!) { + infra_listHelmReleases(clusterName: $clusterName) { + edges { + cursor + node { + createdBy { + userEmail + userId + userName + } + creationTime + displayName + lastUpdatedBy { + userEmail + userId + userName + } + markedForDeletion + metadata { + annotations + creationTimestamp + deletionTimestamp + generation + labels + name + namespace + } + spec { + chartName + chartRepo { + name + url + } + chartVersion + postInstall + postUninstall + preInstall + preUninstall + values + } + status { + checks + isReady + lastReadyGeneration + lastReconcileTime + message { + RawMessage + } + releaseNotes + releaseStatus + resources { + apiVersion + kind + name + namespace + } + } + updateTime + } + } + pageInfo { + endCursor + hasNextPage + hasPreviousPage + startCursor + } + totalCount + } +} + +mutation consoleCreateHelmChart($clusterName: String!, $release: HelmReleaseIn!) { + infra_createHelmRelease(clusterName: $clusterName, release: $release) { + id + } +} + +mutation consoleUpdateHelmChart($clusterName: String!, $release: HelmReleaseIn!) { + infra_updateHelmRelease(clusterName: $clusterName, release: $release) { + id + } +} + +mutation consoleDeleteHelmChart($clusterName: String!, $releaseName: String!) { + infra_deleteHelmRelease(clusterName: $clusterName, releaseName: $releaseName) +} + query authCli_getKubeConfig($name: String!) { infra_getCluster(name: $name) { adminKubeconfig { diff --git a/package.json b/package.json index 8cb270fc8..a8a54a5e3 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "dependencies": { "@jengaicons/react": "^1.3.0", "@mdx-js/react": "^2.3.0", - "@oshq/react-select": "^1.0.1", + "@oshq/react-select": "^1.0.2", "@radix-ui/primitive": "^1.0.1", "@radix-ui/react-alert-dialog": "1.0.4", "@radix-ui/react-checkbox": "^1.0.4", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ae8503634..beab28a70 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -12,8 +12,8 @@ dependencies: specifier: ^2.3.0 version: 2.3.0(react@18.2.0) '@oshq/react-select': - specifier: ^1.0.1 - version: 1.0.1(@radix-ui/react-portal@1.0.4)(classnames@2.3.2)(framer-motion@10.16.16)(rc-virtual-list@3.11.3)(react@18.2.0) + specifier: ^1.0.2 + version: 1.0.2(@radix-ui/react-portal@1.0.4)(classnames@2.3.2)(framer-motion@10.16.16)(rc-virtual-list@3.11.3)(react@18.2.0) '@radix-ui/primitive': specifier: ^1.0.1 version: 1.0.1 @@ -2505,8 +2505,8 @@ packages: json-parse-even-better-errors: 2.3.1 dev: true - /@oshq/react-select@1.0.1(@radix-ui/react-portal@1.0.4)(classnames@2.3.2)(framer-motion@10.16.16)(rc-virtual-list@3.11.3)(react@18.2.0): - resolution: {integrity: sha512-jFaoj7C0dzQBZyj4gbisgS7N3ws2VspMOWfcKdF4aaN5Em0JA8TdVJAOS+xAb+wJcZOtVpKaHoXI4otANNmzaA==} + /@oshq/react-select@1.0.2(@radix-ui/react-portal@1.0.4)(classnames@2.3.2)(framer-motion@10.16.16)(rc-virtual-list@3.11.3)(react@18.2.0): + resolution: {integrity: sha512-YLLz708lyYwPeYRJBJmA9DtPUHDcuiFzDMLNczhALeZzclycvzth6oWPTThsbL1LuAkEADiEQHIqohLnMsl53w==} peerDependencies: '@radix-ui/react-portal': ^1.0.4 classnames: ^2.3.2 diff --git a/src/apps/console/components/id-selector.tsx b/src/apps/console/components/id-selector.tsx index ac56baefd..267f53da6 100644 --- a/src/apps/console/components/id-selector.tsx +++ b/src/apps/console/components/id-selector.tsx @@ -67,6 +67,7 @@ export const IdSelector = ({ case 'environment': case 'managed_service': case 'managed_resource': + case 'helm_release': case 'router': case 'secret': case 'workspace': @@ -121,6 +122,11 @@ export const IdSelector = ({ clusterName: cluster, } : {}), + ...(resType === 'managed_resource' + ? { + namespace: '', + } + : {}), }); if (errors) { diff --git a/src/apps/console/components/key-value-pair.tsx b/src/apps/console/components/key-value-pair.tsx new file mode 100644 index 000000000..72c8843d4 --- /dev/null +++ b/src/apps/console/components/key-value-pair.tsx @@ -0,0 +1,130 @@ +import { MinusCircle } from '@jengaicons/react'; +import { ReactNode, useEffect, useState } from 'react'; +import AnimateHide from '~/components/atoms/animate-hide'; +import { Button, IconButton } from '~/components/atoms/button'; +import { TextInput } from '~/components/atoms/input'; +import { cn, uuid } from '~/components/utils'; + +interface IKeyValuePair { + onChange?( + itemArray: Array>, + itemObject: Record + ): void; + value?: Array>; + label?: ReactNode; + message?: ReactNode; + error?: boolean; +} +const KeyValuePair = ({ + onChange, + value = [], + label, + message, + error, +}: IKeyValuePair) => { + const newItem = [{ key: '', value: '', id: uuid() }]; + const [items, setItems] = useState>>(newItem); + + const handleChange = (_value = '', id = '', target = {}) => { + setItems( + items.map((i) => { + if (i.id === id) { + switch (target) { + case 'key': + return { ...i, key: _value }; + case 'value': + default: + return { ...i, value: _value }; + } + } + return i; + }) + ); + }; + + useEffect(() => { + const formatItems = items.reduce((acc, curr) => { + if (curr.key && curr.value) { + acc[curr.key] = curr.value; + } + return acc; + }, {}); + if (onChange) onChange(Array.from(items), formatItems); + }, [items]); + + useEffect(() => { + if (value.length > 0) { + setItems(Array.from(value).map((v) => ({ ...v, id: uuid() }))); + } + }, []); + + return ( +
+
+
+ {label && ( + {label} + )} + {items.map((item) => ( +
+
+ + handleChange(target.value, item.id, 'key') + } + /> +
+
+ + handleChange(target.value, item.id, 'value') + } + /> +
+ } + variant="plain" + disabled={items.length < 2} + onClick={() => { + setItems(items.filter((i) => i.id !== item.id)); + }} + /> +
+ ))} +
+ +
+ {message} +
+
+
+
+
+
+ ); +}; + +export default KeyValuePair; diff --git a/src/apps/console/components/render-dynamic-field.tsx b/src/apps/console/components/render-dynamic-field.tsx index 2487b59da..7cb571152 100644 --- a/src/apps/console/components/render-dynamic-field.tsx +++ b/src/apps/console/components/render-dynamic-field.tsx @@ -1,5 +1,5 @@ import { NumberInput, TextInput } from '~/components/atoms/input'; -import { IManagedServiceTemplate } from '../server/gql/queries/managed-service-queries'; +import { IMSvTemplate } from '../server/gql/queries/managed-templates-queries'; const RenderDynamicField = ({ field, @@ -8,7 +8,7 @@ const RenderDynamicField = ({ error, message, }: { - field: IManagedServiceTemplate['resources'][number]['fields'][number]; + field: IMSvTemplate['fields'][number]; onChange: (e: { target: { value: any } }) => void; value: any; error?: boolean; diff --git a/src/apps/console/routes/_main+/$account+/$cluster+/$project+/$scope+/$workspace+/_layout.tsx b/src/apps/console/routes/_main+/$account+/$cluster+/$project+/$scope+/$workspace+/_layout.tsx index 943f2e360..2a9b604b7 100644 --- a/src/apps/console/routes/_main+/$account+/$cluster+/$project+/$scope+/$workspace+/_layout.tsx +++ b/src/apps/console/routes/_main+/$account+/$cluster+/$project+/$scope+/$workspace+/_layout.tsx @@ -17,7 +17,6 @@ import { BlackWorkspaceLogo, } from '~/console/components/commons'; import HandleScope, { SCOPE } from '~/console/page-components/new-scope'; -import { IManagedServiceTemplates } from '~/console/server/gql/queries/managed-service-queries'; import { type IWorkspace } from '~/console/server/gql/queries/workspace-queries'; import { GQLServerHandler } from '~/console/server/gql/saved-queries'; import { @@ -38,12 +37,12 @@ import { SubNavDataProvider } from '~/root/lib/client/hooks/use-create-subnav-ac import useDebounce from '~/root/lib/client/hooks/use-debounce'; import { IRemixCtx } from '~/root/lib/types/common'; import { Truncate, handleError } from '~/root/lib/utils/common'; +import { IMSvTemplates } from '~/console/server/gql/queries/managed-templates-queries'; import { IProjectContext } from '../../_layout'; - export interface IWorkspaceContext extends IProjectContext { workspace: IWorkspace; - managedTemplates: IManagedServiceTemplates; + managedTemplates: IMSvTemplates; } const Workspace = () => { @@ -268,6 +267,7 @@ export const loader = async (ctx: IRemixCtx) => { ...getScopeAndProjectQuery(ctx), name: workspace, }); + if (errors) { logger.error(errors); throw errors[0]; @@ -275,7 +275,7 @@ export const loader = async (ctx: IRemixCtx) => { const { data: mTemplates, errors: mErrors } = await GQLServerHandler( ctx.request - ).listTemplates({}); + ).listMSvTemplates({}); if (mErrors) { throw mErrors[0]; } diff --git a/src/apps/console/routes/_main+/$account+/$cluster+/$project+/$scope+/$workspace+/backing-service+/$service/_index.tsx b/src/apps/console/routes/_main+/$account+/$cluster+/$project+/$scope+/$workspace+/backing-service+/$service/_index.tsx deleted file mode 100644 index da361ad4c..000000000 --- a/src/apps/console/routes/_main+/$account+/$cluster+/$project+/$scope+/$workspace+/backing-service+/$service/_index.tsx +++ /dev/null @@ -1,102 +0,0 @@ -import { redirect } from '@remix-run/node'; -import { - Outlet, - useLoaderData, - useOutletContext, - useParams, -} from '@remix-run/react'; -import { CommonTabs } from '~/console/components/common-navbar-tabs'; -import { IManagedService } from '~/console/server/gql/queries/managed-service-queries'; -import { GQLServerHandler } from '~/console/server/gql/saved-queries'; -import { getScopeAndProjectQuery } from '~/console/server/r-utils/common'; -import { - ensureAccountSet, - ensureClusterSet, -} from '~/console/server/utils/auth-utils'; -import logger from '~/root/lib/client/helpers/log'; -import { IRemixCtx } from '~/root/lib/types/common'; -import { IWorkspaceContext } from '../../_layout'; - - -export interface IManagedServiceContext extends IWorkspaceContext { - backendService: IManagedService; -} - -const BackendService = () => { - const rootContext = useOutletContext(); - const { backendService } = useLoaderData(); - return ; -}; - -const Tabs = () => { - const { account, cluster, project, scope, workspace, service } = useParams(); - return ( - - ); -}; - -export const handle = () => { - return { - navbar: , - }; -}; - -export const loader = async (ctx: IRemixCtx) => { - const { service } = ctx.params; - - ensureClusterSet(ctx); - ensureAccountSet(ctx); - - const api = GQLServerHandler(ctx.request).getManagedService; - - try { - const { data, errors } = await api({ - name: service, - ...getScopeAndProjectQuery(ctx), - }); - if (errors) { - logger.error(errors); - throw errors[0]; - } - return { - backendService: data || {}, - }; - } catch (err) { - return redirect(`../backing-services`); - } -}; - -export default BackendService; diff --git a/src/apps/console/routes/_main+/$account+/$cluster+/$project+/$scope+/$workspace+/backing-service+/$service/resources/handle-backend-resources.tsx b/src/apps/console/routes/_main+/$account+/$cluster+/$project+/$scope+/$workspace+/backing-service+/$service/resources/handle-backend-resources.tsx deleted file mode 100644 index 4c68d8ea3..000000000 --- a/src/apps/console/routes/_main+/$account+/$cluster+/$project+/$scope+/$workspace+/backing-service+/$service/resources/handle-backend-resources.tsx +++ /dev/null @@ -1,229 +0,0 @@ -import { useOutletContext } from '@remix-run/react'; -import { useState } from 'react'; -import { TextInput } from '~/components/atoms/input'; -import Select from '~/components/atoms/select'; -import Popup from '~/components/molecule/popup'; -import { toast } from '~/components/molecule/toast'; -import { IdSelector } from '~/console/components/id-selector'; -import MultiStep, { useMultiStep } from '~/console/components/multi-step'; -import RenderDynamicField from '~/console/components/render-dynamic-field'; -import { IDialog } from '~/console/components/types.d'; -import { useConsoleApi } from '~/console/server/gql/api-provider'; -import { IManagedServiceTemplate } from '~/console/server/gql/queries/managed-service-queries'; -import useForm, { dummyEvent } from '~/root/lib/client/hooks/use-form'; -import Yup from '~/root/lib/server/helpers/yup'; -import { IManagedServiceContext } from '../_index'; - -const HandleBackendResources = ({ - show, - setShow, - template, -}: IDialog & { template: IManagedServiceTemplate }) => { - const [isIDLoading, setIsIDLoading] = useState(false); - const { currentStep, onNext, onPrevious } = useMultiStep({ - defaultStep: 1, - totalSteps: 2, - }); - - const [selectedType, setSelectedType] = useState<{ - label: string; - value: string; - resource: IManagedServiceTemplate['resources'][number]; - }>(); - - const api = useConsoleApi(); - const { backendService, workspace } = - useOutletContext(); - - const { - values: valuesFirst, - errors: errorsFirst, - handleChange: handleChangeFirst, - handleSubmit: handleSubmitFirst, - } = useForm({ - initialValues: { - name: '', - displayName: '', - type: '', - }, - validationSchema: Yup.object({ - name: Yup.string().required(), - displayName: Yup.string().required(), - type: Yup.string().required(), - }), - onSubmit: () => { - onNext(); - }, - }); - - const { - values: valuesSecond, - errors: errorsSecond, - handleChange: handleChangeSecond, - handleSubmit: handleSubmitSecond, - } = useForm({ - initialValues: { - ...(selectedType?.resource.fields.reduce((acc, field) => { - return { - ...acc, - [field.name]: field.defaultValue, - }; - }, {}) || {}), - }, - validationSchema: Yup.object({ - ...selectedType?.resource.fields.reduce((acc, curr) => { - return { - ...acc, - [curr.name]: (() => { - let returnYup: any = Yup; - switch (curr.inputType) { - case 'Number': - returnYup = returnYup.number(); - if (curr.min) returnYup = returnYup.min(curr.min); - if (curr.max) returnYup = returnYup.max(curr.max); - break; - case 'String': - returnYup = returnYup.string(); - break; - default: - toast.error( - `Unknown input type ${curr.inputType} for field ${curr.name}` - ); - returnYup = returnYup.string(); - } - - if (curr.required) { - returnYup = returnYup.required(); - } - - return returnYup; - })(), - }; - }, {}), - }), - onSubmit: async (val) => { - // try { - // const { errors: e } = await api.createManagedResource({ - // mres: { - // displayName: valuesFirst.displayName, - // metadata: { - // name: valuesFirst.name, - // namespace: parseTargetNs(workspace), - // }, - // spec: { - // mresKind: { - // kind: selectedType?.resource.kind || '', - // }, - // msvcRef: { - // apiVersion: template.apiVersion || '', - // name: parseName(backendService), - // kind: template.kind!, - // }, - // inputs: { - // ...val, - // }, - // }, - // }, - // }); - // if (e) { - // throw e[0]; - // } - // } catch (err) { - // handleError(err); - // } - }, - }); - - return ( - { - setShow(e); - }} - > - Create new resource -
- - - -
-
- - setIsIDLoading(loading)} - onChange={(v) => { - handleChangeFirst('name')(dummyEvent(v)); - }} - name={valuesFirst.displayName} - className="pt-2xl" - /> -
- - repoNames} + loading={repoNamesLoading} + /> + +