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

Custom PatternNameGenerator fields #79

Open
mschfh opened this issue Nov 17, 2024 · 0 comments · May be fixed by #80
Open

Custom PatternNameGenerator fields #79

mschfh opened this issue Nov 17, 2024 · 0 comments · May be fixed by #80

Comments

@mschfh
Copy link

mschfh commented Nov 17, 2024

The current implementation does not seem to allow passing custom params to PatternNameGenerator, although the documentation mentions predefined names, suggesting that it is possible to add custom fields:

The pattern is like golangs fmt package (https://pkg.go.dev/fmt), but allows for named fields in curly braces. The available predefined names are:

prefix - content of the Prefix field
ext - content of the Extension field
ts - current time as 14-digit GMT Time-stamp
serial - atomically increased serial number for every generated file name. Initial value is 0 if Serial field is not set
ip - primary IP address of the node
host - host name of the node
hostOrIp - host name of the node, falling back to IP address if host name could not be resolved

Please add an exported field for custom parameters. When generating filenames, the predefined fields (prefix, ext, hostOrIp, etc.) should be always set, just changing params to an exported field would break the current default initialization logic:

gowarc/warcfile.go

Lines 86 to 94 in 2cff962

if g.params == nil {
g.params = map[string]interface{}{
"prefix": g.Prefix,
"ext": g.Extension,
"ip": ip(),
"host": host(),
"hostOrIp": hostOrIp(),
}
}

mschfh added a commit to mschfh/gowarc that referenced this issue Nov 17, 2024
Improves field handling by:
- Exporting 'params' field as 'Params' for external configuration
- Ensuring predefined fields (ts, serial, hostOrIp, etc) take precedence over custom ones
- Adding documentation to clarify parameter behavior
- Adding tests for custom fields and precedence rules

Fixes nlnwa#79
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 a pull request may close this issue.

1 participant