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

PR 1 for fogg #1

Merged
merged 69 commits into from
Jun 26, 2018
Merged

PR 1 for fogg #1

merged 69 commits into from
Jun 26, 2018

Conversation

ryanking
Copy link
Contributor

A bunch of stuff here, but would be good to get eyes on it.

@ryanking ryanking requested a review from a team June 26, 2018 00:09
log.Printf("touching %s", d)
_, e = dest.Create(d)
if e != nil {
return e
Copy link
Contributor

@edulop91 edulop91 Jun 26, 2018

Choose a reason for hiding this comment

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

would it be worth errors.Wrap these to capture stacks/potentially easier debugging?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah that's a good idea. This is a large diff already, so I will add a follow-up task to handle that https://app.asana.com/0/335732894489412/723850669292560

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah that's a good idea. This is a large diff already, so I will add a follow-up task to handle that https://app.asana.com/0/335732894489412/723850669292560

apply/apply.go Outdated
log.Printf("templating %s", d)
writer, err := dest.OpenFile(d, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0755)
if err != nil {
panic(err)
Copy link
Contributor

Choose a reason for hiding this comment

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

why panic vs return the error?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good question – I don't know why I did this, I will change it.

AWSProfileProvider *string `json:"aws_profile_provider"`
AWSProviderVersion *string `json:"aws_provider_version,omitempty"`
AWSRegion *string `json:"aws_region"` // maybe rename to provider region
AWSRegions *[]string `json:"aws_regions"` // maybe rename to provider region
Copy link
Contributor

Choose a reason for hiding this comment

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

are these the allowed aws regions?
why *[]string and not just []string?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe there is a better way to do this, but I am doing this because it is optional. But I guess slices are reference types already so that is redundant. Will clean this up in a followup https://app.asana.com/0/335732894489412/723850669292561

Components map[string]*Component `json:"components"`
}

type Component struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should Account, Env and Component share an embedded type?

type Account struct {
  TerraformConfiguration
}

type Env struct {
  TerraformConfiguration
  
  Components map[string]*Component
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I suspect that is the case, but wanted to get things working first. I guess we are at the point where that refactoring could make sense. I will follow up here https://app.asana.com/0/335732894489412/723850669292562

}

func ReadConfig(f io.ReadCloser) (*Config, error) {
defer f.Close()
Copy link
Contributor

Choose a reason for hiding this comment

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

would that potentially be dangerous for the caller?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah possibly, though I have assumed that any method that takes a io.ReadCloser will close it. Perhaps this should be a io.Reader and let the caller close it. I will follow up here https://app.asana.com/0/335732894489412/723850669292563

"github.com/spf13/afero"
)

type account struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

what's the difference between these and the config/config.go ones?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The main difference is the semantics of what is required.

In the config there are a bunch of optional fields that will supplied by our inheritance rules.

My general idea here was to have a separate plan stage in which we apply all the rules. And then apply can be a dumb application of that plan. My hope is that this makes the code somewhat easier to test (because you can assert on the plan results without worrying about how they are applied).

Copy link
Contributor

Choose a reason for hiding this comment

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

👍

fmt.Printf("Version: %s\n", p.Version)
fmt.Println("Accounts:")
for name, account := range p.Accounts {
fmt.Printf("\t%s:\n", name)
Copy link
Contributor

Choose a reason for hiding this comment

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

should these be printing a string(yaml.Marshal())?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe. I wasn't really intending this to be yaml output and I think we should actually move more towards human readable for this. Make sense?

return r
}

func resolveStringArray(def []string, override *[]string) []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 think *override can still be nil

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah yeah because slices are reference types. I will follow up here https://app.asana.com/0/335732894489412/723850669292564

@ryanking
Copy link
Contributor Author

I am going to go ahead and merge this so I can start picking off these pieces in smaller PRs.

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