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

[Internal] Auto generated customizable schemas #4356

Merged
merged 3 commits into from
Jan 3, 2025

Conversation

rauchy
Copy link
Contributor

@rauchy rauchy commented Dec 27, 2024

Changes

Tests

  • make test run locally
  • relevant change in docs/ folder
  • covered with integration tests in internal/acceptance
  • using Go SDK
  • using TF Plugin Framework

@rauchy rauchy temporarily deployed to test-trigger-is December 27, 2024 17:05 — with GitHub Actions Inactive
@rauchy rauchy temporarily deployed to test-trigger-is December 27, 2024 17:05 — with GitHub Actions Inactive
@rauchy rauchy force-pushed the auto-generated-customizable-schemas branch from d95518b to 8382d47 Compare December 30, 2024 10:30
@rauchy rauchy temporarily deployed to test-trigger-is December 30, 2024 10:30 — with GitHub Actions Inactive
@rauchy rauchy temporarily deployed to test-trigger-is December 30, 2024 10:31 — with GitHub Actions Inactive
@rauchy rauchy force-pushed the auto-generated-customizable-schemas branch from 8382d47 to a0c1e9a Compare January 2, 2025 10:30
@rauchy rauchy temporarily deployed to test-trigger-is January 2, 2025 10:30 — with GitHub Actions Inactive
@rauchy rauchy temporarily deployed to test-trigger-is January 2, 2025 10:30 — with GitHub Actions Inactive
@rauchy rauchy force-pushed the auto-generated-customizable-schemas branch from a0c1e9a to aa7c04a Compare January 2, 2025 10:39
@rauchy rauchy temporarily deployed to test-trigger-is January 2, 2025 10:39 — with GitHub Actions Inactive
@rauchy rauchy requested review from mgyucht and tanmay-db January 2, 2025 10:39
@rauchy rauchy temporarily deployed to test-trigger-is January 2, 2025 10:39 — with GitHub Actions Inactive
@rauchy rauchy marked this pull request as ready for review January 2, 2025 10:39
@rauchy rauchy requested review from a team as code owners January 2, 2025 10:39
@rauchy rauchy force-pushed the auto-generated-customizable-schemas branch from aa7c04a to 69bc26b Compare January 2, 2025 10:40
@rauchy rauchy temporarily deployed to test-trigger-is January 2, 2025 10:40 — with GitHub Actions Inactive
@rauchy rauchy temporarily deployed to test-trigger-is January 2, 2025 10:40 — with GitHub Actions Inactive
@rauchy rauchy force-pushed the auto-generated-customizable-schemas branch from 69bc26b to 99b65de Compare January 2, 2025 11:28
@rauchy rauchy temporarily deployed to test-trigger-is January 2, 2025 11:28 — with GitHub Actions Inactive
@rauchy rauchy temporarily deployed to test-trigger-is January 2, 2025 11:28 — with GitHub Actions Inactive
Comment on lines 201 to 203
if schemaProvider, ok := v.(CustomizableSchemaProvider); ok {
cs = schemaProvider.ToSchema(cs)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be raised out of this if block.

@@ -185,7 +197,11 @@ func ResourceStructToSchemaMap(ctx context.Context, v any, customizeSchema func(
nestedBlockObj := typeToSchema(ctx, reflect.ValueOf(v))

if customizeSchema != nil {
cs := customizeSchema(*ConstructCustomizableSchema(nestedBlockObj))
cs := *ConstructCustomizableSchema(nestedBlockObj)
Copy link
Contributor

Choose a reason for hiding this comment

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

Also needs to be called on corresponding data source methods.

@rauchy rauchy force-pushed the auto-generated-customizable-schemas branch from 99b65de to 936f841 Compare January 3, 2025 10:10
@rauchy rauchy temporarily deployed to test-trigger-is January 3, 2025 10:10 — with GitHub Actions Inactive
@rauchy rauchy temporarily deployed to test-trigger-is January 3, 2025 10:10 — with GitHub Actions Inactive
@rauchy rauchy temporarily deployed to test-trigger-is January 3, 2025 10:28 — with GitHub Actions Inactive
@rauchy rauchy temporarily deployed to test-trigger-is January 3, 2025 10:28 — with GitHub Actions Inactive
@eng-dev-ecosystem-bot
Copy link
Collaborator

Test Details: go/deco-tests/12596325628

@rauchy rauchy requested a review from mgyucht January 3, 2025 10:29
Copy link
Contributor

@mgyucht mgyucht left a comment

Choose a reason for hiding this comment

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

LGTM, let's handle follow-ups for ApplySchemaCustomizations inside of typeToSchema to avoid users having to call it recursively manually for hand-written structs.

@@ -17,6 +17,10 @@ import (
"github.com/hashicorp/terraform-plugin-framework/types"
)

type CustomizableSchemaProvider interface {
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's document this.

@rauchy rauchy force-pushed the auto-generated-customizable-schemas branch from 1315b04 to 59a31c6 Compare January 3, 2025 14:08
@rauchy rauchy temporarily deployed to test-trigger-is January 3, 2025 14:09 — with GitHub Actions Inactive
@rauchy rauchy temporarily deployed to test-trigger-is January 3, 2025 14:09 — with GitHub Actions Inactive
@rauchy rauchy force-pushed the auto-generated-customizable-schemas branch from 59a31c6 to 6e206f9 Compare January 3, 2025 15:24
@rauchy rauchy temporarily deployed to test-trigger-is January 3, 2025 15:24 — with GitHub Actions Inactive
Copy link

github-actions bot commented Jan 3, 2025

If integration tests don't run automatically, an authorized user can run them manually by following the instructions below:

Trigger:
go/deco-tests-run/terraform

Inputs:

  • PR number: 4356
  • Commit SHA: 6e206f9f26bf2a1880386e92c9eb78ae62293ea3

Checks will be approved automatically on success.

@rauchy rauchy temporarily deployed to test-trigger-is January 3, 2025 15:24 — with GitHub Actions Inactive
@rauchy rauchy added this pull request to the merge queue Jan 3, 2025
Merged via the queue into main with commit 1b429c3 Jan 3, 2025
12 checks passed
@rauchy rauchy deleted the auto-generated-customizable-schemas branch January 3, 2025 16:59
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.

3 participants