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

Github archive #2691

Open
wants to merge 29 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
0412c35
init new github
garrrikkotua Oct 31, 2024
5705571
types and grid
garrrikkotua Oct 31, 2024
040b95c
client
garrrikkotua Oct 31, 2024
d96883f
move snowflake to lib
garrrikkotua Nov 5, 2024
9c7b4b0
stuff
garrrikkotua Nov 5, 2024
7200b42
integration
garrrikkotua Nov 6, 2024
164240a
progress
garrrikkotua Nov 7, 2024
c9fbc20
Cleanup github webhooks routes
sausage-todd Nov 12, 2024
a5d30d4
remove webhooks logic
garrrikkotua Nov 13, 2024
41d3353
remove some types
garrrikkotua Nov 13, 2024
a5b8aae
Merge branches 'feat/github-archive' and 'main' of github.com:CrowdDo…
gaspergrom Nov 13, 2024
2d59559
types and stuff
garrrikkotua Nov 14, 2024
2377e64
progress
garrrikkotua Nov 14, 2024
d2371e7
Github archive integration frontend
gaspergrom Nov 14, 2024
62d222d
Merge branch 'feat/github-archive' of github.com:CrowdDotDev/crowd.de…
gaspergrom Nov 14, 2024
edb5c80
issues and stuff
garrrikkotua Nov 15, 2024
aedbb35
stuff
garrrikkotua Nov 18, 2024
84ce248
Add org list and design changes
gaspergrom Nov 18, 2024
dffbfac
Merge branch 'feat/github-archive' of github.com:CrowdDotDev/crowd.de…
gaspergrom Nov 18, 2024
bdfd13a
stuff
garrrikkotua Nov 18, 2024
a74fad9
Github archive integration finish and connect
gaspergrom Nov 18, 2024
f18dd04
Merge branch 'feat/github-archive' of github.com:CrowdDotDev/crowd.de…
gaspergrom Nov 18, 2024
b11fc25
Strip trailing spaces
sausage-todd Nov 18, 2024
ddafb39
Make a way to create snowflake client shortly
sausage-todd Nov 18, 2024
45eae0f
Create endpoints for new github onboarding flow
sausage-todd Nov 18, 2024
189c093
Github mapping fix
gaspergrom Nov 18, 2024
c0b1616
Merge branch 'feat/github-archive' of github.com:CrowdDotDev/crowd.de…
gaspergrom Nov 18, 2024
3b1276e
Fetch mappings
gaspergrom Nov 18, 2024
8ed8aac
remove locs from commits
garrrikkotua Nov 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions backend/config/custom-environment-variables.json
Original file line number Diff line number Diff line change
Expand Up @@ -222,5 +222,13 @@
"clientSecret": "CROWD_GITLAB_CLIENT_SECRET",
"callbackUrl": "CROWD_GITLAB_CALLBACK_URL",
"webhookToken": "CROWD_GITLAB_WEBHOOK_TOKEN"
},
"snowflake": {
"privateKey": "CROWD_SNOWFLAKE_PRIVATE_KEY",
"account": "CROWD_SNOWFLAKE_ACCOUNT",
"username": "CROWD_SNOWFLAKE_USERNAME",
"database": "CROWD_SNOWFLAKE_DATABASE",
"warehouse": "CROWD_SNOWFLAKE_WAREHOUSE",
"role": "CROWD_SNOWFLAKE_ROLE"
}
}
1 change: 1 addition & 0 deletions backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
"@crowd/temporal": "workspace:*",
"@crowd/tracing": "workspace:*",
"@crowd/types": "workspace:*",
"@crowd/snowflake": "workspace:*",
"@google-cloud/storage": "5.3.0",
"@octokit/auth-app": "^3.6.1",
"@octokit/core": "^6.1.2",
Expand Down
10 changes: 10 additions & 0 deletions backend/src/api/integration/helpers/githubOrgRepos.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import Permissions from '@/security/permissions'
import GithubIntegrationService from '@/services/githubIntegrationService'
import PermissionChecker from '@/services/user/permissionChecker'

export default async (req, res) => {
new PermissionChecker(req).validateHas(Permissions.values.integrationEdit)

const payload = await GithubIntegrationService.getOrgRepos(req.params.org)
await req.responseHandler.success(req, res, payload)
}
10 changes: 10 additions & 0 deletions backend/src/api/integration/helpers/githubSearchOrgs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import Permissions from '@/security/permissions'
import GithubIntegrationService from '@/services/githubIntegrationService'
import PermissionChecker from '@/services/user/permissionChecker'

export default async (req, res) => {
new PermissionChecker(req).validateHas(Permissions.values.integrationEdit)

const payload = await GithubIntegrationService.findOrgs(req.query.query)
await req.responseHandler.success(req, res, payload)
}
10 changes: 10 additions & 0 deletions backend/src/api/integration/helpers/githubSearchRepos.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import Permissions from '@/security/permissions'
import GithubIntegrationService from '@/services/githubIntegrationService'
import PermissionChecker from '@/services/user/permissionChecker'

export default async (req, res) => {
new PermissionChecker(req).validateHas(Permissions.values.integrationEdit)

const payload = await GithubIntegrationService.findGithubRepos(req.query.query)
await req.responseHandler.success(req, res, payload)
}
12 changes: 12 additions & 0 deletions backend/src/api/integration/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,18 @@ export default (app) => {
`/tenant/:tenantId/integration/:id/github/repos`,
safeWrap(require('./helpers/githubMapReposGet').default),
)
app.get(
`/tenant/:tenantId/integration/github/search/orgs`,
safeWrap(require('./helpers/githubSearchOrgs').default),
)
app.get(
`/tenant/:tenantId/integration/github/search/repos`,
safeWrap(require('./helpers/githubSearchRepos').default),
)
app.get(
`/tenant/:tenantId/integration/github/orgs/:org/repos`,
safeWrap(require('./helpers/githubOrgRepos').default),
)
app.put(
`/discord-authenticate/:tenantId/:guild_id`,
safeWrap(require('./helpers/discordAuthenticate').default),
Expand Down
9 changes: 9 additions & 0 deletions backend/src/conf/configTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,3 +256,12 @@ export interface IRedditConfig {
clientId: string
clientSecret: string
}

export interface SnowflakeConfiguration {
privateKey: string
account: string
username: string
database: string
warehouse: string
role: string
}
5 changes: 5 additions & 0 deletions backend/src/conf/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import {
TwitterConfiguration,
UnleashConfiguration,
WeeklyEmailsConfiguration,
SnowflakeConfiguration,
} from './configTypes'

// TODO-kube
Expand Down Expand Up @@ -172,3 +173,7 @@ export const OPEN_STATUS_API_CONFIG: IOpenStatusApiConfig =
export const GITLAB_CONFIG: GitlabConfiguration = config.get<GitlabConfiguration>('gitlab')

export const REDDIT_CONFIG: IRedditConfig = config.get<IRedditConfig>('reddit')


export const SNOWFLAKE_CONFIG: SnowflakeConfiguration =
config.get<SnowflakeConfiguration>('snowflake')
63 changes: 63 additions & 0 deletions backend/src/services/githubIntegrationService.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import { request } from '@octokit/request'

import { GithubSnowflakeClient, SnowflakeClient } from '@crowd/snowflake'

import { IServiceOptions } from './IServiceOptions'

export default class GithubIntegrationService {
constructor(private readonly options: IServiceOptions) {}

public async getGithubRepositories(org: string) {
const client = SnowflakeClient.fromEnv()
this.options.log.info(`Getting GitHub repositories for org: ${org}`)
const githubClient = new GithubSnowflakeClient(client)
return githubClient.getOrgRepositories({ org, perPage: 10000 })
}

public static async findGithubRepos(query: string) {
const [orgRepos, repos] = await Promise.all([
request('GET /search/repositories', {
q: `owner:${query}`,
}).catch((err) => {
this.options.log.error(`Error getting GitHub repositories for org: ${query}`, err)
return { data: { items: [] } }
}),
request('GET /search/repositories', {
q: query,
}),
])

// console.log([...orgRepos.data.items, ...repos.data.items])

return [...orgRepos.data.items, ...repos.data.items].map((item) => ({
name: item.name,
url: item.html_url,
org: {
name: item.owner.login,
url: item.owner.html_url,
logo: item.owner.avatar_url,
},
}))
}

public static async findOrgs(query: string) {
const response = await request('GET /search/users', {
q: query,
})
return response.data.items.map((item) => ({
name: item.login,
url: item.html_url,
logo: item.avatar_url,
}))
}

public static async getOrgRepos(org: string) {
const response = await request('GET /orgs/{org}/repos', {
org,
})
return response.data.map((repo) => ({
name: repo.name,
url: repo.html_url,
}))
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

This file was deleted.

Loading
Loading