Skip to content
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

Merged
merged 6 commits into from
Feb 20, 2024

Conversation

alinabuzachis
Copy link
Contributor

Refactor job resource

Signed-off-by: Alina Buzachis <[email protected]>
Signed-off-by: Alina Buzachis <[email protected]>
Signed-off-by: Alina Buzachis <[email protected]>
@alinabuzachis alinabuzachis force-pushed the refactoring/job/resource branch from d570883 to 6e3a930 Compare February 15, 2024 17:00
@alinabuzachis alinabuzachis changed the title [WIP] Refactor job resource Refactor job resource Feb 15, 2024
@alinabuzachis alinabuzachis marked this pull request as ready for review February 15, 2024 17:01
Copy link
Contributor

@abikouo abikouo left a 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.

internal/provider/job_resource.go Outdated Show resolved Hide resolved
internal/provider/job_resource.go Outdated Show resolved Hide resolved
Signed-off-by: Alina Buzachis <[email protected]>
Copy link
Contributor

@hakbailey hakbailey left a 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!

@@ -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) {
Copy link
Contributor

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).

}

func (r JobResource) CreateJob(data JobResourceModelInterface) diag.Diagnostics {
func (r *JobResource) CreateJob(data *JobResourceModel) diag.Diagnostics {
Copy link
Contributor

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.

// jobResourceModel maps the resource schema data.
type jobResourceModel struct {
// Job AAP API model
type JobAPIModel struct {
Copy link
Contributor

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.

@alinabuzachis alinabuzachis force-pushed the refactoring/job/resource branch from 7cae37e to bdc35cd Compare February 19, 2024 20:32
Signed-off-by: Alina Buzachis <[email protected]>
@alinabuzachis alinabuzachis merged commit 3565684 into ansible:main Feb 20, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants