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

Add information for cross-major-version aliases #3881

Merged
merged 13 commits into from
Jan 24, 2025

Conversation

danielrbradley
Copy link
Member

@danielrbradley danielrbradley commented Jan 23, 2025

  • Track where each definition (resource or invoke) has come from (source path).
  • Track the resource URI in the default versions file so we can compare between major versions where a rename has happened and add an alias.
  • Track the Azure resource provider namespace and use it when checking if a RP version is active rather than using the module name which might not align to the RP name (and might not be prefixed Microsoft.).

@danielrbradley danielrbradley self-assigned this Jan 23, 2025
Copy link

github-actions bot commented Jan 23, 2025

Does the PR have any schema changes?

Looking good! No breaking changes found.

New resources:

  • network.DnssecConfig
  • network.NetworkVirtualApplianceConnection

New functions:

  • network.getDnssecConfig
  • network.getNetworkVirtualApplianceConnection

Copy link
Contributor

@thomas11 thomas11 left a comment

Choose a reason for hiding this comment

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

Looks like a great improvement. Especially v2.yaml!

Only suggestion in addition to the comments: there are a lot of new map accesses without an , ok guard. Also one slice[0] without length check. Even if the existence of these elements is an invariant, I'd feel better about checking and asserting the invariant instead of failing in hard-to-debug ways later.

provider/pkg/openapi/discover.go Outdated Show resolved Hide resolved
@@ -191,13 +191,31 @@ func NewVersionResources() VersionResources {

type ModuleVersionList = map[ModuleName][]ApiVersion

// Can only by "Resource" or "Invoke"
type DefinitionType string
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 not loving the name "definition" yet because the spec also has type definitions but these are not represented here. Don't have a better idea ATM though.

Copy link
Member Author

Choose a reason for hiding this comment

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

Endpoint? URI? Maybe it's just a Resource, but invokes are like read-only resources?

provider/pkg/providerlist/providerlist.go Show resolved Hide resolved
provider/pkg/versioning/defaultVersion.go Outdated Show resolved Hide resolved
provider/pkg/versioning/defaultVersion.go Outdated Show resolved Hide resolved
Copy link
Contributor

@thomas11 thomas11 left a comment

Choose a reason for hiding this comment

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

I'd still recommend some checks when accessing maps but otherwise LGTM

provider/pkg/util/data_structures.go Show resolved Hide resolved
Copy link

codecov bot commented Jan 24, 2025

Codecov Report

Attention: Patch coverage is 64.08451% with 51 lines in your changes missing coverage. Please review.

Project coverage is 57.26%. Comparing base (86f5987) to head (5e22fa1).
Report is 14 commits behind head on master.

Files with missing lines Patch % Lines
provider/pkg/versioning/defaultVersion.go 76.78% 8 Missing and 5 partials ⚠️
provider/pkg/versioning/specs.go 13.33% 13 Missing ⚠️
provider/pkg/openapi/discover.go 45.45% 10 Missing and 2 partials ⚠️
provider/pkg/versioning/build_schema.go 0.00% 8 Missing ⚠️
provider/pkg/gen/examples.go 71.42% 2 Missing ⚠️
provider/pkg/pcl/pcl.go 0.00% 2 Missing ⚠️
provider/pkg/squeeze/squeeze.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3881      +/-   ##
==========================================
- Coverage   57.38%   57.26%   -0.13%     
==========================================
  Files          79       78       -1     
  Lines       12456    12438      -18     
==========================================
- Hits         7148     7122      -26     
- Misses       4765     4769       +4     
- Partials      543      547       +4     

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

Instead of mapping to the version string, map to a struct containing the version as well as provenance information.
- Replace the list of resource names (which could also be invoke names) to a map of definition names to the definition's source information.
- Change all existing slice iterations with iterating over the sorted keys from the map.
- Fix bug where we added empty versions for versions without any definitions. Instead, skip versions with no definitions found.
- Use the original Azure resource provider namespace rather that our adjusted module names which might not match.

Add Rp namespace to unit tests

This field is now required for active version checking. It's always populated during a real run so we need to add it to tests which hit this path.
DnssecConfig "2018-05-01" and NetworkVirtualApplianceConnection "2023-02-01" don't exist any more, so pick the next closest version that still exists.
- Validate the requested spec additions actually exist.
- Avoid duplicating structs and just assign the whole object.

Remove unused DefinitionType
- This should never happen in reality, but better to be safe.
- Update tests to include resources and the field accessed in the code.
- Use preview-aware sorting.
- Pass sets around instead of converting to and from arrays.
- Remove unused `collections.OrderedKeys`.
- Utilise `UnsortedKeys` in `SortedKeys`.
- Add new `MapOrdered` function to returns an iterator with both the key and value so we can reduce some noise.
- Add a few extra map existence checks too.
- Use util.MapOrdered where possible, or otherwise util.SortedKeys which is generic.
- Add unit test to catch this faster next time.
@pulumi-bot
Copy link
Contributor

This PR has been shipped in release v2.85.0.

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