-
Notifications
You must be signed in to change notification settings - Fork 4
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
Export Helper Function #84
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. We'll see if Webb or Dave have any feedback.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see a technical issue, but the function comment could use some cleanup.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess I shouldn't really penalize you for not improving a pre-existing bad comment (even though you moved it), so, 99% ... 😆 👍🏻
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, well...I was too slow. 👟
// Try plain object schema | ||
objectSchemaType, ok := typeOrData.(*ObjectSchema) | ||
if ok { | ||
return objectSchemaType, true | ||
} | ||
// Next, try ref schema | ||
refSchemaType, ok := typeOrData.(*RefSchema) | ||
if ok { | ||
return refSchemaType.GetObject(), true | ||
} | ||
// Next, try scope schema. | ||
scopeSchemaType, ok := typeOrData.(*ScopeSchema) | ||
if ok { | ||
return scopeSchemaType.Objects()[scopeSchemaType.Root()], true | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like it should be a switch
statement, no?
switch v := typeOrData.(type) {
case *ObjectSchema:
return v, true
case *RefSchema:
return v.GetObject(), true
case *ScopeSchema:
return v.Objects()[scopeSchemaType.Root()], true
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's worth trying. If it fails, lots of tests for ValidateCompatibility will fail.
Changes introduced with this PR
Facilitate type casting schemas to
ObjectSchema
outside of thepluginsdk
package.convertToObjectSchema
ConvertToObjectSchema
method as a package functionBy contributing to this repository, I agree to the contribution guidelines.