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

Remove hardcoded AWS bucket Name from a Few Files #5799

Closed
wants to merge 1 commit into from

Conversation

mstruve
Copy link
Contributor

@mstruve mstruve commented Jan 28, 2020

What type of PR is this? (check all applicable)

  • Refactor

Description

This is only a small number of the places we have hardcoded our old AWS bucket name. I figured I would do these and then make an Issue to handle all of the ones that are in the view and emails which are A LOT and will need some closer attention as some are cloudinary links and some point straight to S3.

Related Ticket

Followup for #5771 and #5555

Added to documentation?

  • no documentation needed

alt_text

@pr-triage pr-triage bot added the PR: unreviewed bot applied label for PR's with no review label Jan 28, 2020
Copy link
Contributor

@maestromac maestromac left a comment

Choose a reason for hiding this comment

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

👍 👍

@pr-triage pr-triage bot added PR: reviewed-approved bot applied label for PR's where reviewer approves changes and removed PR: unreviewed bot applied label for PR's with no review labels Jan 28, 2020
Copy link
Contributor

@citizen428 citizen428 left a comment

Choose a reason for hiding this comment

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

What a tedious tasks, thanks for doing this @mstruve! I know you said you're going to do views in a later PR, but the static public/offline.html could potentially also go in this one.

Copy link
Contributor

@rhymes rhymes left a comment

Choose a reason for hiding this comment

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

Hi @mstruve, thanks a lot for surfacing this but I don't think this is the right approach to fix the issue.

I believe we should download these images and add them to app/assets/images with the others, so that we don't have hardcoded paths pointing to dying buckets or non harcoded paths pointing to potentially non existing images

@@ -5,7 +5,7 @@ class ProfileImage
def initialize(resource)
@resource = resource
@image_link = resource.profile_image_url
@backup_link = "https://thepracticaldev.s3.amazonaws.com/i/99mvlsfu5tfj9m7ku25d.png"
@backup_link = "https://#{ApplicationConfig['AWS_BUCKET_NAME']}.s3.amazonaws.com/i/99mvlsfu5tfj9m7ku25d.png"
Copy link
Contributor

Choose a reason for hiding this comment

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

wouldn't this break local installations when merged?
For example:

  • the local AWS_BUCKET_NAME is not thepracticaldev by default, it's Optional
  • mine is called devto-tests because I configured it to point to my AWS installation
  • this would mean that I'd have to manually upload a file named 99mvlsfu5tfj9m7ku25d.png for this to work

I think it'd have an impact on the other communities as well.

Maybe we could keep this hardcoded until we find a better way to handle this:

  • either we download these images and put them in our assets (my fav option)
  • or we find a way to upload them when the app is setup, through a script or something

Basically I don't think these images should be in AWS at all :)

@@ -2,7 +2,7 @@ module HtmlCssToImage
AUTH = { username: ApplicationConfig["HCTI_API_USER_ID"],
password: ApplicationConfig["HCTI_API_KEY"] }.freeze

FALLBACK_IMAGE = "https://thepracticaldev.s3.amazonaws.com/i/g355ol6qsrg0j2mhngz9.png".freeze
FALLBACK_IMAGE = "https://#{ApplicationConfig['AWS_BUCKET_NAME']}.s3.amazonaws.com/i/g355ol6qsrg0j2mhngz9.png".freeze
Copy link
Contributor

Choose a reason for hiding this comment

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

same as the previous observation

@@ -14,7 +14,7 @@ class SiteConfig < RailsSettings::Base
field :social_networks_handle, type: :string, default: "thepracticaldev"

# images
field :main_social_image, type: :string, default: "https://thepracticaldev.s3.amazonaws.com/i/6hqmcjaxbgbon8ydw93z.png"
field :main_social_image, type: :string, default: "https://#{ApplicationConfig['AWS_BUCKET_NAME']}.s3.amazonaws.com/i/6hqmcjaxbgbon8ydw93z.png"
Copy link
Contributor

@rhymes rhymes Jan 29, 2020

Choose a reason for hiding this comment

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

he're we're definitely breaking the main social image for a pristine installation

@@ -46,7 +46,7 @@ def remove_profile_info
twitch_url: nil, feed_url: nil
)

user.update_columns(profile_image: "https://thepracticaldev.s3.amazonaws.com/i/99mvlsfu5tfj9m7ku25d.png")
user.update_columns(profile_image: "https://#{ApplicationConfig['AWS_BUCKET_NAME']}.s3.amazonaws.com/i/99mvlsfu5tfj9m7ku25d.png")
Copy link
Contributor

Choose a reason for hiding this comment

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

this is further evidence we might want to rethink this approach, we are storing a broken path in the DB:

  • it's either a broken URL for new installers
  • or a URL that points to non existent images if the bucket name is not thepracticaldev

@pr-triage pr-triage bot added PR: reviewed-changes-requested bot applied label for PR's where reviewer requests changes and removed PR: reviewed-approved bot applied label for PR's where reviewer approves changes labels Jan 29, 2020
@mstruve
Copy link
Contributor Author

mstruve commented Jan 29, 2020

@rhymes you are right, a lot of these images should be downloaded and put in the assets folder. Since there is a bit more scope to this than I anticipated I am going to close and make an issue to get it sorted out.

@mstruve mstruve closed this Jan 29, 2020
@rhymes rhymes deleted the mstruve/rm-hardcoded-aws-bucket branch January 29, 2020 14:29
@mstruve
Copy link
Contributor Author

mstruve commented Jan 29, 2020

@rhymes I wasn't sure what labels to put on it but here is the new issue #5810

@rhymes
Copy link
Contributor

rhymes commented Jan 29, 2020

@mstruve went ahead and put them all haahaahha

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: reviewed-changes-requested bot applied label for PR's where reviewer requests changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants