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

Request and response types #27

Merged
merged 2 commits into from
Jun 1, 2021
Merged

Request and response types #27

merged 2 commits into from
Jun 1, 2021

Conversation

kmoe
Copy link
Member

@kmoe kmoe commented May 25, 2021

closes #13

This PR defines:

  • ConfigureProviderRequest
  • ConfigureProviderResponse
  • {Create,Read,Update,Delete}ResourceRequest
  • {Create,Read,Update,Delete}ResourceResponse

Needs State and Plan types (#26) before it will compile.

@kmoe kmoe mentioned this pull request May 25, 2021
// resource. An instance of this request struct is supplied as an argument to
// the resource's Read function.
type ReadResourceRequest struct {
// tfprotov6.ReadResourceRequest has no Config field
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no Config field in tfprotov6.ReadResourceRequest. Should providers have access to config during Read?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe providers only have access to the existing state during read.

@kmoe
Copy link
Member Author

kmoe commented Jun 1, 2021

Requesting review on this now for the included fields, functions, documentation, and names. We can't merge until we have Config, State and Plan types available. which is coming in #16.

The only functions defined on the response structs at the moment are diagnostics helpers. Inside the CRUD functions themselves, providers can manipulate state and plan fields by calling their Get and Set methods directly, e.g.:

func (c computeInstanceResource) Create(ctx context.Context, req framework.ResourceCreateRequest, resp framework.ResourceCreateResponse) {
  req.Plan.Get(...)
  resp.State.Set(...)
}

We could use the same paradigm for diagnostics (as described in #24), defining a Diagnostics type and having providers call something like:

  resp.Diagnostics.AddWarning(...)

I've included the alternative here to see what it looks like, but I think I'm inclining toward the same approach for both state/plan and diagnostics, which would involve removing the diagnostics funcs from this PR and implementing #24 for this PR to depend on.

@kmoe kmoe requested a review from a team June 1, 2021 14:55
@kmoe kmoe marked this pull request as ready for review June 1, 2021 14:55
@paddycarver
Copy link
Contributor

I've included the alternative here to see what it looks like, but I think I'm inclining toward the same approach for both state/plan and diagnostics, which would involve removing the diagnostics funcs from this PR and implementing #24 for this PR to depend on.

I'm in favor of this, and think it's a fine change to make as part of #24.

Copy link
Contributor

@paddycarver paddycarver left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Let's do it 🚀 Needs a rebase, but looks good to me following that :)

kmoe added 2 commits June 1, 2021 17:57
Add request and response types for Provider.Configure and the resource CRUD
functions.
@kmoe kmoe merged commit 3a414cf into main Jun 1, 2021
@kmoe kmoe deleted the katy_req_res branch June 1, 2021 17:07
@github-actions
Copy link

github-actions bot commented Jul 2, 2021

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 2, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Define Request and Response types
2 participants