Skip to content

Conversation

@bendbennett
Copy link
Contributor

Closes: #4

@bendbennett bendbennett added the enhancement New feature or request label Sep 14, 2022
@bendbennett bendbennett added this to the v0.1.0 milestone Sep 14, 2022
@bendbennett bendbennett requested a review from a team as a code owner September 14, 2022 09:08
@bendbennett bendbennett changed the title Add Schema Mutation Functions Add Schema Mutation and Timeout Retrieval Functions Sep 20, 2022
@bflad bflad self-assigned this Sep 20, 2022
Copy link
Contributor

@bflad bflad left a comment

Choose a reason for hiding this comment

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

Overall I think this is on the right track -- I left some comments along the way here to hopefully clarify the public API and logic a little. Please reach out with any questions.

- uses: actions/setup-go@v3
with:
go-version: ${{ steps.go-version.outputs.version }}
go-version-file: 'go.mod'
Copy link
Contributor

Choose a reason for hiding this comment

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

Over in #3 this also dropped the step above, as it's no longer necessary.

with:
go-version: ${{ steps.go-version.outputs.version }}
- uses: goreleaser/goreleaser-action@v2
go-version-file: 'go.mod'
Copy link
Contributor

Choose a reason for hiding this comment

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

Similarly the above step can be dropped

- uses: actions/setup-go@v3
with:
go-version: ${{ steps.go-version.outputs.version }}
go-version-file: 'go.mod'
Copy link
Contributor

Choose a reason for hiding this comment

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

Similarly the above step can be dropped

go.mod Outdated

require (
github.com/google/go-cmp v0.5.9
github.com/hashicorp/terraform-plugin-framework v0.12.1-0.20220913180647-04ff77076480
Copy link
Contributor

Choose a reason for hiding this comment

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

v0.13.0 is available 👍


// Description describes the validation in plain text formatting.
func (validator timeDurationValidator) Description(_ context.Context) string {
return "string must be parseable as time.Duration"
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Practitioners may not know what a time.Duration is or that provider code is typically Go-based to know to lookup the time package documentation, so I would suggest offering some examples in the description or the returned error diagnostic.

create = "create"
read = "read"
update = "update"
del = "delete"
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm sorry for this OCD, but everything else is written out. 😭

	delete = "delete"

Maybe this would be better to create these constants with a little more explanation like:

// Attribute name constants
const (
	attributeNameCreate = "create"
	attributeNameDelete = "delete"
	attributeNameRead   = "read"
	attributeNameUpdate = "update"
)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I used delete to avoid "Constant 'delete' collides with the 'builtin' function" notification in my IDE.

Have rename all using attributeName....

README.md Outdated
func (r exampleResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) {
var data exampleResourceData

diags := req.Config.Get(ctx, &data)
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: I'd always recommend showing fetching from the req.Plan to prevent other provider developer confusion. 😄

README.md Outdated
func (r exampleResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) {
var data exampleResourceData

diags := req.Config.Get(ctx, &data)
Copy link
Contributor

Choose a reason for hiding this comment

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

Similarly regarding req.Plan


// Although the schema validation guarantees that the type for create timeout
// is parseable as a time.Duration, this function accepts any types.Object.
duration, err := time.ParseDuration(createTimeout.(types.String).Value)
Copy link
Contributor

Choose a reason for hiding this comment

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

Should these return early without error if the types.String is null?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Have added checks and return default if types.String is null.

Copy link
Contributor

@bflad bflad left a comment

Choose a reason for hiding this comment

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

This looks good to me 🚀 Let's ship a v0.1.0 😄

@bendbennett bendbennett merged commit 6de121a into main Sep 22, 2022
@github-actions
Copy link

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 Oct 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Schema Mutation and Timeout Retrieval Functions

2 participants