Skip to content

Commit

Permalink
refactor: Add CodeRepository model, service, and permissions
Browse files Browse the repository at this point in the history
This code change adds the CodeRepository model, service, and permissions to the project. It includes the following modifications:

- Added CodeRepository model to the Models/Index.ts file.
- Added CodeRepositoryService to the Services/Index.ts file.
- Created CodeRepositoryService.ts file with the necessary implementation.
- Updated Permission enum in the Permission.ts file to include CreateCodeRepository, DeleteCodeRepository, EditCodeRepository, and ReadCodeRepository permissions.

These changes enable the project to manage code repositories and define the necessary permissions for them.
  • Loading branch information
simlarsen committed Jun 9, 2024
1 parent a24bf07 commit 4c2dfb0
Show file tree
Hide file tree
Showing 6 changed files with 586 additions and 1 deletion.
55 changes: 54 additions & 1 deletion .github/workflows/test.e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:
# Optional. Defaults to repository settings.
retention-days: 7

test-e2e-release:
test-e2e-release-saas:
runs-on: ubuntu-latest
#needs: [test-helm-chart]
env:
Expand Down Expand Up @@ -109,6 +109,59 @@ jobs:
# Maximum 90 days unless changed from the repository settings page.
# Optional. Defaults to repository settings.
retention-days: 7


test-e2e-release-self-hosted:
runs-on: ubuntu-latest
#needs: [test-helm-chart]
env:
CI_PIPELINE_ID: ${{github.run_number}}
steps:
# Docker compose needs a lot of space to build images, so we need to free up some space first in the GitHub Actions runner
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@main
with:
# this might remove tools that are actually needed,
# if set to "true" but frees about 6 GB
tool-cache: false
android: true
dotnet: true
haskell: true
large-packages: true
docker-images: true
swap-storage: true
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 18.3.0
- run: npm run prerun
- name: Start Server with release tag
run: npm run start
- name: Wait for server to start
run: bash ./Tests/Scripts/status-check.sh http://localhost
- name: Run E2E Tests. Run docker container e2e in docker compose file
run: export $(grep -v '^#' config.env | xargs) && docker-compose -f docker-compose.dev.yml up --exit-code-from e2e --abort-on-container-exit e2e || (docker-compose -f docker-compose.dev.yml logs e2e && exit 1)
- name: Upload test results
uses: actions/upload-artifact@v4
# Run this on failure
if: failure()
with:
# Name of the artifact to upload.
# Optional. Default is 'artifact'
name: test-results

# A file, directory or wildcard pattern that describes what to upload
# Required.
path: |
./E2E/playwright-report
./E2E/test-results

# Duration after which artifact will expire in days. 0 means using default retention.
# Minimum 1 day.
# Maximum 90 days unless changed from the repository settings page.
# Optional. Defaults to repository settings.
retention-days: 7



38 changes: 38 additions & 0 deletions Common/Types/Permission.ts
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,11 @@ enum Permission {
DeleteServiceCatalog = 'DeleteServiceCatalog',
EditServiceCatalog = 'EditServiceCatalog',
ReadServiceCatalog = 'ReadServiceCatalog',

CreateCodeRepository = 'CreateCodeRepository',
DeleteCodeRepository = 'DeleteCodeRepository',
EditCodeRepository = 'EditCodeRepository',
ReadCodeRepository = 'ReadCodeRepository',
}

export class PermissionHelper {
Expand Down Expand Up @@ -2442,6 +2447,39 @@ export class PermissionHelper {
isAccessControlPermission: false,
},

{
permission: Permission.CreateCodeRepository,
title: 'Create Code Repository',
description:
'This permission can create Code Repository this project.',
isAssignableToTenant: true,
isAccessControlPermission: true,
},
{
permission: Permission.DeleteCodeRepository,
title: 'Delete Code Repository',
description:
'This permission can delete Code Repository of this project.',
isAssignableToTenant: true,
isAccessControlPermission: true,
},
{
permission: Permission.EditCodeRepository,
title: 'Edit Code Repository',
description:
'This permission can edit Code Repository of this project.',
isAssignableToTenant: true,
isAccessControlPermission: true,
},
{
permission: Permission.ReadCodeRepository,
title: 'Read Code Repository',
description:
'This permission can read Code Repository of this project.',
isAssignableToTenant: true,
isAccessControlPermission: true,
},

{
permission: Permission.CreateServiceCatalog,
title: 'Create Service Catalog',
Expand Down
25 changes: 25 additions & 0 deletions CommonServer/Services/CodeRepositoryService.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import PostgresDatabase from '../Infrastructure/PostgresDatabase';
import CreateBy from '../Types/Database/CreateBy';
import { OnCreate } from '../Types/Database/Hooks';
import DatabaseService from './DatabaseService';
import ObjectID from 'Common/Types/ObjectID';
import Model from 'Model/Models/CodeRepository';

export class Service extends DatabaseService<Model> {
public constructor(postgresDatabase?: PostgresDatabase) {
super(Model, postgresDatabase);
}

protected override async onBeforeCreate(
createBy: CreateBy<Model>
): Promise<OnCreate<Model>> {
createBy.data.secretToken = ObjectID.generate();

return {
carryForward: null,
createBy: createBy,
};
}
}

export default new Service();
3 changes: 3 additions & 0 deletions CommonServer/Services/Index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import BillingPaymentMethodsService from './BillingPaymentMethodService';
import BillingService from './BillingService';
import CallLogService from './CallLogService';
import CallService from './CallService';
import CodeRepositoryService from './CodeRepositoryService';
import DataMigrationService from './DataMigrationService';
import DomainService from './DomainService';
import EmailLogService from './EmailLogService';
Expand Down Expand Up @@ -253,6 +254,8 @@ const services: Array<BaseService> = [
ServiceCatalogService,
ServiceCatalogOwnerTeamService,
ServiceCatalogOwnerUserService,

CodeRepositoryService,
];

export const AnalyticsServices: Array<
Expand Down
Loading

0 comments on commit 4c2dfb0

Please sign in to comment.