-
Notifications
You must be signed in to change notification settings - Fork 38
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
feat: adjust for tokenless v3 #434
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
import logging | ||
import os | ||
from sys import exit | ||
from time import sleep | ||
|
||
|
@@ -95,6 +96,15 @@ def get_token_header_or_fail(token: str) -> dict: | |
return {"Authorization": f"token {token}"} | ||
|
||
|
||
def get_auth_header(token): | ||
tokenless = os.environ.get("TOKENLESS", None) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. are we making this change for the orb and step too? Why doesn't the CLI just do this itself? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i don't think the CLI has access to the same context as the action but i can double check, but you are correct we should make a similar change the the orb and step as well |
||
if tokenless: | ||
headers = {"X-Tokenless": tokenless} | ||
else: | ||
headers = get_token_header_or_fail(token) | ||
return headers | ||
|
||
|
||
@retry_request | ||
def send_put_request( | ||
url: str, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,10 +2,9 @@ | |
import typing | ||
|
||
from codecov_cli.helpers.config import CODECOV_API_URL | ||
from codecov_cli.helpers.encoder import decode_slug, encode_slug | ||
from codecov_cli.helpers.git import get_pull, is_fork_pr | ||
from codecov_cli.helpers.encoder import encode_slug | ||
from codecov_cli.helpers.request import ( | ||
get_token_header_or_fail, | ||
get_auth_header, | ||
log_warnings_and_errors_if_any, | ||
send_post_request, | ||
) | ||
|
@@ -43,15 +42,7 @@ def create_commit_logic( | |
def send_commit_data( | ||
commit_sha, parent_sha, pr, branch, slug, token, service, enterprise_url | ||
): | ||
decoded_slug = decode_slug(slug) | ||
pull_dict = get_pull(service, decoded_slug, pr) if not token else None | ||
if is_fork_pr(pull_dict): | ||
headers = {"X-Tokenless": pull_dict["head"]["slug"], "X-Tokenless-PR": pr} | ||
branch = pull_dict["head"]["slug"] + ":" + branch | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. don't we still need this? |
||
logger.info("The PR is happening in a forked repo. Using tokenless upload.") | ||
else: | ||
headers = get_token_header_or_fail(token) | ||
|
||
headers = get_auth_header(token) | ||
data = { | ||
"commitid": commit_sha, | ||
"parent_commit_id": parent_sha, | ||
|
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.
perhaps we don't need this anymore either