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

AmazonS3InstallationService add constructor #1168

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

smallufo
Copy link

@smallufo smallufo commented Jun 10, 2023

This pull request may resolve #1165

Category (place an x in each of the [ ])

  • bolt (Bolt for Java)
  • bolt-{sub modules} (Bolt for Java - optional modules)
  • slack-api-client (Slack API Clients)
  • slack-api-model (Slack API Data Models)
  • slack-api-*-kotlin-extension (Kotlin Extensions for Slack API Clients)
  • slack-app-backend (The primitive layer of Bolt for Java)

Requirements

Please read the Contributing guidelines and Code of Conduct before creating this issue or pull request. By submitting, you agree to those rules.

@salesforce-cla
Copy link

Thanks for the contribution! Before we can merge this, we need @smallufo to sign the Salesforce Inc. Contributor License Agreement.

@codecov
Copy link

codecov bot commented Jun 12, 2023

Codecov Report

Merging #1168 (7081ab6) into main (25cd87e) will decrease coverage by 0.06%.
The diff coverage is 9.09%.

@@             Coverage Diff              @@
##               main    #1168      +/-   ##
============================================
- Coverage     75.25%   75.20%   -0.06%     
- Complexity     4004     4005       +1     
============================================
  Files           430      430              
  Lines         12528    12538      +10     
  Branches       1261     1262       +1     
============================================
+ Hits           9428     9429       +1     
- Misses         2355     2362       +7     
- Partials        745      747       +2     
Impacted Files Coverage Δ
...t/service/builtin/AmazonS3InstallationService.java 47.79% <9.09%> (-3.21%) ⬇️

... and 1 file with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Member

@seratch seratch left a comment

Choose a reason for hiding this comment

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

Thanks for submitting this PR, but we're yet unable to merge this PR as-is. There are a few things to consider:

  • decide better constructor interface design
  • need to do the same for AmazonS3OAuthStateService
  • write some tests as much as possible

We may add built-in constructor for your use case in the near future (it may be based on this PR) but it's not our top priority right now. So, if you're already happy with your own implementation, please go ahead with it.

Thanks again for your time to work on this!

Comment on lines +18 to +19
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
Copy link
Member

Choose a reason for hiding this comment

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

Can you remove these annotations? We consistently don't use them.

Copy link
Author

Choose a reason for hiding this comment

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

sure ,please do as you wish. I add them because I see them in the dependency graph

public AmazonS3InstallationService(String bucketName) {
this.bucketName = bucketName;
}

@Override
public Initializer initializer() {
return (app) -> {
if (region != null) {
System.setProperty("AWS_REGION" , region);
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 think the system prop name can be the same with env variable. The key should be "aws.region"

Copy link
Member

Choose a reason for hiding this comment

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

Also, modifying the global system properties this way is not a generally recommended programming pratice. Instead, you can simply instantiate credential object to avoid affecting any other parts of your app.

Copy link
Author

Choose a reason for hiding this comment

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

I saw different codes ("AWS_REGION" , "aws.region") in the whole AWS code base , I am not familiar with this (searching environment / system variables). I am not also favor of this type.
You can modify to the correct variable name

private final String bucketName;
private boolean historicalDataEnabled;

public AmazonS3InstallationService(@Nullable String region, @NotNull String accessKey, @NotNull String secretKey, @NotNull String bucketName) {
Copy link
Member

@seratch seratch Jun 12, 2023

Choose a reason for hiding this comment

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

Having four string arguments is not a very easy-to-use interface. more importantly this is not flexible enough for future enhancement. I think receiving a single object representing crendential inputs (either AWS SDK's class or a custom class with builder interface) + bucketName works better for this use case.

Copy link
Author

Choose a reason for hiding this comment

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

OK, depends on you. Just provide a constructor for user to prepare necessary values/keys. Rather than deep digging the system looking for variables.
This also eases testing / mocking.

Copy link
Author

Choose a reason for hiding this comment

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

Point : Let user control what is inputed .

@seratch seratch added this to the 1.x milestone Jun 12, 2023
@seratch seratch self-assigned this Jun 12, 2023
@seratch seratch added enhancement M-T: A feature request for new functionality project:bolt labels Jun 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla:signed enhancement M-T: A feature request for new functionality project:bolt
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AmazonS3InstallationService should accept aws credential in constructor
2 participants