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

[v2 refactoring proposal] Decouple the runner creation from v1 schema #6068

Merged

Conversation

yuwenma
Copy link
Contributor

@yuwenma yuwenma commented Jun 23, 2021

Related: #5673

Fixes #5797

Description
In runner creation, the schema is no longer bundled with v1 schema (latestV1.skaffoldConfig) but used the interface util.VersionedConfig.

All v1 commands are manually tested to make sure this PR does not break existing commands.

Follow-up Work (remove if N/A)
Distinguish v1 and v2 schema based on the in-use apiVersion in skaffold.yaml.

@yuwenma yuwenma requested a review from a team as a code owner June 23, 2021 05:56
@yuwenma yuwenma requested a review from aaron-prindle June 23, 2021 05:56
@google-cla google-cla bot added the cla: yes label Jun 23, 2021
@yuwenma yuwenma requested review from nkubala and tejal29 and removed request for aaron-prindle June 23, 2021 05:56
@yuwenma yuwenma added this to the v1.27.0 milestone Jun 23, 2021
@codecov
Copy link

codecov bot commented Jun 23, 2021

Codecov Report

Merging #6068 (57d478f) into master (0b13fa0) will decrease coverage by 0.62%.
The diff coverage is 47.82%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #6068      +/-   ##
==========================================
- Coverage   69.92%   69.29%   -0.63%     
==========================================
  Files         481      482       +1     
  Lines       18342    18526     +184     
==========================================
+ Hits        12825    12838      +13     
- Misses       4562     4734     +172     
+ Partials      955      954       -1     
Impacted Files Coverage Δ
cmd/skaffold/app/cmd/apply.go 25.00% <0.00%> (ø)
cmd/skaffold/app/cmd/delete.go 57.14% <0.00%> (ø)
cmd/skaffold/app/cmd/deploy.go 56.52% <0.00%> (ø)
cmd/skaffold/app/cmd/filter.go 25.58% <0.00%> (ø)
cmd/skaffold/app/cmd/generate_pipeline.go 61.53% <0.00%> (ø)
cmd/skaffold/app/cmd/render.go 40.74% <0.00%> (ø)
cmd/skaffold/app/cmd/test.go 46.66% <0.00%> (ø)
pkg/skaffold/runner/v1/generate_pipeline.go 0.00% <0.00%> (ø)
pkg/skaffold/runner/v2/generate_pipeline.go 0.00% <ø> (ø)
cmd/skaffold/app/cmd/diagnose.go 62.50% <50.00%> (-2.02%) ⬇️
... and 24 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0b13fa0...57d478f. Read the comment docs.

@tejal29 tejal29 removed their request for review June 23, 2021 15:43
@yuwenma yuwenma force-pushed the integrate-1-runner-interface branch from 6dc89d8 to 7b04197 Compare June 24, 2021 23:04
@yuwenma
Copy link
Contributor Author

yuwenma commented Jun 24, 2021

@nkubala gentle ping.

@yuwenma yuwenma requested a review from tejal29 June 24, 2021 23:05
@yuwenma yuwenma force-pushed the integrate-1-runner-interface branch 2 times, most recently from 23e38b1 to cbf7630 Compare June 24, 2021 23:21
@yuwenma
Copy link
Contributor Author

yuwenma commented Jun 24, 2021

rebased and merge conflict resolved.

@yuwenma yuwenma force-pushed the integrate-1-runner-interface branch 2 times, most recently from 66481d7 to c5846e3 Compare June 24, 2021 23:46
Copy link
Contributor

@nkubala nkubala left a comment

Choose a reason for hiding this comment

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

I see a few TODO leftover in this PR, but I'm not sure they match up with the follow up work detailed in the description. if those aren't going to be addressed in this PR, can we leave a short note in the PR description for what needs to be done later?

I'm also feeling a bit strange about moving the type checking from the method signature into a simple typecast in the method - this seems brittle to me. as an example:

func targetArtifacts(opts config.SkaffoldOptions, configs []util.VersionedConfig) []*latestV1.Artifact {
	var targetArtifacts []*latestV1.Artifact
	for _, cfg := range configs {
		for _, artifact := range cfg.(*latestV1.SkaffoldConfig).Build.Artifacts {

it might be better to abstract this away into Get methods defined on the Pipeline, similar to what we do in the RunContext. or maybe this is just an intermediate step and this will disappear in the future 🤷


if err := validation.Process(configs); err != nil {
// TODO: yuwen Check v1 or v2.
Copy link
Contributor

Choose a reason for hiding this comment

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

should this be addressed in this PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe not, providing a v2 validation is not a small change and may deserve another PR.

@yuwenma
Copy link
Contributor Author

yuwenma commented Jul 7, 2021

I see a few TODO leftover in this PR, but I'm not sure they match up with the follow up work detailed in the description. if those aren't going to be addressed in this PR, can we leave a short note in the PR description for what needs to be done later?

The TODOs are to save some code reading effort for future work, like marks. It's not necessary though. Removed. The detail is in this doc. Per offline discussion, I'll leave it to you to determine how the refactoring should work and I'm only going to focus on the branch v2.

I'm also feeling a bit strange about moving the type checking from the method signature into a simple typecast in the method - this seems brittle to me. as an example:

func targetArtifacts(opts config.SkaffoldOptions, configs []util.VersionedConfig) []*latestV1.Artifact {
	var targetArtifacts []*latestV1.Artifact
	for _, cfg := range configs {
		for _, artifact := range cfg.(*latestV1.SkaffoldConfig).Build.Artifacts {

it might be better to abstract this away into Get methods defined on the Pipeline, similar to what we do in the RunContext. or maybe this is just an intermediate step and this will disappear in the future 🤷

The interface is my refactoring proposal, and this PR shows the implementation details how that could be done.

@yuwenma yuwenma changed the title [v2] Decouple the runner creation from v1 schema [v2 refactoring proposal] Decouple the runner creation from v1 schema Jul 7, 2021
@tejal29 tejal29 force-pushed the integrate-1-runner-interface branch from 88136d1 to f5c01ec Compare July 8, 2021 16:32
@MarlonGamez
Copy link
Contributor

There is one small linter error but I think this is pretty much ready to merge after that

@google-cla
Copy link

google-cla bot commented Jul 8, 2021

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only @googlebot I consent. in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

@google-cla google-cla bot added cla: no and removed cla: yes labels Jul 8, 2021
@tejal29 tejal29 added cla: yes and removed cla: no labels Jul 8, 2021
@tejal29 tejal29 merged commit 24d332c into GoogleContainerTools:master Jul 9, 2021
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.

Explore removing latestv1.Pipeline and latestv1.Artifact from runner & runcontexts everywhere.
4 participants