Skip to content

Commit

Permalink
Support inferred sync on Custom artifacts with a Dockerfile (#3752)
Browse files Browse the repository at this point in the history
Fixes #3751

Signed-off-by: David Gageot <[email protected]>
  • Loading branch information
dgageot authored Feb 28, 2020
1 parent 1ca0138 commit 7ee0c0b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/skaffold/sync/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,9 @@ func syncMapForArtifact(a *latest.Artifact, insecureRegistries map[string]bool)
case a.DockerArtifact != nil:
return docker.SyncMap(a.Workspace, a.DockerArtifact.DockerfilePath, a.DockerArtifact.BuildArgs, insecureRegistries)

case a.CustomArtifact != nil && a.CustomArtifact.Dependencies != nil && a.CustomArtifact.Dependencies.Dockerfile != nil:
return docker.SyncMap(a.Workspace, a.CustomArtifact.Dependencies.Dockerfile.Path, a.CustomArtifact.Dependencies.Dockerfile.BuildArgs, insecureRegistries)

case a.KanikoArtifact != nil:
return docker.SyncMap(a.Workspace, a.KanikoArtifact.DockerfilePath, a.KanikoArtifact.BuildArgs, insecureRegistries)

Expand Down
24 changes: 24 additions & 0 deletions pkg/skaffold/sync/sync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -930,6 +930,30 @@ func TestSyncMap(t *testing.T) {
},
expectedMap: map[string][]string{"main.go": {"/app/main.go"}},
},
{
description: "custom - supported",
artifactType: latest.ArtifactType{
CustomArtifact: &latest.CustomArtifact{
Dependencies: &latest.CustomDependencies{
Dockerfile: &latest.DockerfileDependency{
Path: "Dockerfile",
},
},
},
},
files: map[string]string{
"Dockerfile": "FROM alpine\nCOPY *.go /app/",
"main.go": "",
},
expectedMap: map[string][]string{"main.go": {"/app/main.go"}},
},
{
description: "custom, no dockerfile - not supported",
artifactType: latest.ArtifactType{
CustomArtifact: &latest.CustomArtifact{},
},
shouldErr: true,
},
{
description: "not supported",
artifactType: latest.ArtifactType{},
Expand Down

0 comments on commit 7ee0c0b

Please sign in to comment.