-
Notifications
You must be signed in to change notification settings - Fork 71
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
Simplify adding a external provider #1508
Simplify adding a external provider #1508
Conversation
Move the init code to each provider's manager, and include the provider packages, at the cmd level instead. Signed-off-by: James Tumber <james.tumber@ibm.com>
Add AddCloud public function instead of directly updating cloudTable and add init function for each provider Signed-off-by: James Tumber <james.tumber@ibm.com>
9d0a64a
to
9cb01e3
Compare
Had to drop 9d0a64a because need these changes merged and then update the controller with these changes plus updating the version of caa it references |
@jtumber-ibm I believe with the changes in this PR, CAA project can be used as a library ? |
Yes, that is the plan |
Would it make sense to update also docs/addnewprovider.md as part of this PR? BTW worth mentioning that moving (build) tagged code around made compiling issues before, however, LGTM this time |
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.
@jtumber-ibm Thank you very much for this PR. I didn't aware of the problem that prevents us from using CAA as a library.
I have one question about the root cause of the problem.
The problem is that each provider code needs to update the cloudTable
map in the cloudmgr
package, and it is not a public variable. Right? If so, isn't adding the public function AddCloud
to the original cloudmgr
package enough?
As @snir911 mentioned, peerpods-ctrl
also uses the package. The cloudmgr
pacakge was originally in cmd/cloud-api-adaptor
, and was later moved to pkg/cloud
, so that we can share it with peerpods-ctrl
.
If we move files like aws.go
and ibmcloud.go
back to cmd/cloud-api-adaptor
, I think we also need to copy the same files to the peerpod-ctrl
directory. I think it is somewhat redundant.
WDYT?
@yoheiueda see 9d0a64a for how to include the providers in the peerpod-ctrl. By moving the logic out of that shared package it also means the provider specific dependencies are also separated out. In other words leaving it as is but making the public function change when someone wants to use our project their go.mod/go.sum will include the provider specific dependencies for all our current providers even when you don't want to use them. |
@jtumber-ibm Thank you for the explanation. I got the point. We can't rely on build tags when we wan to exclude unnecessary dependencies in go.mod/go.sum. I am not aware of this point. |
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.
LGTM
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.
/lgtm
@tumberino did you get a chance to test the built caa binary with libvirt and ibmcloud ?
Only tested with ibmcloud so far, do we want to take this approach now and something like #1583 later? |
I am ok either way, ie having this one now and 1583 later. But if 1583 is ready and supersedes this PR then better to go with 1583. I haven't looked at 1583 yet. |
#1583 is a lot lot larger change and therefore has more risk than this one. So I think we go with this one first whilst we wait for more community input on the approach to remove the cyclic dependency issue |
This has broken some link: https://github.com/confidential-containers/cloud-api-adaptor/actions/runs/7078374683/job/19263779058 |
After confidential-containers#1508, need to update the documentation to match the change in process. Signed-off-by: James Tumber <james.tumber@ibm.com>
After #1508, need to update the documentation to match the change in process. Signed-off-by: James Tumber <james.tumber@ibm.com>
With this change it will be easier to create a provider without being merged into our existing code. Instead they can use the existing code as a library to enable their provider.
They would then just need to create their own
main.go
or copy ours as a starting point. And use the import style to include their own provider logic which can exist externally to our code.Example Provider
After this change the following will be possible
main.go
> This is will be the same as upstream mainmanager.go
provider.go
types.go