-
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 job resource #10
Refactor job resource #10
Conversation
Signed-off-by: Alina Buzachis <[email protected]>
Signed-off-by: Alina Buzachis <[email protected]>
Signed-off-by: Alina Buzachis <[email protected]>
d570883
to
6e3a930
Compare
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.
The triggers
parameter is not intended to be passed to the HTTP request to the Controller. It is designed for Terraform to force the creation of a new job resource.
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 comments inline but this looks good!
internal/provider/job_resource.go
Outdated
@@ -41,7 +38,27 @@ func (r *JobResource) Metadata(_ context.Context, req resource.MetadataRequest, | |||
resp.TypeName = req.ProviderTypeName + "_job" | |||
} | |||
|
|||
// Schema defines the schema for the resource. | |||
// Configure adds the provider configured client to the data source. | |||
func (d *JobResource) Configure(_ context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) { |
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.
This seems to alternate between d
and r
as the JobResource variable throughout this file. I would pick one for consistency...probably r
since it's referring to a resource (I think the d
originally came from the inventory data source).
internal/provider/job_resource.go
Outdated
} | ||
|
||
func (r JobResource) CreateJob(data JobResourceModelInterface) diag.Diagnostics { | ||
func (r *JobResource) CreateJob(data *JobResourceModel) diag.Diagnostics { |
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.
What if we called this function LaunchJob
since that's really what it is doing? That would also help differentiate it from the Create
function, and would make it extra clear that both Create
and Update
launch a job.
internal/provider/job_resource.go
Outdated
// jobResourceModel maps the resource schema data. | ||
type jobResourceModel struct { | ||
// Job AAP API model | ||
type JobAPIModel struct { |
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.
Similar to the group resource refactor, I would consider reorganizing this file so that each type is followed by its functions.
7cae37e
to
bdc35cd
Compare
Signed-off-by: Alina Buzachis <[email protected]>
Refactor job resource