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

Split Warmer.warm() into smaller functions #1935

Merged
merged 2 commits into from Apr 15, 2019

Conversation

@2opremio
Copy link
Collaborator

commented Apr 14, 2019

Warmer.warming() was a huge function (~250 loc), making it really hard to read.

This change splits the warmer into smaller functions, improving readability.

After this change Warmer.warming() is still 100 loc, but reads much better.

@2opremio 2opremio force-pushed the 2opremio:refactor-warmer branch from 0983841 to c92865c Apr 14, 2019

@2opremio 2opremio changed the title Split Warmer.warm() into smaller functions [WIP] Split Warmer.warm() into smaller functions Apr 14, 2019

@2opremio 2opremio force-pushed the 2opremio:refactor-warmer branch 3 times, most recently from fe1d18a to dcd3fb3 Apr 15, 2019

Split Warmer.warm() into smaller functions
`Warmer.warming()` was a huge function (~250 loc), making it really hard to read.

This change moves most of it into a new `repoCacheManager`, improving readability.

After this change `Warmer.warming()` is still 100 loc, but reads much better.

@2opremio 2opremio force-pushed the 2opremio:refactor-warmer branch from dcd3fb3 to fefb216 Apr 15, 2019

@2opremio 2opremio requested a review from hiddeco Apr 15, 2019

@2opremio 2opremio changed the title [WIP] Split Warmer.warm() into smaller functions Split Warmer.warm() into smaller functions Apr 15, 2019

// updateImages, refreshes the cache entries for the images passed. It may not succeed for all images.
// It returns the values stored in cache, the number of images it succeeded for and the number
// of images whose manifest wasn't found in the registry.
func (c *repoCacheManager) updateImages(ctx context.Context, registryClient registry.Client, images []imageToUpdate) (map[string]image.Info, int, int) {

This comment has been minimized.

Copy link
@hiddeco

hiddeco Apr 15, 2019

Member

Just a note; I am not a fan of the .., int, int return, but wrapping it in a struct to give it more context does not seem very meaningful either, the comment makes up for it a bit though.

This comment has been minimized.

Copy link
@2opremio

2opremio Apr 15, 2019

Author Collaborator

Yeah, I am not too pleased with this or fetchImagesResult either

Happy to look into any suggestions you may have.

Maybe computing the counters outside of the functions? I gave that a short chance but it was hairy. I will give it another try.

This comment has been minimized.

Copy link
@2opremio

2opremio Apr 15, 2019

Author Collaborator

I didn't find a cleaner way. At least not with a much bigger refactoring.

@hiddeco
Copy link
Member

left a comment

My mind is very pleased with the readability improvement 🌠

@2opremio 2opremio merged commit 686acaa into fluxcd:master Apr 15, 2019

2 checks passed

ci/circleci: build Your tests passed on CircleCI!
Details
ci/circleci: e2e-testing Your tests passed on CircleCI!
Details

@2opremio 2opremio deleted the 2opremio:refactor-warmer branch Apr 15, 2019

@squaremo squaremo added this to the v1.12.1 milestone Apr 24, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.