Skip to content

Commit

Permalink
FAI-14379 | Override mode for GitHub / Jira (#1852)
Browse files Browse the repository at this point in the history
* Override mode for GitHub

* Override mode for Jira

* use regex for jira
  • Loading branch information
dbruno21 authored Dec 10, 2024
1 parent 13818da commit 9aef880
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
4 changes: 4 additions & 0 deletions sources/github-source/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ export class GitHubSource extends AirbyteSourceBase<GitHubConfig> {
return 'github';
}

mode(config: GitHubConfig): string | undefined {
return !config.url ? 'cloud' : 'server';
}

async spec(): Promise<AirbyteSpec> {
// eslint-disable-next-line @typescript-eslint/no-var-requires
return new AirbyteSpec(require('../resources/spec.json'));
Expand Down
15 changes: 14 additions & 1 deletion sources/jira-source/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,13 @@ import {
import {FarosClient} from 'faros-js-client';
import VError from 'verror';

import {DEFAULT_API_URL, DEFAULT_CUTOFF_DAYS, Jira, JiraConfig} from './jira';
import {
DEFAULT_API_URL,
DEFAULT_CUTOFF_DAYS,
Jira,
JIRA_CLOUD_REGEX,
JiraConfig,
} from './jira';
import {RunMode, RunModeStreams, TeamStreamNames} from './streams/common';
import {FarosBoardIssues} from './streams/faros_board_issues';
import {FarosBoards} from './streams/faros_boards';
Expand Down Expand Up @@ -44,6 +50,13 @@ export class JiraSource extends AirbyteSourceBase<JiraConfig> {
return 'jira';
}

mode(config: JiraConfig): string | undefined {
if (!config.url) {
return undefined;
}
return config.url.match(JIRA_CLOUD_REGEX) != null ? 'cloud' : 'server';
}

async spec(): Promise<AirbyteSpec> {
// eslint-disable-next-line @typescript-eslint/no-var-requires
return new AirbyteSpec(require('../resources/spec.json'));
Expand Down
4 changes: 2 additions & 2 deletions sources/jira-source/src/jira.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ const prRegex = new RegExp(
'stateCount=(?<count>[0-9]+)})'
);

const jiraCloudRegex = /^https:\/\/(.*)\.atlassian\.net/g;
export const JIRA_CLOUD_REGEX = /^https:\/\/(.*)\.atlassian\.net/g;
const PREFIX_CHARS = [...'abcdefghijklmnopqrstuvwxyz', ...'0123456789'];

const MAX_SPRINT_HISTORY_FETCH_FAILURES = 5;
Expand Down Expand Up @@ -208,7 +208,7 @@ export class Jira {
throw new VError('Please provide a Jira URL');
}

const isCloud = cfg.url.match(jiraCloudRegex) != null;
const isCloud = cfg.url.match(JIRA_CLOUD_REGEX) != null;
const jiraType = isCloud ? 'Cloud' : 'Server/DC';
logger?.debug(`Assuming ${cfg.url} to be a Jira ${jiraType} instance`);

Expand Down

0 comments on commit 9aef880

Please sign in to comment.