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

[ENHANCEMENT] Struct support #2

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

dnagpal755
Copy link

No description provided.

@ianlopshire
Copy link
Owner

ianlopshire commented Dec 31, 2019

@dnagpal755,

Thanks for opening this PR! I think supporting nested structs is a great feature. Some early comments:

  • Please ensure the documentation is updated to reflect nested structs are supported.
  • Please ensure that test cases are added to cover nested structs.
  • How will embedded structs be handled? Please ensure there are test cases around this.

Thanks again!

@dnagpal755
Copy link
Author

Hi,

Thanks for your comment. I have added these things.

Copy link
Owner

@ianlopshire ianlopshire left a comment

Choose a reason for hiding this comment

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

Looks great! I've added comments around a couple of nitpicky things. I'd also like to see some additional documentation around the new behavior.

value, ok := params[field.name]
if !ok {
value = field.defaultValue
func buildStructSpec(configPath string, t reflect.Type, spec *map[string]fieldSpec) {
Copy link
Owner

Choose a reason for hiding this comment

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

Is there any reason this returns a pointer to a map? A map is already a pointer-ish type

Suggested change
func buildStructSpec(configPath string, t reflect.Type, spec *map[string]fieldSpec) {
func buildStructSpec(configPath string, t reflect.Type, spec map[string]fieldSpec) {

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/ssm"
"github.com/aws/aws-sdk-go/service/ssm/ssmiface"
"github.com/pkg/errors"
)

type (
Copy link
Owner

Choose a reason for hiding this comment

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

Please move these type declarations back to their original places in the file. Making stylistic changes pollutes the diff.

@@ -48,59 +54,56 @@ type Provider struct {
// The behavior of using the `default` and `required` tags on the same struct field is
// currently undefined.
func (p *Provider) Process(configPath string, c interface{}) error {

Copy link
Owner

Choose a reason for hiding this comment

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

Please remove all of the unnecessary white space. Again, this pollutes the diff.

@@ -40,6 +46,7 @@ func TestProvider_Process(t *testing.T) {
F641 float64 `ssm:"/float64/f641"`
F642 float64 `ssm:"/float64/f642" default:"42.42"`
Invalid string
D d
Copy link
Owner

Choose a reason for hiding this comment

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

Please also add a pointer to D to ensure pointers to structs also populate as expected.

var s struct {
    ...
   D1 d
   D2 *d
}

@@ -48,59 +54,56 @@ type Provider struct {
// The behavior of using the `default` and `required` tags on the same struct field is
// currently undefined.
func (p *Provider) Process(configPath string, c interface{}) error {
Copy link
Owner

Choose a reason for hiding this comment

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

Please add documentation around the behavior of nested structs in this comment and in the readme.

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.

2 participants