-
Notifications
You must be signed in to change notification settings - Fork 97
Add organization ID to client connection using header #9
Conversation
Having a look. |
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.
There are some changes I'd like to see, but first checking with my colleagues about the proposal.
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.
Just some quick feedback for now, to collect feedback until I have the time for a real review:
- Org ID should not be provided if authing with an API key, because an API key is for a single org and role, so only applicable with basic auth
- Making org ID mandatory for creating a client is a bad idea
- Allowing the org ID header to be set when using basic auth makes sense
Can you please merge master into the PR, and fix conflicts? I changed the signature of Client.New, so you can add the organization ID to the Config type parameter. |
I shall do - those changes for the config make adding optional orgid a much cleaner change - thanks. Will update in the next day or so. |
This seems like the right place to do so - the resource API calls that require an organization ID that are not-quite RESTful also would need authentication with a user that is an administrator for the organization. So putting it in at this level works out, and also avoids adding orgID parameters all over the place. Co-authored-by: hansnqyr <[email protected]>
I've rebased and the change is now much simpler - thanks. |
Thanks, I'll have a look when I get the time. |
Having a look again. |
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.
Looks much better now, thanks! I will try to get feedback from @marefr this week to make sure this change makes sense.
Requesting changes to signal it still needs to be decided on.
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, but @marefr please review given your knowledge of the functionality.
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.
Minor change. See comment. Otherwise looks good I think 👍
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
Thanks for the contribution! |
Use the change in grafana/grafana-api-golang-client#9 to apply an organization id to the provider. Usage might look like this: ```hcl provider "grafana" { url = "someurl" auth = "adminuser:somepass" } resource "grafana_organization" "neworg" { name = "neworg" admin = "neworgadmin" } provider "grafana" { alias = "neworg" url = "someurl" auth = "neworgadmin:somepass" org_id = grafana_organization.neworg.org_id } resource "grafana_data_source" "neworg_graphite" { provider = grafana.neworg type = "graphite" name = "neworg-graphite" } ``` Co-authored-by: hansnqyr <[email protected]>
Use the change in grafana/grafana-api-golang-client#9 to apply an organization id to the provider. Usage might look like this: ```hcl provider "grafana" { url = "someurl" auth = "adminuser:somepass" } resource "grafana_organization" "neworg" { name = "neworg" admin = "neworgadmin" } provider "grafana" { alias = "neworg" url = "someurl" auth = "neworgadmin:somepass" org_id = grafana_organization.neworg.org_id } resource "grafana_data_source" "neworg_graphite" { provider = grafana.neworg type = "graphite" name = "neworg-graphite" } ``` Co-authored-by: hansnqyr <[email protected]>
Use the change in grafana/grafana-api-golang-client#9 to apply an organization id to the provider. Usage might look like this: ```hcl provider "grafana" { url = "someurl" auth = "adminuser:somepass" } resource "grafana_organization" "neworg" { name = "neworg" admin = "neworgadmin" } provider "grafana" { alias = "neworg" url = "someurl" auth = "neworgadmin:somepass" org_id = grafana_organization.neworg.org_id } resource "grafana_data_source" "neworg_graphite" { provider = grafana.neworg type = "graphite" name = "neworg-graphite" } ``` Co-authored-by: hansnqyr <[email protected]>
This seems like the right place to do so - the resource API calls that require an organization ID that are not-quite RESTful also would need authentication with a user that is an administrator for the organization. So putting it in at this level works out, and also avoids adding orgID parameters all over the place.
Co-authored-by: hansnqyr [email protected]
This change was previously submitted to nytm/go-grafana-api#62
It is a prerequisite for this PR: grafana/terraform-provider-grafana#110