Skip to content

Commit

Permalink
Generic create function
Browse files Browse the repository at this point in the history
Signed-off-by: R-Lawton <[email protected]>
  • Loading branch information
R-Lawton committed Sep 10, 2024
1 parent b568787 commit e4ee846
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions src/utils/createResource.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@

import {
k8sCreate,
K8sModel,
} from '@openshift-console/dynamic-plugin-sdk';
import { History } from 'history';


export function handleCreate(model: K8sModel, data, namespace: string, policyType: string, history: History) {
type model = K8sModel
type data = {
apiVersion: string;
kind: string;
metadata: {
name: string;
namespace: string;
};
spec: {
[key: string]: any;
};

};
type namespace = string
try {
k8sCreate({
model: model,
data: data,
ns: namespace,
});
console.log('Policy created successfully', model.kind);
history.push(`/k8s/ns/${namespace}/kuadrant.io~v1alpha1~${policyType}/${data.metadata.name}`)
} catch (error) {
console.error('Failed to create Policy:', error);
}
};

0 comments on commit e4ee846

Please sign in to comment.