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

Publish fails when using ko on Windows. #246

Closed
ZCube opened this issue Nov 17, 2020 · 5 comments · Fixed by #247
Closed

Publish fails when using ko on Windows. #246

ZCube opened this issue Nov 17, 2020 · 5 comments · Fixed by #247

Comments

@ZCube
Copy link

ZCube commented Nov 17, 2020

C:\Users\zcube>ko publish --platform=all github.com/mattmoor/warm-image/cmd/sleeper -L
2020/11/17 22:17:29 Using base gcr.io/distroless/static:nonroot for github.com/mattmoor/warm-image/cmd/sleeper
2020/11/17 22:17:29 No matching credentials were found, falling back on anonymous
2020/11/17 22:17:32 Building github.com/mattmoor/warm-image/cmd/sleeper for linux/amd64
2020/11/17 22:17:40 Building github.com/mattmoor/warm-image/cmd/sleeper for linux/arm64
2020/11/17 22:17:48 Building github.com/mattmoor/warm-image/cmd/sleeper for linux/ppc64le
2020/11/17 22:17:57 Building github.com/mattmoor/warm-image/cmd/sleeper for linux/s390x
2020/11/17 22:18:04 failed to publish images: error publishing ko://github.com/mattmoor/warm-image/cmd/sleeper: repository can only contain the runes `abcdefghijklmnopqrstuvwxyz0123456789_-./`: ko.local\sleeper-ebdb8b8b13d4bbe1d3592de055016d37

Publish fails when using ko on Windows.
I think it's because it uses OS.Seperator. It looks like you need to replace filepath.join with path.join.

@jonjohnsonjr
Copy link
Collaborator

jonjohnsonjr commented Nov 17, 2020

I don't have a windows machine to test this on, so I would appreciate your help testing #247

I'm also curious if specifying a local path to a build target works, e.g. ko publish ./cmd/ko works on linux, but I'm not sure what the windows equivalent to that is (and if it works at all).

We use filepath.Join when producing the filesystem for the resulting image, so that will probably be broken for you as well unless you have a windows base image, and I'm pretty sure there are a number of other issues (cc @tcnghia).

I don't know of a way to tell go "hey please use filepath for this target GOOS/GOARCH, not the GOOS/GOARCH of my system", but I'll poke around.

@ZCube
Copy link
Author

ZCube commented Nov 17, 2020

#247 works fine. Backslash is now properly replaced with forward slash. Windows supports forward slashes, but Linux does not support backslashes, so I think it is better to unify them with forward slashes.

C:\Users\zcube\go\src\github.com\google\ko\ko publish --platform=linux/amd64 github.com/mattmoor/warm-image/cmd/sleeper -L
2020/11/18 03:07:53 Using base gcr.io/distroless/static:nonroot for github.com/mattmoor/warm-image/cmd/sleeper
2020/11/18 03:07:53 No matching credentials were found, falling back on anonymous
2020/11/18 03:07:55 Building github.com/mattmoor/warm-image/cmd/sleeper for linux/amd64
2020/11/18 03:07:56 Loading ko.local/sleeper-ebdb8b8b13d4bbe1d3592de055016d37:e42fda13bfad5fd545576860d5940a7c41b129a778bb75276d4457ec33c0e71c
2020/11/18 03:07:56 Loaded ko.local/sleeper-ebdb8b8b13d4bbe1d3592de055016d37:e42fda13bfad5fd545576860d5940a7c41b129a778bb75276d4457ec33c0e71c
2020/11/18 03:07:56 Adding tag latest
2020/11/18 03:07:56 Added tag latest
ko.local/sleeper-ebdb8b8b13d4bbe1d3592de055016d37:e42fda13bfad5fd545576860d5940a7c41b129a778bb75276d4457ec33c0e71c 
ko.local/sleeper-ebdb8b8b13d4bbe1d3592de055016d37                                15814528440884a26a1727cce087c73a021329d9e07131df2e1d0027a9524c05   08c831570535        50 years ago        14.8MB
ko.local/sleeper-ebdb8b8b13d4bbe1d3592de055016d37                                e42fda13bfad5fd545576860d5940a7c41b129a778bb75276d4457ec33c0e71c   9d20ce27b0de        50 years ago        14.9MB
ko.local/sleeper-ebdb8b8b13d4bbe1d3592de055016d37                                latest                                                             9d20ce27b0de        50 years ago        14.9MB
...

C:\Users\zcube\go\src\github.com\google>docker run --rm -ti ko.local/sleeper-ebdb8b8b13d4bbe1d3592de055016d37 --help
Usage of /ko-app/sleeper:
  -alsologtostderr
        log to standard error as well as files
  -log_backtrace_at value
        when logging hits line file:N, emit a stack trace
  -log_dir string
        If non-empty, write log files in this directory
  -logtostderr
        log to standard error instead of files
  -mode string
        One of: sleep or copy (default "sleep")
  -stderrthreshold value
        logs at or above this threshold go to stderr
  -to string
        Where to copy this binary
  -v value
        log level for V logs
  -vmodule value
        comma-separated list of pattern=N settings for file-filtered logging

and without local

C:\Users\zcube\go\src\github.com\google>set KO_DOCKER_REPO=reg.zcube.kr/docker
C:\Users\zcube\go\src\github.com\google>C:\Users\zcube\go\src\github.com\google\ko\ko publish --platform=linux/amd64 github.com/mattmoor/warm-image/cmd/sleeper             
2020/11/18 03:15:01 Using base gcr.io/distroless/static:nonroot for github.com/mattmoor/warm-image/cmd/sleeper
2020/11/18 03:15:01 No matching credentials were found, falling back on anonymous
2020/11/18 03:15:03 Building github.com/mattmoor/warm-image/cmd/sleeper for linux/amd64
2020/11/18 03:15:04 Publishing reg.zcube.kr/docker/sleeper-ebdb8b8b13d4bbe1d3592de055016d37:latest
2020/11/18 03:15:05 failed to publish images: error publishing ko://github.com/mattmoor/warm-image/cmd/sleeper: HEAD https://reg.zcube.kr/v2/docker/sleeper-ebdb8b8b13d4bbe1d3592de055016d37/blobs/sha256:39e1bf9c1e20c05c5f7518da99343cd96ff7c3f07b1efafc92f220112945d067: unsupported status code 401

It works. The 401 error is because my registry is not ready.

Thanks.

@ZCube
Copy link
Author

ZCube commented Nov 17, 2020

ko publish ./cmd/ko

set KO_DOCKER_REPO=reg.zcube.kr/docker

C:\Users\zcube\go\src\github.com\google\ko>ko publish ./cmd/ko
2020/11/18 03:26:41 Using base gcr.io/distroless/static:nonroot for github.com/google/ko/cmd/ko
2020/11/18 03:26:41 No matching credentials were found, falling back on anonymous
2020/11/18 03:26:43 Building github.com/google/ko/cmd/ko for linux/amd64
2020/11/18 03:26:56 Publishing reg.zcube.kr/docker/ko-099ba5bcefdead87f92606265fb99ac0:latest
2020/11/18 03:26:56 failed to publish images: error publishing ko://github.com/google/ko/cmd/ko: HEAD https://reg.zcube.kr/v2/docker/ko-099ba5bcefdead87f92606265fb99ac0/blobs/sha256:72164b581b02b1eb297b403bcc8fc1bfa245cb52e103a3a525a0835a58ff58e2: unsupported status code 401

@jonjohnsonjr
Copy link
Collaborator

Thank you for your help!

C:\Users\zcube\go\src\github.com\google\ko>ko publish ./cmd/ko

Does this break if you use backslash? Maybe not worth fixing but I am just curious.

@ZCube
Copy link
Author

ZCube commented Nov 17, 2020

C:\Users\zcube\go\src\github.com\google\ko>ko publish .\cmd\ko

This fails. What you need to create is the URL path, not the operating system's file path.

C:\Users\zcube\go\src\github.com\google\ko>ko publish ./cmd/ko
2020/11/18 03:55:15 Using base gcr.io/distroless/static:nonroot for github.com/google/ko/cmd/ko
2020/11/18 03:55:15 No matching credentials were found, falling back on anonymous
2020/11/18 03:55:17 Building github.com/google/ko/cmd/ko for linux/amd64
2020/11/18 03:55:21 Publishing reg.zcube.kr/docker/ko-099ba5bcefdead87f92606265fb99ac0:latest
2020/11/18 03:55:21 failed to publish images: error publishing ko://github.com/google/ko/cmd/ko: HEAD https://reg.zcube.kr/v2/docker/ko-099ba5bcefdead87f92606265fb99ac0/blobs/sha256:e59bd8947ac7af2c8f4403b183326986ab554bbc262739cf5d9d596c7c7a3aca: unsupported status code 401
C:\Users\zcube\go\src\github.com\google\ko>ko publish .\cmd\ko
2020/11/18 03:55:26 Using base gcr.io/distroless/static:nonroot for .\cmd\ko
2020/11/18 03:55:26 No matching credentials were found, falling back on anonymous
2020/11/18 03:55:28 Building .\cmd\ko for linux/amd64
2020/11/18 03:55:32 failed to publish images: error publishing ko://.\cmd\ko: repository can only contain the runes `abcdefghijklmnopqrstuvwxyz0123456789_-./`: docker/.\cmd\ko-4f1cdbd9822e4e6955d23ffb7c3b30ac

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 a pull request may close this issue.

2 participants