-
Notifications
You must be signed in to change notification settings - Fork 16
fix(config): generate #975
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,6 +24,21 @@ func NewDefaultConfigGenerator(logs scribe.Emitter) DefaultConfigGenerator { | |
| } | ||
|
|
||
| func (g DefaultConfigGenerator) Generate(config Configuration) error { | ||
| g.logs.Process("Check: %s", config.NGINXConfLocation) | ||
| if info, err := os.Stat(config.NGINXConfLocation); err == nil { | ||
| g.logs.Subprocess("Configuration file already exists") | ||
| if info.Size() > 0 { | ||
| userConf, err := os.ReadFile(config.NGINXConfLocation) | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
||
| g.logs.Subprocess("Set configuration (in %s) as template", config.NGINXConfLocation) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think we should do this, it's changing the functionality here. The template previously was hard coded, and the intent of this buildpack was that the initial generated configuration would always be simple & if you out grow it, then you need to just supply your own config file. If we go down the path of allowing custom templates, that feels like it opens up a lot of area of things we need to support.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I understand. I guess reading the example, I was (probably wrongfully) assuming that the full config capabilites are possible: https://github.com/paketo-buildpacks/samples/blob/main/web-servers/nginx-sample/nginx.conf E.g.,
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @dmikusa would you be in favour of not overwriting the configuration file though when present? I think that is a "bug"? Or is this intended?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think I understand what you are saying.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, ok. Yes, that is a confusing bit. The The template config that happens in your PR is when we generate a configuration file because there is no nginx.conf file at all. It's meant to be the "quick start" option for some standard use cases like serving up files or a SPA app. This is where things like There are an almost infinite number of ways you can configure nginx. In a previous buildpack, we tried to be very flexible and support a ton of different config options. What ended up happening is that we just invented another (arguably worse) way to configure Nginx. With this buildpack, we mad the decision to limit what the auto generation would do to a few common use cases. That way users can quickly get started with those common cases, and when/if they outgrow what that can do, then they can use standard Nginx config to accomplish their goals (not some special thing only applicable to buildpacks).
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yes, my $0.02 is that the bug here is not checking if the file exists. We should not overwrite a user supplied config file. I think we can just add a check to make sure it doesn't exist and that should solve this issue. If you supply a file, even if it's empty, then we'll attempt to use that. That said, I'd be OK generating a separate error if you supply an empty nginx.conf file. That's pretty obviously not going to work. I just think that's a separate thing from the generation of an nginx.conf file.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I made another PR but there are weird test errors. |
||
|
|
||
| DefaultConfigTemplate = string(userConf) | ||
| } | ||
| } | ||
|
|
||
| g.logs.Process("Generating %s", config.NGINXConfLocation) | ||
| t := template.Must(template.New("template.conf").Delims("$((", "))").Parse(DefaultConfigTemplate)) | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.