Skip to content

Commit

Permalink
feat: add set labels resource viewer (#78)
Browse files Browse the repository at this point in the history
This change adds the Set Labels resource viewer.
  • Loading branch information
ChristopherFry committed Jul 26, 2022
1 parent e06350c commit 066bcd1
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { getResourceQuotaStructuredMetadata } from './FirstClassViewers/Structur
import { getRoleStructuredMetadata } from './FirstClassViewers/StructuredMetadata/resources/role';
import { getRoleBindingStructuredMetadata } from './FirstClassViewers/StructuredMetadata/resources/roleBinding';
import { getServiceStructuredMetadata } from './FirstClassViewers/StructuredMetadata/resources/service';
import { getSetLabelsStructuredMetadata } from './FirstClassViewers/StructuredMetadata/resources/setLabels';
import {
CustomMetadataFn,
StructuredMetadata,
Expand All @@ -43,6 +44,9 @@ const getCustomMetadataFn = (
case 'fn.kpt.dev/v1alpha1/ApplyReplacements':
return getApplyReplacementsStructuredMetadata;

case 'fn.kpt.dev/v1alpha1/SetLabels':
return getSetLabelsStructuredMetadata;

case 'kpt.dev/v1/Kptfile':
return getKptfileStructuredMetadata;

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

export const getSetLabelsStructuredMetadata = (
resource: KubernetesResource,
): Metadata => {
const setLabels = resource as SetLabels;

return {
setLabels: setLabels.labels,
};
};
31 changes: 31 additions & 0 deletions plugins/cad/src/types/SetLabels.ts
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 { KubernetesKeyValueObject } from './KubernetesResource';

export type SetLabels = {
kind: string;
apiVersion: string;
metadata: SetLabelsMetadata;
labels: KubernetesKeyValueObject;
};

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

0 comments on commit 066bcd1

Please sign in to comment.