feat(dremio): Onboarding STACKIT Dremio#1482
Conversation
|
This PR was marked as stale after 7 days of inactivity and will be closed after another 7 days of further inactivity. If this PR should be kept open, just add a comment, remove the stale label or push new commits to it. |
…vice. Adding: - Dremio SDK integration - `.../services/dremio/` directory with packages and stubs for both dremio instances and users
First draft for the implementation of a Dremio instance resource.
Not propagating it renders the provider unusable for Dremio, because Dremio is no global STACKIT API yet.
The aim of this commit was to dry up and atomize common fields which are both used by the instance resource and data resource. By drying up the methods and model constellation we can make use of one implementation. Also removed the endpoints object.
The data resource does not read all the fields. There is only one authentication setup read, because only one can be used at a time. Also we are not reading the client secret here.
Opted for fully aligning the status quo with the possiblity for improvement later on. It is the more practical and aligned solution. On changes of the sdk we will update the TFP accordingly.
Fyusel
left a comment
There was a problem hiding this comment.
Very nice, had a first look. Need to run tests and have a deeper look
| } | ||
|
|
||
| // Metadata should return the full name of the data source, such as | ||
| // examplecloud_thing. |
There was a problem hiding this comment.
nitpick: This is enough:
// Metadata returns the data source type name.
| ctx = core.InitProviderContext(ctx) | ||
|
|
||
| projectId := model.ProjectId.ValueString() | ||
| region := model.Region.ValueString() |
There was a problem hiding this comment.
region := d.providerData.GetRegionWithOverride(model.Region)
|
|
||
| instanceResp, err := d.client.DefaultAPI.GetDremioInstance(ctx, projectId, region, instanceId).Execute() | ||
| if err != nil { | ||
| var oapiErr *oapierror.GenericOpenAPIError |
There was a problem hiding this comment.
Replace this please and use utils.LogError() here instead (e.g. see network - datasource.go)
There was a problem hiding this comment.
Also this line is missing in the construct:
resp.State.RemoveResource(ctx)
| } | ||
|
|
||
| // Maps instance fields to the provider's internal model | ||
| func mapModelFields(instanceResp *dremioSdk.DremioResponse, model *Model) error { |
|
|
||
| model.Id = utils.BuildInternalTerraformId( | ||
| model.ProjectId.ValueString(), | ||
| model.Region.ValueString(), |
There was a problem hiding this comment.
use region from parameter here
| tflog.Info(ctx, "Dremio user state imported") | ||
| } | ||
|
|
||
| func mapFields(userResp *dremioSdk.DremioUserResponse, model *UserModel) error { |
|
|
||
| model.Id = utils.BuildInternalTerraformId( | ||
| model.ProjectId.ValueString(), | ||
| model.Region.ValueString(), |
| "project_id": config.StringVariable(testutil.ProjectId), | ||
| "region": config.StringVariable(testutil.Region), | ||
| "display_name": config.StringVariable("dremioMinInstance"), | ||
| "authentication_type": config.StringVariable("local-only"), |
There was a problem hiding this comment.
same here: use sdk values please
| tempConfig["description"] = config.StringVariable("description-upd") | ||
|
|
||
| // switching idp to azuread | ||
| tempConfig["authentication_type"] = config.StringVariable("azuread") |
| Required: true, | ||
| }, | ||
| "region": schema.StringAttribute{ | ||
| Required: true, |
There was a problem hiding this comment.
region is optional (provider default is then taken)
Moving Password field to UserModel, so mapFields() can be used both for the resource and the data source.
Description
This is the onboarding PR for integration STACKIT Dremio into the STACKIT Terraform Provider.
It adds for customer the ability to:
Checklist
make fmtexamples/directory)make generate-docs(will be checked by CI)make test(will be checked by CI)make lint(will be checked by CI)