Skip to content

Commit

Permalink
feat: add cluster issuer resource viewer (#82)
Browse files Browse the repository at this point in the history
This change adds the Cluster Issuer resource viewer.
  • Loading branch information
ChristopherFry committed Jul 27, 2022
1 parent bc4d327 commit 9a0627a
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import React from 'react';
import { getApplyReplacementsStructuredMetadata } from './FirstClassViewers/StructuredMetadata/resources/applyReplacements';
import { getClusterIssuerStructuredMetadata } from './FirstClassViewers/StructuredMetadata/resources/clusterIssuer';
import { getConfigMapStructuredMetadata } from './FirstClassViewers/StructuredMetadata/resources/configMap';
import { getIngressStructuredMetadata } from './FirstClassViewers/StructuredMetadata/resources/ingress';
import { getKptfileStructuredMetadata } from './FirstClassViewers/StructuredMetadata/resources/kptfile';
Expand Down Expand Up @@ -43,6 +44,9 @@ const getCustomMetadataFn = (
groupVersionKind: string,
): CustomMetadataFn | undefined => {
switch (groupVersionKind) {
case 'cert-manager.io/v1/ClusterIssuer':
return getClusterIssuerStructuredMetadata;

case 'fn.kpt.dev/v1alpha1/ApplyReplacements':
return getApplyReplacementsStructuredMetadata;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/**
* 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 { ClusterIssuer } from '../../../../../../types/ClusterIssuer';
import { KubernetesResource } from '../../../../../../types/KubernetesResource';
import { Metadata } from '../StructuredMetadata';

export const getClusterIssuerStructuredMetadata = (
resource: KubernetesResource,
): Metadata => {
const clusterIssuer = resource as ClusterIssuer;

return {
server: clusterIssuer.spec.acme.server,
email: clusterIssuer.spec.acme.email,
privateKeySecretName: clusterIssuer.spec.acme.privateKeySecretRef?.name,
};
};
45 changes: 45 additions & 0 deletions plugins/cad/src/types/ClusterIssuer.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/**
* 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 ClusterIssuer = {
kind: string;
apiVersion: string;
metadata: ClusterIssuerMetadata;
spec: ClusterIssuerSpec;
};

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

export type ClusterIssuerSpec = {
acme: ACMEIssuer;
};

export type ACMEIssuer = {
server: string;
email?: string;
privateKeySecretRef?: ACMEIssuerPrivateKeySecretRef;
};

export type ACMEIssuerPrivateKeySecretRef = {
name: string;
};

0 comments on commit 9a0627a

Please sign in to comment.