Skip to content

Commit

Permalink
kill jib profile and rewrite as flags
Browse files Browse the repository at this point in the history
  • Loading branch information
briandealwis committed Sep 5, 2019
1 parent 0504be7 commit 50bf6e0
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 54 deletions.
6 changes: 0 additions & 6 deletions docs/content/en/schemas/v1beta14.json
Original file line number Diff line number Diff line change
Expand Up @@ -1208,11 +1208,6 @@
"[\"--no-build-cache\"]"
]
},
"profile": {
"type": "string",
"description": "selects which Maven profile to activate *(Maven-only)*.",
"x-intellij-html-description": "selects which Maven profile to activate <em>(Maven-only)</em>."
},
"project": {
"type": "string",
"description": "selects which sub-project to build for multi-module builds.",
Expand All @@ -1221,7 +1216,6 @@
},
"preferredOrder": [
"project",
"profile",
"args"
],
"additionalProperties": false,
Expand Down
14 changes: 0 additions & 14 deletions pkg/skaffold/build/local/jib_maven_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,6 @@ func TestBuildJibMavenToDocker(t *testing.T) {
"mvn -Djib.console=plain jib:_skaffold-fail-if-jib-out-of-date -Djib.requiredVersion=" + jib.MinimumJibMavenVersion + " --projects module --also-make package jib:dockerBuild -Djib.containerize=module -Dimage=img:tag",
),
},
{
description: "build with module and profile",
artifact: &latest.JibArtifact{Project: "module", Profile: "profile"},
commands: testutil.CmdRun(
"mvn -Djib.console=plain jib:_skaffold-fail-if-jib-out-of-date -Djib.requiredVersion=" + jib.MinimumJibMavenVersion + " --activate-profiles profile --projects module --also-make package jib:dockerBuild -Djib.containerize=module -Dimage=img:tag",
),
},
{
description: "fail build",
artifact: &latest.JibArtifact{},
Expand Down Expand Up @@ -132,13 +125,6 @@ func TestBuildJibMavenToRegistry(t *testing.T) {
"mvn -Djib.console=plain jib:_skaffold-fail-if-jib-out-of-date -Djib.requiredVersion=" + jib.MinimumJibMavenVersion + " --projects module --also-make package jib:build -Djib.containerize=module -Dimage=img:tag",
),
},
{
description: "build with module and profile",
artifact: &latest.JibArtifact{Project: "module", Profile: "profile"},
commands: testutil.CmdRun(
"mvn -Djib.console=plain jib:_skaffold-fail-if-jib-out-of-date -Djib.requiredVersion=" + jib.MinimumJibMavenVersion + " --activate-profiles profile --projects module --also-make package jib:build -Djib.containerize=module -Dimage=img:tag",
),
},
{
description: "fail build",
artifact: &latest.JibArtifact{},
Expand Down
4 changes: 0 additions & 4 deletions pkg/skaffold/jib/jib_maven.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,6 @@ func mavenArgs(a *latest.JibArtifact) []string {
args := []string{"jib:_skaffold-fail-if-jib-out-of-date", "-Djib.requiredVersion=" + MinimumJibMavenVersion}
args = append(args, a.Flags...)

if a.Profile != "" {
args = append(args, "--activate-profiles", a.Profile)
}

if a.Project == "" {
// single-module project
args = append(args, "--non-recursive")
Expand Down
28 changes: 4 additions & 24 deletions pkg/skaffold/jib/jib_maven_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func TestGetCommandMaven(t *testing.T) {
expectedCmd func(workspace string) exec.Cmd
}{
{
description: "maven no profile",
description: "maven basic",
jibArtifact: latest.JibArtifact{},
filesInWorkspace: []string{},
expectedCmd: func(workspace string) exec.Cmd {
Expand All @@ -132,37 +132,21 @@ func TestGetCommandMaven(t *testing.T) {
},
},
{
description: "maven with profile",
jibArtifact: latest.JibArtifact{Profile: "profile"},
filesInWorkspace: []string{},
expectedCmd: func(workspace string) exec.Cmd {
return MavenCommand.CreateCommand(ctx, workspace, []string{"jib:_skaffold-fail-if-jib-out-of-date", "-Djib.requiredVersion=" + MinimumJibMavenVersion, "--activate-profiles", "profile", "--non-recursive", "jib:_skaffold-files-v2", "--quiet"})
},
},
{
description: "maven with wrapper no profile",
description: "maven with wrapper",
jibArtifact: latest.JibArtifact{},
filesInWorkspace: []string{"mvnw", "mvnw.bat"},
expectedCmd: func(workspace string) exec.Cmd {
return MavenCommand.CreateCommand(ctx, workspace, []string{"jib:_skaffold-fail-if-jib-out-of-date", "-Djib.requiredVersion=" + MinimumJibMavenVersion, "--non-recursive", "jib:_skaffold-files-v2", "--quiet"})
},
},
{
description: "maven with wrapper no profile",
description: "maven with wrapper",
jibArtifact: latest.JibArtifact{},
filesInWorkspace: []string{"mvnw", "mvnw.cmd"},
expectedCmd: func(workspace string) exec.Cmd {
return MavenCommand.CreateCommand(ctx, workspace, []string{"jib:_skaffold-fail-if-jib-out-of-date", "-Djib.requiredVersion=" + MinimumJibMavenVersion, "--non-recursive", "jib:_skaffold-files-v2", "--quiet"})
},
},
{
description: "maven with wrapper and profile",
jibArtifact: latest.JibArtifact{Profile: "profile"},
filesInWorkspace: []string{"mvnw", "mvnw.bat"},
expectedCmd: func(workspace string) exec.Cmd {
return MavenCommand.CreateCommand(ctx, workspace, []string{"jib:_skaffold-fail-if-jib-out-of-date", "-Djib.requiredVersion=" + MinimumJibMavenVersion, "--activate-profiles", "profile", "--non-recursive", "jib:_skaffold-files-v2", "--quiet"})
},
},
{
description: "maven with multi-modules",
jibArtifact: latest.JibArtifact{Project: "module"},
Expand Down Expand Up @@ -197,13 +181,9 @@ func TestGenerateMavenArgs(t *testing.T) {
}{
{latest.JibArtifact{}, "image", false, nil, []string{"-Djib.console=plain", "jib:_skaffold-fail-if-jib-out-of-date", "-Djib.requiredVersion=" + MinimumJibMavenVersion, "--non-recursive", "prepare-package", "jib:goal", "-Dimage=image"}},
{latest.JibArtifact{}, "image", true, nil, []string{"-Djib.console=plain", "jib:_skaffold-fail-if-jib-out-of-date", "-Djib.requiredVersion=" + MinimumJibMavenVersion, "--non-recursive", "-DskipTests=true", "prepare-package", "jib:goal", "-Dimage=image"}},
{latest.JibArtifact{Profile: "profile"}, "image", false, nil, []string{"-Djib.console=plain", "jib:_skaffold-fail-if-jib-out-of-date", "-Djib.requiredVersion=" + MinimumJibMavenVersion, "--activate-profiles", "profile", "--non-recursive", "prepare-package", "jib:goal", "-Dimage=image"}},
{latest.JibArtifact{Profile: "profile"}, "image", true, nil, []string{"-Djib.console=plain", "jib:_skaffold-fail-if-jib-out-of-date", "-Djib.requiredVersion=" + MinimumJibMavenVersion, "--activate-profiles", "profile", "--non-recursive", "-DskipTests=true", "prepare-package", "jib:goal", "-Dimage=image"}},
{latest.JibArtifact{Project: "module"}, "image", false, nil, []string{"-Djib.console=plain", "jib:_skaffold-fail-if-jib-out-of-date", "-Djib.requiredVersion=" + MinimumJibMavenVersion, "--projects", "module", "--also-make", "package", "jib:goal", "-Djib.containerize=module", "-Dimage=image"}},
{latest.JibArtifact{Project: "module"}, "image", true, nil, []string{"-Djib.console=plain", "jib:_skaffold-fail-if-jib-out-of-date", "-Djib.requiredVersion=" + MinimumJibMavenVersion, "--projects", "module", "--also-make", "-DskipTests=true", "package", "jib:goal", "-Djib.containerize=module", "-Dimage=image"}},
{latest.JibArtifact{Project: "module", Profile: "profile"}, "image", false, nil, []string{"-Djib.console=plain", "jib:_skaffold-fail-if-jib-out-of-date", "-Djib.requiredVersion=" + MinimumJibMavenVersion, "--activate-profiles", "profile", "--projects", "module", "--also-make", "package", "jib:goal", "-Djib.containerize=module", "-Dimage=image"}},
{latest.JibArtifact{Project: "module", Profile: "profile"}, "image", true, nil, []string{"-Djib.console=plain", "jib:_skaffold-fail-if-jib-out-of-date", "-Djib.requiredVersion=" + MinimumJibMavenVersion, "--activate-profiles", "profile", "--projects", "module", "--also-make", "-DskipTests=true", "package", "jib:goal", "-Djib.containerize=module", "-Dimage=image"}},
{latest.JibArtifact{Project: "module", Profile: "profile"}, "registry.tld/image", true, map[string]bool{"registry.tld": true}, []string{"-Djib.console=plain", "jib:_skaffold-fail-if-jib-out-of-date", "-Djib.requiredVersion=" + MinimumJibMavenVersion, "--activate-profiles", "profile", "--projects", "module", "--also-make", "-DskipTests=true", "package", "jib:goal", "-Djib.containerize=module", "-Djib.allowInsecureRegistries=true", "-Dimage=registry.tld/image"}},
{latest.JibArtifact{Project: "module"}, "registry.tld/image", true, map[string]bool{"registry.tld": true}, []string{"-Djib.console=plain", "jib:_skaffold-fail-if-jib-out-of-date", "-Djib.requiredVersion=" + MinimumJibMavenVersion, "--projects", "module", "--also-make", "-DskipTests=true", "package", "jib:goal", "-Djib.containerize=module", "-Djib.allowInsecureRegistries=true", "-Dimage=registry.tld/image"}},
}
for _, test := range tests {
args := GenerateMavenArgs("goal", test.image, &test.in, test.skipTests, test.insecureRegistries)
Expand Down
3 changes: 0 additions & 3 deletions pkg/skaffold/schema/latest/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -756,9 +756,6 @@ type JibArtifact struct {
// Project selects which sub-project to build for multi-module builds.
Project string `yaml:"project,omitempty"`

// Profile selects which Maven profile to activate *(Maven-only)*.
Profile string `yaml:"profile,omitempty"`

// Flags are additional build flags passed to the builder.
// For example: `["--no-build-cache"]`.
Flags []string `yaml:"args,omitempty"`
Expand Down
8 changes: 6 additions & 2 deletions pkg/skaffold/schema/v1beta13/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
// 2. Removals:
// jibMaven builder
// jibGradle builder
// jibMaven profile removed
// 3. No updates
func (config *SkaffoldConfig) Upgrade() (util.VersionedConfig, error) {
var newConfig next.SkaffoldConfig
Expand All @@ -49,10 +50,13 @@ func upgradeOnePipeline(oldPipeline, newPipeline interface{}) error {
for i, a := range oldBuild.Artifacts {
switch {
case a.JibMavenArtifact != nil:
flags := a.JibMavenArtifact.Flags
if a.JibMavenArtifact.Profile != "" {
flags = append(flags, "--activate-profiles", a.JibMavenArtifact.Profile)
}
newBuild.Artifacts[i].JibArtifact = &next.JibArtifact{
Project: a.JibMavenArtifact.Module,
Profile: a.JibMavenArtifact.Profile,
Flags: a.JibMavenArtifact.Flags,
Flags: flags,
}
case a.JibGradleArtifact != nil:
newBuild.Artifacts[i].JibArtifact = &next.JibArtifact{
Expand Down
3 changes: 2 additions & 1 deletion pkg/skaffold/schema/v1beta13/upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ build:
- image: gcr.io/k8s-skaffold/jib-maven
jibMaven:
args: ['-v']
profile: prof
- image: gcr.io/k8s-skaffold/jib-gradle
jibGradle:
args: ['-v']
Expand Down Expand Up @@ -96,7 +97,7 @@ build:
target: //mytarget
- image: gcr.io/k8s-skaffold/jib-maven
jib:
args: ['-v']
args: ['-v', '--activate-profiles', 'prof']
- image: gcr.io/k8s-skaffold/jib-gradle
jib:
args: ['-v']
Expand Down

0 comments on commit 50bf6e0

Please sign in to comment.