-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Add yaml tag filepath
that converts marked fields to absolute paths.
#5194
Conversation
Codecov Report
@@ Coverage Diff @@
## master #5194 +/- ##
==========================================
- Coverage 71.82% 71.75% -0.07%
==========================================
Files 387 388 +1
Lines 13928 14008 +80
==========================================
+ Hits 10004 10052 +48
- Misses 3190 3211 +21
- Partials 734 745 +11
Continue to review full report at Codecov.
|
something's wrong with the |
@@ -37,6 +37,8 @@ import ( | |||
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/util" | |||
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/validation" | |||
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/update" | |||
skutil "github.com/GoogleContainerTools/skaffold/pkg/skaffold/util" |
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: we usually call this pkgutil
i think
switch parentStruct.Kind() { | ||
case reflect.Struct: | ||
t := parentStruct.Type() | ||
var errs []error |
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.
did my yearly reading on handling multiple errors in go, and i realized something i hadn't before: errors.Wrap
is actually meant to handle this. https://golang.org/doc/go1.13#error_wrapping
the idea is that for each successive error you encounter, you wrap it in the previous error: errors.Wrap(prevErr, newErr)
.
then later when you get that fully wrapped error, you continuously call errors.Unwrap
until you get nil - do that in a while loop and you can unwind the errors, like popping them off a stack.
anyway, multiple error handling in go is stupid any way you slice it so i'm not gonna say you should do this in this PR, but just wanted to share my revelation :)
closing in favor of #5205. We retain the current behavior of CWD being the base dir. |
Fixes: #5204
This PR introduces a new yaml tag
filepath
forconfig.go
which converts the marked field to an absolute path.This is useful since the current code assumes all relative paths in the skaffold config are defined from the
os.Getwd()
directory. With #5160 we'll open up support for multiple skaffold configs. Doing an upfront file path massaging avoids having to maintain the info for base paths for each config individually which can be error prone.It also fixes this assumption that the current working directory isn't the skaffold config location but the skaffold executable dir.
(comment on context.go)
Followup: After this is merged, we can remove
WorkingDir
fromruncontext
and manyfilepath.Join
s strewn throughout the codebase become redundant.