Skip to content

Commit fe5fc7e

Browse files
Merge pull request #129 from intelops/ui-fixes
Minor fixes
2 parents c3e1b19 + b593732 commit fe5fc7e

File tree

35 files changed

+622
-107
lines changed

35 files changed

+622
-107
lines changed

.github/workflows/core-ci.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,15 @@ jobs:
4444
- name: Test
4545
run: |
4646
cd core
47+
sudo apt install dos2unix -y
48+
# install openapi-generator-cli
49+
mkdir -p $HOME/ogc
50+
curl https://raw.githubusercontent.com/OpenAPITools/openapi-generator/master/bin/utils/openapi-generator-cli.sh > $HOME/ogc/openapi-generator-cli && chmod a+x $HOME/ogc/openapi-generator-cli
4751
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
4852
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
4953
export GOPATH=$HOME/go
5054
export GOBIN=$GOPATH/bin
51-
export PATH=$PATH:$GOROOT:$GOBIN
55+
export PATH=$PATH:$GOPATH:$GOBIN:$HOME/ogc
5256
go test -v ./... -race -coverprofile=coverage.out -coverpkg=./... -covermode=atomic
5357
cd ..
5458
- name: Upload coverage to Codecov
@@ -142,4 +146,4 @@ jobs:
142146
format: 'github'
143147
output: 'dependency-results.sbom.json'
144148
image-ref: '.'
145-
github-pat: ${{ secrets.GH_TOKEN }}
149+
github-pat: ${{ secrets.GH_TOKEN }}

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
/app/scratch/
88
/core/core
99
/.idea
10-
/core/openapitools.json
1110
/core/coverage.out
12-
/app/coverage
11+
/app/coverage
12+
openapitools.json

app/crds/project-crd.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ spec:
5151
type: string
5252
branch:
5353
type: string
54+
isPublic:
55+
type: boolean
5456
oldVersions:
5557
type: array
5658
items:

app/src/routes/code-operations.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ codeOperationsRouter.post('/generate', requireUserNameMiddleware, async (request
3939
const cleanup = (downloadedPrjPath: string) => {
4040
// remove directory created, delete directory recursively
4141
rimraf(downloadedPrjPath).then((result: any) => {
42+
Logger.debug(`Result: ${result}`);
4243
Logger.debug(`${downloadedPrjPath} is cleaned up`);
4344
});
4445
};
@@ -53,8 +54,8 @@ codeOperationsRouter.post('/generate', requireUserNameMiddleware, async (request
5354
if (!projectResource.spec.json
5455
|| projectResource.spec.json === '{}'
5556
|| projectResource.spec.json.length === 0
56-
|| !JSON.parse(projectResource.spec.json).nodes
57-
|| JSON.parse(projectResource.spec.json).nodes?.length === 0) {
57+
|| !JSON.parse(projectResource.spec.json)?.nodes
58+
|| JSON.parse(projectResource.spec.json)?.nodes?.length === 0) {
5859
const message = `unable to generate code, have at least a node added to your project: ${projectResource.spec.displayName}[${projectId}].`;
5960
return resource.status(500).json(getGenerateCodeError(message));
6061
}

app/src/routes/models.ts

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,20 @@ export interface CompageEdge {
8888
export interface CompageJson {
8989
edges: Map<string, CompageEdge>;
9090
nodes: Map<string, CompageNode>;
91-
version: string;
91+
version?: string;
92+
workspace?: any;
93+
undoHistory?: any;
94+
potentialNode?: any;
95+
potentialEdge?: any;
96+
plugins?: any;
97+
panels?: any;
98+
editor?: any;
9299
}
93100

94101
export interface Repository {
95102
name: string;
96103
branch: string;
104+
isPublic: boolean;
97105
}
98106

99107
// all keys are of string format
@@ -196,12 +204,19 @@ export interface DeleteProjectError {
196204
}
197205

198206
export const initializeEmptyProjectEntity = () => {
199-
const repository: Repository = {branch: '', name: ''};
207+
const repository: Repository = {branch: '', name: '', isPublic: false};
200208
const user: User = {email: '', name: ''};
201209
const json: CompageJson = {
202210
edges: new Map<string, CompageEdge>(),
203211
nodes: new Map<string, CompageNode>(),
204-
version: ''
212+
version: '',
213+
editor: {},
214+
panels: {},
215+
plugins: {},
216+
undoHistory: {},
217+
workspace: {},
218+
potentialEdge: {},
219+
potentialNode: {}
205220
};
206221
const projectEntity: ProjectEntity = {
207222
displayName: '',

app/src/routes/projects-operations.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ const addToGithub = (projectEntity: ProjectEntity, response: Response) => {
9292
base64Json,
9393
'first commit',
9494
sha).then(resp => {
95+
Logger.debug(`commitCompageJson Response: ${JSON.stringify(resp.data)}`);
9596
const message = `The .compage/config.json in Repository for '${projectEntity.displayName}' is committed, ${projectEntity.displayName}[${projectEntity.id}] project is created successfully.`;
9697
Logger.info(message);
9798
return response.status(200).json(getCreateProjectResponse(projectEntity, message));
@@ -166,8 +167,9 @@ const updateFromGithub = (projectEntity: ProjectEntity, response: Response) => {
166167
// creates repository on GitHub and commits first version of yaml
167168
const createOnGithub = (projectEntity: ProjectEntity, response: Response) => {
168169
// TODO change description
169-
return createRepository(projectEntity.user.name, projectEntity.repository.name, projectEntity.repository.name)
170+
return createRepository(projectEntity.user.name, projectEntity.repository.name, projectEntity.repository.name, projectEntity.repository.isPublic)
170171
.then(resp => {
172+
Logger.debug(`createRepository Response: ${JSON.stringify(resp.data)}`);
171173
// create .compage/config.json file in GitHub repo
172174
return addToGithub(projectEntity, response);
173175
}).catch(error => {

app/src/util/github-client.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const ACCEPT = `application/vnd.github+json`;
55
const USER_REPO_URL = `https://api.github.com/user/repos`;
66
const REPO_URL = `https://api.github.com/repos`;
77

8-
export const createRepository = async (userName: string, repositoryName: string, description: string) => {
8+
export const createRepository = async (userName: string, repositoryName: string, description: string, isPublic: boolean) => {
99
return axios({
1010
headers: {
1111
Accept: ACCEPT,
@@ -14,7 +14,7 @@ export const createRepository = async (userName: string, repositoryName: string,
1414
url: USER_REPO_URL, method: 'POST', data: {
1515
name: repositoryName,
1616
description,
17-
private: true,
17+
private: !isPublic,
1818
}
1919
});
2020
};

app/src/util/project-client.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const convertProjectEntityToProjectResourceSpec = (projectId: string, userName:
1616
const repository: Repository = {
1717
branch: '',
1818
name: '',
19+
isPublic: projectEntity.repository.isPublic
1920
};
2021

2122
// if repository name is not set, add displayName as repository name.

charts/compage/templates/crds/project-crd.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ spec:
5353
type: string
5454
branch:
5555
type: string
56+
isPublic:
57+
type: boolean
5658
metadata:
5759
type: string
5860
version:

core/Dockerfile

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Build stage will be used:
33
# - for building the application for production
44
# - as target for development (see devspace.yaml)
5-
FROM golang:1.20.2-alpine3.17 as builder
5+
FROM golang:1.20.5-alpine3.18 as builder
66

77
# Create project directory (workdir)
88
WORKDIR /app
@@ -22,17 +22,15 @@ FROM alpine:3.18.2
2222
# Create project directory (workdir)
2323
WORKDIR /app
2424

25-
RUN apk update && apk add protoc && apk add openjdk8
26-
RUN apk update && apk add bash && apk add curl && apk add jq && apk add --update go \
25+
RUN apk update && apk add protoc && apk add dos2unix && apk add openjdk8 && apk add make && apk add bash && apk add curl && apk add jq && apk add --update go \
2726
&& curl https://raw.githubusercontent.com/OpenAPITools/openapi-generator/master/bin/utils/openapi-generator-cli.sh \
2827
> /app/openapi-generator-cli \
29-
&& chmod u+x /app/openapi-generator-cli \
30-
&& export PATH=$PATH:/app/
28+
&& chmod a+x /app/openapi-generator-cli
3129

3230
# Downloading and installing Maven
33-
ARG MAVEN_VERSION=3.9.2
31+
ARG MAVEN_VERSION=3.9.3
3432
ARG USER_HOME_DIR="/root"
35-
ARG BASE_URL=https://apache.osuosl.org/maven/maven-3/${MAVEN_VERSION}/binaries
33+
ARG BASE_URL=https://dlcdn.apache.org/maven/maven-3/${MAVEN_VERSION}/binaries
3634
RUN mkdir -p /usr/share/maven /usr/share/maven/ref \
3735
&& echo "Downloading maven" \
3836
&& curl -fsSL -o /tmp/apache-maven.tar.gz ${BASE_URL}/apache-maven-${MAVEN_VERSION}-bin.tar.gz \
@@ -41,17 +39,20 @@ RUN mkdir -p /usr/share/maven /usr/share/maven/ref \
4139
&& echo "Cleaning and setting links" \
4240
&& rm -f /tmp/apache-maven.tar.gz \
4341
&& ln -s /usr/share/maven/bin/mvn /usr/bin/mvn
42+
4443
ENV MAVEN_HOME /usr/share/maven
4544
ENV MAVEN_CONFIG "$USER_HOME_DIR/.m2"
4645

47-
ENV PATH="/usr/local/go/bin:$PATH"
46+
ENV PATH="/usr/local/go/bin:$PATH:/app/"
4847
ENV GOPATH /go
4948
ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH
5049
RUN mkdir -p "$GOPATH/src" "$GOPATH/bin" && chmod -R 777 "$GOPATH"
5150

5251
# test if the below command avoids loading the files later.
5352
RUN /app/openapi-generator-cli version
5453
RUN go version
54+
RUN go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
55+
RUN go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
5556
COPY --from=builder /app/core /
5657
COPY templates /app/templates
5758
# Application port (optional)

0 commit comments

Comments
 (0)