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

fix: OTP 21 compatibility #4

Merged
merged 1 commit into from
Jul 6, 2018

Conversation

hauptbenutzer
Copy link
Contributor

This fixes GCloud private key decoding for OTP 21, in which the decoding return format has changed.
See #3

Copy link
Member

@premist premist 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 for your contribution! I would like to request some cosmetic adjustments.

@@ -5,12 +5,14 @@ defmodule GcsSigner do

@base_url "https://storage.googleapis.com"

@otp_greater_21? :erlang.system_info(:otp_release) >= '21'
Copy link
Member

Choose a reason for hiding this comment

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

Is it possible to change single quote to double quote, since this project uses double quote as a convention?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

:erlang.system_info(:otp_release) returns an erlang charlist, which in elixir is denoted by single quotes. If I were to compare with a Binary (double quotes), the result would always be false:

iex> '21' >= "21"
false

Copy link
Member

Choose a reason for hiding this comment

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

Ah I see! Thanks for the insight 😄

content_type: String.t,
expires: integer
]
verb: String.t(),
Copy link
Member

@premist premist Jul 4, 2018

Choose a reason for hiding this comment

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

May I ask if there is a reason why indentation has changed here? I would prefer keeping the original indentation to match with other parts of our codebase.

String.t,
sign_url_opts
) :: String.t
%{client_email: String.t(), private_key: String.t()},
Copy link
Member

@premist premist Jul 4, 2018

Choose a reason for hiding this comment

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

Same with the change above - may I ask if there is a reason why indentation and method call format has changed here? I would prefer keeping the original indentation to match with other parts of our codebase.

"Signature" => signature
} |> URI.encode_query

qs =
Copy link
Member

Choose a reason for hiding this comment

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

Separating righthand looks nice on the signature, so thank you for adjusting it.

On here however original code formatting feels better in terms of indentation. What do you think?

@@ -66,18 +73,30 @@ defmodule GcsSigner do

string
|> :public_key.sign(:sha256, private_key)
|> Base.encode64
|> Base.encode64()
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 the parenthesis here for consistency?

private_key
else
private_key
# grab privateKey from the record tuple
Copy link
Member

Choose a reason for hiding this comment

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

I'd like to suggest moving this comment to above L96, since comment is in the middle of the pipe methods which makes private_key and subsequent method disconnected.

@premist
Copy link
Member

premist commented Jul 4, 2018

@hauptbenutzer I added lots of coding style change suggestions, if you feel it's quite overwhelming I'm also open to directly adding commits on your branch to make appropriate adjustments, and merge when it's done :)

@hauptbenutzer hauptbenutzer force-pushed the feat/otp-21-compatiblity branch from 64853f9 to 851f496 Compare July 4, 2018 07:43
@hauptbenutzer
Copy link
Contributor Author

@premist Sorry for that -- I had my editor configured to elixir format on save, so that's what that was about. I boiled it down to functional changes only and rebased on current master.

Copy link
Member

@premist premist left a comment

Choose a reason for hiding this comment

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

I added Travis matrix to test against OTP 20 and 21, and looks like basic Credo/Dialyzer tests pass on both versions!

@premist premist merged commit 48735c9 into shakrmedia:master Jul 6, 2018
@premist
Copy link
Member

premist commented Jul 6, 2018

Thanks for your contribution!

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

Successfully merging this pull request may close these issues.

2 participants