Skip to content

Instantly share code, notes, and snippets.

@ashu8912
Created March 31, 2022 13:25
Show Gist options
  • Save ashu8912/fa8c981f05b947d8d45b72e3d564e970 to your computer and use it in GitHub Desktop.
Save ashu8912/fa8c981f05b947d8d45b72e3d564e970 to your computer and use it in GitHub Desktop.
import { Headlamp, Plugin, Registry, K8s } from '@kinvolk/headlamp-plugin/lib';
import { apply } from '@kinvolk/headlamp-plugin/types/lib/k8s';
import { KubeObjectInterface, makeKubeObject } from '@kinvolk/headlamp-plugin/types/lib/k8s/cluster';
import React from 'react';
let sampleCR1: KubeObjectInterface = {
apiVersion: 'stable.example.com/v1',
kind: 'CronTab',
metadata: {
name: 'my-new-cron-object',
namespace: 'default'
},
spec: {
cronSpec: '* * * * */5',
image: 'my-awesome-cron-image'
}
}
function CustomResources() {
const args: [string, string, string][] = [['stable.example.com', 'v1', 'crontabs']]
const Customresource = K8s.crd.makeCustomResourceClass(args, true)
Customresource.useApiGet((item) => {
console.log(item)
}, sampleCR1.metadata.name, sampleCR1.metadata.namespace, (error) => {
console.log(error)
});
return <div>Hello</div>;
}
class CustomResourceExample extends Plugin {
initialize(registry: Registry) {
registry.registerSidebarItem('cluster', 'customresources', 'Crs', '/customresources')
registry.registerRoute({path: '/customresources', sidebar: 'crs', component: () => <CustomResources/>})
return true;
}
}
Headlamp.registerPlugin('custom-resource-test', new CustomResourceExample());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment