Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Re-apply Portal Dashboard: Treat Part's Metadata as untyped JSON #3566

Merged
merged 6 commits into from
Sep 17, 2024

Conversation

mikhailshilkov
Copy link
Member

@mikhailshilkov mikhailshilkov commented Sep 9, 2024

Re-applies #3123 after it's been reverted in #3500

The only functional change compared to the original PR is a rename of DashboardPartsResponsePosition to DashboardPartsPositionResponse. Upstream have probably shuffled type definitions in some way that makes us choose a different name.

As discussed after the initial review, I've also added two things to help avoid confusion in the future:

  • Asserts that the types that we rely on during overrides are actually present in the original schema
  • Text comments in the examples about the importance of non-markdown parts in tests

Fix #3562
Fix #1412
Fix #747
Fix https://github.com/pulumi/customer-support/issues/1737 (I imported the created dashboard and received the settings of dashboard parts. No automated test for that.)

Copy link

github-actions bot commented Sep 9, 2024

Does the PR have any schema changes?

Found 10 breaking changes:

Types

  • 🟡 "azure-native:portal:DashboardParts": properties: "metadata" type changed from "#/types/azure-native:portal:MarkdownPartMetadata" to "#/types/azure-native:portal:DashboardPartMetadata"
  • 🟡 "azure-native:portal:DashboardPartsResponse": properties: "metadata" type changed from "#/types/azure-native:portal:MarkdownPartMetadataResponse" to "#/types/azure-native:portal:DashboardPartMetadataResponse"
  • 🔴 "azure-native:portal:MarkdownPartMetadata" missing
  • 🔴 "azure-native:portal:MarkdownPartMetadataResponse" missing
  • 🔴 "azure-native:portal:MarkdownPartMetadataSettings" missing
  • 🔴 "azure-native:portal:MarkdownPartMetadataSettingsContent" missing
  • 🔴 "azure-native:portal:MarkdownPartMetadataSettingsContentResponse" missing
  • 🔴 "azure-native:portal:MarkdownPartMetadataSettingsContentSettings" missing
  • 🔴 "azure-native:portal:MarkdownPartMetadataSettingsContentSettingsResponse" missing
  • 🔴 "azure-native:portal:MarkdownPartMetadataSettingsResponse" missing
    No new resources/functions.

@mikhailshilkov mikhailshilkov changed the title Mikhailshilkov/portal dashboard 2 Re-apply Portal Dashboard: Treat MarkdownPartMetadata as untyped JSON Sep 9, 2024
@mikhailshilkov mikhailshilkov changed the title Re-apply Portal Dashboard: Treat MarkdownPartMetadata as untyped JSON Re-apply Portal Dashboard: Treat Part's Metadata and Inputs as untyped JSON Sep 9, 2024
@mikhailshilkov mikhailshilkov changed the title Re-apply Portal Dashboard: Treat Part's Metadata and Inputs as untyped JSON Re-apply Portal Dashboard: Treat Part's Metadata as untyped JSON Sep 9, 2024
Copy link

codecov bot commented Sep 9, 2024

Codecov Report

Attention: Patch coverage is 98.38710% with 2 lines in your changes missing coverage. Please review.

Project coverage is 58.39%. Comparing base (392852d) to head (7843308).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
provider/pkg/gen/schema.go 75.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3566      +/-   ##
==========================================
+ Coverage   57.77%   58.39%   +0.62%     
==========================================
  Files          66       67       +1     
  Lines        8294     8418     +124     
==========================================
+ Hits         4792     4916     +124     
+ Misses       3055     3054       -1     
- Partials      447      448       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mikhailshilkov mikhailshilkov force-pushed the mikhailshilkov/portal-dashboard-2 branch from 3161932 to 0e45e16 Compare September 9, 2024 14:51
@mikhailshilkov mikhailshilkov marked this pull request as ready for review September 9, 2024 15:56
Copy link
Member

@danielrbradley danielrbradley left a comment

Choose a reason for hiding this comment

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

To discuss further:

  1. How do we make this less fragile if upstream changes again in the future?
  2. How do we know if the dashboard is actually usable and not just deployable (as these seem to be different)?
  3. Is this in scope to fully manage the implementation of the types as custom code or should we just ensure any value can be passed in.

@mikhailshilkov mikhailshilkov force-pushed the mikhailshilkov/portal-dashboard-2 branch 5 times, most recently from a6b42c6 to e1f6efd Compare September 16, 2024 10:07
@mikhailshilkov mikhailshilkov force-pushed the mikhailshilkov/portal-dashboard-2 branch from e1f6efd to 7843308 Compare September 16, 2024 10:09
@mikhailshilkov
Copy link
Member Author

I think our long-term answer to the questions above is in #3571

Therefore, I removed the extra checks from this PR and brought it back to as pure revert as possible to minimize the probability of breaking something and the diff versus #3571

@mjeffryes @thomas11 please take a look

Copy link
Member

@mjeffryes mjeffryes left a comment

Choose a reason for hiding this comment

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

Given the commit history, I found it difficult to verify this as a simple revert + rename, but approving the merge on that basis to get back to a non-broken state for the customer.

Comments are notes of things to make sure we improve with #3571 or whatever PR we land for a long term solution.

Comment on lines +147 to +148
// SchemaTypeOverrides returns the map of custom resource schema overrides per resource token.
func SchemaTypeOverrides() map[string]schema.ComplexTypeSpec {
Copy link
Member

Choose a reason for hiding this comment

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

Why is it SchemaTypeOverrides here, but TypeOverrides on the struct?

@@ -550,12 +550,24 @@ func genMixins(pkg *pschema.PackageSpec, metadata *resources.AzureAPIMetadata) e
}
pkg.Types[tok] = t
}
for tok, t := range customresources.SchemaTypeOverrides() {
Copy link
Member

Choose a reason for hiding this comment

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

This should probably be checking that the type being overridden exists?

}
metadata.Types[tok] = r
}
for tok, r := range customresources.MetaTypeOverrides() {
Copy link
Member

Choose a reason for hiding this comment

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

This should probably be checking that the type being overridden exists?

@@ -38,6 +38,11 @@ type CustomResource struct {
// Resource metadata. Defines the parameters and properties that are used for diff calculation and validation.
// Optional, by default the metadata is assumed to be derived from Azure Open API specs.
Meta *AzureAPIResource
// MetaTypes are net-new auxiliary metadata types defined for this resource. Optional.
Copy link
Member

Choose a reason for hiding this comment

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

AZ-Native n00b question probably, but what are "auxiliary metadata types"?

}
for tok, r := range customresources.MetaTypeOverrides() {
metadata.Types[tok] = r
}
Copy link
Member

Choose a reason for hiding this comment

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

Nit. It's strange to me that these overrides and mixins are splatted into the package here with so little context. Why are do we do overrides after mixins? Why are are the functions above and the workspaceSqlAadAdmin description added in a totally different way?

types := map[string]schema.ComplexTypeSpec{}
for _, r := range featureLookup {
for n, v := range r.TypeOverrides {
types[n] = v
Copy link
Member

Choose a reason for hiding this comment

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

no check for collisions between CustomResource instances?

@mikhailshilkov mikhailshilkov merged commit fb1064e into master Sep 17, 2024
23 checks passed
@mikhailshilkov mikhailshilkov deleted the mikhailshilkov/portal-dashboard-2 branch September 17, 2024 08:42
@pulumi-bot
Copy link
Contributor

This PR has been shipped in release v2.62.0.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
4 participants