Skip to content

Feature/remote tags - #219

Merged
dnephin merged 2 commits into
dnephin:mainfrom
aidan-mundy-forks:feature/remote-tags
Oct 23, 2021
Merged

Feature/remote tags#219
dnephin merged 2 commits into
dnephin:mainfrom
aidan-mundy-forks:feature/remote-tags

Conversation

@aidan-mundy

Copy link
Copy Markdown
Contributor

Closes #216

@CLAassistant

CLAassistant commented Oct 21, 2021

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@dnephin dnephin left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thanks! LGTM

I think this is a good way of handling backwards compat. I left a very minor style suggestion, but I'll merge this as-is, and leave it to you if you think it's worth changing in a follow up.

Comment thread tasks/image/image.go
Comment on lines +72 to +75
// forEachRemoteTagNoFallback runs a function for each remote tag
func (t *Task) forEachRemoteTagNoFallback(each func(string) error) error {
return t.forEachProvidedTag(each, t.config.RemoteTags)
}

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

What does NoFallback in the name mean here?

I often try to avoid functions that only call one other function, especially when there are other functions with similar names. I guess each of the callers of this function could instead directly call:

t.forEachProvidedTag(each, t.config.RemoteTags)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

"NoFallback" in this case refers to the lack of "fallback" to Local tags when there are no remote tags. I generally agree on avoiding "functions that only call one other function", except when the call is (and always should be) exactly the same across multiple callers.

Initially, I did not have this function at all, and forEachTag instead called forEachRemoteTag, causing local tags to be applied twice if there were no remote tags. Using a call to forEachProvidedTag entices a later (and more forgetful) me to go back and "DRY" the code by changing it back to forEachRemoteTag 🤦‍♂️. I figure that this is a case of trading actually DRY code for slightly more nested depth in the codebase. Perhaps forEachRemoteTagNoFallbackToLocal would be a more clear name though?

@dnephin
dnephin merged commit 76e10c8 into dnephin:main Oct 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for some remote tags, and some local-only tags

3 participants