-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
kfctl support relative path #4331
Conversation
bootstrap/pkg/utils/k8utils.go
Outdated
|
||
log.Infof("Downloading %v to %v", configFile, appFile) | ||
err = gogetter.GetFile(appFile, configFile) | ||
// Check if configFile is a remote file. |
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 we refactor the code to make this easier to test?
One thought would be to define a function isRemoteFile and then we could add a unittest to cover the cases
- remote URI
- relative path
- absolute 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.
done
test error:
related to kubeflow/testing#490? |
/retest |
1 similar comment
/retest |
} | ||
|
||
// If the config file is a remote URI, check to see if the current directory | ||
// is empty because we will be generating the KfApp there. | ||
cwd := "" |
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.
why initialie to "" as opposed to getCwd()?
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.
Is this the current directory or is it a bool indicating whether its empty?
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.
nit: Should we clean this code up a bit? isCwdEmpty is returning the current directory but only if its empty.
That's a bit convulated. Should we change isCwdEmpty to isDirEmpty(cwd) and return a bool
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.
done
bootstrap/pkg/utils/k8utils.go
Outdated
Code: int(kfapis.INVALID_ARGUMENT), | ||
Message: fmt.Sprintf("Error parsing file path: %v", err), | ||
} | ||
} else { |
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.
nit: move the code out of the else block since code in the if statement will never reach it.
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.
done
filePath: "http://github.com", | ||
isRemote: true, | ||
}, | ||
{ |
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.
nit: add the test case "abc.txt"
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.
done
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.
Reviewable status: 0 of 4 files reviewed, 5 unresolved discussions (waiting on @jlewi, @lluunn, and @richardsliu)
bootstrap/pkg/kfapp/coordinator/coordinator.go, line 352 at r2 (raw file):
if isRemoteFile { cwd, err = os.Getwd() if err != nil {
I think we can replace this if/else block and just do
c.kfDef.Spec.Appdir= path.Dir(appFile)
At this point appFile should be the path to a local File because
- Either cfgFile is a local file and we set appFile=localFile
- We copied the remote file to the current directory and appFile is the local path it was copied to.
/hold |
/hold cancel |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: jlewi The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
* support relative path * refactor util, add unit test * address review * fix * fix
* support relative path * refactor util, add unit test * address review * fix * fix
use neturl.Parse instead of ParseRequestURI because the latter only works with abs path.
https://golang.org/pkg/net/url/#ParseRequestURI
/cc @jlewi @richardsliu
kubeflow/kfctl#49
This change is![Reviewable](https://camo.githubusercontent.com/23b05f5fb48215c989e92cc44cf6512512d083132bd3daf689867c8d9d386888/68747470733a2f2f72657669657761626c652e696f2f7265766965775f627574746f6e2e737667)