Skip to content

Commit

Permalink
feat(CRDs): cluster-level GET for Namespaced CRDs (#366)
Browse files Browse the repository at this point in the history
  • Loading branch information
silasbw authored and JacopoDaeli committed Dec 5, 2018
1 parent 952bc00 commit 9adcc04
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lib/swagger-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,18 @@ class Root extends Component {
acc[method] = { operationId: `${method}${name}` }
return acc
}, {})
//
// Namespaced CRDs get a cluster-level GET endpoint.
// Similar to GET /api/v1/pods.
//
if (manifest.spec.scope === 'Namespaced') {
const clusterPath = `/apis/${group}/${version}/${name}`
spec.paths[clusterPath] = {
get: {
operationId: `getCluster${name}`
}
}
}

const watchPaths = {
watchCluster: `/apis/${group}/${version}/watch/${name}`,
Expand Down
1 change: 1 addition & 0 deletions test/swagger-client.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ describe('lib.swagger-client', () => {
}
}
client.addCustomResourceDefinition(crd)
expect(client.apis['stable.example.com'].v1.foos.get).is.a('function')
expect(client.apis['stable.example.com'].v1.namespaces('default').foos.get).is.a('function')
expect(client.apis['stable.example.com'].v1.namespaces('default').foos.post).is.a('function')
expect(client.apis['stable.example.com'].v1.namespaces('default').foos('blah').get).is.a('function')
Expand Down

0 comments on commit 9adcc04

Please sign in to comment.