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

Allow configuring jib plugin type #2964

Merged
merged 11 commits into from
Nov 6, 2019

Conversation

briandealwis
Copy link
Member

Fixes #2963.

Note that this is a somewhat unorthodox change as it exposes an internal and previously ignored field from the v1beta14's jib config.

Description

In #2808 we unified the jibMaven and jibGradle configuration blocks into a single jib block. The Skaffold-Jib builder looks for certain files to determine the Jib plugin type (Maven or Gradle). We've had a report where Skaffold-Jib was unable to guess the Jib plugin type. This PR adds the ability to explicitly configure the jib block to specify the plugin type.

The unified JibArtifact already has a Type field which allows explicitly specifying the builder type. This field is internal and not marshalled. The intent was to expose this field to encode a Go enum (with corresponding MarshalYAML() and UnmarshalYAML()) but I punted at the time as it required teaching the schema generator to output JSON schema enum. But I realized that the pkg/skaffold/schema/validation approach was easier, but it requires changing the type of Type.

User facing changes
This PR changes the type of JibArtifact's Type field and exposes it. As a result:

  • v1beta14 and v1beta15's jib now have optional type fields
  • skaffold fix on v1beta13 jibMaven and jibGradle configurations will now have a type field

Reviewer Notes

  • The code flow looks good.
  • Unit test added.
  • User facing changes look good.

Release Notes

jib artifacts can explicitly specify the plugin type as maven or gradle

Copy link
Member

@chanseokoh chanseokoh left a comment

Choose a reason for hiding this comment

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

Is it possible to update old schemas? There's a build error saying you shouldn't (if I understood it right).

pkg/skaffold/schema/validation/validation.go Outdated Show resolved Hide resolved
pkg/skaffold/schema/validation/validation.go Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Oct 1, 2019

Codecov Report

Merging #2964 into master will increase coverage by 0.04%.
The diff coverage is 93.75%.

Impacted Files Coverage Δ
pkg/skaffold/schema/v1beta14/config.go 100% <ø> (ø) ⬆️
pkg/skaffold/schema/latest/config.go 100% <ø> (ø) ⬆️
pkg/skaffold/schema/v1beta15/config.go 100% <ø> (ø) ⬆️
pkg/skaffold/schema/v1beta16/config.go 100% <ø> (ø) ⬆️
pkg/skaffold/schema/v1beta13/upgrade.go 92.3% <100%> (+0.64%) ⬆️
pkg/skaffold/schema/validation/validation.go 100% <100%> (ø) ⬆️
pkg/skaffold/jib/jib_init.go 89.55% <100%> (+0.66%) ⬆️
pkg/skaffold/jib/jib.go 73.48% <50%> (ø) ⬆️

@@ -778,6 +778,8 @@ type JibArtifact struct {
// For example: `["--no-build-cache"]`.
Flags []string `yaml:"args,omitempty"`

// Type the Jib builder type (internal: see jib.PluginType)
Type int `yaml:"-"`
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be fine as it actually helps making the upgrade process to not break when the detection mechanism doesn't work. It is a conservative change. I will use admin rights to merge this PR.

@balopat balopat added the docs-modifications runs the docs preview service on the given PR label Oct 10, 2019
@container-tools-bot
Copy link

Please visit http://35.236.103.231:1313 to view changes to the docs.

@container-tools-bot container-tools-bot removed the docs-modifications runs the docs preview service on the given PR label Oct 10, 2019
Copy link
Member

@chanseokoh chanseokoh left a comment

Choose a reason for hiding this comment

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

The Jib logic part looks good.

@briandealwis
Copy link
Member Author

Sorry @balopat, this totally slipped through the cracks.

Copy link
Contributor

@balopat balopat left a comment

Choose a reason for hiding this comment

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

I wonder if we can make the string an enum / oneOf somehow

@@ -778,6 +778,8 @@ type JibArtifact struct {
// For example: `["--no-build-cache"]`.
Flags []string `yaml:"args,omitempty"`

// Type the Jib builder type (internal: see jib.PluginType)
Type int `yaml:"-"`
// Type the Jib builder type; normally determined automatically. Valid types are:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// Type the Jib builder type; normally determined automatically. Valid types are:
// Type the Jib builder type; if not set then it is detected automatically. Valid types are:

@briandealwis
Copy link
Member Author

I need to update this in light of #3041

@briandealwis
Copy link
Member Author

I hacked up the schema generator to emit JSON schema enums. PTAL!

@balopat
Copy link
Contributor

balopat commented Nov 6, 2019

This is awesome, thanks for putting the enum together as well!

@balopat balopat merged commit c019740 into GoogleContainerTools:master Nov 6, 2019
@balopat
Copy link
Contributor

balopat commented Nov 6, 2019

Merged with admin privileges for the historical version change as it actually helps with upgrades.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Jib configuration block should allow explicitly setting type
5 participants