Skip to content

Commit

Permalink
Feature flag fetching projects by search criteria
Browse files Browse the repository at this point in the history
  • Loading branch information
subbuvenk-atlas committed Dec 16, 2024
1 parent 30bde85 commit 0eb66de
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 7 additions & 2 deletions src/client/gitlab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
import { GitlabHttpMethodError, InvalidConfigFileError } from '../models/errors';
import { INVALID_YAML_ERROR } from '../models/error-messages';
import { queryParamsGenerator } from '../utils/url-utils';
import { isGitlabMaintainerTokenEnabled } from '../services/feature-flags';

export enum HttpMethod {
GET = 'GET',
Expand Down Expand Up @@ -289,16 +290,20 @@ export const getProjectBranch = async (
};

/**
* Get project data that the token role is at least a maintainer of, filtered by search criteria.
* Get project data filtered by search criteria.
* @param search - search criteria i.e. project name
* @param groupToken - Gitlab access token
*/
export const getMaintainedProjectsBySearchCriteria = async (
search: string,
groupToken: string,
): Promise<GitlabAPIProject[]> => {
const roleFilter = isGitlabMaintainerTokenEnabled()
? { min_access_level: GitLabAccessLevels.MAINTAINER.toString() }
: { owned: 'true' };

const params = {
min_access_level: GitLabAccessLevels.MAINTAINER.toString(),
...roleFilter,
search,
};

Expand Down
2 changes: 1 addition & 1 deletion src/services/feature-flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const isDocumentComponentLinksDisabled = (defaultValue = false): boolean => {
return process.env.DISABLE_DOCUMENT_COMPONENT_LINKS === 'true' || defaultValue;
};

const isGitlabMaintainerTokenEnabled = (defaultValue = false): boolean => {
export const isGitlabMaintainerTokenEnabled = (defaultValue = false): boolean => {
return process.env.ENABLE_GITLAB_MAINTAINER_TOKEN === 'true' || defaultValue;
};

Expand Down

0 comments on commit 0eb66de

Please sign in to comment.