-
Notifications
You must be signed in to change notification settings - Fork 12
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
Refactor group resource #9
Refactor group resource #9
Conversation
Signed-off-by: Alina Buzachis <[email protected]>
Signed-off-by: Alina Buzachis <[email protected]>
Signed-off-by: Alina Buzachis <[email protected]>
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.
Some minor suggestions inline but this looks good!
internal/provider/group_resource.go
Outdated
func (d *GroupResource) Configure(_ context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) { | ||
if req.ProviderData == nil { | ||
return | ||
} | ||
|
||
client, ok := req.ProviderData.(*AAPClient) | ||
if !ok { | ||
resp.Diagnostics.AddError( | ||
"Unexpected Resource Configure Type", | ||
fmt.Sprintf("Expected *AAPClient, got: %T. Please report this issue to the provider developers.", req.ProviderData), | ||
) | ||
|
||
return | ||
} | ||
|
||
d.client = client |
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.
func (d *GroupResource) Configure(_ context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) { | |
if req.ProviderData == nil { | |
return | |
} | |
client, ok := req.ProviderData.(*AAPClient) | |
if !ok { | |
resp.Diagnostics.AddError( | |
"Unexpected Resource Configure Type", | |
fmt.Sprintf("Expected *AAPClient, got: %T. Please report this issue to the provider developers.", req.ProviderData), | |
) | |
return | |
} | |
d.client = client | |
func (r *GroupResource) Configure(_ context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) { | |
if req.ProviderData == nil { | |
return | |
} | |
client, ok := req.ProviderData.(*AAPClient) | |
if !ok { | |
resp.Diagnostics.AddError( | |
"Unexpected Resource Configure Type", | |
fmt.Sprintf("Expected *AAPClient, got: %T. Please report this issue to the provider developers.", req.ProviderData), | |
) | |
return | |
} | |
r.client = client |
It doesn't really matter what variable we use here but probably best to keep it consistent throughout the file.
internal/provider/group_resource.go
Outdated
err := json.Unmarshal(body, &result) | ||
if err != nil { | ||
return err | ||
// Create request body from host data |
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.
// Create request body from host data | |
// Create request body from group data |
internal/provider/group_resource.go
Outdated
|
||
// Read Terraform plan data into the model | ||
resp.Diagnostics.Append(req.State.Get(ctx, &data)...) | ||
// Update host in AAP |
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.
// Update host in AAP | |
// Update group in AAP |
// Schema defines the schema for the group resource. | ||
func (r *GroupResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) { | ||
resp.Schema = schema.Schema{ | ||
Attributes: map[string]schema.Attribute{ | ||
|
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.
Could we update the group_url
attribute to just be url
? It seems redundant to indicate that it is the URL for the group object.
Signed-off-by: Alina Buzachis <[email protected]>
Signed-off-by: Alina Buzachis <[email protected]>
Signed-off-by: Alina Buzachis <[email protected]>
Refactor group resource