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

fix: repo info for Gitlab does not support group nesting #140

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ export class AwsAppsPlatformApi {

if (this.gitProvider===GitProviders.GITLAB)
{
resultBody = await result.value.json();
resultBody = result.value;
faymard marked this conversation as resolved.
Show resolved Hide resolved
}
else if (this.gitProvider===GitProviders.GITHUB)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export class GitLabAPI implements ISCMBackendAPI {
}
else
{
groupName=""
groupName=gitProjectGroup
repoName = gitRepoName;
}
const url = `https://${gitHost}/api/v4/projects?search=${repoName}`;
Expand Down Expand Up @@ -156,7 +156,7 @@ export class GitLabAPI implements ISCMBackendAPI {
isSuccuess: true,
message: `Retrieved file content successfully`,
httpResponse : result.status,
value:resultBody.content
value: Buffer.from(resultBody.content, 'base64').toString()
faymard marked this conversation as resolved.
Show resolved Hide resolved
};
}
}
Expand Down
10 changes: 6 additions & 4 deletions backstage-plugins/plugins/aws-apps-common/src/utils/git-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,20 @@ export const getRepoInfo = (entity:Entity) : IRepositoryInfo => {

switch (gitProvider) {
case GitProviders.GITLAB:
var projectSlugArray = entity.metadata.annotations ? entity.metadata.annotations['gitlab.com/project-slug']?.toString().split('/') : [];
return {
gitProvider,
gitHost: entity.metadata.annotations ? entity.metadata.annotations['gitlab.com/instance']?.toString() : "",
gitRepoName: entity.metadata.annotations ? entity.metadata.annotations['gitlab.com/project-slug']?.toString() : "",
gitProjectGroup: entity.metadata.annotations ? entity.metadata.annotations['gitlab.com/project-slug']?.toString().split('/')[0] : "",
gitRepoName: projectSlugArray.pop() || "", // get last element of path for the repository name or empty string if the array is empty
gitProjectGroup: projectSlugArray.join("/"), // re-join the remainder of the array to get the namespace
isPrivate: true
}
case GitProviders.GITHUB:
var projectSlugArray = entity.metadata.annotations ? entity.metadata.annotations['github.com/project-slug']?.toString().split('/') : []
return {
gitHost: "github.com",
gitRepoName: entity.metadata.annotations ? entity.metadata.annotations['github.com/project-slug']?.toString().split('/')[1] : "",
gitOrganization: entity.metadata.annotations ? entity.metadata.annotations['github.com/project-slug']?.toString().split('/')[0] : "",
gitRepoName: projectSlugArray[1], // get last element of the array (repo name)
gitOrganization: projectSlugArray[0], // get first element of the array (organization)
gitProvider,
isPrivate: true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ const AwsEnvironmentProviderCard = ({
};

let repoInfo = getRepoInfo(entity);
repoInfo.gitProjectGroup = 'aws-environments'

const params = {
repoInfo,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ const DeleteEnvironmentPanel = ({

const [disabled, setDisabled] = useState(false);
let repoInfo = getRepoInfo(entity);
repoInfo.gitProjectGroup = 'aws-environments';

const deleteRepo = () => {
api.deleteRepository({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ const DeleteProviderPanel = ({

const [disabled, setDisabled] = useState(false);
let repoInfo = getRepoInfo(entity);
repoInfo.gitProjectGroup = 'aws-providers';

const deleteRepo = () => {

Expand Down