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

Add Deploysource as proto model #5112

Merged
merged 6 commits into from
Sep 19, 2024
Merged

Add Deploysource as proto model #5112

merged 6 commits into from
Sep 19, 2024

Conversation

Warashi
Copy link
Contributor

@Warashi Warashi commented Aug 6, 2024

What this PR does / why we need it:

Retry of #5050
I noticed that the piped also uses the Deploysource, so I defined it not in the plugin proto but in the model proto.

Which issue(s) this PR fixes:

Part of #4980

Does this PR introduce a user-facing change?:

  • How are users affected by this change:
  • Is this breaking change:
  • How to migrate (if breaking change):

Signed-off-by: Shinnosuke Sawada-Dazai <shin@warashi.dev>
Signed-off-by: Shinnosuke Sawada-Dazai <shin@warashi.dev>
Signed-off-by: Shinnosuke Sawada-Dazai <shin@warashi.dev>
Copy link

codecov bot commented Aug 6, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 22.83%. Comparing base (b8bdedc) to head (48ab49c).
Report is 82 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5112      +/-   ##
==========================================
+ Coverage   22.78%   22.83%   +0.05%     
==========================================
  Files         409      419      +10     
  Lines       43720    45297    +1577     
==========================================
+ Hits         9961    10344     +383     
- Misses      32975    34158    +1183     
- Partials      784      795      +11     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Comment on lines 25 to 28
// The configuration of the application which is independent for plugins.
GenericApplicationSpec generic_application_config = 3;
// The configuration of the application which is specific for plugins.
PluginApplicationSpec application_config = 4;
Copy link
Member

Choose a reason for hiding this comment

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

For these two, I think we need the data structure under the pkg/config package. So, how about passing this as bytes to the plugin, and the plugin will import the pipecd pkg/config package to unmarshal it? In that case, we can reuse the logic of the marshal/unmarshal config we currently have.

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I removed GenericApplicationSpec.
PluginApplicationSpec's fields are api_version, kind, and spec.
The api_version and kind are common for all plugins, so I defined as fields.
The field spec is defined as bytes, as you pointed out.

Comment on lines 31 to 32
message GenericApplicationSpec {
// TODO: Add more fields to support generic application spec.
Copy link
Member

Choose a reason for hiding this comment

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

Screenshot 2024-08-06 at 11 15 31
I just realized the plugin does not need the GenericApplicationSpec at all 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I removed GenericApplicationSpec from the model because the plugin does not need it, as you pointed out.

Signed-off-by: Shinnosuke Sawada-Dazai <shin@warashi.dev>
Signed-off-by: Shinnosuke Sawada-Dazai <shin@warashi.dev>

option go_package = "github.com/pipe-cd/pipecd/pkg/model";

message DeploymentSource {
Copy link
Member

Choose a reason for hiding this comment

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

Note: repoDir is removed because it is only being used in the deploysource package. We will change our way to clone/prepare source later.

// The git commit revision of the source code.
string revision = 2;
// The configuration of the application which is specific for plugins.
PluginApplicationSpec application_config = 3;
Copy link
Member

Choose a reason for hiding this comment

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

I don't get the point of having this type of definition instead of just using bytes. Could you help me understand more about this 👀

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think kind and api_version exist for all configurations, so I defined them separately.
Additionally, these definitions reflect the limitation of the config.

Copy link
Member

Choose a reason for hiding this comment

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

@Warashi Thanks for the explanation 🙏 I think this place we should not define a new type for lower maintenance costs. It could be better to just use bytes type here and both piped and plugin source code will use the config.ApplicationConfig type and marshall function defined in config package. wdyt? 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@khanhtc1202
Do you mean config.Config?
I think the plugin source code will not use this because the config struct will be defined in the plugin code, not in the piped code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this place we should not define a new type for lower maintenance costs.

I got your point 👍🏻
I'll try to define a function or struct/method used by both piped and plugins.
I think this definition will use the generic type parameter.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@khanhtc1202
I fixed the type as bytes as you pointed.
In this PR, I want to define DeploymentSource only.
I'll implement config.ApplicationConfig or a similar one in another PR when I need it.

Copy link
Member

Choose a reason for hiding this comment

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

@Warashi Thank you 👍

Signed-off-by: Shinnosuke Sawada-Dazai <shin@warashi.dev>
Copy link
Member

@khanhtc1202 khanhtc1202 left a comment

Choose a reason for hiding this comment

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

Thank you 💯

@Warashi Warashi enabled auto-merge (squash) September 19, 2024 06:12
@Warashi Warashi merged commit 29dd1b6 into master Sep 19, 2024
17 checks passed
@Warashi Warashi deleted the deploysource-model branch September 19, 2024 06:12
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.

3 participants