-
Notifications
You must be signed in to change notification settings - Fork 244
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
Fix create, push and watch commands on windows #672
Fix create, push and watch commands on windows #672
Conversation
1f359dc
to
2031542
Compare
pkg/component/component.go
Outdated
@@ -131,6 +132,25 @@ func CreateFromPath(client *occlient.Client, name string, componentImageType str | |||
return nil | |||
} | |||
|
|||
// Reads file path form URL file:///C:/path/to/file to C:\path\to\file | |||
func ReadFilePath(u *url.URL) string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this functions ReadFilePath
and GenFilePath
should go in pkg/util/util.go
other than one comment, everything looks good to me, worked on my linux machine |
3005787
to
5b482dc
Compare
@surajnarwade thanks for the review. I've moved those methods to |
@kadel could you review it or assign someone? |
cc @anmolbabu @mik-dass @syamgk please review this PR |
@dgolovin @surajnarwade I will test this on a windows machine |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code LGTM. I have a few comments however. Works on Linux 👍 Need to test on Windows.
pkg/occlient/occlient.go
Outdated
@@ -1647,7 +1647,7 @@ func tar(tw *taro.Writer, fileName string, destFile string) error { | |||
} | |||
splitFileName := strings.Split(fileName, destFile)[1] | |||
|
|||
hdr.Name = destFile + splitFileName | |||
hdr.Name = destFile + strings.Replace(splitFileName, "\\", "/", -1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mind adding a small comment that this is intended for Windows / Mac OS / Linux support?
pkg/util/util.go
Outdated
@@ -59,3 +62,22 @@ func NamespaceOpenShiftObject(componentName string, applicationName string) (str | |||
// Return the hyphenated namespaced name | |||
return fmt.Sprintf("%s-%s", componentName, applicationName), nil | |||
} | |||
|
|||
// Reads file path form URL file:///C:/path/to/file to C:\path\to\file | |||
func ReadFilePath(u *url.URL) string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should add tests for this.. but we can ignore this for now just so we can fix the commands on Windows for the time being. Can you add a TODO: Write tests comment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure, I'll look if I can add tests, to make PR checks back to green, if I fail, then adding TODO
is my backup plan.
@anmolbabu I think #639 is a different problem and this fix is not going to help. |
@cdrage I've added tests and comment, why replacing '\' to '/' is required. |
This LGTM! |
59dc855
to
a90d8b7
Compare
I've squashed all commits in one and fixed some typos in test messages. |
pkg/util/util.go
Outdated
|
||
// Converts file path on windows to /C:/path/to/file to work in URL | ||
func GenFileUrl(location string, os string) string { | ||
var urlPath string = location |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think string is redundant here it can be simplified to var urlPath = location
or urlPath:=location
pkg/util/util.go
Outdated
|
||
// Reads file path form URL file:///C:/path/to/file to C:\path\to\file | ||
func ReadFilePath(u *url.URL, os string) string { | ||
var location string = u.Path |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above
pkg/util/util.go
Outdated
var location string = u.Path | ||
if os == WIN { | ||
location = strings.Replace(u.Path, "/", "\\", -1) | ||
location = location[1:len(location)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be simplified to location = location[1:]
a90d8b7
to
45dd041
Compare
@mik-dass fixed. Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code LGTM and I build and ran the PR on windows and it works 👍
Unfortunately this needs a re-based as we merged in some pretty big PRs. The code LGTM however! So after re-base, feel free to merge. |
Fix adds coversion for windows paths to urls and back
45dd041
to
c73cd86
Compare
@cdrage rebased on top of master. |
Fix #641 and #635