Skip to content

Commit

Permalink
feat(addCustomResourceDefinition): add support for /status and /scale…
Browse files Browse the repository at this point in the history
… CRD endpoints (#335)
  • Loading branch information
jirihybek authored and silasbw committed Oct 4, 2018
1 parent c06e7cf commit 0511bb4
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
22 changes: 22 additions & 0 deletions lib/swagger-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,28 @@ class Root extends Component {
};
});

// Add status endpoint - see https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.11/#customresourcesubresourcestatus-v1beta1-apiextensions-k8s-io
if (manifest.spec.subresources && manifest.spec.subresources.status) {

const statusPath = `/apis/${ group }/${ version }${ namespace }/${ name }/{name}/status`;
spec.paths[statusPath] = ['get', 'put'].reduce((acc, method) => {
acc[method] = { operationId: `${ method }Template${ name }` };
return acc;
}, {});

}

// Add scale endpoints - see https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.11/#customresourcesubresourcescale-v1beta1-apiextensions-k8s-io
if (manifest.spec.subresources && manifest.spec.subresources.scale) {

const statusPath = `/apis/${ group }/${ version }${ namespace }/${ name }/{name}/scale`;
spec.paths[statusPath] = ['get', 'put'].reduce((acc, method) => {
acc[method] = { operationId: `${ method }Template${ name }` };
return acc;
}, {});

}

this._addSpec(spec);
}
}
Expand Down
1 change: 1 addition & 0 deletions scripts/templates/ts-interface.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@
{{method}}(options ?: {{parameterType}}): {{returnType}}
{{/calls}}
loadSpec(): Promise<Api>
addCustomResourceDefinition(schema: object): void
}
1 change: 1 addition & 0 deletions typings/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5971,6 +5971,7 @@ declare namespace KubernetesClient {
'version': Version
// Calls
loadSpec(): Promise<Api>
addCustomResourceDefinition(schema: object): void
}

interface ApiClient {
Expand Down

0 comments on commit 0511bb4

Please sign in to comment.