You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: cmd/project-api/README.md
+66-5Lines changed: 66 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -43,9 +43,13 @@ This service handles the following NATS subjects:
43
43
44
44
### Prerequisites
45
45
46
-
This service uses the [GOA Framework](https://goa.design/) for API generation. You'll need to install GOA before building the service.
46
+
-[**Go**](https://go.dev/): the service is built with the Go programming language [[Install](https://go.dev/doc/install)]
47
+
-[**Kubernetes**](https://kubernetes.io/): used for deployment of resources [[Install](https://kubernetes.io/releases/download/)]
48
+
-[**Helm**](https://helm.sh/): used to manage kubernetes applications [[Install](https://helm.sh/docs/intro/install/)]
49
+
-[**NATS**](https://docs.nats.io/): used to communicate with other LFX V2 services [[Install](https://docs.nats.io/running-a-nats-service/introduction/installation)]
50
+
-[**GOA Framework**](https://goa.design/): used for API code generation
47
51
48
-
#### Installing GOA Framework
52
+
#### GOA Framework
49
53
50
54
Follow the [GOA installation guide](https://goa.design/docs/2-getting-started/1-installation/) to install GOA:
51
55
@@ -77,31 +81,88 @@ This command generates:
77
81
- Service interfaces and types
78
82
- Transport layer implementations
79
83
80
-
#### 2. Development Workflow
84
+
#### 2. Set up resources and external services
85
+
86
+
The service relies on some resources and external services being spun up prior to running this service.
87
+
88
+
-[NATS service](https://docs.nats.io/): ensure you have a NATS server instance running and set the `NATS_URL` environment variable with the URL of the server
- [NATS key-value bucket](https://docs.nats.io/nats-concepts/jetstream/key-value-store): once you have a NATS service running, you need to create a bucket used by the project service.
|LOG_LEVEL|the log level for outputted logs|info|false|
109
+
|LOG_ADD_SOURCE|whether to add the source field to outputted logs|false|false|
110
+
111
+
#### 4. Development Workflow
81
112
82
113
1. **Make design or implementation changes**: Edit files in the `design/` directory for design changes, and edit the other files for implementation changes.
114
+
83
115
2. **Regenerate code**: Run `make apigen` after design changes
116
+
84
117
3. **Build the service**:
85
118
```bash
86
119
make build
87
120
```
88
-
4.**Run the service** (for development):
121
+
4. **Run the service**:
89
122
```bash
90
123
make run
91
124
92
-
#enable debug logging
125
+
#or run with debug logs enabled
93
126
make debug
127
+
128
+
# or run with the go command to set custom flags
129
+
# -bind string interface to bind on (default "*")
130
+
# -d enable debug logging (default false)
131
+
# -p string listen port (default "8080")
132
+
go run
94
133
```
95
134
5. **Run tests**:
96
135
```bash
97
136
make test
137
+
138
+
# or run go test to set custom flags
139
+
go test. -v
98
140
```
99
141
142
+
6. **Docker build + K8**
143
+
144
+
```bash
145
+
# Build the dockerfile (from the root of the repo)
# Check that the REST API is accessible by hitting the `/livez` endpoint (you should get a response of OK if it is working):
155
+
#
156
+
# Note: replace the hostname with the host from ./charts/lfx-v2-project-service/ingressroute.yaml
157
+
curl http://lfx-api.k8s.orb.local/livez
158
+
```
159
+
100
160
### Add new API endpoints
101
161
Note: follow the [Development Workflow](#2-development-workflow) section on how to run the service code
102
162
1. **Update design files**: Edit project file in`design/` to include specicification of the new endpoint with all of its supported parameters, responses, and errors, etc.
103
163
2. **Regenerate code**: Run `make apigen` after design changes
104
164
3. **Implement code**: Implement the new endpoint in`service_endpoint.go`. Follow similar standards of the other endpoint methods. Include tests forthe new endpointin`service_endpoint_test.go`.
165
+
4. **Update heimdall ruleset**: Ensure that `/charts/lfx-v2-project-service/templates/ruleset.yaml` has the route and method for the endpoint set so that authentication is configured when deployed
105
166
106
167
### Add new message handlers
107
168
Note: follow the [Development Workflow](#2-development-workflow) section on how to run the service code
0 commit comments