Skip to content
This repository has been archived by the owner on Jun 29, 2022. It is now read-only.

New internal package for helper functions #588

Merged
merged 2 commits into from
Jun 16, 2020

Conversation

ipochi
Copy link
Member

@ipochi ipochi commented Jun 9, 2020

This PR adds a new internal package that is not exposed to the outside world. The intention is to begin consolidating functions in various util packages scattered in the codebase.

The first function that is to be added is RenderTemplate which renders the provided go template.

Copy link
Member

@invidian invidian left a comment

Choose a reason for hiding this comment

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

LGTM, but while we move things around, it would be great to add some tests, as it shouldn't be too hard.

internal/doc.go Outdated Show resolved Hide resolved
internal/template/template.go Show resolved Hide resolved
@ipochi ipochi force-pushed the imran/create-internal-package-for-helper-functions branch from 96e7bc4 to 2fbb1a2 Compare June 9, 2020 13:56
@ipochi ipochi requested a review from invidian June 9, 2020 13:58
@ipochi ipochi force-pushed the imran/create-internal-package-for-helper-functions branch from 2fbb1a2 to ad58fa2 Compare June 9, 2020 14:22
@ipochi ipochi requested a review from iaguis June 9, 2020 14:24
invidian
invidian previously approved these changes Jun 9, 2020
Copy link
Member

@invidian invidian left a comment

Choose a reason for hiding this comment

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

Just one nit, otherwise looks good, though the commits could be re-organized a bit. We could do:

  • introduce new package
  • switch existing code to use new package
  • remove unused code

internal/template/template_test.go Outdated Show resolved Hide resolved
Adding a new internal package for utility and helper functions that
need not be exposed outside.

Currently there are lot of util packages in the codebase. Having an
internal package helps in consolidating all such helper functions in
this internal package rather than having separate util package/files
in different places in the codebase.

The first function that is to be added is RenderTemplate which renders
provided go template.

Adds unit tests for the same.

Signed-off-by: Imran Pochi <imran@kinvolk.io>
Since RenderTemplate function is now part of the `internal` package,
this caused duplication. Hence the file `template.go` is removed from
the codebase.

Also we update the references to `util.RenderTemplate` to now refer to
the correct package and function.

Signed-off-by: Imran Pochi <imran@kinvolk.io>
@ipochi ipochi force-pushed the imran/create-internal-package-for-helper-functions branch from ad58fa2 to f0f21f3 Compare June 9, 2020 15:26
@ipochi
Copy link
Member Author

ipochi commented Jun 9, 2020

Just one nit, otherwise looks good, though the commits could be re-organized a bit. We could do:

  • introduce new package
  • switch existing code to use new package
  • remove unused code

Commit 1: introduces new package and its tests
Commit 2: removes old code and points to the new package

Copy link
Member

@knrt10 knrt10 left a comment

Choose a reason for hiding this comment

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

+1 LGTM


internaltemplate "github.com/kinvolk/lokomotive/internal/template"
Copy link
Member

Choose a reason for hiding this comment

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

Q: Why is it imported as internaltemplate? Name conflicts?

Copy link
Member

Choose a reason for hiding this comment

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

Can we import it as internaltemplate everywhere else? So it becomes easier to read code?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes Suraj, name conflicts with Go library template package.

@invidian invidian merged commit c7b64f4 into master Jun 16, 2020
@invidian invidian deleted the imran/create-internal-package-for-helper-functions branch June 16, 2020 06:56
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants