-
Notifications
You must be signed in to change notification settings - Fork 192
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add CustomResourceDefinition (WIP) #149
Conversation
Adds `CustomResourceDefinition`, which replaces `ThirdPartyResources` starting Kubernetes 1.7.
@fhemberger thank you for starting on this -- we definitely need it. I'll take a look tomorrow or the next day and see if I can help with the tests! |
@silasbw Great, thank you. I got something wrong with the implementation but couldn't find out what it was … probably I'm just missing something. Also CRDs can be namespace or cluster specific, I think a part of that is still missing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry the delay. Hope the review is still helpful.
lib/custom-resource-definition.js
Outdated
class CustomResourceDefinition extends ApiGroup { | ||
constructor(options) { | ||
options = Object.assign({}, options, { | ||
path: options.group, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you want (will also "fix" one of your unit tests):
path: `apis/${ options.group }`,
https://kubernetes.io/docs/tasks/access-kubernetes-api/extend-api-custom-resource-definitions/
test/api-extensions.test.js
Outdated
// improvements to our integration test harness to make this work well. | ||
common.only('unit', 'can POST and GET', done => { | ||
async.series([ | ||
next => common.apiExtensions.post({ body: testApiExtensions }, next), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You want this:
next => common.apiExtensions.customresourcedefinitions.post({ body: testApiExtensions }, next),
next => common.apiExtensions.customresourcedefinitions.get(testCustomResourceName, next)
https://kubernetes.io/docs/api-reference/v1.8/#-strong-write-operations-strong--254
lib/api-extensions.js
Outdated
path: 'apis/apiextensions.k8s.io', | ||
version: options.version || 'v1beta1', | ||
groupResources: [ | ||
'customresourcedefinition' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pluralize: customresourcedefinitions
The code automatically creates a singular alias so apiExtensions.customresourcedefinitions
and apiExtensions.customresourcedefinition
will both work, but you need to specify the plural version here.
lib/api-extensions.js
Outdated
'customresourcedefinition' | ||
], | ||
namespaceResources: [ | ||
{ name: 'customresourcedefinition', Constructor: CustomResourceDefiniton } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pluralize here too.
test/api-extensions.test.js
Outdated
|
||
beforeTesting('unit', () => { | ||
nock(common.apiExtensions.url) | ||
.post(`${ common.apiExtensions.path }`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you'll need to update these mocks:
.post(`${ common.apiExtensions.path }/customresourcedefinitions`)
.reply(201, testApiExtensions)
.get(`${ common.apiExtensions.path }/customresourcedefinitions/${ testCustomResourceName }`)
.reply(200, testApiExtensions);
test/common.js
Outdated
@@ -76,6 +79,9 @@ function injectApis(options) { | |||
rbac: { Constructor: Rbac }, | |||
thirdPartyResources: { | |||
Constructor: ThirdPartyResources, options: { group: 'kubernetes-client.com' } | |||
}, | |||
customResourceDefinition: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pluralize (similar to thirdPartyResources
)
Thanks, but now 4 instead of two tests are failing … 🤔 |
Hey @fhemberger sent you https://github.com/fhemberger/kubernetes-client/pull/1. unit tests work, integration tests have some issues. I'll take a look at those when i get a moment. |
Tweaks discussed in #149
…rnetes-client into feature/custom-resources
Ok, back from vacation, updated PR with your changes, @silasbw. |
Hey @fhemberger, I sent you some tweaks to fix integration tests, etc: https://github.com/fhemberger/kubernetes-client/pull/2 Sorry this has been such a slog and thanks for sticking with it. We're working on making these types of contributions much easier to make. |
@silasbw Awesome, tests are passing! 💯 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🏆 !!
I published these changes in |
Adds
CustomResourceDefinition
, which replacesThirdPartyResources
starting Kubernetes 1.7.This is still work in progress, not sure I got your setup right. Tests are failing at the moment. Would be cool if you could give me a hand with this.