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

runtime/client: add util func to check conn options compatibility with env #594

Merged
merged 1 commit into from
Jun 30, 2023

Conversation

aryan9600
Copy link
Member

Add CheckEnvironmentCompatibility() to check whether the configured connection options are compatible with the environment, by checking env vars like HTTP_PROXY and HTTPS_PROXY.

// CheckEnvironmentCompatibility checks if the enviornment is compatible with
// the configured connection options.
func (o *ConnectionOptions) CheckEnvironmentCompatibility() error {
if !o.AllowHTTP {
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe inverse this condition to reduce the levels of nested conditions in the function?

if o.AllowHTTP {
    return nil
}
...

Copy link
Member Author

Choose a reason for hiding this comment

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

i prefer to keep it the current way since it keeps all the logic related to the o.AllowHTTP field in a single block making it relatively easy for this function to be expanded for when we add more options.


// CheckEnvironmentCompatibility checks if the enviornment is compatible with
// the configured connection options.
func (o *ConnectionOptions) CheckEnvironmentCompatibility() error {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could this function be called Validate() ?

Copy link
Member Author

Choose a reason for hiding this comment

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

i prefer the current name over Validate() as imo, the latter means that its checking the configured options are valid which is a bit misleading.

@aryan9600 aryan9600 force-pushed the http-env-var branch 3 times, most recently from eca38b5 to 6ea71a1 Compare June 27, 2023 06:47
@aryan9600 aryan9600 requested a review from hiddeco June 27, 2023 08:40
@aryan9600 aryan9600 force-pushed the http-env-var branch 4 times, most recently from 609fbf9 to 71dd9a0 Compare June 29, 2023 13:54
Copy link
Member

@stefanprodan stefanprodan left a comment

Choose a reason for hiding this comment

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

LGTM

@aryan9600 aryan9600 requested a review from makkes June 29, 2023 13:56
@stefanprodan stefanprodan added the area/runtime Controller runtime related issues and pull requests label Jun 29, 2023
…h env

Add `CheckEnvironmentCompatibility()` to check whether the configured
connection options are compatible with the environment, by checking env
vars like `HTTP_PROXY` and `HTTPS_PROXY`.

Signed-off-by: Sanskar Jaiswal <jaiswalsanskar078@gmail.com>
@aryan9600 aryan9600 merged commit ea9224f into main Jun 30, 2023
@aryan9600 aryan9600 deleted the http-env-var branch June 30, 2023 11:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/runtime Controller runtime related issues and pull requests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants