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

Connections #15939

Merged
merged 28 commits into from
Feb 9, 2021
Merged

Connections #15939

merged 28 commits into from
Feb 9, 2021

Conversation

jgoizueta
Copy link
Member

See https://app.clubhouse.io/cartoteam/story/117351 & https://app.clubhouse.io/cartoteam/story/117356

Experimental implementation of connections.

PENDING: (delayed decisions)

  • data_imports, synchronizations: add connection_id foreign key, assign from parameters
  • consider: connections are not deleted, but deactivated => old imports can be traced to their connection parameters
  • full migration support of connections
  • encrypt password, token on exports/imports (migrations), hide in logs
  • decide: oauth creation pre-creates connection record
  • consider: ConnectionManager identifies connections by name => API does as well (impacts previous decision)

Rafa de la Torre and others added 7 commits February 5, 2021 12:44
As per review comments.

The default environment in Rails is development, so the fallback is
better removed.

Also, better use Rails `Rails.env` instead of environment variables
for checks (at least cleaner and nicer).
Prevent rspec from being executed in any env other than test
* add git tags and docker labels
Copy link
Contributor

@dgaubert dgaubert left a comment

Choose a reason for hiding this comment

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

Apart from what Rubocop is claiming, I have a minor question about if we need to define the version of the google's gems in gemfiles or not. Left some comments, nothing blocking.

Note: rubocop's comments make hard to read the code of the PR. Didn't find how to hide them.

LGTM

@@ -11,6 +11,7 @@ sudo make install

### Features
Copy link
Contributor

Choose a reason for hiding this comment

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

We will need an entry with a description of what's implemented in this PR, won't we?


def destroy
@connection_manager.delete_connection(params[:id])
head :ok
Copy link
Contributor

Choose a reason for hiding this comment

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

Not familiar with this line, I guess it responds with 200/4 Ok, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

yep

service = params[:service]
connection = @connection_manager.find_oauth_connection(service)
# shouldn't it return a presented connection? and raise an exception if not found?
if connection
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't we use methods such as .present?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, I think's preferable for clarity/style, even though here connection is either a Connection or nil, so it shouldn't make any difference (present? takes into account other values that are not falsy but are empty like [] or blank like '')

connection = @connection_manager.fetch_connection(params[:id])
@connection_manager.check(connection)
connector = Carto::Connector.new(parameters: {}, connection: connection, user: current_user, logger: nil)
render_jsonp({ connected: @connection_manager.check(connection) }, 200)
Copy link
Contributor

Choose a reason for hiding this comment

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

We are calling @connection_manager.check(connection) twice for the controller method.

Copy link
Member Author

Choose a reason for hiding this comment

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

oopsie!

render_jsonp({ connected: @connection_manager.check(connection) }, 200)
end

def projects
Copy link
Contributor

Choose a reason for hiding this comment

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

Question: I guess only the BigQuery connector has the concept of projects, no?.

Copy link
Member Author

Choose a reason for hiding this comment

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

Affirmative.

end

def rescue_from_invalid_connection(exception)
code = exception.message =~ /Access Denied/im ? 401 : 422
Copy link
Contributor

Choose a reason for hiding this comment

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

403 fits better for an Access denied errors.

Copy link
Member Author

Choose a reason for hiding this comment

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

You're right!


# Unify connectors of dual type
oauth_connectors.each do |oauth_connector|
db_connector = db_connectors.find { |c| c[:connector] == oauth_connector[:connector] }
Copy link
Contributor

Choose a reason for hiding this comment

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

db_connectors might not be initialized when not types.include?(Carto::Connection::TYPE_DB_CONNECTOR). no?

Copy link
Member Author

Choose a reason for hiding this comment

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

it's initialized to [] at the top, so no problem

@jgoizueta jgoizueta changed the base branch from master to connectors February 9, 2021 17:07
@jgoizueta jgoizueta marked this pull request as ready for review February 9, 2021 17:07
'spatialCoverage': this.dataset.country_name,
'variableMeasured': keyVariables,
'version': this.dataset.version,
'url': `https://carto.com${this.$router.resolve({ name: 'catalog-dataset-summary', params: {...this.$route.params} }).href}`
Copy link

Choose a reason for hiding this comment

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

A space is required after '{' object-curly-spacing
A space is required before '}' object-curly-spacing

@jgoizueta jgoizueta merged commit 9a11e55 into connectors Feb 9, 2021
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.

None yet

5 participants