Skip to content

Refactor formatKeyName function for better reusability and structure #668

@coderabbitai

Description

@coderabbitai

Proposal

Based on discussion in PR #663, there are two potential improvements to the formatKeyName function in components/odh-notebook-controller/controllers/notebook_runtime.go:

1. Move .json suffix addition up in the call chain

Currently, the .json suffix is added within the formatKeyName function. The proposal is to:

  • Remove the .json suffix from formatKeyName
  • Add it at the call site: data[formattedName + ".json"] = metadataParsed

2. Rename function for better reusability

Rename formatKeyName to sanitizeName to make it more generic and potentially reusable in other parts of the codebase.

Benefits

  • Separation of concerns: the sanitization logic is separate from the specific .json suffix requirement
  • Better reusability: a generic sanitizeName function could be used elsewhere
  • Clearer intent: the function name would better reflect its generic sanitization purpose

References

Requested by: @jstourac

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions