Skip to content

Commit

Permalink
16 add endpoints for passing appointment data to and from campus (#19)
Browse files Browse the repository at this point in the history
* refactor to match new BB template architecture

* appooitments units and people endpoints working

* slots endpoint working

* add question property to question object being returned

* slots, questions and qands endpoints created

* create and delete appts

* new .secrets.baseline

* adding yaml files for documentation

* update provider id for engineering

* updated yaml files

* fix issue with missing or invalid person_id for units api

* updated docs to include units api

* image_url added to units and people,
next_avail added to units

* updateappointment endpoint and documentation

* update conventions and changelong

* add build.yaml file

* updated secrets baseline
  • Loading branch information
clint156 authored May 1, 2023
1 parent 4bcec96 commit 5825d7f
Show file tree
Hide file tree
Showing 109 changed files with 8,289 additions and 3,321 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Build

on:
push:
branches: [ develop ]
pull_request:
branches: [ develop ]

jobs:

build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: '1.20'
check-latest: true

- name: Build
run: make
38 changes: 9 additions & 29 deletions .secrets.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -128,46 +128,26 @@
"is_secret": false
}
],
"driven/contactinfo/uiuc_contactinfo.go": [
"driven/uiucadapters/laundryadapter.go": [
{
"type": "Secret Keyword",
"filename": "driven/contactinfo/uiuc_contactinfo.go",
"hashed_secret": "e8a1c6ef3889d4c1f0fe37af5c9a782d3dc45f00",
"filename": "driven/uiucadapters/laundryadapter.go",
"hashed_secret": "0cf56cce952f22a8ea044fe0ff52f2ddbba6e462",
"is_verified": false,
"line_number": 117,
"line_number": 163,
"is_secret": false
}
],
"driven/courses/uiuc_courses.go": [
"driven/uiucadapters/wayfindingadapter.go": [
{
"type": "Secret Keyword",
"filename": "driven/courses/uiuc_courses.go",
"hashed_secret": "a2b25e53b264bf5320c253983eb50156d07ec037",
"filename": "driven/uiucadapters/wayfindingadapter.go",
"hashed_secret": "abd4b25cafb785cdf391edc04f82d8af45e1405c",
"is_verified": false,
"line_number": 133,
"is_secret": false
}
],
"driven/laundry/csc_laundryview.go": [
{
"type": "Secret Keyword",
"filename": "driven/laundry/csc_laundryview.go",
"hashed_secret": "09ff4b16fe5c5d3fe24fc78231db976393d46f9a",
"is_verified": false,
"line_number": 99,
"is_secret": false
}
],
"driven/location/uiuc_buildingdata.go": [
{
"type": "Secret Keyword",
"filename": "driven/location/uiuc_buildingdata.go",
"hashed_secret": "d42e283b5bff2a623b6f332fd14ac698166810fa",
"is_verified": false,
"line_number": 77,
"line_number": 41,
"is_secret": false
}
]
},
"generated_at": "2023-02-15T20:09:55Z"
"generated_at": "2023-05-01T21:52:28Z"
}
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- Prepare the project to become open source [#2](https://github.com/rokwire/gateway-building-block/issues/2)

## 2.0.3 - 5/1/23
### Added
--appointments end points and interfaces

### Changed
--updated old code to new building block template model


## 1.2.6 - 3/9/23
### Fixed
--Security vulnerability in golang.org/x/text/language
Expand Down
44 changes: 32 additions & 12 deletions CONVENTIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ We should keep the changelog up to date as this is part of the open source platf

## API Documentation
When implementing an API:
- Use [swag](https://github.com/swaggo/swag) annotations when defining a new API handler function
- Run `make swagger` to generate the `swagger.yaml`, `swagger.json`, and `docs.go` files stored in the `docs/` folder. To run this command, you will need to install [swag](https://github.com/swaggo/swag). This command will automatically generate Open API 3 documentation for all functions using the annotations. Please do not change any of the files in the `docs/` folder manually.
- Test you API via the documentation - Open http://localhost/gateway/api/doc/ui/ , choose "Local server" from the "Servers" combobox and run your API. This is an alternative to Postman. Make sure to set the correct value in the `HOST` environment variable (eg. http://localhost/gateway) before running the service to access the docs.
- Define the OpenAPI 3.0 documentation for the API in the appropriate yaml files stored in `driver/web/docs` folder.
- Run `make oapi-gen-docs` to generate the `def.yaml` file stored in `driver/web/docs/gen` folder. To run this command, you will need to install [swagger-cli](https://github.com/APIDevTools/swagger-cli). This command will merge all OpenAPI files into the `def.yaml` file. Please do not change the `def.yaml` file manually.
- Test you API via the documentation - Open http://localhost/<name>/doc/ui/ , choose "Local server" from the "Servers" combobox and run your API. This is an alternative to Postman. Make sure to set the correct value in the `<NAME>_BASE_URL` environment variable (eg. http://localhost/<name>) before running the service to access the docs.

## Pull Requests
Pull requests should be linked to the associated issue with a [keyword](https://docs.github.com/en/issues/tracking-your-work-with-issues/creating-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword) in the description (eg. `Resolves #{issue number}`). This will close the issue automatically when the PR is merged.
Expand All @@ -22,18 +22,38 @@ Whenever a new interface is created, a unit test should be created for each func

When updating or changing existing implementations, run the associated unit tests to ensure that they still pass. If they do not, the implementation changes likely changed the interface as well. If the change to the interface was intentional, update the unit tests as needed to make them pass and document the [Breaking Change](#breaking-changes). If the change was not intentional, rework your implementation changes to keep the interface consistent and ensure all tests pass.

### Mocks
To test some components of the system in isolation, it may be necessary to mock some interfaces. Mocks should be automatically generated using the [Mockery](https://github.com/vektra/mockery) utility. Mockery can be installed by running `go install github.com/vektra/mockery/v2@latest`. One example of an interface that will need to be mocked is the `interfaces.Storage` interface. To generate (or regenerate) the mocks for the storage interface using Mockery, `cd core/interfaces` then run `mockery --name=Storage`.

## Releases
Whenever a new release is made, the following process should be followed.

1. Make a pull request from `develop` into `main` named `Release vX.X.X` (eg. `Release v1.1.7`)
### Dev Releases
Changes to the `develop` branch will be continuously deployed into the dev environment to be tested. When several significant changes have been merged into the `develop` branch and have been tested, a new dev release should be made.

To make a dev release:

1. Checkout the `develop` branch and `git pull` to ensure you have the latest updates locally.
2. Update the "Unreleased" version in the [CHANGELOG](CHANGELOG.md#unreleased) to `[X.X.X] - YYYY-MM-dd` (eg. `[1.1.7] - 2022-06-08`).
3. Update [SECURITY.md](SECURITY.md) to reflect the latest supported and unsupported versions.
4. Update the latest version in any docs or source code as needed.
5. Make any changes needed to document [breaking changes](#breaking-changes) and [deprecations](#deprecations).
6. Commit all changes to the `develop` branch with the commit message `Release vX.X.X` (eg. `Release v1.1.7).
7. Create a new tag from the `develop` branch called `vX.X.X` (eg. `v1.1.7`).
8. Push changes to `develop` branch and create remote tag atomically using `git push --atomic origin develop vX.X.X` (eg. `git push --atomic origin develop v1.1.7`).
> **NOTE:** Pushing to `develop` will automatically trigger a deployment to the `dev` environment. Pushing and creating the new tag atomically will ensure that the deployment pipeline correctly uses the new tag to set the version on the build it generates.
### Production Releases
When you are ready to move a release to the production environment:
1. Make a pull request from `develop` into `main` named `Release vX.X.X` (eg. `Release v1.1.7`).
2. Review the changes included in the update to ensure they are all production ready.
3. Update the "Unreleased" version in the [CHANGELOG](CHANGELOG.md#unreleased) to `X.X.X - YYYY-MM-dd` (eg. `[1.1.7] - 2022-06-08`) on the `develop` branch.
4. Update [SECURITY.md](SECURITY.md) to reflect the latest supported and unsupported versions on the `develop` branch.
5. Update the latest version in any docs or source code as needed on the `develop` branch.
6. Make any changes needed to document [breaking changes](#breaking-changes) and [deprecations](#deprecations).
7. Merge the pull request using "Create a merge commit"
8. Create a new tag from the `main` branch called `vX.X.X` (eg. `v1.1.7`)
9. **RECOMMENDED** - Publish a new [GitHub Release](https://docs.github.com/en/repositories/releasing-projects-on-github/managing-releases-in-a-repository#creating-a-release) from this tag with the title `vX.X.X` (eg. `v1.1.7`). Include the contents from the [CHANGELOG](CHANGELOG.md) for this latest version in the release notes, as well as a link to the whole [CHANGELOG](CHANGELOG.md) on the `main` branch. For libraries this is highly recommended.
3. Checkout the `main` branch and `git pull` to ensure you have the latest updates locally.
4. Run `git merge --ff-only origin/develop`. If this merge fails, merge any changes from `main` back into `develop` then restart from Step 3.
> **NOTE:** While this is slightly cumbersome, GitHub does not currently support fast-forward merge through the pull request user interface. We want to use fast-forward merging to preserve the linear history from develop without introducing a new merge commit (like `Create a merge commit`), or rebasing and changing commit hashes unnecessarily (like `Rebase and merge`). This will ensure that the exact same commit hash is used to build for staging and production that was used to build for develop.
5. Run `git push`.
6. **RECOMMENDED** - Publish a new [GitHub Release](https://docs.github.com/en/repositories/releasing-projects-on-github/managing-releases-in-a-repository#creating-a-release) from this tag with the title `vX.X.X` (eg. `v1.1.7`). Include the contents from the [CHANGELOG](CHANGELOG.md) for this latest version in the release notes, as well as a link to the whole [CHANGELOG](CHANGELOG.md) on the `main` branch. For libraries this is highly recommended.

Pushing to the `main` branch will automatically trigger a deployment to the `stage` environment. Once the release has been tested appropriately, the production pipeline can be manually triggered to deploy the same Docker image in the `stage` environment to the `prod` environment.

## Breaking Changes
Breaking changes should be avoided when possible, but will sometimes be necessary. In the event that a breaking change does need to be made, this change should be documented clearly for developers relying on the functionality. This includes the following items:
Expand All @@ -57,4 +77,4 @@ When a release including the deprecation is created, the following steps must be
* Update the `Upgrading > Migration steps > Unreleased` section in the README to the latest version (eg. `Upgrading > Migration steps > v1.1.0`)
* Include a copy of the upgrade instructions from the README in the release notes

When the deprecated components are finally removed, follow the process to document this as a [Breaking Change](#breaking-changes).
When the deprecated components are finally removed, follow the process to document this as a [Breaking Change](#breaking-changes).
32 changes: 18 additions & 14 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,29 +1,33 @@
FROM golang:1.20.1-buster as builder
FROM golang:1.20-alpine as builder

ENV CGO_ENABLED=0

RUN mkdir /gateway-app
WORKDIR /gateway-app
RUN apk add --no-cache --update make git

RUN mkdir /app
WORKDIR /app
# Copy the source from the current directory to the Working Directory inside the container
COPY . .
RUN make

FROM alpine:3.16.2
FROM alpine:3.17.2

#we need timezone database
RUN apk --no-cache add tzdata
RUN apk add --no-cache --update tzdata

COPY --from=builder /gateway-app/bin/apigateway /
COPY --from=builder /gateway-app/docs/swagger.yaml /docs/swagger.yaml
COPY --from=builder /app/bin/application /
COPY --from=builder /app/driver/web/docs/gen/def.yaml /driver/web/docs/gen/def.yaml

COPY --from=builder /gateway-app/assets/assets.json /assets/assets.json
COPY --from=builder /app/driver/web/client_permission_policy.csv /driver/web/client_permission_policy.csv
COPY --from=builder /app/driver/web/client_scope_policy.csv /driver/web/client_scope_policy.csv
COPY --from=builder /app/driver/web/admin_permission_policy.csv /driver/web/admin_permission_policy.csv
COPY --from=builder /app/driver/web/bbs_permission_policy.csv /driver/web/bbs_permission_policy.csv
COPY --from=builder /app/driver/web/tps_permission_policy.csv /driver/web/tps_permission_policy.csv
COPY --from=builder /app/driver/web/system_permission_policy.csv /driver/web/system_permission_policy.csv

COPY --from=builder /gateway-app/driver/web/authorization_model.conf /driver/web/authorization_model.conf
COPY --from=builder /gateway-app/driver/web/authorization_policy.csv /driver/web/authorization_policy.csv
COPY --from=builder /app/vendor/github.com/rokwire/core-auth-library-go/v3/authorization/authorization_model_scope.conf /app/vendor/github.com/rokwire/core-auth-library-go/v3/authorization/authorization_model_scope.conf
COPY --from=builder /app/vendor/github.com/rokwire/core-auth-library-go/v3/authorization/authorization_model_string.conf /app/vendor/github.com/rokwire/core-auth-library-go/v3/authorization/authorization_model_string.conf

COPY --from=builder /etc/passwd /etc/passwd

#we need timezone database
COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo

ENTRYPOINT ["/apigateway"]
ENTRYPOINT ["/application"]
Loading

0 comments on commit 5825d7f

Please sign in to comment.