Skip to content

Commit 51b26a2

Browse files
Merge pull request #171 from intelops/fix-chart-issues
Fix chart issues
2 parents 51cb1dd + f1d7468 commit 51b26a2

26 files changed

+343
-195
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,5 @@ openapitools.json
1414
/ui/.env.kind.cluster
1515
/app/compage-app.sqlite3
1616
/deploy/build/
17+
/app/secure-connect-compage.zip
18+
/charts/compage/secure-connect-compage.zip

CONTRIBUTING.md

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ To contribute code.
1919
GO111MODULE=on
2020
GOFLAGS=-mod=vendor
2121
```
22-
3. Ensure you have Node.js(LTS >= 18.12.0) installed for Core and UI part of the compage.
23-
4. Ensure you have access to any Kubernetes (tested on KinD) cluster to store the compage projects and users related data on it.
22+
3. Ensure you have Node.js(LTS >= v18.18.0) installed for app and ui part of the compage.
2423
#### KinD
2524
- Install KinD from https://kind.sigs.k8s.io/docs/user/quick-start/#installing-from-release-binaries
2625
- Create KinD cluster using below command
@@ -29,19 +28,16 @@ To contribute code.
2928
./create-kind-cluster.sh
3029
```
3130
- Check if you can access the cluster created in previous step, and you are able to list down the pods.
32-
5. Fork the project.
33-
6. Clone the project: `git clone https://github.com/[YOUR_USERNAME]/compage && cd compage`
34-
7. kindly refer compage.md file to know the structure of the project.
35-
8. The Compage has three servers (subprojects) which need to be started to run the compage on local
31+
4. Fork the project.
32+
5. Clone the project: `git clone https://github.com/[YOUR_USERNAME]/compage && cd compage`
33+
6. kindly refer compage.md file to know the structure of the project.
34+
7. The Compage has three servers (subprojects) which need to be started to run the compage on local
3635
- core (Golang), navigate to core directory and follow its [core README](./core/README.md)
3736
- app (Node.js), navigate to app directory and follow its [app README](./app/README.md)
3837
- ui (ReactJs), navigate to ui directory and follow its [ui README](./ui/README.md)
39-
9. Commit changes *([Please refer the commit message conventions](https://www.conventionalcommits.org/en/v1.0.0/))*
40-
10. Push commits.
41-
11. Open pull request.
42-
43-
## Improving the Documentation
44-
The documentation is contained within `./docs` and made with Docusaurus. See the [Docs README](./docs/README.md) for infos about developing the docs.
38+
8. Commit changes *([Please refer the commit message conventions](https://www.conventionalcommits.org/en/v1.0.0/))*
39+
9. Push commits.
40+
10. Open pull request.
4541
4642
## Regenerate the gRPC code from .proto files
4743
- Install below packages in order to regenerate the gRPC code.
@@ -57,5 +53,5 @@ The documentation is contained within `./docs` and made with Docusaurus. See the
5753
```shell
5854
buf generate
5955
```
60-
## How are K8s and GitHub interacted with above three components?
61-
![architecture-med.png](images/architecture-med.png)
56+
## How are DB(sqlite/cassandra) and GitHub interacted with above three components?
57+
![architecture.png](images/architecture-med.png)

app/Dockerfile

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,23 @@ RUN apk update && apk add git
1616
COPY --from=builder /app/dist /server/dist
1717
COPY --from=builder /app/node_modules /server/node_modules
1818
COPY --from=builder /app/protobufs /server/protobufs
19+
20+
ARG USER_NAME=compageuser
21+
ARG GROUP_NAME=compagegroup
1922
### Add new user
20-
RUN adduser -D -g '' compageuser
23+
RUN addgroup -g 1001 $GROUP_NAME && adduser -D -u 1001 -G $GROUP_NAME $USER_NAME
24+
USER $USER_NAME
25+
26+
### create workdir directory
2127
RUN mkdir -p $HOME/.compage/workdir
2228
RUN chmod -R 777 $HOME/.compage/workdir
23-
USER compageuser
29+
RUN chown -R $USER_NAME:$GROUP_NAME $HOME/.compage/workdir
30+
31+
### create logs directory
32+
RUN mkdir -p $HOME/.compage/logs
33+
RUN chmod -R 777 $HOME/.compage/logs
34+
RUN chown -R $USER_NAME:$GROUP_NAME $HOME/.compage/logs
35+
2436
ENV NODE_ENV=production
2537
EXPOSE 5000
2638
CMD [ "node", "dist/src/app.js" ]

app/README.md

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,37 @@
11
# app
2-
- This is a component that connects to different git-platforms and push-pull repositories.
3-
- This also uses Cassandra or SQLite (based on configuration) databases to persist projects, git platforms, and users related details.
2+
3+
- This is a component that connects to different git-platforms and push-pull repositories.
4+
- This also uses Cassandra or SQLite (based on configuration) databases to persist projects, git platforms, and users
5+
related details.
46
- It's an Express.js based REST server and gRPC client to a core component.
5-
- The sqlite is used as a database for development. To use cassandra, you need to set the following environment variables in your terminal along with a `environment DB_TYPE='cassandra'`.
7+
- The sqlite is used as a database for development. To use cassandra, you need to set the following environment
8+
variables in your terminal along with a `environment DB_TYPE='cassandra'`.
9+
10+
#### Use cassandra as a database
11+
612
```bash
7-
export CASSANDRA_CONTACT_POINTS = 'localhost';
8-
export CASSANDRA_LOCAL_DATA_CENTER = 'datacenter1';
9-
export CASSANDRA_KEYSPACE = 'compage';
10-
export CASSANDRA_USERNAME = 'cassandra';
11-
export CASSANDRA_PASSWORD = 'cassandra';
13+
export DB_TYPE='cassandra';
14+
export CASSANDRA_CONTACT_POINTS = 'localhost';
15+
export CASSANDRA_LOCAL_DATA_CENTER = 'datacenter1';
16+
export CASSANDRA_KEYSPACE = 'compage';
17+
export CASSANDRA_USERNAME = 'cassandra';
18+
export CASSANDRA_PASSWORD = 'cassandra';
19+
```
20+
21+
- To start the cassandra server on local, you can fire command `docker-compose up -d` from the setup directory of
22+
compage/app.
23+
24+
#### Use SQLite as a database
25+
26+
```shell
27+
export DB_TYPE='sqlite'
1228
```
13-
- To start the cassandra server on local, you can fire command `docker-compose up -d` from the setup directory of compage/app.
1429

1530
#### How to run this component?
31+
1632
- Navigate to app directory [`cd app`] from root directory of compage
1733
- Fire `npm install` to install the dependencies
18-
- Run `npm run dev` command to start the express-server. This command will auto-reload the changes you make to app directory.
34+
- Run `npm run dev` command to start the express-server. This command will auto-reload the changes you make to app
35+
directory.
1936
- If something goes wrong, you want to kill the process on port 5000, run the following command
20-
```sudo kill -9 `sudo lsof -t -i:5000```
37+
```sudo kill -9 `sudo lsof -t -i:5000```

app/src/integrations/simple-git/common.ts

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -42,19 +42,17 @@ export const gitOperations = async (git: SimpleGit, repositoryBranch?: string, p
4242
branchName = repositoryBranch + '-' + projectVersion;
4343
}
4444

45-
if (repositoryBranch && projectVersion) {
46-
// checkoutLocalBranch checks out local branch with name supplied
47-
await git.checkoutLocalBranch(branchName)
48-
.then(
49-
(success: any) => {
50-
Logger.debug(`git checkoutLocalBranch succeeded: ${JSON.stringify(success)}`);
51-
}, (failure: any) => {
52-
Logger.debug(`git checkoutLocalBranch failed: ${JSON.stringify(failure)}`);
53-
error = `git checkoutLocalBranch failed: ${JSON.stringify(failure)}`;
54-
});
55-
if (error.length > 0) {
56-
return error;
57-
}
45+
// checkoutLocalBranch checks out local branch with name supplied
46+
await git.checkoutLocalBranch(branchName)
47+
.then(
48+
(success: any) => {
49+
Logger.debug(`git checkoutLocalBranch succeeded: ${JSON.stringify(success)}`);
50+
}, (failure: any) => {
51+
Logger.debug(`git checkoutLocalBranch failed: ${JSON.stringify(failure)}`);
52+
error = `git checkoutLocalBranch failed: ${JSON.stringify(failure)}`;
53+
});
54+
if (error.length > 0) {
55+
return error;
5856
}
5957

6058
// Finally, push to online repository

app/src/integrations/simple-git/newProject.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import Logger from '../../utils/logger';
44
import {NewProjectGitServerRequest} from './models';
55

66
export const pushNewProjectToGitServer = async (newProjectGitServerRequest: NewProjectGitServerRequest): Promise<string> => {
7-
console.log('pushNewProjectToGitServer' + newProjectGitServerRequest.generatedProjectPath);
87
const options: Partial<SimpleGitOptions> = {
98
baseDir: newProjectGitServerRequest.generatedProjectPath,
109
binary: 'git',

app/src/routes/codeOperations.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import {getProjectGrpcClient} from '../grpc/project';
22
import {Router} from 'express';
33
import * as fs from 'fs';
4-
import * as os from 'os';
54
import {
65
cloneExistingProjectFromGitServer,
76
pushToExistingProjectOnGitServer,
@@ -40,9 +39,12 @@ codeOperationsRouter.post('/generate', requireEmailMiddleware, async (request, r
4039

4140
const cleanup = (downloadedPrjPath: string) => {
4241
// remove directory created, delete directory recursively
43-
rimraf(downloadedPrjPath).then((result: any) => {
44-
Logger.debug(`Result: ${result}`);
45-
Logger.debug(`${downloadedPrjPath} is cleaned up`);
42+
rimraf(downloadedPrjPath).then((result: boolean) => {
43+
if (result) {
44+
Logger.debug(`${downloadedPrjPath} is cleaned up`);
45+
} else {
46+
Logger.debug(`${downloadedPrjPath} is not cleaned up`);
47+
}
4648
});
4749
};
4850

app/src/services/gitPlatformService.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,20 @@ import {GitPlatformEntity} from '../models/gitPlatform';
22
import {GitPlatformDao} from '../store/gitPlatformDao';
33
import {SqliteGitPlatformDaoImpl} from '../store/sqliteGitPlatformDaoImpl';
44
import {CassandraGitPlatformDaoImpl} from '../store/cassandraGitPlatformDaoImpl';
5+
import config from '../utils/constants';
56

67
export class GitPlatformService {
78
private gitPlatformDao: GitPlatformDao;
89

910
constructor() {
10-
// create the appropriate gitPlatformDao based on the environment
11-
this.gitPlatformDao = process.env.NODE_ENV === 'production'
12-
? new CassandraGitPlatformDaoImpl()
13-
: new SqliteGitPlatformDaoImpl();
11+
// create the appropriate gitPlatformDao based on the DB_TYPE
12+
if (config.db?.type === 'cassandra') {
13+
this.gitPlatformDao = new CassandraGitPlatformDaoImpl();
14+
} else if (config.db?.type === 'sqlite') {
15+
this.gitPlatformDao = new SqliteGitPlatformDaoImpl();
16+
} else {
17+
throw new Error('Invalid process.env.DB_TYPE');
18+
}
1419
}
1520

1621
async createGitPlatform(gitPlatform: GitPlatformEntity): Promise<GitPlatformEntity> {

app/src/services/projectService.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,20 @@ import {ProjectEntity} from '../models/project';
22
import {ProjectDao} from '../store/projectDao';
33
import {SqliteProjectDaoImpl} from '../store/sqliteProjectDaoImpl';
44
import {CassandraProjectDaoImpl} from '../store/cassandraProjectDaoImpl';
5+
import config from '../utils/constants';
56

67
export class ProjectService {
78
private projectDao: ProjectDao;
89

910
constructor() {
10-
// create the appropriate projectDao based on the environment
11-
this.projectDao = process.env.NODE_ENV === 'production'
12-
? new CassandraProjectDaoImpl()
13-
: new SqliteProjectDaoImpl();
11+
// create the appropriate projectDao based on the DB_TYPE
12+
if (config.db?.type === 'cassandra') {
13+
this.projectDao = new CassandraProjectDaoImpl();
14+
} else if (config.db?.type === 'sqlite') {
15+
this.projectDao = new SqliteProjectDaoImpl();
16+
} else {
17+
throw new Error('Invalid process.env.DB_TYPE');
18+
}
1419
}
1520

1621
async createProject(project: ProjectEntity): Promise<ProjectEntity> {

app/src/services/userService.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,20 @@ import {UserEntity} from '../models/user';
22
import {UserDao} from '../store/userDao';
33
import {SqliteUserDaoImpl} from '../store/sqliteUserDaoImpl';
44
import {CassandraUserDaoImpl} from '../store/cassandraUserDaoImpl';
5+
import config from '../utils/constants';
56

67
export class UserService {
78
private userDao: UserDao;
89

910
constructor() {
10-
// create the appropriate userDao based on the environment
11-
this.userDao = process.env.NODE_ENV === 'production'
12-
? new CassandraUserDaoImpl()
13-
: new SqliteUserDaoImpl();
11+
// create the appropriate userDao based on the DB_TYPE
12+
if (config.db?.type === 'cassandra') {
13+
this.userDao = new CassandraUserDaoImpl();
14+
} else if (config.db?.type === 'sqlite') {
15+
this.userDao = new SqliteUserDaoImpl();
16+
} else {
17+
throw new Error('Invalid process.env.DB_TYPE');
18+
}
1419
}
1520

1621
async createUser(user: UserEntity): Promise<UserEntity> {

0 commit comments

Comments
 (0)