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

Refactor config writing #419

Merged

Conversation

feifeiiiiiiiiiii
Copy link
Contributor

@feifeiiiiiiiiiii feifeiiiiiiiiiii commented Nov 6, 2018

Signed-off-by: qinpengfei [email protected]

Proposed changes

Refactor write file code, reduce redundant code

Checklist

Before creating a PR, run through this checklist and mark each as complete.

  • I have read the CONTRIBUTING doc
  • I have added tests that prove my fix is effective or that my feature works
  • I have checked that all unit tests pass after adding my changes
  • I have updated necessary documentation
  • I have rebased my branch onto master
  • I will ensure my PR is targeting the master branch and pulling from my branch from my own fork

@pleshakov pleshakov added the enhancement Pull requests for new features/feature enhancements label Nov 6, 2018
Copy link
Contributor

@pleshakov pleshakov left a comment

Choose a reason for hiding this comment

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

Thanks for the PR. I left a few suggestions.

Also, could you possibly use createFileAndWrite in

func (nginx *Controller) AddOrUpdateDHParam(dhparam string) (string, error) {
?

if err != nil {
glog.Fatalf("Failed to open %v: %v", filename, err)
glog.Fatalf("%v", err.Error())
Copy link
Contributor

Choose a reason for hiding this comment

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

It is better to add more context to the log message:

glog.Fatalf("Failed to write NGINX conf: %v", err)

Additionally, I don't see why we need to use err.Error()) instead of just err

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@pleshakov ok I will modify in accordance with you suggest

if err != nil {
glog.Fatalf("Failed to open %v: %v", filename, err)
glog.Fatalf("%v", err.Error())
Copy link
Contributor

Choose a reason for hiding this comment

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

Similar to the main NGINX conf, better to add more context to the error message: "Failed to write version config: %v"

Copy link
Contributor

@pleshakov pleshakov left a comment

Choose a reason for hiding this comment

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

Thanks for addressing the suggestions!

Could you possibly address 2 additional suggestions and then rebase against the master?

internal/nginx/nginx.go Outdated Show resolved Hide resolved
internal/nginx/nginx.go Outdated Show resolved Hide resolved
@feifeiiiiiiiiiii
Copy link
Contributor Author

feifeiiiiiiiiiii commented Nov 10, 2018

@pleshakov modify and rebase done, but I not sure rebase is right, pls check

@pleshakov
Copy link
Contributor

@feifeiiiiiiiiiii looks good, thank you! the rebase went well

Please squash your commits into a single one rebasing one more time, and we'd be happy merge it.

@feifeiiiiiiiiiii
Copy link
Contributor Author

feifeiiiiiiiiiii commented Nov 12, 2018

@pleshakov squash commits into a single commit has done, pls check

Signed-off-by: qinpengfei <[email protected]>

refactor func AddOrUpdateDHParam  && add more context to log message

Signed-off-by: qinpengfei <[email protected]>

remove unnecessary log

Signed-off-by: qinpengfei <[email protected]>

fix log message

Co-Authored-By: feifeiiiiiiiiiii <[email protected]>

fix log message

Co-Authored-By: feifeiiiiiiiiiii <[email protected]>
@pleshakov pleshakov merged commit 10d2749 into nginxinc:master Nov 12, 2018
@feifeiiiiiiiiiii feifeiiiiiiiiiii deleted the feature/refactor_write_config branch November 13, 2018 01:52
@pleshakov pleshakov changed the title refactor write config Refactor config writing Nov 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Pull requests for new features/feature enhancements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants