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

Create conversions package #1520

Merged
merged 28 commits into from
May 31, 2021
Merged

Conversation

theunrepentantgeek
Copy link
Member

@theunrepentantgeek theunrepentantgeek commented May 27, 2021

What this PR does / why we need it:

Moves much of the code around creation of storage variants out of the astmodel package and into a package dedicated to generation of conversions.

Requires PR #1495 to be merged first. PR #1495 has been merged.

Special notes for your reviewer:

The PR is almost entirely moving files and renaming types (see below for the exception). However, not every file rename has been detected and correctly shown in the PR, so in some cases we see new-file + file-deleted.

The one functional change is that functions are named for the type being converted, not for the version. This can be seen in the changes to the (relocated) golden files, where ConvertToVNext() now becomes AssignPropertiesToPerson(). In the actuall generated code, where the versions are date based, the change will look like ConvertToV20180501() becoming AssignPropertiesToBatchAccount().

How does this PR make you feel:
gif

If applicable:

  • this PR contains tests

Base automatically changed from feature/storage-conversions to master May 27, 2021 01:45
@theunrepentantgeek theunrepentantgeek force-pushed the feature/conversions-package branch from 7e05710 to 326c98a Compare May 27, 2021 01:49
Copy link
Member

@babbageclunk babbageclunk left a comment

Choose a reason for hiding this comment

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

I like the AssignPropertiesTo/From naming a lot more.


import (
"fmt"
"github.com/Azure/azure-service-operator/hack/generator/pkg/astmodel"
Copy link
Member

Choose a reason for hiding this comment

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

Move this down into a separate this-module stanza along with the astbuilder import?

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed.

Comment on lines 9 to 10
"github.com/Azure/azure-service-operator/hack/generator/pkg/astmodel"
"github.com/Azure/azure-service-operator/hack/generator/pkg/conversions"
Copy link
Member

Choose a reason for hiding this comment

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

Split these out?

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed.

Comment on lines 9 to 10
"bytes"
"github.com/Azure/azure-service-operator/hack/generator/pkg/astmodel"
Copy link
Member

Choose a reason for hiding this comment

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

Same

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed.

}
}

//TODO: Remove this?
Copy link
Member

Choose a reason for hiding this comment

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

So should you? 😉

Copy link
Member Author

Choose a reason for hiding this comment

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

Those methods were introduced as a part of relocating things one by one into the new package, but I'll keep them. Fixed the comments.


import (
"github.com/Azure/azure-service-operator/hack/generator/pkg/astmodel"
Copy link
Member

Choose a reason for hiding this comment

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

Same here

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed.


import (
"github.com/Azure/azure-service-operator/hack/generator/pkg/astmodel"
Copy link
Member

Choose a reason for hiding this comment

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

Same

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed.

@codecov-commenter
Copy link

Codecov Report

Merging #1520 (beaf925) into master (8f36359) will increase coverage by 0.01%.
The diff coverage is 84.57%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1520      +/-   ##
==========================================
+ Coverage   63.23%   63.25%   +0.01%     
==========================================
  Files         175      175              
  Lines       11583    11597      +14     
==========================================
+ Hits         7325     7336      +11     
- Misses       3601     3604       +3     
  Partials      657      657              
Impacted Files Coverage Δ
...erator/pkg/codegen/storage/storage_type_factory.go 0.00% <0.00%> (ø)
...or/pkg/conversions/property_assignment_function.go 69.88% <84.00%> (ø)
...tor/pkg/conversions/property_conversion_context.go 84.37% <84.37%> (ø)
.../generator/pkg/conversions/property_conversions.go 80.20% <87.75%> (ø)
...or/pkg/conversions/property_conversion_endpoint.go 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8f36359...beaf925. Read the comment docs.

Copy link
Member

@babbageclunk babbageclunk left a comment

Choose a reason for hiding this comment

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

Nice fix!

@theunrepentantgeek theunrepentantgeek merged commit 034cf47 into master May 31, 2021
@theunrepentantgeek theunrepentantgeek deleted the feature/conversions-package branch May 31, 2021 01:57
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