-
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
Update skaffold init --artifact to use JSON structs instead of paths #2364
Update skaffold init --artifact to use JSON structs instead of paths #2364
Conversation
…d into jib-skaffold-init
…d into jib-skaffold-init
…d into jib-skaffold-init
…d into jib-skaffold-init
…kaffold into jib-skaffold-init
…d into update-skaffold-init-analyze
…kaffold into jib-skaffold-init
…d into update-skaffold-init-analyze
…kaffold into jib-skaffold-init
cmd/skaffold/app/cmd/init.go
Outdated
@@ -42,7 +42,7 @@ func NewCmdInit() *cobra.Command { | |||
f.BoolVar(&skipBuild, "skip-build", false, "Skip generating build artifacts in Skaffold config") | |||
f.BoolVar(&force, "force", false, "Force the generation of the Skaffold config") | |||
f.StringVar(&composeFile, "compose-file", "", "Initialize from a docker-compose file") | |||
f.StringSliceVarP(&cliArtifacts, "artifact", "a", nil, "'='-delimited dockerfile/image pair to generate build artifact\n(example: --artifact=/web/Dockerfile.web=gcr.io/web-project/image)") | |||
f.StringArrayVarP(&cliArtifacts, "artifact", "a", nil, "'='-delimited builder JSON/image pair to generate build artifact\n(example: --artifact='{\"name\":\"Docker\",\"payload\":{\"path\":\"/web/Dockerfile.web\"}}=gcr.io/web-project/image')") |
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.
Just asking... won't /web/Dockerfile.web
read more natural without the leading /
? It may usually be a relative path? I can't remember exactly, but can this handle absolute path properly?
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.
Looks good to me.
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.
in principle I think I'm fine with this approach. the JSON fields feel a little weird to me though.
--artifact '{"name": "Docker", "payload": {"path": "/path"}}=gcr.io/repo/image'
this reads to me like "the name of this artifact is Docker" rather than "the name of the builder this artifact is meant for is Docker", and it's confusing what the "payload" is. also, we have this entire JSON struct "equal to" the image name, so it's just kind of hard to parse out the semantics of what is actually being provided to skaffold.
WDYT about moving the image name into the JSON payload itself? then we can change the name
field to builder
, get rid of the payload
field and just have the path
and the image
inside the JSON.
--artifact '{"builder": "Docker", "path": "/path", "image": "gcr.io/repo/image"}'
this feels a little more clear to me, and should still work with the backwards compatibility logic.
@nkubala The reason there's a separate "payload" field rather than just putting the rest of the fields in one flat json struct is because different builders have different builder-specific configuration values. Things like jib's module name, or build system (maven/gradle), or jib's I do agree about changing "name" to "builder", and moving the image after the '=' into the json as well. |
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.
LGTM when CI is green
Is there some command I can run to fix this? This doesn't happen locally. |
yeah i'm not really sure why that's happening....i've never seen this happen on any other PRs, but it seems like a travis issue. let's try rerunning and see if it fixes itself |
No luck. Looks like it's just mac too. |
Follow up to #2276 (last one probably).
This PR makes changes to
skaffold init --artifact
to allow passing in non-Docker builders via CLI. Rather than passing a path/image pair, which doesn't provide enough information for some builders,--artifact
now takes a JSON struct/image pair. Example below:This new format isn't very user friendly due to the verbosity of the JSON (although the old method of
path=image
is still available), but it should make passing non-docker builder information from IDEs using askaffold init --analyze
-->skaffold init --artifact=...
workflow fairly straightforward.