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

Don't panic when MultiPublisher is given zero publishers #216

Merged
merged 1 commit into from
Oct 6, 2020

Conversation

imjasonh
Copy link
Member

@imjasonh imjasonh commented Oct 5, 2020

Fixes #215

cc @ian-mi

@codecov-commenter
Copy link

codecov-commenter commented Oct 6, 2020

Codecov Report

Merging #216 into master will decrease coverage by 0.17%.
The diff coverage is 16.66%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #216      +/-   ##
==========================================
- Coverage   37.23%   37.05%   -0.18%     
==========================================
  Files          33       33              
  Lines        1402     1414      +12     
==========================================
+ Hits          522      524       +2     
- Misses        790      800      +10     
  Partials       90       90              
Impacted Files Coverage Δ
pkg/commands/resolver.go 12.57% <0.00%> (-0.81%) ⬇️
pkg/publish/multi.go 60.00% <100.00%> (+10.00%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 01820ce...b890235. Read the comment docs.

@imjasonh imjasonh changed the title Return error when MultiPublisher is given zero publishers Don't panic when MultiPublisher is given zero publishers Oct 6, 2020
@jonjohnsonjr
Copy link
Collaborator

This ignores -P or -B flags, and always uses -P behavior.

Hm... what if we always append the default publisher and just added push as a default publisher Option and guarded all this with a boolean:

https://github.com/google/ko/blob/dc30efcfd8b6f6a8aa381c715390013f9c1fa23b/pkg/publish/default.go#L128-L151

Then that keeps everything in sync and we don't have to worry about naming logic drift, plus we can just return an error from multipublisher if len(publishers) == 0 and it's pretty easy to follow the logic.

MultiPublisher now returns an error when it's configured with no
publishers, and resolver.go now appends a nop publisher when it's
configured not to publish, that simulates a publish without actually
pushing any images.

.
@jonjohnsonjr
Copy link
Collaborator

~/go/src/github.com/google/ko ((b890235...)) $ ko publish -B --push=false ./cmd/ko/
2020/10/06 09:44:44 Using base gcr.io/distroless/static:nonroot for github.com/google/ko/cmd/ko
2020/10/06 09:44:46 Building github.com/google/ko/cmd/ko for linux/amd64
gcr.io/jonjohnson-test/ko/ko@sha256:77582412aa5b7919ff07951ebdac05fd145463c802ddf254bca3065292c3059f

Dope.

@jonjohnsonjr jonjohnsonjr merged commit e780390 into ko-build:master Oct 6, 2020
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 this pull request may close these issues.

ko resolve segfaults when push=false
3 participants