-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Build: pass api_client down to environment/builders/etc #10390
Conversation
For #10289 we won't have the credentials hardcoded in our settings anymore, but instead we will be provided with a dynamic token for the build to use, for this reason we now have to pass the api client object around.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like a great first integration. Definitely interesting to see classmethod
s getting turned into instance methods, but it seems like not a huge amount of data to pass around.
self.api_client = api_client | ||
|
||
if self.record and not self.api_client: | ||
raise ValueError("api_client is required when record=True") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Solid defensive programming 👍
@@ -167,33 +166,23 @@ def get_config_params(self): | |||
versions = [] | |||
downloads = [] | |||
subproject_urls = [] | |||
# Avoid hitting database and API if using Docker build environment | |||
if settings.DONT_HIT_API: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have DONT_HIT_API and DONT_HIT_DB settings, which seem like inverses of the same value 🙃
Does it make sense to try to remove the DONT_HIT_API & DONT_HIT_DB settings as a later refactor here, or are they still needed in other places in the codebase?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I think we should just always assume that builders hit our API, and the rest of our code the DB.
Looks like we can just remove DONT_HIT_API
, I can try to remove DONT_HIT_DB
in another PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. I think these variables where only useful when we didn't have Docker development setup.
@@ -227,7 +226,7 @@ def get_command(self): | |||
return ' '.join(self.command) | |||
return self.command | |||
|
|||
def save(self): | |||
def save(self, api_client): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume it's easier to pass it in here, than to put the client on the BuildCommand when it's created?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it touches less code, and the API client is scoped to where is needed (just this method), since commands can be optionally saved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like a great first integration. Definitely interesting to see classmethod
s getting turned into instance methods, but it seems like not a huge amount of data to pass around.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like a solid change to me 👍
For #10289 we won't have the credentials hardcoded in our settings anymore, but instead we will be provided with a dynamic token for the build to use, for this reason we now have to pass the api client object around.
We were using the
DONT_HIT_API
just for testing, instead of doing that, I'm just mocking the api client.