Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ func resourceDatasourcePermissionGet(d *schema.ResourceData, meta any) (string,
if d.Id() != "" {
client, _, id = OAPIClientFromExistingOrgResource(meta, d.Id())
}
if id == "*" {
return "*", nil
}
resp, err := client.Datasources.GetDataSourceByUID(id)
if err != nil {
return "", err
Expand All @@ -96,6 +99,9 @@ func resourceDatasourcePermissionGetType(d *schema.ResourceData, meta any) (stri
if d.Id() != "" {
client, _, id = OAPIClientFromExistingOrgResource(meta, d.Id())
}
if id == "*" {
return "", nil
}
resp, err := client.Datasources.GetDataSourceByUID(id)
if err != nil {
return "", err
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,16 +204,23 @@ func (r *resourceDatasourcePermissionItem) Delete(ctx context.Context, req resou
}

func (r *resourceDatasourcePermissionItem) datasourceQuery(client *client.GrafanaHTTPAPI, datasourceUID string) error {
if datasourceUID == "*" {
return nil
}
_, err := client.Datasources.GetDataSourceByUID(datasourceUID)
return err
}

// resolveWriteOpts returns the ds_type client option for write operations.
// if dsType is provided it is used directly; otherwise GetDataSourceByUID is called to look it up.
// Wildcard UIDs ("*") skip the lookup entirely since they represent all datasources.
func (r *resourceDatasourcePermissionItem) resolveWriteOpts(orgIDStr, dsUID string, dsType types.String) ([]access_control.ClientOption, error) {
if !dsType.IsNull() && dsType.ValueString() != "" {
return []access_control.ClientOption{withQueryParam("ds_type", dsType.ValueString())}, nil
}
if dsUID == "*" {
return nil, nil
}
c, _, err := r.clientFromNewOrgResource(orgIDStr)
if err != nil {
return nil, err
Expand Down
Loading