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

Fix redundant Jib image flags generated by init #3191

Merged
merged 3 commits into from
Nov 6, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 0 additions & 2 deletions pkg/skaffold/jib/jib_init.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,12 @@ func (j Jib) CreateArtifact(manifestImage string) *latest.Artifact {
if j.Project != "" {
jibMaven.Project = j.Project
}
jibMaven.Flags = []string{"-Dimage=" + manifestImage}
a.ArtifactType = latest.ArtifactType{JibArtifact: jibMaven}
} else if j.BuilderName == PluginName(JibGradle) {
jibGradle := &latest.JibArtifact{Type: string(JibGradle)}
if j.Project != "" {
jibGradle.Project = j.Project
}
jibGradle.Flags = []string{"-Dimage=" + manifestImage}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should have been --image too, I think?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-Dimage= will work as well, and I know --image doesn't work when put before, say, jibDockerBuild, so I prefer it to --image. It's safer.

a.ArtifactType = latest.ArtifactType{JibArtifact: jibGradle}
}

Expand Down
28 changes: 11 additions & 17 deletions pkg/skaffold/jib/jib_init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,23 +187,19 @@ func TestCreateArtifact(t *testing.T) {
config: Jib{BuilderName: "Jib Gradle Plugin", FilePath: filepath.Join("path", "to", "build.gradle"), Image: "image", Project: "project"},
manifestImage: "different-image",
expectedArtifact: latest.Artifact{
ImageName: "different-image",
Workspace: filepath.Join("path", "to"),
ArtifactType: latest.ArtifactType{
JibArtifact: &latest.JibArtifact{Project: "project", Flags: []string{"-Dimage=different-image"}, Type: string(JibGradle)},
},
ImageName: "different-image",
Workspace: filepath.Join("path", "to"),
ArtifactType: latest.ArtifactType{JibArtifact: &latest.JibArtifact{Project: "project", Type: string(JibGradle)}},
},
},
{
description: "jib gradle without image and project",
config: Jib{BuilderName: "Jib Gradle Plugin", FilePath: filepath.Join("path", "to", "build.gradle")},
manifestImage: "different-image",
expectedArtifact: latest.Artifact{
ImageName: "different-image",
Workspace: filepath.Join("path", "to"),
ArtifactType: latest.ArtifactType{
JibArtifact: &latest.JibArtifact{Flags: []string{"-Dimage=different-image"}, Type: string(JibGradle)},
},
ImageName: "different-image",
Workspace: filepath.Join("path", "to"),
ArtifactType: latest.ArtifactType{JibArtifact: &latest.JibArtifact{Type: string(JibGradle)}},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

About #3190 (comment), is it easy to get rid of type: gradle or it is safe to put them?

Copy link
Contributor Author

@TadCordle TadCordle Nov 6, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@briandealwis would know better than I. But I can try some stuff.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be safe to remove.

},
},
{
Expand All @@ -213,19 +209,17 @@ func TestCreateArtifact(t *testing.T) {
expectedArtifact: latest.Artifact{
ImageName: "different-image",
Workspace: filepath.Join("path", "to"),
ArtifactType: latest.ArtifactType{JibArtifact: &latest.JibArtifact{Project: "project", Flags: []string{"-Dimage=different-image"}, Type: string(JibMaven)}},
ArtifactType: latest.ArtifactType{JibArtifact: &latest.JibArtifact{Project: "project", Type: string(JibMaven)}},
},
},
{
description: "jib maven without image and project",
config: Jib{BuilderName: "Jib Maven Plugin", FilePath: filepath.Join("path", "to", "pom.xml")},
manifestImage: "different-image",
expectedArtifact: latest.Artifact{
ImageName: "different-image",
Workspace: filepath.Join("path", "to"),
ArtifactType: latest.ArtifactType{
JibArtifact: &latest.JibArtifact{Flags: []string{"-Dimage=different-image"}, Type: string(JibMaven)},
},
ImageName: "different-image",
Workspace: filepath.Join("path", "to"),
ArtifactType: latest.ArtifactType{JibArtifact: &latest.JibArtifact{Type: string(JibMaven)}},
},
},
{
Expand All @@ -234,7 +228,7 @@ func TestCreateArtifact(t *testing.T) {
manifestImage: "different-image",
expectedArtifact: latest.Artifact{
ImageName: "different-image",
ArtifactType: latest.ArtifactType{JibArtifact: &latest.JibArtifact{Flags: []string{"-Dimage=different-image"}, Type: string(JibGradle)}},
ArtifactType: latest.ArtifactType{JibArtifact: &latest.JibArtifact{Type: string(JibGradle)}},
},
},
}
Expand Down