From 20c6878100c21815b5fd31e9e54db9a2d2df8b0f Mon Sep 17 00:00:00 2001 From: Marlon Gamez Date: Wed, 4 Nov 2020 15:54:37 -0800 Subject: [PATCH 1/5] expand init generate API to support specifying context for artifacts --- .../initializer/build/builders_test.go | 26 +++++++++++----- pkg/skaffold/initializer/build/cli.go | 30 +++++++++++-------- pkg/skaffold/initializer/build/init.go | 2 +- pkg/skaffold/initializer/build/util.go | 13 ++++++-- pkg/skaffold/initializer/config_test.go | 2 +- 5 files changed, 49 insertions(+), 24 deletions(-) diff --git a/pkg/skaffold/initializer/build/builders_test.go b/pkg/skaffold/initializer/build/builders_test.go index eea58ff39a0..1ed716efdfd 100644 --- a/pkg/skaffold/initializer/build/builders_test.go +++ b/pkg/skaffold/initializer/build/builders_test.go @@ -242,10 +242,11 @@ func TestAutoSelectBuilders(t *testing.T) { func TestProcessCliArtifacts(t *testing.T) { tests := []struct { - description string - artifacts []string - shouldErr bool - expectedPairs []BuilderImagePair + description string + artifacts []string + shouldErr bool + expectedPairs []BuilderImagePair + expectedWorkspaces []string }{ { description: "Invalid pairs", @@ -277,8 +278,8 @@ func TestProcessCliArtifacts(t *testing.T) { { description: "Valid", artifacts: []string{ - `{"builder":"Docker","payload":{"path":"/path/to/Dockerfile"},"image":"image1"}`, - `{"builder":"Jib Gradle Plugin","payload":{"path":"/path/to/build.gradle"},"image":"image2"}`, + `{"builder":"Docker","payload":{"path":"/path/to/Dockerfile"},"image":"image1", "context": "path/to/docker/workspace"}`, + `{"builder":"Jib Gradle Plugin","payload":{"path":"/path/to/build.gradle"},"image":"image2", "context":"path/to/jib/workspace"}`, `{"builder":"Jib Maven Plugin","payload":{"path":"/path/to/pom.xml","project":"project-name","image":"testImage"},"image":"image3"}`, `{"builder":"Buildpacks","payload":{"path":"/path/to/package.json"},"image":"image4"}`, }, @@ -299,15 +300,26 @@ func TestProcessCliArtifacts(t *testing.T) { Builder: buildpacks.ArtifactConfig{File: "/path/to/package.json"}, ImageName: "image4", }, + { + Builder: docker.ArtifactConfig{File: "/path/to/Dockerfile2"}, + ImageName: "image5", + }, + }, + expectedWorkspaces: []string{ + "path/to/docker/workspace", + "path/to/jib/workspace", + "", + "", }, }, } for _, test := range tests { testutil.Run(t, test.description, func(t *testutil.T) { - pairs, err := processCliArtifacts(test.artifacts) + pairs, workspaces, err := processCliArtifacts(test.artifacts) t.CheckErrorAndDeepEqual(test.shouldErr, err, test.expectedPairs, pairs) + t.CheckDeepEqual(test.expectedWorkspaces, workspaces) }) } } diff --git a/pkg/skaffold/initializer/build/cli.go b/pkg/skaffold/initializer/build/cli.go index 724c1609ebb..351c9869e97 100644 --- a/pkg/skaffold/initializer/build/cli.go +++ b/pkg/skaffold/initializer/build/cli.go @@ -32,6 +32,7 @@ import ( type cliBuildInitializer struct { cliArtifacts []string builderImagePairs []BuilderImagePair + workspaces []string builders []InitBuilder skipBuild bool enableNewFormat bool @@ -49,7 +50,7 @@ func (c *cliBuildInitializer) ProcessImages(images []string) error { func (c *cliBuildInitializer) BuildConfig() latest.BuildConfig { return latest.BuildConfig{ - Artifacts: Artifacts(c.builderImagePairs), + Artifacts: Artifacts(c.builderImagePairs, c.workspaces), } } @@ -62,29 +63,32 @@ func (c *cliBuildInitializer) GenerateManifests() (map[GeneratedBuilderImagePair } func (c *cliBuildInitializer) processCliArtifacts() error { - pairs, err := processCliArtifacts(c.cliArtifacts) + pairs, workspaces, err := processCliArtifacts(c.cliArtifacts) if err != nil { return err } c.builderImagePairs = pairs + c.workspaces = workspaces return nil } -func processCliArtifacts(cliArtifacts []string) ([]BuilderImagePair, error) { +func processCliArtifacts(cliArtifacts []string) ([]BuilderImagePair, []string, error) { var pairs []BuilderImagePair + var workspaces []string for _, artifact := range cliArtifacts { - // Parses JSON in the form of: {"builder":"Name of Builder","payload":{...},"image":"image.name"}. + // Parses JSON in the form of: {"builder":"Name of Builder","payload":{...},"image":"image.name","context":"artifact.context"}. // The builder field is parsed first to determine the builder type, and the payload is parsed // afterwards once the type is determined. a := struct { - Name string `json:"builder"` - Image string `json:"image"` + Name string `json:"builder"` + Image string `json:"image"` + Workspace string `json:"context"` }{} if err := json.Unmarshal([]byte(artifact), &a); err != nil { // Not JSON, use backwards compatible method parts := strings.Split(artifact, "=") if len(parts) != 2 { - return nil, fmt.Errorf("malformed artifact provided: %s", artifact) + return nil, nil, fmt.Errorf("malformed artifact provided: %s", artifact) } pairs = append(pairs, BuilderImagePair{ Builder: docker.ArtifactConfig{File: parts[0]}, @@ -100,7 +104,7 @@ func processCliArtifacts(cliArtifacts []string) ([]BuilderImagePair, error) { Payload docker.ArtifactConfig `json:"payload"` }{} if err := json.Unmarshal([]byte(artifact), &parsed); err != nil { - return nil, err + return nil, nil, err } pair := BuilderImagePair{Builder: parsed.Payload, ImageName: a.Image} pairs = append(pairs, pair) @@ -111,7 +115,7 @@ func processCliArtifacts(cliArtifacts []string) ([]BuilderImagePair, error) { Payload jib.ArtifactConfig `json:"payload"` }{} if err := json.Unmarshal([]byte(artifact), &parsed); err != nil { - return nil, err + return nil, nil, err } parsed.Payload.BuilderName = a.Name pair := BuilderImagePair{Builder: parsed.Payload, ImageName: a.Image} @@ -122,14 +126,16 @@ func processCliArtifacts(cliArtifacts []string) ([]BuilderImagePair, error) { Payload buildpacks.ArtifactConfig `json:"payload"` }{} if err := json.Unmarshal([]byte(artifact), &parsed); err != nil { - return nil, err + return nil, nil, err } pair := BuilderImagePair{Builder: parsed.Payload, ImageName: a.Image} pairs = append(pairs, pair) default: - return nil, fmt.Errorf("unknown builder type in CLI artifacts: %q", a.Name) + return nil, nil, fmt.Errorf("unknown builder type in CLI artifacts: %q", a.Name) } + + workspaces = append(workspaces, a.Workspace) } - return pairs, nil + return pairs, workspaces, nil } diff --git a/pkg/skaffold/initializer/build/init.go b/pkg/skaffold/initializer/build/init.go index 6d6dcdf35eb..d9d1dab7f2b 100644 --- a/pkg/skaffold/initializer/build/init.go +++ b/pkg/skaffold/initializer/build/init.go @@ -54,7 +54,7 @@ func (d *defaultBuildInitializer) ProcessImages(images []string) error { func (d *defaultBuildInitializer) BuildConfig() latest.BuildConfig { return latest.BuildConfig{ - Artifacts: Artifacts(d.builderImagePairs), + Artifacts: Artifacts(d.builderImagePairs, nil), } } diff --git a/pkg/skaffold/initializer/build/util.go b/pkg/skaffold/initializer/build/util.go index 05eaf0b84c6..cfce9a5f942 100644 --- a/pkg/skaffold/initializer/build/util.go +++ b/pkg/skaffold/initializer/build/util.go @@ -62,16 +62,23 @@ func findExactlyOneMatchingBuilder(builderConfigs []InitBuilder, image string) i return matchingConfigIndex } -func Artifacts(pairs []BuilderImagePair) []*latest.Artifact { +// Artifacts takes builder image pairs and workspaces and creates a list of latest.Artifacts from the data. +func Artifacts(pairs []BuilderImagePair, workspaces []string) []*latest.Artifact { var artifacts []*latest.Artifact - for _, pair := range pairs { + for i, pair := range pairs { artifact := &latest.Artifact{ ImageName: pair.ImageName, ArtifactType: pair.Builder.ArtifactType(), } - workspace := filepath.Dir(pair.Builder.Path()) + var workspace string + if workspaces != nil { + workspace = workspaces[i] + } + if workspace == "" { + workspace = filepath.Dir(pair.Builder.Path()) + } if workspace != "." { fmt.Fprintf(os.Stdout, "using non standard workspace: %s\n", workspace) artifact.Workspace = workspace diff --git a/pkg/skaffold/initializer/config_test.go b/pkg/skaffold/initializer/config_test.go index bee137b98dc..382f75b0fc4 100644 --- a/pkg/skaffold/initializer/config_test.go +++ b/pkg/skaffold/initializer/config_test.go @@ -63,7 +63,7 @@ func (s stubBuildInitializer) PrintAnalysis(io.Writer) error { func (s stubBuildInitializer) BuildConfig() latest.BuildConfig { return latest.BuildConfig{ - Artifacts: build.Artifacts(s.pairs), + Artifacts: build.Artifacts(s.pairs, nil), } } From 0ad9b083f902c8c0ef294387a96bcb4e035828a5 Mon Sep 17 00:00:00 2001 From: Marlon Gamez Date: Thu, 5 Nov 2020 13:49:22 -0800 Subject: [PATCH 2/5] fix test --- pkg/skaffold/initializer/build/builders_test.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/pkg/skaffold/initializer/build/builders_test.go b/pkg/skaffold/initializer/build/builders_test.go index 1ed716efdfd..cee1e05796a 100644 --- a/pkg/skaffold/initializer/build/builders_test.go +++ b/pkg/skaffold/initializer/build/builders_test.go @@ -300,10 +300,6 @@ func TestProcessCliArtifacts(t *testing.T) { Builder: buildpacks.ArtifactConfig{File: "/path/to/package.json"}, ImageName: "image4", }, - { - Builder: docker.ArtifactConfig{File: "/path/to/Dockerfile2"}, - ImageName: "image5", - }, }, expectedWorkspaces: []string{ "path/to/docker/workspace", From d7d59babb5bb2aac3144c09cba9d53c933748499 Mon Sep 17 00:00:00 2001 From: Marlon Gamez Date: Mon, 9 Nov 2020 14:52:33 -0800 Subject: [PATCH 3/5] update docs to show example --- docs/content/en/docs/pipeline-stages/init.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/content/en/docs/pipeline-stages/init.md b/docs/content/en/docs/pipeline-stages/init.md index b768ef2c171..684bf54bb5b 100644 --- a/docs/content/en/docs/pipeline-stages/init.md +++ b/docs/content/en/docs/pipeline-stages/init.md @@ -164,7 +164,7 @@ For multiple artifacts, use `--artifact` multiple times. ```bash microservices$skaffold init \ -a '{"builder":"Docker","payload":{"path":"leeroy-app/Dockerfile"},"image":"gcr.io/k8s-skaffold/leeroy-app"}' \ - -a '{"builder":"Docker","payload":{"path":"leeroy-web/Dockerfile"},"image":"gcr.io/k8s-skaffold/leeroy-web"}' + -a '{"builder":"Docker","payload":{"path":"leeroy-web/Dockerfile"},"image":"gcr.io/k8s-skaffold/leeroy-web","context":"path/to/context"}' ``` will produce an `skaffold.yaml` config like this @@ -178,7 +178,7 @@ build: - image: gcr.io/k8s-skaffold/leeroy-app context: leeroy-app - image: gcr.io/k8s-skaffold/leeroy-web - context: leeroy-web + context: path/to/context deploy: kubectl: manifests: From e327cc6587609e25ba66c04c356c9739719072eb Mon Sep 17 00:00:00 2001 From: Marlon Gamez Date: Tue, 10 Nov 2020 10:40:17 -0800 Subject: [PATCH 4/5] make workspace part of BuilderImagePair --- pkg/skaffold/initializer/build/builders.go | 1 + .../initializer/build/builders_test.go | 19 +++++------- pkg/skaffold/initializer/build/cli.go | 29 ++++++++----------- pkg/skaffold/initializer/build/init.go | 2 +- pkg/skaffold/initializer/build/json_test.go | 2 +- pkg/skaffold/initializer/build/util.go | 9 ++---- pkg/skaffold/initializer/config_test.go | 2 +- 7 files changed, 26 insertions(+), 38 deletions(-) diff --git a/pkg/skaffold/initializer/build/builders.go b/pkg/skaffold/initializer/build/builders.go index 4771fc11ded..99b1b45d7a8 100644 --- a/pkg/skaffold/initializer/build/builders.go +++ b/pkg/skaffold/initializer/build/builders.go @@ -51,6 +51,7 @@ type InitBuilder interface { type BuilderImagePair struct { Builder InitBuilder ImageName string + Workspace string } // GeneratedBuilderImagePair pairs a discovered builder with a diff --git a/pkg/skaffold/initializer/build/builders_test.go b/pkg/skaffold/initializer/build/builders_test.go index cee1e05796a..4db367b0194 100644 --- a/pkg/skaffold/initializer/build/builders_test.go +++ b/pkg/skaffold/initializer/build/builders_test.go @@ -194,12 +194,12 @@ func TestAutoSelectBuilders(t *testing.T) { images: []string{"image1", "image2", "image3"}, expectedPairs: []BuilderImagePair{ { - jib.ArtifactConfig{BuilderName: jib.PluginName(jib.JibGradle), File: "build.gradle", Image: "image1"}, - "image1", + Builder: jib.ArtifactConfig{BuilderName: jib.PluginName(jib.JibGradle), File: "build.gradle", Image: "image1"}, + ImageName: "image1", }, { - jib.ArtifactConfig{BuilderName: jib.PluginName(jib.JibMaven), File: "pom.xml", Image: "image2"}, - "image2", + Builder: jib.ArtifactConfig{BuilderName: jib.PluginName(jib.JibMaven), File: "pom.xml", Image: "image2"}, + ImageName: "image2", }, }, expectedBuildersLeft: []InitBuilder{docker.ArtifactConfig{File: "Dockerfile"}}, @@ -287,10 +287,12 @@ func TestProcessCliArtifacts(t *testing.T) { { Builder: docker.ArtifactConfig{File: "/path/to/Dockerfile"}, ImageName: "image1", + Workspace: "path/to/docker/workspace", }, { Builder: jib.ArtifactConfig{BuilderName: "Jib Gradle Plugin", File: "/path/to/build.gradle"}, ImageName: "image2", + Workspace: "path/to/jib/workspace", }, { Builder: jib.ArtifactConfig{BuilderName: "Jib Maven Plugin", File: "/path/to/pom.xml", Project: "project-name", Image: "testImage"}, @@ -301,21 +303,14 @@ func TestProcessCliArtifacts(t *testing.T) { ImageName: "image4", }, }, - expectedWorkspaces: []string{ - "path/to/docker/workspace", - "path/to/jib/workspace", - "", - "", - }, }, } for _, test := range tests { testutil.Run(t, test.description, func(t *testutil.T) { - pairs, workspaces, err := processCliArtifacts(test.artifacts) + pairs, err := processCliArtifacts(test.artifacts) t.CheckErrorAndDeepEqual(test.shouldErr, err, test.expectedPairs, pairs) - t.CheckDeepEqual(test.expectedWorkspaces, workspaces) }) } } diff --git a/pkg/skaffold/initializer/build/cli.go b/pkg/skaffold/initializer/build/cli.go index 351c9869e97..b7075e9ffea 100644 --- a/pkg/skaffold/initializer/build/cli.go +++ b/pkg/skaffold/initializer/build/cli.go @@ -32,7 +32,6 @@ import ( type cliBuildInitializer struct { cliArtifacts []string builderImagePairs []BuilderImagePair - workspaces []string builders []InitBuilder skipBuild bool enableNewFormat bool @@ -50,7 +49,7 @@ func (c *cliBuildInitializer) ProcessImages(images []string) error { func (c *cliBuildInitializer) BuildConfig() latest.BuildConfig { return latest.BuildConfig{ - Artifacts: Artifacts(c.builderImagePairs, c.workspaces), + Artifacts: Artifacts(c.builderImagePairs), } } @@ -63,18 +62,16 @@ func (c *cliBuildInitializer) GenerateManifests() (map[GeneratedBuilderImagePair } func (c *cliBuildInitializer) processCliArtifacts() error { - pairs, workspaces, err := processCliArtifacts(c.cliArtifacts) + pairs, err := processCliArtifacts(c.cliArtifacts) if err != nil { return err } c.builderImagePairs = pairs - c.workspaces = workspaces return nil } -func processCliArtifacts(cliArtifacts []string) ([]BuilderImagePair, []string, error) { +func processCliArtifacts(cliArtifacts []string) ([]BuilderImagePair, error) { var pairs []BuilderImagePair - var workspaces []string for _, artifact := range cliArtifacts { // Parses JSON in the form of: {"builder":"Name of Builder","payload":{...},"image":"image.name","context":"artifact.context"}. // The builder field is parsed first to determine the builder type, and the payload is parsed @@ -88,7 +85,7 @@ func processCliArtifacts(cliArtifacts []string) ([]BuilderImagePair, []string, e // Not JSON, use backwards compatible method parts := strings.Split(artifact, "=") if len(parts) != 2 { - return nil, nil, fmt.Errorf("malformed artifact provided: %s", artifact) + return nil, fmt.Errorf("malformed artifact provided: %s", artifact) } pairs = append(pairs, BuilderImagePair{ Builder: docker.ArtifactConfig{File: parts[0]}, @@ -104,9 +101,9 @@ func processCliArtifacts(cliArtifacts []string) ([]BuilderImagePair, []string, e Payload docker.ArtifactConfig `json:"payload"` }{} if err := json.Unmarshal([]byte(artifact), &parsed); err != nil { - return nil, nil, err + return nil, err } - pair := BuilderImagePair{Builder: parsed.Payload, ImageName: a.Image} + pair := BuilderImagePair{Builder: parsed.Payload, ImageName: a.Image, Workspace: a.Workspace} pairs = append(pairs, pair) // FIXME: shouldn't use a human-readable name? @@ -115,10 +112,10 @@ func processCliArtifacts(cliArtifacts []string) ([]BuilderImagePair, []string, e Payload jib.ArtifactConfig `json:"payload"` }{} if err := json.Unmarshal([]byte(artifact), &parsed); err != nil { - return nil, nil, err + return nil, err } parsed.Payload.BuilderName = a.Name - pair := BuilderImagePair{Builder: parsed.Payload, ImageName: a.Image} + pair := BuilderImagePair{Builder: parsed.Payload, ImageName: a.Image, Workspace: a.Workspace} pairs = append(pairs, pair) case buildpacks.Name: @@ -126,16 +123,14 @@ func processCliArtifacts(cliArtifacts []string) ([]BuilderImagePair, []string, e Payload buildpacks.ArtifactConfig `json:"payload"` }{} if err := json.Unmarshal([]byte(artifact), &parsed); err != nil { - return nil, nil, err + return nil, err } - pair := BuilderImagePair{Builder: parsed.Payload, ImageName: a.Image} + pair := BuilderImagePair{Builder: parsed.Payload, ImageName: a.Image, Workspace: a.Workspace} pairs = append(pairs, pair) default: - return nil, nil, fmt.Errorf("unknown builder type in CLI artifacts: %q", a.Name) + return nil, fmt.Errorf("unknown builder type in CLI artifacts: %q", a.Name) } - - workspaces = append(workspaces, a.Workspace) } - return pairs, workspaces, nil + return pairs, nil } diff --git a/pkg/skaffold/initializer/build/init.go b/pkg/skaffold/initializer/build/init.go index d9d1dab7f2b..6d6dcdf35eb 100644 --- a/pkg/skaffold/initializer/build/init.go +++ b/pkg/skaffold/initializer/build/init.go @@ -54,7 +54,7 @@ func (d *defaultBuildInitializer) ProcessImages(images []string) error { func (d *defaultBuildInitializer) BuildConfig() latest.BuildConfig { return latest.BuildConfig{ - Artifacts: Artifacts(d.builderImagePairs, nil), + Artifacts: Artifacts(d.builderImagePairs), } } diff --git a/pkg/skaffold/initializer/build/json_test.go b/pkg/skaffold/initializer/build/json_test.go index f5d6178f8be..dff251963f2 100644 --- a/pkg/skaffold/initializer/build/json_test.go +++ b/pkg/skaffold/initializer/build/json_test.go @@ -37,7 +37,7 @@ func TestPrintAnalyzeJSON(t *testing.T) { }{ { description: "builders and images with pairs", - pairs: []BuilderImagePair{{jib.ArtifactConfig{BuilderName: jib.PluginName(jib.JibGradle), Image: "image1", File: "build.gradle", Project: "project"}, "image1"}}, + pairs: []BuilderImagePair{{Builder: jib.ArtifactConfig{BuilderName: jib.PluginName(jib.JibGradle), Image: "image1", File: "build.gradle", Project: "project"}, ImageName: "image1"}}, builders: []InitBuilder{docker.ArtifactConfig{File: "Dockerfile"}}, images: []string{"image2"}, expected: `{"builders":[{"name":"Jib Gradle Plugin","payload":{"image":"image1","path":"build.gradle","project":"project"}},{"name":"Docker","payload":{"path":"Dockerfile"}}],"images":[{"name":"image1","foundMatch":true},{"name":"image2","foundMatch":false}]}` + "\n", diff --git a/pkg/skaffold/initializer/build/util.go b/pkg/skaffold/initializer/build/util.go index cfce9a5f942..be8c9ebb252 100644 --- a/pkg/skaffold/initializer/build/util.go +++ b/pkg/skaffold/initializer/build/util.go @@ -63,19 +63,16 @@ func findExactlyOneMatchingBuilder(builderConfigs []InitBuilder, image string) i } // Artifacts takes builder image pairs and workspaces and creates a list of latest.Artifacts from the data. -func Artifacts(pairs []BuilderImagePair, workspaces []string) []*latest.Artifact { +func Artifacts(pairs []BuilderImagePair) []*latest.Artifact { var artifacts []*latest.Artifact - for i, pair := range pairs { + for _, pair := range pairs { artifact := &latest.Artifact{ ImageName: pair.ImageName, ArtifactType: pair.Builder.ArtifactType(), } - var workspace string - if workspaces != nil { - workspace = workspaces[i] - } + workspace := pair.Workspace if workspace == "" { workspace = filepath.Dir(pair.Builder.Path()) } diff --git a/pkg/skaffold/initializer/config_test.go b/pkg/skaffold/initializer/config_test.go index 382f75b0fc4..bee137b98dc 100644 --- a/pkg/skaffold/initializer/config_test.go +++ b/pkg/skaffold/initializer/config_test.go @@ -63,7 +63,7 @@ func (s stubBuildInitializer) PrintAnalysis(io.Writer) error { func (s stubBuildInitializer) BuildConfig() latest.BuildConfig { return latest.BuildConfig{ - Artifacts: build.Artifacts(s.pairs, nil), + Artifacts: build.Artifacts(s.pairs), } } From d51c76fdca4dab29561e1f145222a6de49cad6a1 Mon Sep 17 00:00:00 2001 From: Marlon Gamez Date: Tue, 10 Nov 2020 13:23:09 -0800 Subject: [PATCH 5/5] fix some docs and comments --- docs/content/en/docs/pipeline-stages/init.md | 2 +- pkg/skaffold/initializer/build/cli.go | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/docs/content/en/docs/pipeline-stages/init.md b/docs/content/en/docs/pipeline-stages/init.md index 684bf54bb5b..d1d496b285e 100644 --- a/docs/content/en/docs/pipeline-stages/init.md +++ b/docs/content/en/docs/pipeline-stages/init.md @@ -162,7 +162,7 @@ To generate a skaffold `build` config, use the `--artifact` flag per artifact. For multiple artifacts, use `--artifact` multiple times. ```bash -microservices$skaffold init \ +skaffold init \ -a '{"builder":"Docker","payload":{"path":"leeroy-app/Dockerfile"},"image":"gcr.io/k8s-skaffold/leeroy-app"}' \ -a '{"builder":"Docker","payload":{"path":"leeroy-web/Dockerfile"},"image":"gcr.io/k8s-skaffold/leeroy-web","context":"path/to/context"}' ``` diff --git a/pkg/skaffold/initializer/build/cli.go b/pkg/skaffold/initializer/build/cli.go index b7075e9ffea..a955f201a90 100644 --- a/pkg/skaffold/initializer/build/cli.go +++ b/pkg/skaffold/initializer/build/cli.go @@ -73,9 +73,11 @@ func (c *cliBuildInitializer) processCliArtifacts() error { func processCliArtifacts(cliArtifacts []string) ([]BuilderImagePair, error) { var pairs []BuilderImagePair for _, artifact := range cliArtifacts { - // Parses JSON in the form of: {"builder":"Name of Builder","payload":{...},"image":"image.name","context":"artifact.context"}. - // The builder field is parsed first to determine the builder type, and the payload is parsed - // afterwards once the type is determined. + // Parses artifacts in 1 of 2 forms: + // 1. JSON in the form of: {"builder":"Name of Builder","payload":{...},"image":"image.name","context":"artifact.context"}. + // The builder field is parsed first to determine the builder type, and the payload is parsed + // afterwards once the type is determined. + // 2. Key-value pair: `path/to/Dockerfile=imageName` (deprecated, historical, Docker-only) a := struct { Name string `json:"builder"` Image string `json:"image"`