-
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 go tag filepath
that converts marked fields to absolute paths
#5205
Add go tag filepath
that converts marked fields to absolute paths
#5205
Conversation
Codecov Report
@@ Coverage Diff @@
## master #5205 +/- ##
==========================================
- Coverage 71.82% 71.82% -0.01%
==========================================
Files 387 388 +1
Lines 13928 14036 +108
==========================================
+ Hits 10004 10081 +77
- Misses 3190 3208 +18
- Partials 734 747 +13
Continue to review full report at Codecov.
|
@@ -12,7 +12,7 @@
build:
artifacts:
- image: gcr.io/first-week-244218/getting-started-pipeline
- context: /skaffold/integration/testdata/generate_pipeline/existing_other
+ context: .
kaniko: {}
tagPolicy:
gitCommit: {} |
pkg/skaffold/yamltags/paths.go
Outdated
} | ||
|
||
func filepathTagExists(f reflect.StructField) bool { | ||
yamltags, ok := f.Tag.Lookup("yamltags") |
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.
yamltags
just doesn't seem to be appropriate. Is there some prior art that we could leverage here, like the Go validator's dir
and file
types??
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.
yamltags
just doesn't seem to be appropriate.
We are already using yamltags
as the key for custom validation tags. Although I don't mind making this one different.
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.
maybe convert: "dir"
? I think validate isn't correct either since we aren't validating the actual directory exists.
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 there some prior art that we could leverage here, like the Go validator's dir and file types??
I think that the validator
package is validating the dir or file exists on the filesystem, which isn't what we're trying to do.
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.
Although we are bashing these values to make them reference to files and directories on disk, these values may be relative to places other than the current directory (e.g., within an artifact workspace).
After discussing with @briandealwis, removed the invocation of |
I think this looks good. As for Brian's point about using |
My point is really that these has nothing to do with YAML. Our Why don't we add a |
filepath
that converts marked fields to absolute pathsfilepath
that converts marked fields to absolute paths
Updated. PTAL @briandealwis, @MarlonGamez |
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.
Should pkg/skaffold/yamltags/paths*.go
be moved to pkg/skaffold/config
?
This PR introduces a new tag
skaffold:"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.User facing changes:
There are no user facing changes. We retain the current behavior of relative path base being the CWD.