-
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
Tasks/KubeloginInstallerV0/utils.ts
Outdated
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
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.
Implemented the utlity code
Tasks/KubeloginInstallerV0/utils.ts
Outdated
} 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) {
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.
Used switch block
Tasks/KubeloginInstallerV0/utils.ts
Outdated
} | ||
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.
…ubAPICallInKubeLoginInstallerV0
…beLoginInstallerV0' of https://github.com/microsoft/azure-pipelines-tasks into users/v-dmerugu/AddingAuthorizationForGithubAPICallInKubeLoginInstallerV0
…ubAPICallInKubeLoginInstallerV0
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: