Skip to content

Commit

Permalink
feat: add persistent volume claim resource viewer (#73)
Browse files Browse the repository at this point in the history
This change adds a Persistent Volume Claim resource viewer.
  • Loading branch information
ChristopherFry committed Jul 21, 2022
1 parent e0ae65e commit 38d54ef
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import React from 'react';
import { getApplyReplacementsStructuredMetadata } from './FirstClassViewers/StructuredMetadata/resources/applyReplacements';
import { getConfigMapStructuredMetadata } from './FirstClassViewers/StructuredMetadata/resources/configMap';
import { getKptfileStructuredMetadata } from './FirstClassViewers/StructuredMetadata/resources/kptfile';
import { getPersistentVolumeClaimStructuredMetadata } from './FirstClassViewers/StructuredMetadata/resources/persistentVolumeClaim';
import { getResourceQuotaStructuredMetadata } from './FirstClassViewers/StructuredMetadata/resources/resourceQuota';
import { getRoleStructuredMetadata } from './FirstClassViewers/StructuredMetadata/resources/role';
import { getRoleBindingStructuredMetadata } from './FirstClassViewers/StructuredMetadata/resources/roleBinding';
Expand Down Expand Up @@ -55,6 +56,9 @@ const getCustomMetadataFn = (
case 'v1/ConfigMap':
return getConfigMapStructuredMetadata;

case 'v1/PersistentVolumeClaim':
return getPersistentVolumeClaimStructuredMetadata;

case 'v1/ResourceQuota':
return getResourceQuotaStructuredMetadata;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/**
* Copyright 2022 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import { KubernetesResource } from '../../../../../../types/KubernetesResource';
import { PersistentVolumeClaim } from '../../../../../../types/PersistentVolumeClaim';
import { Metadata } from '../StructuredMetadata';

export const getPersistentVolumeClaimStructuredMetadata = (
resource: KubernetesResource,
): Metadata => {
const persistentVolumeClaim = resource as PersistentVolumeClaim;

return {
accessModes: persistentVolumeClaim.spec.accessModes,
storage: persistentVolumeClaim.spec.resources?.requests?.storage,
};
};
44 changes: 44 additions & 0 deletions plugins/cad/src/types/PersistentVolumeClaim.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/**
* Copyright 2022 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import { KubernetesKeyValueObject } from './KubernetesResource';

export type PersistentVolumeClaim = {
kind: string;
apiVersion: string;
metadata: PersistentVolumeClaimMetadata;
spec: PersistentVolumeClaimSpec;
};

export type PersistentVolumeClaimMetadata = {
name: string;
namespace?: string;
labels?: KubernetesKeyValueObject;
annotations?: KubernetesKeyValueObject;
};

export type PersistentVolumeClaimSpec = {
accessModes?: string[];
resources?: PersistentVolumeClaimResources;
};

export type PersistentVolumeClaimResources = {
requests?: PersistentVolumeClaimResourcesRequests;
};

export type PersistentVolumeClaimResourcesRequests = {
storage?: string;
};

0 comments on commit 38d54ef

Please sign in to comment.