-
Notifications
You must be signed in to change notification settings - Fork 2.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
Adding Authorization for Github api call In KubeLoginInstallerV0 #20725
base: master
Are you sure you want to change the base?
Adding Authorization for Github api call In KubeLoginInstallerV0 #20725
Conversation
/ azp run |
Azure Pipelines successfully started running 3 pipeline(s). |
…ubAPICallInKubeLoginInstallerV0
…ubAPICallInKubeLoginInstallerV0
…ubAPICallInKubeLoginInstallerV0
if (taskLib.getBoolFeatureFlag('USE_AUTHORIZATION_FOR_API_CALL')){ | ||
const token = getGithubEndPointToken(); | ||
if (token) { | ||
request.headers['Authorization'] = 'token ' + token; |
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.
Let's extract explicit utility method to reduce code duplication
} else if (githubEndpointObject.scheme) { | ||
throw new Error(taskLib.loc("InvalidEndpointAuthScheme", githubEndpointObject.scheme)); | ||
} | ||
} |
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.
Let's reduce code nesting by inverting if (!!githubEndpointObject) {
} | ||
catch(error) | ||
{ | ||
throw new Error(taskLib.loc("Failed to retrieve GitHub endpoint token:", error.message)); |
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.
Let's create less generic exception type here.
Task name: KubeLoginInstallerV0
Description: KubeloginInstallerV0 task is calling github API anonymously, so here we are adding authorization using Oauth and pat to access the github API.
Documentation changes required: (Y/N) N
Added unit tests: (Y/N) N
Attached related issue: https://github.com/microsoft/azure-pipelines-tasks/issues/19097
Checklist: