Skip to content

Commit

Permalink
feat: Added ChaosHub, Environments, Chaos Infrastructure pages (#4048)
Browse files Browse the repository at this point in the history
Signed-off-by: Hrishav <[email protected]>
  • Loading branch information
hrishavjha committed Jul 3, 2023
1 parent fdf5113 commit fd50a5b
Show file tree
Hide file tree
Showing 133 changed files with 8,138 additions and 17 deletions.
4 changes: 1 addition & 3 deletions chaoscenter/web/src/api/LitmusAPIProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ export interface APIConfig {
};
restEndpoints: {
authUri: string;
ngPlatformUri: string;
ngLoggingUri: string;
chaosManagerUri: string;
};
}
Expand Down Expand Up @@ -110,7 +108,7 @@ export const LitmusAPIProvider: React.FC<LitmusAPIProviderProps> = ({
children
}): React.ReactElement => {
if (config.restEndpoints) {
axios.defaults.baseURL = config.restEndpoints.ngPlatformUri;
axios.defaults.baseURL = config.restEndpoints.authUri;
axios.defaults.headers.common['Authorization'] = `Bearer ${token}`;
}

Expand Down
1 change: 1 addition & 0 deletions chaoscenter/web/src/api/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ export * from './chaoshubs';
export * from './experiments';
export * from './infrastructures';
export * from './log';
export * from './probe';
export * from './stats';
export * from './checkResourceID';
50 changes: 50 additions & 0 deletions chaoscenter/web/src/api/core/infrastructures/connectChaosInfra.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { gql, useMutation } from '@apollo/client';
import type { GqlAPIMutationRequest, GqlAPIMutationResponse } from '@api/types';
import type { Toleration } from '@models';
import type { InfrastructureInstallationType } from '@api/entities';

export interface connectChaosInfraRequest {
projectID: string;
request: {
name: string;
environmentID: string;
description?: string;
platformName: string;
infraNamespace?: string;
serviceAccount?: string;
infraScope: string;
infraNsExists?: boolean;
infraSaExists?: boolean;
skipSsl?: boolean;
nodeSelector?: string;
tolerations?: Array<Toleration>;
infrastructureType?: InfrastructureInstallationType;
tags?: Array<string>;
};
}

export interface connectChaosInfraManifestModeResponse {
registerInfra: {
manifest: string;
};
}

export function connectChaosInfraManifestMode(
options?: GqlAPIMutationRequest<connectChaosInfraManifestModeResponse, connectChaosInfraRequest>
): GqlAPIMutationResponse<connectChaosInfraManifestModeResponse, connectChaosInfraRequest> {
const [connectChaosInfraMutation, result] = useMutation<
connectChaosInfraManifestModeResponse,
connectChaosInfraRequest
>(
gql`
mutation registerInfra($projectID: ID!, $request: RegisterInfraRequest!) {
registerInfra(projectID: $projectID, request: $request) {
manifest
}
}
`,
options
);

return [connectChaosInfraMutation, result];
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { gql, useMutation } from '@apollo/client';
import type { GqlAPIMutationRequest, GqlAPIMutationResponse } from '@api/types';

export interface DeleteKubernetesChaosInfraRequest {
projectID: string;
infraID: string;
}

export interface DeleteKubernetesChaosInfraResponse {
deleteChaosInfra: string;
}

export function deleteKubernetesChaosInfra(
options?: GqlAPIMutationRequest<DeleteKubernetesChaosInfraResponse, DeleteKubernetesChaosInfraRequest>
): GqlAPIMutationResponse<DeleteKubernetesChaosInfraResponse, DeleteKubernetesChaosInfraRequest> {
const [deleteChaosInfraMutation, result] = useMutation<
DeleteKubernetesChaosInfraResponse,
DeleteKubernetesChaosInfraRequest
>(
gql`
mutation deleteInfra($projectID: ID!, $infraID: String!) {
deleteInfra(projectID: $projectID, infraID: $infraID)
}
`,
options
);

return [deleteChaosInfraMutation, result];
}
2 changes: 2 additions & 0 deletions chaoscenter/web/src/api/core/infrastructures/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export * from './deleteKubernetesChaosInfrastructure';
export * from './getKubernetesChaosInfrastructureManifest';
export * from './testKubernetesChaosInfrastructureConnection';
export * from './getVersionDetails';
export * from './listKubernetesChaosInfrastructure';
export * from './getKubeObject';
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { gql, useMutation } from '@apollo/client';
import type { GqlAPIMutationRequest, GqlAPIMutationResponse } from '@api/types';

export interface TestKubernetesChaosInfrastructureConnectionRequest {
projectID: string;
infraId: string;
}

export interface TestKubernetesChaosInfrastructureConnectionResponse {
testKubernetesInfraConnection: boolean;
}

export function testKubernetesChaosInfrastructureConnection(
options?: GqlAPIMutationRequest<
TestKubernetesChaosInfrastructureConnectionResponse,
TestKubernetesChaosInfrastructureConnectionRequest
>
): GqlAPIMutationResponse<
TestKubernetesChaosInfrastructureConnectionResponse,
TestKubernetesChaosInfrastructureConnectionRequest
> {
const [testKubernetesChaosInfrastructureConnectionMutation, result] = useMutation<
TestKubernetesChaosInfrastructureConnectionResponse,
TestKubernetesChaosInfrastructureConnectionRequest
>(
gql`
mutation testKubernetesChaosInfrastuctureConnection($projectID: ID!, $infraId: String!) {
testKubernetesInfraConnection(projectID: $projectID, infraId: $infraId)
}
`,
options
);

return [testKubernetesChaosInfrastructureConnectionMutation, result];
}
135 changes: 135 additions & 0 deletions chaoscenter/web/src/api/core/probe/addProbe.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
import { gql, useMutation } from '@apollo/client';
import type { Identifiers, Probe, ProbeType } from '@api/entities';
import type { GqlAPIMutationRequest, GqlAPIMutationResponse } from '@api/types';

export interface AddProbeRequest {
identifiers: Identifiers;
request: {
probeId?: string;
name: string;
description?: string;
tags?: Array<string>;
type: ProbeType;
httpProperties?: Probe['httpProperties'];
cmdProperties?: Probe['cmdProperties'];
k8sProperties?: Probe['k8sProperties'];
promProperties?: Probe['promProperties'];
};
}

export interface AddProbeResponse {
addProbe: Probe;
}

export function addHTTPProbe(
options?: GqlAPIMutationRequest<AddProbeResponse, AddProbeRequest>
): GqlAPIMutationResponse<AddProbeResponse, AddProbeRequest> {
const [addHTTPProbeMutation, result] = useMutation<AddProbeResponse, AddProbeRequest>(
gql`
mutation addHTTPProbe($request: ProbeRequest!, $identifiers: IdentifiersRequest!) {
addProbe(request: $request, identifiers: $identifiers) {
probeId
name
description
type
httpProperties {
probeTimeout
interval
url
insecureSkipVerify
}
}
}
`,
options
);

return [addHTTPProbeMutation, result];
}

export function addCMDProbe(
options?: GqlAPIMutationRequest<AddProbeResponse, AddProbeRequest>
): GqlAPIMutationResponse<AddProbeResponse, AddProbeRequest> {
const [addCMDProbeMutation, result] = useMutation<AddProbeResponse, AddProbeRequest>(
gql`
mutation addCMDProbe($request: ProbeRequest!, $identifiers: IdentifiersRequest!) {
addProbe(request: $request, identifiers: $identifiers) {
probeId
name
description
type
cmdProperties {
probeTimeout
interval
command
comparator {
type
value
}
}
}
}
`,
options
);

return [addCMDProbeMutation, result];
}

export function addPROMProbe(
options?: GqlAPIMutationRequest<AddProbeResponse, AddProbeRequest>
): GqlAPIMutationResponse<AddProbeResponse, AddProbeRequest> {
const [addPROMProbeMutation, result] = useMutation<AddProbeResponse, AddProbeRequest>(
gql`
mutation addPROMProbe($request: ProbeRequest!, $identifiers: IdentifiersRequest!) {
addProbe(request: $request, identifiers: $identifiers) {
probeId
name
description
type
promProperties {
probeTimeout
interval
retry
comparator {
type
value
}
}
}
}
`,
options
);

return [addPROMProbeMutation, result];
}

export function addK8SProbe(
options?: GqlAPIMutationRequest<AddProbeResponse, AddProbeRequest>
): GqlAPIMutationResponse<AddProbeResponse, AddProbeRequest> {
const [addK8SProbeMutation, result] = useMutation<AddProbeResponse, AddProbeRequest>(
gql`
mutation addK8SProbe($request: ProbeRequest!, $identifiers: IdentifiersRequest!) {
addProbe(request: $request, identifiers: $identifiers) {
probeId
name
description
type
k8sProperties {
probeTimeout
interval
retry
group
version
resource
namespace
}
}
}
`,
options
);

return [addK8SProbeMutation, result];
}
27 changes: 27 additions & 0 deletions chaoscenter/web/src/api/core/probe/deleteProbe.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { gql, useMutation } from '@apollo/client';
import type { Identifiers } from '@api/entities';
import type { GqlAPIMutationRequest, GqlAPIMutationResponse } from '@api/types';

export interface DeleteProbeRequest {
identifiers: Identifiers;
probeID: string;
}

export interface DeleteProbeResponse {
deleteProbe: boolean;
}

export function deleteProbe(
options?: GqlAPIMutationRequest<DeleteProbeResponse, DeleteProbeRequest>
): GqlAPIMutationResponse<DeleteProbeResponse, DeleteProbeRequest> {
const [deleteProbeMutation, result] = useMutation<DeleteProbeResponse, DeleteProbeRequest>(
gql`
mutation deleteChaosHub($probeID: ID!, $identifiers: IdentifiersRequest!) {
deleteProbe(probeID: $probeID, identifiers: $identifiers)
}
`,
options
);

return [deleteProbeMutation, result];
}
Loading

0 comments on commit fd50a5b

Please sign in to comment.