Skip to content
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

Always add image flag to jib builders in skaffold init #2854

Merged
merged 1 commit into from
Sep 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 3 additions & 10 deletions pkg/skaffold/jib/jib_init.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,7 @@ func (j Jib) Describe() string {
func (j Jib) CreateArtifact(manifestImage string) *latest.Artifact {
workspace := filepath.Dir(j.FilePath)

a := &latest.Artifact{ImageName: j.Image}
if j.Image == "" {
a.ImageName = manifestImage
}
a := &latest.Artifact{ImageName: manifestImage}

if workspace != "." {
a.Workspace = workspace
Expand All @@ -74,19 +71,15 @@ func (j Jib) CreateArtifact(manifestImage string) *latest.Artifact {
if j.Project != "" {
jibMaven.Module = j.Project
}
if j.Image == "" {
jibMaven.Flags = []string{"-Dimage=" + manifestImage}
}
jibMaven.Flags = []string{"-Dimage=" + manifestImage}
a.ArtifactType = latest.ArtifactType{JibMavenArtifact: jibMaven}

} else if j.BuilderName == JibGradle.Name() {
jibGradle := &latest.JibGradleArtifact{}
if j.Project != "" {
jibGradle.Project = j.Project
}
if j.Image == "" {
jibGradle.Flags = []string{"-Dimage=" + manifestImage}
}
jibGradle.Flags = []string{"-Dimage=" + manifestImage}
a.ArtifactType = latest.ArtifactType{JibGradleArtifact: jibGradle}
}

Expand Down
22 changes: 10 additions & 12 deletions pkg/skaffold/jib/jib_init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,10 @@ func TestCreateArtifact(t *testing.T) {
config: Jib{BuilderName: JibGradle.Name(), FilePath: filepath.Join("path", "to", "build.gradle"), Image: "image", Project: "project"},
manifestImage: "different-image",
expectedArtifact: latest.Artifact{
ImageName: "image",
ImageName: "different-image",
Workspace: filepath.Join("path", "to"),
ArtifactType: latest.ArtifactType{
JibGradleArtifact: &latest.JibGradleArtifact{Project: "project"},
JibGradleArtifact: &latest.JibGradleArtifact{Project: "project", Flags: []string{"-Dimage=different-image"}},
},
},
},
Expand All @@ -173,9 +173,7 @@ func TestCreateArtifact(t *testing.T) {
ImageName: "different-image",
Workspace: filepath.Join("path", "to"),
ArtifactType: latest.ArtifactType{
JibGradleArtifact: &latest.JibGradleArtifact{
Flags: []string{"-Dimage=different-image"},
},
JibGradleArtifact: &latest.JibGradleArtifact{Flags: []string{"-Dimage=different-image"}},
},
},
},
Expand All @@ -184,10 +182,10 @@ func TestCreateArtifact(t *testing.T) {
config: Jib{BuilderName: JibMaven.Name(), FilePath: filepath.Join("path", "to", "pom.xml"), Image: "image", Project: "project"},
manifestImage: "different-image",
expectedArtifact: latest.Artifact{
ImageName: "image",
ImageName: "different-image",
Workspace: filepath.Join("path", "to"),
ArtifactType: latest.ArtifactType{
JibMavenArtifact: &latest.JibMavenArtifact{Module: "project"},
JibMavenArtifact: &latest.JibMavenArtifact{Module: "project", Flags: []string{"-Dimage=different-image"}},
},
},
},
Expand All @@ -199,9 +197,7 @@ func TestCreateArtifact(t *testing.T) {
ImageName: "different-image",
Workspace: filepath.Join("path", "to"),
ArtifactType: latest.ArtifactType{
JibMavenArtifact: &latest.JibMavenArtifact{
Flags: []string{"-Dimage=different-image"},
},
JibMavenArtifact: &latest.JibMavenArtifact{Flags: []string{"-Dimage=different-image"}},
},
},
},
Expand All @@ -210,8 +206,10 @@ func TestCreateArtifact(t *testing.T) {
config: Jib{BuilderName: JibGradle.Name(), FilePath: "build.gradle", Image: "image"},
manifestImage: "different-image",
expectedArtifact: latest.Artifact{
ImageName: "image",
ArtifactType: latest.ArtifactType{JibGradleArtifact: &latest.JibGradleArtifact{}},
ImageName: "different-image",
ArtifactType: latest.ArtifactType{
JibGradleArtifact: &latest.JibGradleArtifact{Flags: []string{"-Dimage=different-image"}},
},
},
},
}
Expand Down